Introduction to Variant Controls - MATLAB & Simulink (original) (raw)

Main Content

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 totrue. 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 ofEngineType 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:

Model with variant controls in variant block and in variant parameter

See Also

Topics