Programming Previous page   Next Page

The Portfolio subsref Method

When MATLAB encounters a subscripted reference, such as that made in the getAccountNumber function

MATLAB calls the portfolio subsref method to interpret the reference. If you do not define a subsref method, the above statement is undefined for portfolio objects (recall that here p is an object, not just a structure).

The portfolio subsref method must support field-name and numeric indexing for the getAccountNumber function to access the portfolio name field.

Note that the portfolio implementation of subsref is designed to provide access to specific elements of the name field; it is not a general implementation that provides access to all structure data, such as the stock class implementation of subsref.

See the subsref help entry for more information about indexing and objects.


Previous page  Changing the Portfolio Constructor Object Precedence Next page

© 1994-2005 The MathWorks, Inc.