| Simulink® | ![]() |
| On this page… |
|---|
A mask is a custom user interface for a subsystem that hides the subsystem's contents, making it appear to the user as an atomic block with its own icon and parameter dialog box. Note that this is different from an Atomic Subsystem, which the Simulink software treats as a unit when determining the execution order of block methods. Masking a subsystem provides only graphical, not functional, grouping. The Simulink Mask Editor enables you to create a mask for any subsystem. Masking a subsystem allows you to
Replace the parameter dialogs of a subsystem and its contents with a single parameter dialog with its own block description, parameter prompts, and help text
Replace a subsystem's standard icon with a custom icon that depicts its purpose
Prevent unintended modification of subsystems by hiding their contents behind a mask
Create a custom block by encapsulating a block diagram that defines the block's behavior in a masked subsystem and then placing the masked subsystem in a library
Note You can also mask S-Function and Model blocks. The instructions for masking Subsystem blocks apply to S-Function and Model blocks as well except where noted. |
Masks can include any of the following features.
The mask icon replaces a subsystem's standard icon, i.e., it appears in a block diagram in place of the standard icon for a subsystem block. The Simulink product uses MATLAB code that you supply to draw the custom icon. You can use any of the MATLAB drawing commands in the icon code. This gives you great flexibility in designing an icon for a masked subsystem.
You can define a set of user-settable parameters for a masked subsystem. The value of a parameter is stored in the mask workspace (see Mask Workspace) as the value of a variable whose name you specify. These associated variables allow you to link mask parameters to specific parameters of blocks inside a masked subsystem (internal parameters) such that setting a mask parameter sets the associated block parameter (see Linking Mask Parameters to Block Parameters).
Note If you intend to allow the user to specify the model referenced by a masked Model block or a Model block in a masked subsystem, you must ensure that the mask requires that the user specify the model name as a literal value rather than as a workspace variable. This is because Simulink updates model reference targets before evaluating block parameters. The recommended way to force the user to specify the model name as a literal is to use a pop-up control on the mask to specify the model name. See Pop-Up Control for more information. |
The mask parameter dialog box contains controls that enable a user to set the values of the mask's parameters and hence the values of any internal parameters linked to the mask parameters.
The mask parameter dialog box replaces the subsystem's standard parameter dialog box, i.e., clicking on the masked subsystem's icon causes the mask dialog box to appear instead of the standard parameter dialog box for a Subsystem block
Note Use the 'mask' option of the open_system command to open a block's mask dialog box at the MATLAB command line or in an M program. |
You can customize every feature of the mask dialog box, including which parameters appear on the dialog box, the order in which they appear, parameter prompts, the controls used to edit the parameters, and the parameter callbacks (code used to process parameter values entered by the user).
The initialization code is MATLAB code that you specify and that the Simulink software runs to initialize the masked subsystem at critical times, such as updating the model or starting simulation. You can use the initialization code to set the initial values of the masked subsystem's mask parameters. See Initialization Pane for more information.
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. You can use model and mask workspace variables to initialize a masked subsystem and to set the values of blocks inside the masked subsystem, subject to the following rules.
The Permit Hierarchical Resolution option of the subsystem must be set to All or ExplicitOnly. See Resolving Symbols, Hierarchical Symbol Resolution, and Permit Hierarchical Resolution for more information.
A block parameter expression can refer only to variables defined in the mask workspaces of the subsystem or nested subsystems that contain the block or in the model's workspace.
A valid reference to a variable defined on more than one level in the model hierarchy resolves to the most local definition. For example, suppose that model M contains masked subsystem A, which contains masked subsystem B. Further suppose that B refers to a variable x that exists in both A's and M's workspaces. In this case, the reference resolves to the value in A's workspace.
A masked subsystem's initialization code can refer only to variables in its local workspace.
The mask workspace of a Model block is not visible to the model that it references. Any variables used by the referenced model must resolve to workspaces defined in the referenced model or to the base (i.e., the MATLAB) workspace.
Hierarchical Symbol Resolution in Mask Workspaces. When the Simulink software tries to resolve a symbol defined in a masked block, it searches the mask workspaces in hierarchical order, then proceeds upward to the model and base workspaces. See Resolving Symbols for information about symbol resolution.
See Masking a Subsystem for an overview of the process of creating a masked subsystem. See Masked Subsystem Example for an example of the process.
![]() | Working with Block Masks | Masked Subsystem Example | ![]() |

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 |