MATLAB Functions | Help Desk |
subsasgn
Overloaded method forA(i)=B
, A{i}=B
, and A.field=B
A = subsasgn(A,S,B)
A = subsasgn(A,S,B)
is called for the syntax A(i)=B
, A{i}=B
, or A.i=B
when A
is an object. S
is a structure array with the fields:
type
: A string containing '()'
, '{}'
, or '.'
, where '()'
specifies integer subscripts; '{}'
specifies cell array subscripts, and '.'
specifies subscripted structure fields.
subs
: A cell array or string containing the actual subscripts.
A(1:2,:)=B
calls A=subsasgn(A,S,B)
where S
is a 1-by-1 structure with S.type='()'
and S.subs = {1:2,':'}
. A colon used as a subscript is passed as the string ':'
.
The syntax A{1:2}=B
calls A=subsasgn(A,S,B)
where S.type='{}'
.
The syntax A.field=B
calls subsasgn(A,S,B)
where S.type='.'
and S.subs='field'
.
These simple calls are combined in a straightforward way for more complicated subscripting expressions. In such cases length(S)
is the number of subscripting levels. For instance, A(1,2).name(3:5)=B
calls A=subsasgn(A,S,B)
where S
is 3-by-1 structure array with the following values:subsref
Overloaded method for A(i)
, A{i}
and A.field
See Using MATLAB for more information about overloaded methods and subsasgn
.