Instantiate Enumerated Data in MATLAB Function Blocks

To instantiate an enumerated type in a MATLAB Function block, use dot notation to specify ClassName.EnumName. For example, the following MATLAB® function checkState instantiates the enumerated types switchmode and led from Control an LED Display. The dot notation appears highlighted in the code.

function led = checkState(state)

if state == switchmode.ON
    led = led.GREEN;
    led = led.RED;

Related Examples

More About

Was this topic helpful?