The automatic conversion of enumeration classes to char enable you to use enumeration
members in this case.
Enumeration Arrays
Create enumeration arrays by:
- Concatenating enumeration members using []
- Assigning enumeration members to an array using indexed assignment
Create an enumeration array of class WeekDays by concatenating enumeration members:
wd = [WeekDays.Tuesday,WeekDays.Wednesday,WeekDays.Friday];
Create an enumeration array of class WeekDays by indexed assignment:
a(1) = WeekDays.Tuesday;
a(2) = WeekDays.Wednesday;
a(3) = WeekDays.Friday;
Mixed Enumeration Members and char Vectors
You can concatenate enumeration members and char vectors as long as the char vector
represents an enumeration member.
clear a
a = [WeekDays.Wednesday,'Friday'];
class(a)
ans =
WeekDays
You can also assign a char vector to an enumeration array:
clear a
a(1) = WeekDays.Wednesday;
a(2) = 'Friday';
class(a)
ans =
WeekDays
Refer to Enumerations