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 계정에 로그인하거나 계정을 새로 만드십시오.