Skip to Main Content Skip to Search
Product Documentation

Saving and Loading Enumerations

Basic Knowledge

See the save and load functions and Understanding the Save and Load Process for general information on saving and loading objects.

See the enumeration function to list enumeration names.

Built-In and Value-Based Enumeration Classes

When you save enumerations that derive from built-in classes or that are value-based classes with properties, MATLAB saves the names of the enumeration members and the definition of each member.

When loading these types of enumerations, MATLAB preserves names over underlying values. If the saved named value is different from the current class definition, MATLAB uses the value defined in the current class, and then issues a warning.

Simple and Handle-Based Enumeration Classes

When you save simple enumerations (those having no properties, superclasses, or values associated with the member names) or those enumerations derived from the handle class, MATLAB saves the names and any underlying values.

However, when loading these types of enumerations, MATLAB does not check the values associated with the names in the current class definition. This behavior results from the fact that simple enumerations have no underlying values and handle-based enumerations can legally have values that are different than those defined by the class.

What Causes Loading as a Struct Instead of an Object

The addition of a new named value or a new property made to a class subsequent to saving an enumeration does not trigger a warning during load.

If there are changes to the enumeration class definition that do not prevent MATLAB from loading the object (that is, all of the named values in the MAT-File are present in the modified class definition), then MATLAB issues a warning that the class has changed and loads the enumeration.

In the following cases, MATLAB issues a warning and loads as much of the saved data as possible as a struct:

Struct Fields

The returned struct has the following fields:

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS