Programming Previous page   Next Page

The Stock set Method

The set method provides a "property name" interface like the get method. It is designed to update the number of shares, the share value, and the descriptor. The current value and the date are automatically updated.

Note that this function creates and returns a new stock object with the new values, which you then copy over the old value. For example, given the stock object,

the following set command updates the share price.

It is necessary to copy over the original stock object (i.e., assign the output to s) because MATLAB does not support passing arguments by reference. Hence the set method actually operates on a copy of the object.


Previous page  The Stock get Method The Stock subsref Method Next page

© 1994-2005 The MathWorks, Inc.