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
true. When a variant control evaluates to
true, Simulink activates the variant choice that corresponds to that variant
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
then switch between the subsystems based on the value of
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
1 and the value of
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, and
EngineType == 3in the Variant Subsystem block named
Engine. 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 == 1and
nc == 2in the variant parameter
kv. For more information on how to control value variations, see Variant Control Mode in Variant Parameters.