23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Designing User Classes in <strong>MATLAB</strong><br />

The first argument is the object being referenced. The second argument, S,<br />

is a structure array with two fields:<br />

• S.type is a string containing '()', ’{}', or'.' specifying the subscript<br />

type. The parentheses represent a numeric array; the curly braces, a cell<br />

array; and the dot, a structure array.<br />

• S.subs is a cell array or string containing the actual subscripts. A colon<br />

used as a subscript is passed as a cell array containing the string ':'.<br />

For instance, the expression<br />

A(1:2,:)<br />

causes <strong>MATLAB</strong> to call subsref(A,S), whereS is a 1-by-1 structure with<br />

S.type = '()'<br />

S.subs = {1:2,':'}<br />

Similarly, the expression<br />

uses<br />

A{1:2}<br />

S.type ='{}'<br />

S.subs = {1:2}<br />

The expression<br />

A.field<br />

calls subsref(A,S) where<br />

S.type = '.'<br />

S.subs = 'field'<br />

These simple calls are combined for more complicated subscripting<br />

expressions. In such cases, length(S) is the number of subscripting levels.<br />

For example,<br />

9-17

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!