How Do I Interactively Set Up a Model with User Input?

조회 수: 5 (최근 30일)
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
MathWorks Support Team 2025년 11월 10일
편집: MathWorks Support Team 2025년 11월 10일
Referring to the "Introduction to Variant Controls":
  • 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.
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개)

카테고리

Help CenterFile Exchange에서 Variant Hierarchical Components에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by