Define Enumeration Classes
In this section...
“Enumeration Class” on page 14-5
“Construct an Enumeration Member” on page 14-5
“Convert to Superclass Value” on page 14-6
“Define Methods in Enumeration Classes” on page 14-7
“Define Properties in Enumeration Classes” on page 14-7
“Enumeration Class Constructor Calling Sequence” on page 14-8Enumeration Class
Create an enumeration class by adding an enumeration block to a class definition. For
example, the WeekDays class enumerates a set of days of the week.classdef WeekDays
enumeration
Monday, Tuesday, Wednesday, Thursday, Friday
end
endTo execute the MATLAB code in the following sections, place the WeekDays class
definition in a .m file on your path.Construct an Enumeration Member
Refer to an enumeration member using the class name and the member name:ClassName.MemberNameFor example, assign the enumeration member WeekDays.Tuesday to the variable
today:today = WeekDays.Tuesday;today is a variable of class WeekDays:whosDefine Enumeration Classes