Main Content

Masking Fundamentals

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

  • 提供一个对话框,使您只能访问底层块的选择参数

  • 提供特定于蒙版块的用户自定义描述

  • Initialize parameters using MATLAB®代码

Consider the modelmasking_examplethat represents the equation of liney = mx + b.

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.

这里的变量mrepresents slope and the variablebrepresents the intercept for the line equationy = mx + b.

The mask dialog box displays the fields forSlope截距that are internally mapped to variablesmb.

屏蔽块不支持内容预览。金宝app要预览子系统的内容,请参阅预览模型组件的内容.

Tip

For masking examples, seeSimulink Masking Examples. The examples are grouped by type. In an example model:

  • To view the mask definition, double-click theView Maskblock.

  • 要查看蒙版对话框,请双击块。

Examples of few blocks that cannot be masked are:

  • Scope blocks

  • Simulink Function block

  • Initialize, Terminate and Reset Function blocks

  • Gauge blocks

Masking Terminology

Term Description

面具图标

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 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 theInitialization窗格编辑器对话框的窗格。例如,添加初始化代码以自动设置参数值。

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.

Mask documentation

Description and usage information for a masked block defined in the Mask Editor.

Mask dialog box

一个对话框,包含用于设置掩码参数值的字段,并提供掩码描述。

Mask workspace

定义蒙版参数或包含初始化代码的掩码具有掩码工作区。此工作区存储掩码参数的评估值和掩码使用的临时值。

相关话题