Main Content

.NET Enumerations in MATLAB

Create and combine .NET enumerations in MATLAB®

MATLAB allows you to work with .NET enumerations using features of the MATLAB enumeration class and some features unique to the .NET Framework.

Enumerations contain members, methods, and underlying values. Terms you should know:

  • Enumeration — In MATLAB, a class having a finite set of named instances. In the following topics, the term enumeration refers to a .NET enumeration.

  • Enumeration member — Named instance of an enumeration class.

  • Underlying value — Numeric value associated with an enumeration member.


The MATLAB language supports user-defined enumeration classes. If you are using enumerations defined in MATLAB, refer to the topics under the creating MATLAB classes Enumerations category.


bitnot.NET enumeration object bit-wise NOT instance method


Pass System.Enum Arguments

Examples using System.Enum arguments.

NetDocEnum Example Assembly

Example source code.

Work with Members of a .NET Enumeration

This example uses the System.DayOfWeek enumeration.

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

How to convert a .NET enumeration values.

Iterate Through a .NET Enumeration

This example shows how to display member names of the System.DayOfWeek enumeration.

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

This example shows how to combine members of an enumeration to create MATLAB variables.

Read Special System Folder Path

This example how to use the Microsoft® Environment.SpecialFolder enum.

Default Methods for an Enumeration

By default, MATLAB provides relational operators, conversion methods, and bitwise methods for a .NET enumeration.

Underlying Enumeration Values

MATLAB supports enumerations of any numeric type.


Limitations to Support of .NET Enumerations

.NET features not supported in MATLAB.