MATLAB: How to create a popup control to set the mask block parameters in a masked subsystem in Simulink

blockcontroldialogdynamicmaskparameterspopupsimulinksubsystem

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.

Best Answer

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'))
set_param(gcb,'MaskValues',{'Default','1','1'})
end
Help on creating Dynamic dialogs can be found at the following URL: