オブジェクトの保存と読み込み
オブジェクトの保存と読み込みのプロセスのカスタマイズ
MATLAB® では、オブジェクトでの load
関数と save
関数の使用に対して既定の動作が用意されていますが、次の 2 つの手法のいずれかを使用して、オブジェクトのシリアル化 (保存) および逆シリアル化 (読み込み) のプロセスをカスタマイズできます。
推奨:
matlab.mixin.CustomElementSerialization
(R2024b 以降) から継承する。
詳細については、シリアル化プロセスをカスタマイズする状況を参照してください。
クラス
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 以降) |
トピック
オブジェクトでの save
および load
の既定の動作
- オブジェクトの既定の保存と読み込みのプロセス
MATLAB は、オブジェクトをシリアル化 (保存) および逆シリアル化する (読み込む) ためのいくつかの既定のガイドラインに従います。 - プロパティ初期化の順序依存を回避
依存プロパティの set メソッドを定義して、初期化の順序依存を回避します。
オブジェクトのシリアル化のカスタマイズ
- シリアル化プロセスをカスタマイズする状況
オブジェクトの保存と読み込みのプロセスを変更する。 - 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
.