Identifying ordinal position of an enumerated value

1 次查看(过去 30 天)
is there a function, enum_ordinal for instance that returns an ordinal position of the enuerated value in the enumerated type?
classdef WeekDays
enumeration
Monday, Tuesday, Wednesday, Thursday, Friday
end
end
temp=enum_ordinal(Tuesday)
temp = 2
  3 个评论
Jim Johnson
Jim Johnson 2011-10-24
Actually I am using enumerated types in StateFlow and use the following to create the enumerated type
Simulink.defineIntEnumType('BasicColors', ...
{'Red', 'Yellow', 'Blue'}, [0;1;2],...
'AddClassNameToEnumNames', true);
I can find the value of an enumeration
BasicColors.Yellow == BasicColors(1)
ans =
1
but no way to determine the number of enumerations, in this case it should be 3 but size doesn't work just returns the length of the string 'BasicColors'
size BasicColors
ans =
1 11
Any help out there, the help in Matlab seems to be lacking here?
If I could find the number of enumeration values I could loop thru them looking for a match.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simulink Functions 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by