Each variant choice in your model is associated with a conditional expression called
variant control. The way you specify your variant controls determines the active variant
choice. Variant control mode parameter available in the block
parameters dialog box allows you to select
Label mode for modeling Variant blocks.
This image shows the block parameters dialog box of a Variant Subsystem block that contains four variant choices:
The first choice is commented out by adding the
before the variant control.
The second choice is the
(default) and is activated when no
variant control evaluates to
The third choice is activated when the expression
version==2 evaluates to
The fourth choice is activated when the expression
version==1 evaluates to
You can specify at most one variant choice as the default for the model. As shown
in the image above, the
Linear Controller subsystem is defined as
the default variant choice. During model compilation, if Simulink® finds that no variant control evaluates to
uses the default choice.
In the dialog box, select the variant choice and change its Variant
control property to
While each variant choice is associated with a variant control, only one variant
control can evaluate to
true at a time. When a variant control
true, Simulink activates the variant choice that corresponds to that variant control.
At most one variant choice can be active. The active variant cannot be changed once
model is compiled.
In this example, you can activate either the
choice or the
Nonlinear Controller variant choice by specifying
appropriate values for
|Value of ||Value of ||Active variant choice|
You can specify the values of
version at the MATLAB® Command Window.
When a variant control activates one variant choice, Simulink considers the other variant choices to be inactive. Simulink ignores inactive variant choices during simulation. However, Simulink continues to execute block callbacks inside the inactive variant choices.
When you are prototyping variant choices, you can create empty Subsystem blocks with no inputs or outputs inside the Variant Subsystem block. The empty subsystem recreates the situation in which that subsystem is inactive without the need for completely modeling the variant choice.
For an empty variant choice, you can either specify a variant activation condition
or comment out the variant condition by placing a
% symbol before
If this variant choice is active during simulation, Simulink ignores the empty variant choice. However, Simulink continues to execute block callbacks inside the empty variant choices.
When you open a model, variant blocks display the name of the variant that was active the last time that you saved your model. Use the Variant menu to open the active variant. Right-click the block and select Variant > Open. Then select the active variant.
Use this command to find the current active choice:
Use this command to find the path to the current active choice:
CompiledActiveChoiceBlock parameter is
supported only for the Variant Subsystem block.
Active variant cannot be changed once the model is compiled.