matlab.System.saveObjectImpl - Save System object in MAT file - MATLAB (original) (raw)
Main Content
Class: matlab.System
Save System object in MAT file
Syntax
s = saveObjectImpl(obj)
Description
[s](#mw%5F60c06946-43d2-44cb-a227-5074e8c9fbb1) = saveObjectImpl([obj](#btlsxxm-1%5Fsep%5Fmw%5F353aa417-3412-46f8-81f1-586adf7da5a8))
specifies the System objectâ„¢ properties and state values to be saved in a structure or MAT file.
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.
Your loadObjectImpl method should correspond to yoursaveObjectImpl
method to ensure that all saved properties and data are loaded.
Run-Time Details
save
calls saveObject
, which then calls saveObjectImpl
. To save a System object in generated code, the object must be unlocked and it cannot contain or be a child object.
End users can use load
, which calls loadObjectImpl
to load a saved System object into their workspace.
Method Authoring Tips
- You must set
Access = protected
for this method. - Save the state of an object only if the object is in use. When the user loads that saved object, it loads in that usage state.
- To save child object information, use the associated
saveObject
method within thesaveObjectImpl
method.
Input Arguments
System object handle used to access properties, states, and methods specific to the object. If your saveObjectImpl
method does not use the object, you can replace this input with ~
.
Output Arguments
Examples
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 in use.
methods (Access = protected)
function s = saveObjectImpl(obj)
s = saveObjectImpl@matlab.System(obj);
s.child = matlab.System.saveObject(obj.child);
s.protectedprop = obj.protectedprop;
s.pdependentprop = obj.pdependentprop;
if isLocked(obj)
s.state = obj.state;
end
end
end
Version History
Introduced in R2012b