MATLAB allows you to work with .NET enumerations using features of the MATLAB enumeration class and some features unique to the .NET Framework.
An example of an enumeration is System.DayOfWeek
.
The C# example NetDocEnum.cs
, in the matlabroot
/extern/examples/NET/NetSample
folder, defines enumerations used in examples.
Work with Members of a .NET Enumeration
To display the member names of an enumeration, use the MATLAB enumeration
function.
Refer to a .NET Enumeration Member
You use an enumeration member in your code as an instance of an enumeration.
Display .NET Enumeration Members as Character Vectors
To get the descriptive name of an enumeration, use the char
method.
Convert .NET Enumeration Values to Type Double
To convert a value to a MATLAB double
,
type:
Iterate Through a .NET Enumeration
To create MATLAB arrays from an enumeration, use the static System.Enum
methods GetNames
and GetValues
.
Use .NET Enumerations to Test for Conditions
With relational operators, you can use enumeration members in if
and switch
statements and other functions that
test for equality.
Use Bit Flags with .NET Enumerations
Many .NET languages support bit-wise operations on enumerations
defined with the System.Flags
attribute.
Read Special System Folder Path
Default Methods for an Enumeration
By default, MATLAB provides the following methods for a .NET enumeration:
MATLAB supports enumerations of any numeric type.
Limitations to Support of .NET Enumerations
You cannot create arrays of .NET enumerations, or any .NET objects, in MATLAB.