A masked block can pass values to the block parameters under the mask. The underlying blocks use the passed values during simulation to execute the block logic.
A masked block has variables associated with mask parameters. These variables are stored in the mask workspace for a model and can correspond to a block parameter under the mask. When such a block is evaluated, the block variables look for matching values in the mask workspace to get a value.
The mapping of variables from the mask workspace to the base workspace must be correct. A correct mapping ensures that the right block variable is assigned the value that is passed from the mask.
Use any of these options to pass values to blocks under the mask:
Parameter promotion (recommended)
Referencing block parameters using variable names (For the Edit Parameter only)
When you promote a block parameter to its mask, the block parameter becomes accessible from the mask dialog box, allowing you to pass a value for the block parameter. Parameter promotion ensures correct mapping of parameter values and is a recommended way to pass values to the block from the mask dialog box. For more information on promoting a parameter, see Promote Parameter to Mask.
You can use MATLAB® code in the Initialization pane of the Mask Editor to assign or pass values to the block parameters under the mask. You can assign a fixed value to a block parameter, specify an acceptable range for the input values, or specify a value for the child block. For more information, see Initialize Mask.
You can add an Edit parameter to the mask dialog box and pass values to the block parameters through it. The values that you provide for the Edit parameter in the mask dialog box automatically becomes associated with the block parameter, by using the techniques described in Symbol Resolution.
Consider the model
which contains a masked Subsystem block and governs the equation
= mx + b. Here,
variables controlling the slope and intercept of the equation and
are associated with the Gain and the Constant block,
assigned to the mask parameters Slope and Intercept,
respectively, as parameter names in the Mask Editor.
When you type values for Slope and Intercept in
the mask dialog box, these values are internally assigned to the variables
When the model is simulated, the Gain block and the Constant block
search for numeric values of
apply them to resolve the equation
y = mx + b.