Enumerated data is data that has a finite set of values. An enumerated data type is a user-defined type whose values belong to a predefined set of symbols, also called enumerated values. Each enumerated value consists of a name and an underlying numeric value.
Like other Simulink® blocks, MATLAB Function blocks support an integer-based enumerated type derived from the class Simulink.IntEnumType. The instances of the class represent the values that comprise the enumerated type. The allowable values for an enumerated type must be 32-bit integers, but do not need to be consecutive.
For example, the following MATLAB® script defines an integer-based enumerated data type named PrimaryColors:
classdef(Enumeration) PrimaryColors < Simulink.IntEnumType enumeration Red(1), Blue(4), Yellow(8) end end
PrimaryColors is restricted to three enumerated values:
|Enumerated Value||Enumerated Name||Underlying Numeric Value|
You can exchange enumerated data between MATLAB Function blocks and other Simulink blocks in a model as long as the enumerated type definition is based on the Simulink.IntEnumType class.
For comprehensive information about enumerated data support in Simulink, see Define Enumerated Data Types for MATLAB Function Blocks.