Guy on Simulink

Simulink & Model-Based Design

Dynamics Mask Icons for Subsystem Variants

Today I will illustrate how to combine two features I like: Subsystem Variants and Masking.

The Question

I created a subsystem with two variants and I have specific masks for each variant:

Subsystem variants with different masks

I would like to automatically display the mask of the active variant on the top subsystem.

The Solution

As you probably guessed, the trick is to define the correct Icon Drawing Commands for the top subsystem. After juggling with multiple options, I came up with the following process:

  • Use get_param to determine the active variant
  • Use find_system to determine the subsystem corresponding to the active variant
  • Use get_param to obtain a string containing the Icon Drawing Commands of the active variant
  • Evaluate this string as the top subsystem Icon Drawing Commands

All together, the Mask Editor should look like this:

Icon Drawing Commands seen in the Mask Editor

And your model will behave like this:

Subsystem variants with different masks, in action!

Now it's your turn

Have you integrated Subsystem Variants in your workflow? Leave a comment here.

|
  • print

评论

要发表评论,请点击 此处 登录到您的 MathWorks 帐户或创建一个新帐户。