saveObjectImpl

Class: matlab.System
Package: matlab

Save System object in MAT file

Syntax

saveObjectImpl(obj)

Description

saveObjectImpl(obj) defines what System object™ obj property and state values are saved in a MAT file when a user calls save on that object. save calls saveObject, which then calls saveObjectImpl. If you do not define a saveObjectImpl method for your System object class, only public properties and properties with the DiscreteState attribute are saved. To save any private or protected properties or state information, you must define a saveObjectImpl in your class definition file.

You should save the state of an object only if the object is locked. When the user loads that saved object, it loads in that locked state.

To save child object information, you use the associated saveObject method within the saveObjectImpl method.

End users can use load, which calls loadObjectImpl to load a System object into their workspace.

    Note:   You must set Access = protected for this method.

Input Arguments

obj

System object handle

Examples

expand all

Define Property and State Values to Save

Define what is saved for the System object. Call the base class version of saveObjectImpl to save public properties. Then, save any child System objects and any protected and private properties. Finally, save the state, if the object is locked.

methods (Access = protected)
   function s = saveObjectImpl(obj)      
      s = saveObjectImpl@matlab.System(obj);
      s.child = matlab.System.saveObject(obj.child);
      s.protected = obj.protected;
      s.pdependentprop = obj.pdependentprop;
      if isLocked(obj)
         s.state = obj.state;
      end
   end
end
Was this topic helpful?