Enumerations for Property Values
In this section...
“Syntax for Property/Enumeration Definition” on page 14-17
“Example of Restricted Property” on page 14-17
Syntax for Property/Enumeration Definition
You can restrict the values that are allowed for a property to members of an enumeration
class. Define the property as restricted to a specific enumeration class in the class
definition using this syntax:
properties
PropName EnumerationClass
end
This syntax restricts values of PropName to members of the enumeration class
EnumerationClass.
Example of Restricted Property
For example, the Days class defines a property named Today. The allowed values for the
Today property are enumeration members of the WeekDays class.
The WeekDays class defines the enumerations:
classdef WeekDays
enumeration
Monday, Tuesday, Wednesday, Thursday, Friday
end
end
Use the WeekDays enumerations to restrict the allowed values of the Today property:
classdef Days
properties
Today WeekDays
end
end
Create an object of the Days class.
Enumerations for Property Values