对象保存和加载
优化对象保存和加载过程
通过对您的类实施特定方法来自定义保存和加载对象的过程。这些方法可以改善版本兼容性、避免初始化依赖项,以及将功能还原到所加载的对象。
主题
如何保存和加载对象
- 对象的保存和加载过程
MATLAB® 在保存和加载操作中处理对象,以便加载的对象处于已知状态。 - 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.
自定义保存和加载
- 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
EnablingConstructOnLoad
allows object modification in the constructor when you do not want to implement aloadobj
method. - Save and Load Objects from Class Hierarchies
Class can call theloadobj
andsaveobj
methods defined by superclasses in the class hierarchy from their ownloadobj
andsaveobj
methods. - Restore Listeners
You can restore property listeners from theloadobj
method.