This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

Object Save and Load

Optimize the object save and load process

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.


saveobj Modify save process for object
loadobj Modify load process for object


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

Enabling ConstructOnLoad allows object modification in the constructor when you do not want to implement a loadobj method.

Save and Load Objects from Class Hierarchies

Class can call the loadobj and saveobj methods defined by superclasses in the class hierarchy from their own loadobj and saveobj methods.

Restore Listeners

You can restore property listeners from the loadobj method.

Save and Load Dynamic Properties

The save function does not save dynamic property attributes. Use saveobj and loadobj methods to restore nondefault attributes values to dynamic properties.

Was this topic helpful?