Main Content

enumeration

Class enumeration members and names

Description

example

enumerationClassNamedisplays the names of the enumeration members for the MATLAB®class with the nameClassName.

example

enumeration(obj)displays the names of the enumeration members for the class ofobj.

example

m= enumeration(___)returns the enumeration members in the column vectorm.

example

[m,s] = enumeration(___)returns the enumeration members in the column vectormand the member names in the cell arrays. The names inscorrespond element-wise to the enumeration members inm.

Examples

collapse all

Display the enumeration member names for the matlab.lang.OnOffSwitchState class.

enumerationmatlab.lang.OnOffSwitchState
Enumeration members for class 'matlab.lang.OnOffSwitchState': off on

Display the enumeration member names for the matlab.lang.OnOffSwitchState class using an enumeration member object.

e = matlab.lang.OnOffSwitchState.off; enumeration(e)
Enumeration members for class 'matlab.lang.OnOffSwitchState': off on

Return the enumeration members for the matlab.lang.OnOffSwitchState class in a column vector.

m = enumeration('matlab.lang.OnOffSwitchState')
m = 2x1 OnOffSwitchState enumeration array off on

Return the enumeration members of the matlab.lang.OnOffSwitchState class in a column vector and the enumeration names in a cell array.

[m,s] = enumeration('matlab.lang.OnOffSwitchState')
m = 2x1 OnOffSwitchState enumeration array off on
s =2x1 cell{'off'} {'on' }

Input Arguments

collapse all

Enumeration class name, specified as a character vector or string scalar.

Data Types:char|string

Instance of enumeration class.

Output Arguments

collapse all

Enumeration members, returned as a column vector.

Enumeration member names, returned as a cell array of character vectors.

More About

collapse all

Behavior Description

Behavior of theenumerationfunction.

  • An enumeration class that derives from a built-in class can specify more than one name for a given enumeration member.

  • When you call theenumeration函数没有输出参数,MATLAB显示器only the first name for each enumeration member (as specified in the class definition). To see all available enumeration members and their names, use the two output arguments. For example,[m,s] = enumeration(obj);.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Introduced in R2009b