Documentation Center

  • Trial Software
  • Product Updates

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 myMode and myLED from Control an LED Display. The dot notation appears highlighted in the code.

function led = checkState(state)
%#codegen

if state == myMode.ON
    led = myLED.GREEN;
else
    led = myLED.RED;
end
Was this topic helpful?