function a = subsasgn(a, index, val)
% subsasgn - Defines generic index-based assignment for objects.
%
% Author: Cengiz Gunay <cgunay@emory.edu>, 2006/02/06
% Copyright (c) 2007 Cengiz Gunay <cengique@users.sf.net>.
% This work is licensed under the Academic Free License ("AFL")
% v. 3.0. To view a copy of this license, please look at the COPYING
% file distributed with this software or visit
% http://opensource.org/licenses/afl-3.0.php.
if size(index, 2) > 1
% recursive
a = subsasgn(a, index(1), subsasgn(subsref(a, index(1)), index(2:end), val));
else
switch index.type
case '()'
a(index.subs{:}) = val;
case '.'
a = set(a, index.subs, val);
case '{}'
a{index.subs{:}} = val;
end
end