Products & Services Industries Academia Support User Community Company

Learn more about MATLAB   

saveobj - Modify save process for object

Syntax

b = saveobj(a)

Description

b = saveobj(a) is called by the save function if the class of a defines a saveobj method. save writes the returned value, b, to the MAT-file.

Define a loadobj method to take the appropriate action when loading the object.

If A is an array of objects, MATLAB invokes saveobj separately for each object saved.

Examples

Call the superclass saveobj method from the subclass implementation of saveobj with the following syntax:

classdef mySub < super
   methods
      function sobj = saveobj(obj)
         % Call superclass saveobj method
         sobj = saveobj@super(obj); 
         % Perform subclass save operations
         ...
      end
   ...
   end
...
end

See Saving and Loading Objects from Class Hierarchies.

 

Update object when saved:

function b = saveobj(a)
   % If the object does not have an account number,
   % call method to add account number to AccountNumber property
   if isempty(a.AccountNumber) 
      a.AccountNumber = getAccountNumber(a);
   end
   b = a;
end

See Example — Maintaining Class Compatibility.

See Also

load | loadobj | save

Tutorials

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS