Introduction to Variant Controls
The components of a Simulink® model that contain variants are activated or deactivated based on the variant choice that you select.
Each variant choice in your model is associated with a variant
control. Variant controls determine which variant choice is active. By changing
the value of a variant control, you can switch the active variant choice. While each variant
choice is associated with a variant control, only one variant control can evaluate to
true
. When a variant control evaluates to true
,
Simulink activates the variant choice that corresponds to that variant control.
Suppose you want to simulate a model that represents a vehicle with three possible engine
configurations: 1-cylinder gas, 4-cylinder gas, and 8-cylinder gas. In this scenario, the
value of throttle is an input to the engine that differs for different configurations. You
could implement each engine configuration as a separate subsystem inside the Variant
Subsystem block named Engine
and then switch between the
subsystems based on the value of EngineType
. Similarly, you could use a
variant parameter kv
to store multiple values of throttle and then switch
between the values based on the value of nc
. For example, if the value of
EngineType
is 1
and the value of nc
is 2
, a throttle value of 20
is provided as an input to
the Engine_2_cyl_petrol
subsystem during simulation.
In this example:
Structural variations are controlled by using the variant controls
EngineType == 1
,EngineType == 2
, andEngineType == 3
in the Variant Subsystem block namedEngine
. For more information on how to control structural variations, see Variant Control Modes in Variant Blocks.Value variations are controlled by using the variant controls
nc == 1
andnc == 2
in the variant parameterkv
. For more information on how to control value variations, see Variant Control Mode in Variant Parameters.