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 avariant 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 totrue
. When a variant control evaluates totrue
, 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: 4-cylinder gas, 6-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 theVariant Subsystemblock namedEngine
and then switch between the subsystems based on the value ofEngineType
. Similarly, you could use a variant parameterkv
to store multiple values of throttle and then switch between the values based on the value ofnc
. For example, if the value ofEngineType
is1
and the value ofnc
is2
, a throttle value of20
is provided as an input to theEngine_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 theVariant Subsystemblock namedEngine
. For more information on how to control structural variations, seeVariant 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, seeVariant Control Mode in Variant Parameters.