Hello Daniel,
I hope this message finds you well.
Below is the detailed explanation on how to pass mask parameters to the 'Enumerated Constant' block in Simulink. To illustrate this process clearly, I have created a sample Simulink model. Within this model, 'Enumerated Constant' block, which I have named as 'E_Const', is nested inside a subsystem.
Screenshot of Subsystem:
Screenshot of Simulink model:
A 'Display' block is connected to this subsystem, allowing us to view the output value of the 'Enumerated Constant' block with ease.
Let's begin by setting up the foundation for passing parameters from the mask. The first step involves creating a class in MATLAB that encapsulates all the potential values the 'Enumerated Constant' block can assume. Taking the above issue as a reference, I have chosen the following values: 'Negative', 'Zero', and 'Positive'.
The corresponding class file has been titled 'S1DemoSign.m'. Below is the code that defines it:
classdef S1DemoSign < Simulink.IntEnumType
As a next step, create a mask parameter named 'EnumValue'. This parameter will be of the 'popup' type, allowing us to select a valid value for the 'Enumerated Constant' block from a dropdown menu. You can set up the parameter by entering the enumeration values as demonstrated in the screenshot provided below.
Moving on to the mask's Initialization section, we'll employ the 'set_param' function. This function allows us to dynamically adjust the value of the 'Enumerated Constant' block. The code snippet below illustrates how this is achieved:
enumValue = get_param(gcb, 'EnumValue');
set_param([gcb '/E_Const'], 'Value', ['S1DemoSign.' enumValue]);
Below I have included screenshots showcasing the system's output.
Hope it helps!