Pass Values to Blocks Under the Mask

The masking_example assigns the input values using the mask dialog box directly to block parameters underneath the mask, as described in Masking Fundamentals. The values are assigned, so the search that always occurs when a block parameter needs a value finds the mask parameter value automatically, as described in Symbol Resolution.

You can use the Mask Editor to insert any desired calculation between a value in the mask dialog box and an underlying block parameter

For more information, see the Initialization Pane.

To calculate a block parameter value, first break the link between the mask and block parameters by giving them different names. To facilitate such changes, Dialog variables lists all mask parameters.

You cannot use mask initialization code to change mask parameter default values in a library block or any other block.

You can use the initialization code for a masked block to link mask parameters indirectly to block parameters. In this approach, the initialization code creates variables in the mask workspace whose values are functions of the mask parameters and that appear in expressions that set the values of parameters of blocks concealed by the mask.

If you need both the character vector and the evaluated value, clear the Evaluate option. To get the value of a base workspace variable entered as the literal value of the mask parameter, use the MATLAB® evalin command in the mask initialization code. Suppose that the user types 'gain' as the literal value of the mask parameter k where gain is the name of a base workspace variable. To obtain the value of the base workspace variable, use the following command in the initialization code for the mask:

value = evalin('base', k)

These values are stored in variables in the mask workspace. A masked block can access variables in its mask workspace. A workspace is associated with each masked subsystem that you create. The current values of the subsystem parameters are stored in the workspace and any variables created by the block initialization code and parameter callbacks.

To use a masked subsystem in a referenced model having model arguments, do not create in the mask workspace a variable that derives its value from a mask parameter. Instead, use blocks under the masked subsystem to perform the calculations for the mask workspace variable.

See Also


Was this topic helpful?