Name Size Bytes Class Attributes
today 1x1 104 WeekDays
today
today =
Tuesday
Convert to Superclass Value
If an enumeration class specifies a superclass, convert an enumeration object to the
superclass by passing the object to the superclass constructor. However, the superclass
constructor must be able to accept its own class as input and return an instance of the
superclass. MATLAB built-in numeric classes, such as uint32, allow this conversion.
For example, the Bearing class derives from the uint32 built-in class:
classdef Bearing < uint32
enumeration
North (0)
East (90)
South (180)
West (270)
end
end
Assign the Bearing.East member to the variable a:
a = Bearing.East;
Pass a to the superclass constructor and return a uint32 value:
b = uint32(a);
whos
Name Size Bytes Class Attributes
a 1x1 60 Bearing
b 1x1 4 uint32
The uint32 constructor accepts an object of the subclass Bearing and returns and
object of class uint32.
14 Enumerations