MATLAB: How to change the names and values of variables in a masked subsystem from the command line in MATLAB 7.0.4 (R14SP2)

masksimulinksubsystem

I have a model containing a masked subsystem with 2 tunable variables. I am trying to change the names of the variables and their values in the Mask Editor from the MATLAB command line.

Best Answer

The following sample code shows how to change the names and access the values of the variables in the Mask Editor of a masked subsystem from the MATLAB command line:
To be able to execute this code, download the attached sample model autoMask_model.mdl and select the subsystem.
1. To rename the variables in the Mask Editor to be ‘a’ as the first variable and ‘b’ as the second variable use:
set_param(gcb,'MaskVariables', ['a=@1', ';', 'b=@2'])
get_param(gcb,'MaskVariables')
2. To set and access the values of the variables 'a' and 'b' use:
set_param(gcb,'MaskValueString','5|6') % a = 5 and b = 6
get_param(gcb,'MaskValueString')
3. To change the ‘Prompts’ names in the window properties of the masked subsystem use:
set_param(gcb,'MaskPromptString','New_hello|New_inc')
get_param(gcb,'MaskPromptString')