MATLAB:如何获取枚举的所有项目的数组?

Tha*_*yen 5 matlab

我想获取MATLAB中枚举内所有项的数组值?有没有任何功能允许我这样做?

Bob*_*ore 5

假设您正在讨论MATLAB枚举对象(而不是java.lang.Enumeration),您可以使用"枚举"函数来获取枚举成员的列表.从MATLAB文档,http://www.mathworks.com/help/techdoc/ref/enumeration.html,

m = enumeration(ClassName) returns the enumeration members for the class in the column vector m of objects.
m = enumeration(obj) returns the enumeration members for the class of object, obj, in the column vector m of objects
Run Code Online (Sandbox Code Playgroud)

另请参阅MathWorks网站上的优秀视频教程,网址为http://www.mathworks.com/videos/matlab/enumerations-in-r2010b.html

  • 我想要注意你应该使用`enumeration('EnumName')`而不是`enumeration(EnumName)`. (2认同)