enumeration - Class enumeration members and names - MATLAB (original) (raw)
Main Content
Class enumeration members and names
Syntax
Description
enumeration [ClassName](#d126e473241)
displays the names of the enumeration members for the MATLAB® class with the name ClassName
.
enumeration([obj](#d126e473267))
displays the names of the enumeration members for the class of obj
.
[m](#d126e473288) = enumeration(___)
returns the enumeration members in the column vector m
.
[[m](#d126e473288),[s](#d126e473305)] = enumeration(___)
returns the enumeration members in the column vector m
and the member names in the cell array s
. The names ins
correspond element-wise to the enumeration members inm
.
Examples
Display Enumeration Member Names
Display the enumeration member names for the matlab.lang.OnOffSwitchState class.
enumeration matlab.lang.OnOffSwitchState
Enumeration members for class 'matlab.lang.OnOffSwitchState':
off
on
Display Enumeration Member Names from Object
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
Get Enumeration Members
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
Get Enumeration Members and Names
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
ClassName
— Enumeration class name
character vector | string
Enumeration class name, specified as a character vector or string scalar.
Data Types: char
| string
obj
— Instance of enumeration class
object
Instance of enumeration class.
Output Arguments
m
— Enumeration members
column vector
Enumeration members, returned as a column vector.
s
— Enumeration member names
cell array
Enumeration member names, returned as a cell array of character vectors.
More About
Behavior Description
Behavior of the enumeration
function.
- An enumeration class that derives from a built-in class can specify more than one name for a given enumeration member.
- When you call the
enumeration
function with no output arguments, MATLAB displays 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™.
Thread-Based Environment
Run code in the background using MATLAB® backgroundPool
or accelerate code with Parallel Computing Toolbox™ ThreadPool
.
Version History
Introduced in R2009b