Documentation Center

  • Trial Software
  • Product Updates
我们为许可用户提供了部分翻译好的中文文档。您只需登录便可查阅这些文档

enumeration

Display class enumeration members and names

Syntax

enumeration ClassName
enumeration(obj)
m = enumeration(ClassName)
m = enumeration(obj)
[m,s] = enumeration(ClassName)
[m,s] = enumeration(obj)

Description

enumeration ClassName displays the names of the enumeration members for the MATLAB® class with the name ClassName.

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

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.

[m,s] = enumeration(ClassName) returns the names of the enumeration members in the cell array of strings s. The names in s correspond element-wise to the enumeration members in m.

[m,s] = enumeration(obj) returns the enumeration members for the class of object, obj, in the column vector m of objects.

Input Arguments

ClassName

The name of the enumeration class, in single quotes.

obj

A instance of an enumeration class.

Output Arguments

m

Column vector of enumeration members.

s

Cell array of strings containing the enumeration names.

Examples

All examples use the following enumeration class.

classdef Boolean < logical
   enumeration
      No  (0)
      Yes (1)
      Off (0)
      On  (1)
   end
end
 

Display the names of the enumeration members for class Boolean:

enumeration Boolean
Enumerations for class Boolean:

    No
    Yes
 

Get the enumeration members for class Boolean in a column vector of objects:

members = enumeration('Boolean')
members = 

    No 
    Yes
 

Get all available enumeration members and their names:

[members, names] = enumeration('Boolean')
members = 

    No 
    Yes
    No 
    Yes


names = 

    'No'
    'Yes'
    'Off'
    'On'

More About

expand all

Tips

  • 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);).

See Also

Tutorials

Was this topic helpful?