23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

Examples of the subsref Method<br />

See the following sections for examples of the subsref method:<br />

• “The Polynom subsref Method” on page 9-31<br />

• “The Asset subsref Method” on page 9-46<br />

• “The Stock subsref Method” on page 9-54<br />

• “The Portfolio subsref Method” on page 9-68<br />

Handling Subscripted Assignment<br />

The use of a subscript or field designator with an object on the left-hand side<br />

of an assignment statement is known as a subscripted assignment. <strong>MATLAB</strong><br />

calls a method named subsasgn in these situations. Object subscripted<br />

assignment can be of three forms - an array index, a cell array index, and a<br />

structure field name.<br />

A(I) = B<br />

A{I} = B<br />

A.field = B<br />

Each of these results in a call to subsasgn of the form<br />

A = subsasgn(A,S,B)<br />

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

S, has the same fields as those used with subsref. The third argument, B,<br />

is the new value.<br />

Examples of the subsasgn Method<br />

See the following sections for examples of the subsasgn method:<br />

• “The Asset subsasgn Method” on page 9-47<br />

• “The Stock subsasgn Method” on page 9-55<br />

9-19

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

Saved successfully!

Ooh no, something went wrong!