Programming Previous page   Next Page

The Asset subsasgn Method

The subsasgn method is the assignment equivalent of the subsref method. This version enables you to change the data contained in an object using one-based numeric indexing and structure field name indexing. The outer switch statement determines if the index is a numeric or field name syntax. The inner switch statements map the index value to the appropriate value in the stock structure.

MATLAB calls subsasgn whenever you execute an assignment statement (e.g., A(i) = val, A{i} = val, or A.fieldname = val).

The subsasgn method enables you to assign values to the asset object data structure using two techniques. For example, suppose you have a child stock object s. (If you want to run this statement, you first need to create a stock constructor method.)

Within stock class methods, you could change the descriptor field with either of the following statements

or

See the The Stock subsasgn Method for an example of how the child subsasgn method calls the parent subsasgn method.


Previous page  The Asset subsref Method The Asset display Method Next page

© 1994-2005 The MathWorks, Inc.