对象保存和加载
优化对象保存和加载过程
通过对您的类实施特定方法来自定义保存和加载对象的过程。这些方法可以改善版本兼容性、避免初始化依赖项,以及将功能还原到所加载的对象。
类
matlab.mixin.CustomElementSerialization | Customize how objects are serialized and deserialized (自 R2024b 起) |
matlab.serialization.ElementSerializationContent | Representation of serialized object (自 R2024b 起) |
matlab.serialization.SerializationContext | Context in which objects are serialized (自 R2024b 起) |
主题
如何保存和加载对象
- 对象的保存和加载过程
MATLAB® 在保存和加载操作中处理对象,以便加载的对象处于已知状态。 - Avoid Property Initialization Order Dependency
Avoid initialization order dependency by defining set methods for dependent properties.
自定义保存和加载
- When to Customize the Serialization Process
Modify the save and load process for objects. - Maintain Backward and Forward Compatibility Between Class Definitions
Modify the save and load process to provide class version compatibility. - Serialization with Class Hierarchies
Subclasses can callmatlab.mixin.CustomElementSerialization
methods of their superclasses. - Transitioning Serialization and Deserialization Processes to matlab.mixin.CustomElementSerialization
Consider transitioning tomatlab.mixin.CustomElementSerialization
from olderloadobj
andsaveobj
implementations. - Code Patterns for saveobj and loadobj
Use these patterns to implement custom save and load processes usingsaveobj
andloadobj
.