MATLAB Object-Oriented Programming

(Joyce) #1

Returning the contents of each cell of S.subs gives the index values for the first
dimension and a char vector ':' for the second dimension:


S.subs{:}


ans =


1 2 3 4


ans =


:


The default subsref returns all array elements in rows 1 through 4 and all the columns
in the array.


Similarly, this expression:


A{1:4}


Uses a cell array containing the numbers 1, 2, 3, 4.


S.type ='{}'
S.subs = {1:4}


The default subsref returns the contents of all cell array elements in rows 1 through 4
and all the columns in the array.


This expression:


A.Name


Calls subsref(A,S), where the struct S has these values:


S.type = '.'
S.subs = 'Name'


Compound Indexed References


These simple calls are combined for more complicated indexing expressions. In such
cases, length(S) is the number of indexing levels. For example,


A(1,2).PropertyName(1:4)


calls subsref(A,S), where S is a 3-by-1 array of structs with the values:


Indexed Reference
Free download pdf