- Simulink models can have variant subsystems. A variant subsystem contains subsystems and/or model references as variant choices.
- Each variant choice in your model is associated with a conditional expression called variant control.
- When a variant control evaluates to true, Simulink activates the variant choice that corresponds to that variant control. Only one variant control can evaluate to true.
- By changing the value of a variant control, you can switch the active variant choice.
How Do I Interactively Set Up a Model with User Input?
5 ビュー (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2021 年 3 月 22 日
編集済み: MathWorks Support Team
2025 年 11 月 10 日
I have a Simulink model that has variant subsystems. Ultimately, I want to create a simple way for a user, who is not familiar with this model, to set up the model (i.e. choose the variant choice for each subsystem).
採用された回答
MathWorks Support Team
2025 年 11 月 10 日
編集済み: MathWorks Support Team
2025 年 11 月 10 日
Referring to the "Introduction to Variant Controls":
Variant choices can be controlled with a label variant control or an expression variant control (and starting in R2020b "sim codegen switching"). Please read more at the following documentation page to learn more:
While this list does not exhaust all the options to update variant choices, here are three common ways.
1. Use hyperlinks on text in Simulink to invoke MATLAB code when clicked
2. Use a subsystem's mask as a drop down menu
3. Use MATLAB Live Scripts
The attached examples were created in R2020a. Please use R2020a or later to open the examples.
One folder contains examples that use the "label" variant control mode. Another folder contains examples that use the "expression" variant control mode
Note that Simulink's default behavior is to choose the active variant choice during update diagram (Ctrl +D):
0 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!