Main Content

Reduce MAT-File Size for Saved Objects

Default Values

If a property often has the same value, define a default value for that property. When the user saves the object to a MAT-file, MATLAB® does not save the value of a property if the current value equals the default value. MATLAB saves the default value on a per class basis to avoid saving the value for every object.

For more information on how MATLAB evaluates default value expressions, see Define Properties with Default Values.

Dependent Properties

Use a dependent property when the property value must be calculated at run time. A dependent property is not saved in the MAT-file when you save an object. Instances of the class do not allocate memory to hold a value for a dependent property.

Dependent is a property attribute (see Property Attributes for a complete list.)

Transient Properties

MATLAB does not store the values of transient properties. Transient properties can store data in the object temporarily as an intermediate computation step or for faster retrieval. Use transient properties when you easily can reproduce the data at run time or when the data represents intermediate state that can be discarded.

Avoid Saving Unwanted Variables

Do not save variables that you do not want to load. Be sure that an object is still valid before you save it. For example, if you save a deleted handle object, MATLAB loads it as a deleted handle.

Related Topics