MATLAB Function Reference
  Go to function:
    Search    Help Desk 
subsref    Examples   See Also

Overloaded method for A(I), A{I} and A.field

Syntax

Description

B = subsref(A,S) is called for the syntax A(i), A{i}, or A.i when A is an object. S is a structure array with the fields:

Examples

The syntax A(1:2,:) calls subsref(A,S) 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} calls subsref(A,S) where S.type='{}' .

The syntax A.field calls subsref(A,S) 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) calls subsref(A,S) where S is 3-by-1 structure array with the following values:

S(1).type='()'
S(2).type='.'
S(3).type='()'
S(1).subs={1,2}
S(2).subs='name'
S(3).subs={3:5}

See Also

subsasgn    Overloaded method for A(i)=B, A{i}=B, and A.field=B

See Using MATLAB for more information about overloaded methods and subsref.



[ Previous | Help Desk | Next ]