A mask is a custom interface for a block that hides the block content, making it appear as an atomic block with its own icon and parameter dialog box. It encapsulates the block logic, provides controlled access to the block data, and simplifies the graphical appearance of a model.
When you mask a block, a mask definition is created and saved along with the block. A mask changes only the block interface, and not the underlying block characteristics. You can provide access to one or more underlying block parameters by defining corresponding mask parameters on the mask.
Mask a Simulink® block to:
Display a meaningful icon on a block
Provide a customized dialog box for the block
Provide a dialog box that enables you to access only select parameters of the underlying blocks
Provide users customized description that is specific to the masked block
Initialize parameters using MATLAB® code
Consider the model that represents the equation of line
y = mx +
Each block has its own dialog box, making it complicated to specify the values for the line equation variables. To simplify the user interface, a mask is applied on the top-level subsystem block.
Here the variable
m represents slope and the variable
b represents the intercept for the line equation
y = mx +
The mask dialog box displays the fields for Slope and
Intercept that are internally mapped to variables
Masked blocks do not support content preview. To preview the contents of a subsystem, see Preview Content of Model Components.
For masking examples, see Masking Example Models. The examples are grouped by type. In an example model:
To view the mask definition, double-click the View Mask block.
To view the mask dialog box, double-click the block.
Examples of few blocks that cannot be masked are:
Simulink Function block
Initialize, Terminate and Reset Function blocks
The masked block icon generated using drawing commands. Mask icon can be static or change dynamically with underlying block parameter values.
The parameters that are defined in the Mask Editor and appear on the mask dialog box. Setting the value of a mask parameter on the mask dialog box sets the corresponding block parameter value.
Mask initialization code
MATLAB Code that initializes a masked block or reflects current parameter values. Add mask initialization code in the Initialization pane of the Mask Editor dialog box. For example, add initialization code to set a parameter value automatically.
Mask dialog callback code
MATLAB Code that runs in the base workspace when the value of a mask parameter changes. Use callback code to change the appearance of a mask dialog box dynamically and reflect current parameter values. For example, enable visible parameters on the dialog box.
Description and usage information for a masked block defined in the Mask Editor.
Mask dialog box
A dialog box that contains fields for setting mask parameter values and provides mask description.
Masks that define mask parameters or contain initialization code have a mask workspace. This workspace stores the evaluated values of the mask parameters and temporary values used by the mask.