| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Simulink |
| Contents | Index |
| Learn more about Simulink |
The masking_example assigns the values input using the Mask Parameters dialog box directly to block parameters underneath the mask, as described in Understanding Mask Parameters. The assignment occurs because the block parameter and the mask parameter have the same name, so the search that always occurs when a block parameter needs a value finds the mask parameter value automatically, as described in Resolving Symbols.
You can use the Mask Editor to insert any desired calculation between a value in the Mask Parameters dialog box and an underlying block parameter:

See the Initialization Pane reference for reference information about all Initialization pane capabilities. This section shows you how to use it for calculating block parameter values.
In order to calculate a value for a block parameter, you must first break the link between the mask and block parameters by giving them different names. To facilitate such changes, the Dialog variables subpane lists all mask parameters. The Initialization pane for the masking_example looks like this:

You cannot use mask initialization code to change mask parameter default values in a library block or any other block.
You can use a masked block's initialization code 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 string entered 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. For example, suppose the user enters the string '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 mask's initialization code:
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's parameters are stored in the workspace as well as any variables created by the block's initialization code and parameter callbacks.
![]() | Roadmap for Dynamic Masks | Controlling Masks Programmatically | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |