Create a Simple Mask
You can mask a block interactively by using the Mask Editor or mask it programmatically. This example describes how to mask a block by using the Mask Editor. To mask a block programmatically, see Control Masks Programmatically.
For masking examples, see Simulink Masking Examples.
Step 1: Open Mask Editor
Open the model in which you want to mask a block. For example, open
This model contains a Subsystem block that models the equation for a line:
y = mx + b.
Select the Subsystem block and on the Subsystem tab, in the Mask group,click Create Mask.
Step 2: Define the Mask
The Mask Editor contains four tabs that enable you to define the block mask and customize the dialog box for the mask.
For detailed information on each pane, see Mask Editor Overview.
Parameters & Dialog Tab
Use this tab to add controls like parameters, displays, and action items to the mask dialog box.
To add Edit boxes to the block mask.
In the left pane, under Parameter, click Edit twice to add two new rows in the Dialog box pane.
Interceptin the Prompt column for the two Edit parameters. The value that you enter in Prompt column appears on the mask dialog box. Similarly, type
bin the Name column. The value you enter in Name column is the mask parameter name. The mask parameter name must be a valid MATLAB® name.
In the right pane, under Property editor, provide values in the Properties, Dialog, and Layout sections.
To preview the mask dialog box without exiting the Mask Editor, click Preview.
For detailed information, see Parameters & Dialog Pane.
A Simulink® mask parameter cannot reference another parameter on the same mask.
Use this pane to specify MATLAB code to control the mask parameters. For example,you can provide a predefined value for a mask parameter.
Consider the equation
y = mx + b in the example. To set the value
of the child block corresponding to 'm', you can use the
function in the code pane.
For detailed information, see Code Pane.
Use this tab to create an icon for the block mask. Mask Editor provides you with two modes of authoring block icon.
Mask Drawing Commands
Graphical Icon Editor: You can create and edit the mask icon of a block through a graphical environment. The various features in Graphical Icon Editor helps you to create icons with ease. Launch Graphical Icon Editor from Mask Editor.
The interactive graphical environment provides graphical tools like pen, curvature, text, scissor, connector, and equation (which supports LaTeX) to create rich graphical icons. Grids, smart guides, and rulers help you to create pixel-perfect icons. Apart from the drawing tools, a few built-in shapes, such as Resistor, Inductor, and Rotational Damper, are readily available. For more information, see Create and Edit Masked Block Icon Using Graphical Icon Editor
Mask Drawing Commands: Use a set of mask drawing commands to create masked block icon. You can use the Properties pane on the left to specify icon properties and icon visibility. For detailed information, see Icon drawing commands.
Mask parameter constraints help you to create validations on a mask parameter without having to write your own validation code. There are three types of constraints, Parameter Constraint, Cross Parameter Constraints, and Port Constraints.
Parameter Constraint: A mask can contain parameters that accept user input values. You can provide input values for mask parameters using the mask dialog box. Constraints ensure that the input for the mask parameter is within a specified range. For example, consider a masked Gain block. You can set a constraint where the input value must be between 1 and 10. If you provide an input that is outside the specified range, an error displays. Constraint Browser on the left pane helps you to manage Shared Constraints.
Cross Parameter Constraint: Cross-parameter constraints are applied among two or more Edit or Combobox type mask parameters. You can use a cross parameter constraint when you want to specify scenarios such as, Parameter1 must be greater than Parameter2.
Port Constraint: You can specify constraints on the input and output ports of a masked block. The port attributes are checked against the constraints when you compile the model.
Step 3: Operate on Mask
You can preview the mask and choose to unmask the block or edit the block mask.
Double-click the masked block.
The mask dialog box appears.
Type values in the
Interceptboxes of the mask dialog box. To view the output, simulate the model.
To edit the mask definition, select the subsystem block and click Edit Mask from the Subsystem tab in the Toolstrip. For more information, see Manage Existing Masks.
Select the masked block and on the Subsystem Block tab, in the Mask group, click Look Under Mask to view:
The blocks inside the masked subsystem
The built-in block dialog box of a masked block
The base mask dialog box of a linked masked block