Main Content

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 namedEngineand then switch between the subsystems based on the value ofEngineType. Similarly, you could use a variant parameterkvto store multiple values of throttle and then switch between the values based on the value ofnc. For example, if the value ofEngineTypeis1and the value ofncis2, a throttle value of20is provided as an input to theEngine_2_cyl_petrolsubsystem during simulation.

In this example:

  • Structural variations are controlled by using the variant controlsEngineType == 1,EngineType == 2, andEngineType == 3in 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 controlsnc == 1andnc == 2in the variant parameterkv. For more information on how to control value variations, seeVariant Control Mode in Variant Parameters.

Model with variant controls in variant block and in variant parameter

Related Examples

More About