Thang Nguyen
Thang Nguyen

Reputation: 79

MATLAB: How to get an array of all items of an enumeration?

I would like to get the array value of all of the items inside an enumeration in MATLAB? Is there any function allow me to do that?

Upvotes: 7

Views: 5634

Answers (1)

Bob Gilmore
Bob Gilmore

Reputation: 13758

Assuming that you're talking about a MATLAB Enumeration object (and not a java.lang.Enumeration), you can use the "enumeration" function to get a list of the enumeration members. From the MATLAB documentation, at 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

See also the excellent video tutorial at the MathWorks web site, at http://www.mathworks.com/videos/matlab/enumerations-in-r2010b.html

Upvotes: 8

Related Questions