Documentation Center

  • Trial Software
  • Product Updates

Add Inputs, Outputs, and Parameters as Enumerated Data

You can add inputs, outputs, and parameters as enumerated data, according to these guidelines:

For:Do This:

Inputs

Inherit from the enumerated type of the connected Simulink® signal or specify the enumerated type explicitly.

Outputs

Always specify the enumerated type explicitly.

Parameters

For tunable parameters, specify the enumerated type explicitly.

For non-tunable parameters, derive properties from an enumerated parameter in a parent Simulink masked subsystem or enumerated variable defined in the MATLAB® base workspace.

To add enumerated data to a MATLAB Function block:

  1. In the MATLAB Function Block Editor, select Edit Data.

  2. In the Ports and Data Manager, select Add > Data.

  3. In the Name field, enter a name for the enumerated data.

    For parameters, the name must match the enumerated masked parameter or workspace variable name.

  4. In the Type field, specify an enumerated type.

    To specify an explicit enumerated type:

    1. Select Enum:<class name> from the drop-down menu in the Type field.

    2. Replace <class name> with the name of an enumerated data type that you defined in a MATLAB file on the MATLAB path.

      For example, you can enter Enum:led in the Type field. (See Define Enumerated Data Types for MATLAB Function Blocks.)

        Note:   The Complexity field disappears when you select Enum:<class name> because enumerated data types do not support complex values.

      For example, the following output ledval has an explicit enumerated type, led:

    To inherit the enumerated type from a connected Simulink signal (for inputs only):

    1. Select Inherit:Same as Simulink from the drop-down menu in the Type field.

      For example, the following input state inherits its enumerated type switchmode from a Simulink signal:

  5. Click Apply.

Was this topic helpful?