Programming |
The saveobj Method
MATLAB looks for the portfolio saveobj
method whenever the save
command is passed a portfolio object. If @portfolio/saveobj
exists, MATLAB passes the portfolio object to saveobj
, which must then return the modified object as an output argument. The following implementation of saveobj
determines if the object has already been assigned an account number from a previous save operation. If not, saveobj
calls getAccountNumber
to obtain the number and assigns it to the accountNumber
field.
function b = saveobj(a) if isempty(a.accountNumber) a.accountNumber = getAccountNumber(a); end b = a;
Example -- Defining saveobj and loadobj for Portfolio | The loadobj Method |
© 1994-2005 The MathWorks, Inc.