Create Mask Parameter Structure to Simplify Tuning and Data Management
This example shows how to create a structure of mask parameters and refer to the structure from a mask to simplify tuning and data management.
Create structure of mask parameters to:
Manage simulation data
Iteratively tune mask parameters between model simulations and code generation
Separate the parameter tuning process from the modifying the model or mask dialog box
Use mask parameter structures in your simulation or code generation workflow:
Use the argument ParameterValueStruct
in get_param
and set_param
commands to create and associate struct containing parameter names and current values for masked blocks.
Open the model.
open_system("slexMaskingBasic")
The example model contains a masked block named mx + b
with mask parameters Slope
and Intercept
.
Create a structure for the mask parameters of the block named mx + b
. In general, to create a struct containing parameter names and current value for any masked block, use
structName = get_param(blockName or handle,"ParamtereValueStruct")
lineParams = get_param("slexMaskingBasic/mx + b","ParameterValuesStruct")
lineParams = struct with fields:
m: 5
b: 2
Associate the mask parameters of mx + b
with the values in the structure lineParams
.
set_param("slexMaskingBasic/mx + b", "ParameterValuesStruct",'lineParams')
The values of the mask parameters reference the fields of the structure lineParams
in the mask dialog box.
Modify the value of the mask parameter Slope
by modifying the structure field lineParams.m
.
lineParams.m = 12;
The value of the mask parameter Slope
is changed in the mask dialog box.
To modify the value of popup and check box parameters, use the set_param
command after modifying the value in the mask parameter structure. Popup and checkbox parameters use the values from the structure instead of referencing the structure field names. In mx + b
block mask, the check box parameter checkDatatype
is "on"
. Set the checkDatatype
parameter to "off"
.
lineParams.checkDatatype = "off"; set_param("slexMaskingBasic/mx + b", "ParameterValuesStruct",'lineParams')