Object Save and Load
Customize the process of saving and loading objects by implementing specific methods for your class. These methods can improve version compatibility, avoid initialization dependences, and restore functionality to loaded objects.
How Save and Load Works with Objects
- Save and Load Process for Objects
MATLAB® processes objects in the save and load operations so that loaded objects are in a known state.
- Modify the Save and Load Process
Modify the save and load process to provide class version compatibility.
- Basic saveobj and loadobj Pattern
Use these basic programming patterns to implement custom save and load processes.
Customize Save and Load
- Reduce MAT-File Size for Saved Objects
Specifying default values for properties in the class definition can reduce MAT-file size when saving multiple objects of the same class.
- Improve Version Compatibility with Default Values
Using default values when adding properties to a class definition ensures that objects defined with previous versions have appropriate values when loaded.
- Save Object Data to Recreate Graphics Objects
It is more efficient to save data and recreated graphics than to save the whole graphics hierarchy in the MAT-file.
- Avoid Property Initialization Order Dependency
Avoid initialization order dependency by defining set methods for dependent properties.
- Maintain Class Compatibility
Use hidden dependent properties to maintain class compatibility.
- Initialize Objects When Loading
ConstructOnLoadallows object modification in the constructor when you do not want to implement a
- Save and Load Objects from Class Hierarchies
Class can call the
saveobjmethods defined by superclasses in the class hierarchy from their own
- Restore Listeners
You can restore property listeners from the