MATLAB Object-Oriented Programming

(Joyce) #1

Save and Load Enumerations


In this section...
“Basic Knowledge” on page 14-45
“Built-In and Value-Based Enumeration Classes” on page 14-45
“Simple and Handle-Based Enumeration Classes” on page 14-45
“Causes: Load as struct Instead of Object” on page 14-46

Basic Knowledge


See the save and load functions and “Save and Load Process for Objects” on page 13-2
for general information on saving and loading objects.

To see a list of enumeration names defined by a class, use the enumeration function.

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 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 that have no properties, superclasses, or values
associated with the member names or enumerations derived from the handle class,
MATLAB saves the names and any underlying values.

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 values defined by the class.

Save and Load Enumerations
Free download pdf