When to Customize the Serialization Process - MATLAB & Simulink (original) (raw)

Supporting backward and forward compatibility of classes is the primary reason to customize the serialization (saving) and deserialization (loading) process for objects. Customize the serialization process when you change a class definition, including but not limited to:

How to Modify the Serialization Process

MATLABĀ® includes two ways to customize the serialization process:

The recommended process for customizing serialization is to inherit frommatlab.mixin.CustomElementSerialization. This mixin, combined with the functionality of matlab.serialization.ElementSerializationContent and matlab.serialization.SerializationContext, enables you to control what information is serialized and deserialized. This control supports robust backward and forward compatibility between different versions of the same class.matlab.serialization.SerializationContext can be useful when serializing to destinations other than MAT files.matlab.mixin.CustomElementSerialization also supports the addition of dynamic properties during serialization, which loadobj andsaveobj do not.

Use loadobj and saveobj when:

See Also

matlab.mixin.CustomElementSerialization | matlab.serialization.ElementSerializationContent | matlab.serialization.SerializationContext | loadobj | saveobj