I created a subsystem with two variants and I have specific masks for each variant:
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:
What are some reasons to use Variant Subsystems? Is it to try out different algorithms in the code, for example vehicle braking algorithms that will afterwards be compared in order to select the one with the best performance?
It is common to have multiple models of the same plant. For some tasks, a high-fidelity model is required. For some other tasks, a lower-fidelity plant is acceptable and simulates faster.
Another use case is switching between a simulated plant and hardware drivers, as I illustrated here:
For those interested in generating code, you can use the “Generate preprocessor conditionals” option, to generate code for all variants, but build only one selected using a “#define” in the code.
Leave a Reply
About
Guy Rouleau and Seth Popinchalk are Application Engineers for MathWorks. They write here about Simulink and other MathWorks tools used in Model-Based Design.
What are some reasons to use Variant Subsystems? Is it to try out different algorithms in the code, for example vehicle braking algorithms that will afterwards be compared in order to select the one with the best performance?
@KE: The use case you mention is one possibility.
It is common to have multiple models of the same plant. For some tasks, a high-fidelity model is required. For some other tasks, a lower-fidelity plant is acceptable and simulates faster.
Another use case is switching between a simulated plant and hardware drivers, as I illustrated here:
http://blogs.mathworks.com/seth/2011/12/27/model-based-design-dilemma/
For those interested in generating code, you can use the “Generate preprocessor conditionals” option, to generate code for all variants, but build only one selected using a “#define” in the code.