Documentation

Masking Fundamentals

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 is saved along with it. A mask changes only the interface to the block, 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.

You can 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 masking_example that governs the equation of line y = mx + b.

Each block has its own block dialog box making it complicated to specify the values for the variables for the line equation. 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 + b.

The mask dialog box displays the fields for Slope and Intercept that are internally mapped to variables m and b.

If you use a mask only to represent the contents of a subsystem, consider using content preview instead. Masked blocks do not support content preview. For details, see Preview Content of Hierarchical Items .

    Tip   To view the masking examples, see Simulink Masking Examples. Notice that the examples of similar type are grouped. 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.

Masking Terminology

Terminology Table

TermDescription

Mask icon

The masked block icon generated using drawing commands. Mask icon can be static or change dynamically with underlying block parameter values.

Mask parameters

The parameters that are defined in 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 Mask Editor dialog box. For examples, 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 to reflect current parameter values. For example, enable visible parameters on the dialog box.

Mask documentation

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.

Mask workspace

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.

More About

Was this topic helpful?