Main Content

Promote Parameter to Mask

块和子系统可以具有与之关联的多个参数。块蒙版允许您在隐藏其他参数的同时公开其中一个或多个参数。将特定参数促进掩模块简化了接口,并使您可以指定块用户可以查看和设置的参数。

您可以使用Promote掩码编辑器上的按钮将块的任何基础参数推广到块蒙版或子系统蒙版。促进的块参数与蒙版中的参数相关联,使您能够从“掩码”对话框编辑参数值。

Promote parameters from the block dialog box to the mask:

  • To customize the mask dialog box by moving the required parameters from the block dialog box to the mask dialog box.

  • To reuse a library block at different instances of a model. For each instance of the library block, you can create individual mask dialog box by promoting parameters for each block.

Consider the block dialog box of theGainblock, which has parameters such asGain,,,,Multiplication

仅公开Gainparameter, mask theGainblock and promote theGainparameter to the mask dialog box.

同样,您可以掩盖子系统块,并将参数从子系统块的子块中升级到掩模。如果子系统子块参数的数据类型相同,则可以将单个掩码参数与多个促进参数相关联。例如,您可以促进多个Gain子系统中的参数到蒙版上的一个对话框。

如果参数是数据类型的弹出or数据类型,选项也必须相同,以便将参数一起推广。这Evaluateattribute for all the parameters to be promoted must be similar.

For a related example, see促进掩模参数

您还可以更改促进参数的属性。例如,您可以使促销参数仅读取或隐藏。有关属性的更多信息,请参阅Property editor

促进基础参数以阻止掩码

  1. 选择the block whose parameter you want to promote.

  2. Block选项卡,单击Create Mask

  3. In the面具Editordialog box, click the参数和对话框标签。

  4. In the控件窗格,单击Promote

  5. In theProperty editor窗格,旁边类型选项,,,,click

    使用促进参数选择器对话框以选择要宣传的参数。

  6. 为了将参数添加到促进参数list, select a parameter from the可促进的参数s表并单击添加到促进的参数列表按钮

    To view the parameter properties such asType,悬停在参数名称中可促进的参数pane.

    小费

    • 您可以使用儿童块list or the搜索框以查找基础块参数以促进。

    • 为了防止在模拟过程中调整财产,您可以禁用Tunable在促进可调参数的同时属性。

  7. 点击OK

  8. In the面具Editor对话框,编辑促进参数的提示名称,然后单击OK。您不能编辑变量名。您可以更改属性编辑器部分中促进参数的属性。例如,您可以将促进的参数标记为仅读取,评估,隐藏和可调。有关更多信息,请参阅Property editor

  9. 点击OK。看看块面膜。仅您宣传的参数才能设置。

    笔记

    • You can use促进一切促进所有参数。促进一切is available for all block masks except for subsystem masks.

    • To remove a promoted parameter, select the parameter and press删除key.

    • You cannot view or promote parameters of a nested masked or linked child block.

    • Do not promote the parameters of built-in Simulink blocks, as these blocks may have internal callbacks associated with them.

Promote Underlying Parameters to Subsystem Mask

  1. 选择the subsystem.

  2. 子系统块tab, in the面具小组,单击Create Mask

  3. In the面具Editordialog box, click the参数和对话框标签。

  4. In the控件窗格,单击Promote

  5. In theProperty editor窗格,旁边类型选项,,,,click

  6. In the促进参数选择器对话框,选择要宣传的参数。

  7. 为了将参数添加到促进参数list, select a parameter from the可促进的参数s表并单击添加到促进的参数列表按钮

    您可以将相同数据类型的参数从不同的子块添加到促进参数列表。例如,Gainparameter from a different child block can be added to the促进参数list to promote to the singleGainparameter on the mask.

  8. 点击OK

  9. In the面具Editor对话框,编辑促进参数的提示名称,然后单击OK。您不能编辑变量名。

  10. 点击OK。看看块面膜。仅您宣传的参数才能设置。

未解决的促进参数

当促进的参数与基础块参数断开连接时,未解决促进的参数。未解决的促进参数可能会导致模型错误,因为促进的参数找不到相应的块参数。由于这些原因中的任何一个原因,促进参数可能无法解决:

  • 这underlying block is deleted.

  • 这underlying block is replaced with another block of same name but does not have the specified parameter.

  • 下面的块移到另一个面具中。

Best Practices

  • Set the value of a promoted parameter only in the mask dialog box and not in the underlying block dialog box or from the command line.

  • 曾经晋升的参数不能再次推广到任何其他面具。

  • Do not edit theEvaluateattribute of the promoted parameter. This property is inherited from the block parameter.

  • If you are promoting a nontunable parameter, do not edit theTunable属性。

  • Parameters of a masked or linked child block cannot be viewed or promoted.

  • Callbacks associated with a block parameter are promoted to the block mask and not to the subsystem mask. User-defined callbacks are sequentially executed after the dynamic dialog callback execute.

在掩码上促进块参数

You can use Parameter Promotion to promote any underlying parameter of a block either to a block mask or to a subsystem mask. This model contains a subsystem that has 3 Gain blocks (增益1,,,,增益2,,,,and *Gain3). The variable K represents the Gain parameter for these Gain blocks. You can promote only the Gain parameter of each of these Gain blocks to the block mask as a single parameter. When you do so, the parameter K is available on the mask for editing and its value will be applied to增益1,,,,增益2,,,,and增益3blocks.

  1. 选择子系统块。

  2. 子系统块tab, in the面具小组,单击Create Mask/Edit Mask

  3. 在“掩码编辑器”对话框中,单击参数和对话框标签。

  4. In the控件窗格,单击Promote

  5. In theProperty editorpane,类型选项字段,单击

  6. In the促进参数选择器dialog box, select增益1

  7. 选择Gainfrom the可促进的参数s表并单击添加到促进的参数列表按钮。Similarly, add Gain parameter for增益2

  8. 点击OK

  9. In the Mask Editor dialog box, edit the prompt names for theGain范围。这里使用的提示是Common gain

  10. 点击OK完成以多对多促销方式创建子系统面具。

  11. Simulate the model. Notice that the value 4 is passed from the mask to the underlying block增益1,,,,增益2,,,,and增益3。In this case, the output shows 64.

open_system('promote_block_param_to_mask');

Related Topics