How do I create a popup control to set the mask block parameters in a masked subsystem in Simulink?

26 views (last 30 days)
I would like to create a popup control to set the mask block parameters in a masked subsystem in Simulink.
The Pop-up control should allow me to set the Mask block parameters to either DEFAULT or USER-DEFINED.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 16 Nov 2021
Edited: MathWorks Support Team on 16 Nov 2021
To accomplish this, you need to define a Popup control variable in the mask. The Popup control variable will enable you to toggle between the 'Default set' and a 'User-Defined' set. Set the Assignment Field of the Variable to 'Literal'. Then define the Popup Strings as follows:
Default|UserDefined
For help on Popup Control, refer to the "How Masked Parameters are Stored" section at the following URL:
Use the Initialization commands field in the mask to define the Default Masked parameters. Take a look at sample code below. The code uses a Dynamic dialog to set the MaskValues to Default Values. The mask has a Popup control variable and 2 parameters. The Default Value of the parameters in this case are set to '1' and '1' by using set_param. Note that the Mask values are specified as cell arrays.
if (strcmp(def,'Default'))\n set_param(gcb,'MaskValues',{'Default','1','1'})\nend
Help on creating Dynamic dialogs can be found at the following URL:

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!