Main Content

Variant Condition Propagation Overview

Automatically Identify Variant Regions Using Variant Condition Propagation

Simulink® determines the model components that are active during simulation by the process of variant condition propagation. This process evaluates the variant controls specified on the variant blocks and automatically propagates the variant conditions to the connecting blocks. Variant conditions can propagate through signal lines, buses, and function calls to reach other blocks in the model. The process deactivates the model components associated with the inactive choices, and they are not included in simulation. You can control condition propagation to define variant regions in the model.

Variant condition propagation

Visualize Propagated Variant Conditions Using Variant Conditions Legend

You can use the Variant Conditions Legend to visualize the propagated variant conditions that activate each variant choice. Simulink annotates model components if there are variant conditions on them, and the Variant Conditions Legend displays the condition that corresponds to each annotation.

Consider this model containing multiple variant choices feeding into Variant Source blocks. A specific variant condition activates each variant choice.

To view the Variant Conditions Legend, on the Debug tab, select Information Overlays > Variant Legend.


If Variant Legend is not available, on the Debug tab, select Information Overlays > Variant Conditions.

The Variant Conditions Legend dialog box appears. By default, the Variant Conditions Legend displays the variant condition annotation, the variant condition during simulation, and the source of the variant condition variables. To view the variant condition in the generated code, select Show generated code conditions.

The variant conditions on the blocks are annotated as v:C, where v is the variant semantic indicator and C represents the variant condition index. You can click through the hyperlinked variant annotations to observe which parts of the model the condition corresponds to. For example, if you click v:3, the parts of the model that have the condition V==3 are highlighted as shown in this image.

When you pause on a block that has a variant condition, the tooltip displays the variant annotation and the related variant condition for the block. To view the variant condition annotation tooltip, the Variant Condition option must be selected.

In the legend, the source of the variant condition variables are also displayed. The variables can originate from a mask, a model, or a base workspace. All the variables used in a block must originate from the same source. In a model, the variables originating from different mask workspaces can have the same name and have different values. To observe the source of the variables, click the hyperlinked workspaces.


With the Variant activation time parameter set to update diagram, the source of variables displayed for inactive choices may be incorrect. The inactive choices are removed prior to propagation of signal attributes and are therefore not evaluated.

To view the Variant Condition Legend programmatically, use the variantLegend function in the MATLAB® Command Window.

Variant condition annotations have these properties:

  • There are no annotations on unconditional blocks.

  • To reduce clutter, the legend only displays the final computed conditions. For example, if you enter a variant condition in a Variant Source block, that condition appears in the annotations only when you apply your changes.

  • The conditions in the legend are sorted during display.

  • In the legend, a condition is set to false if the blocks associated with that condition are never active.

    For example, the Inport4 block is connected to the Variant Source1 block, whose condition is V==1. Variant Source1 is connected to the Variant Source2 block, which activates Variant Source1 only when V==4. Therefore, Inport4 can only be active when V==1 && V==4, a condition that is always false.

  • In the legend, the (default) keyword is displayed as negated condition.

Condition Propagation Scenarios

This table lists the topics that explain how condition propagation works with different model components.

Variant Subsystem block

Propagate conditions outside a Variant Subsystem block.

Adaptive interface capability of a Variant Subsystem block.

Propagate Variant Conditions Outside a Variant Subsystem Block

Propagate conditions to conditionally executed subsystem blocks such as Enable, Trigger, Reset, and Function-Call Subsystem when they are used as variant choices within a Variant Subsystem block.

Use Variant Subsystem block to create an export-function model.

Use Variant Subsystem Blocks with Conditionally Executed Subsystems
Output variant function-call signals at the outports of a Variant Subsystem.Variant Function-Call Signals on Variant Subsystem Outport
Variant Source and Variant Sink blocksPropagate conditions from Variant Source and Variant Sink blocks.Variant Condition Propagation with Variant Sources and Sinks
Variant Source blockPropagate conditions to conditionally executed subsystem blocks such as Enable, Trigger, Reset, and Function-Call Subsystem .Propagate Variant Conditions from Variant Source Blocks to Conditionally Executed Subsystems
Output variant function-call signals at the outport of a Variant Source.Use Variant Source Block to Receive or Output Function-Call Signals for Simulation and Code Generation
Propagate conditions to virtual and nonvirtual subsystems.Propagate Variant Conditions from Variant Source Blocks to Subsystem Blocks
Propagate conditions to Model blocks.Variant Condition Propagation with Model Block
Propagate conditions to bus element blocks.Variant Condition Propagation with Bus
Variant Connector blockPropagate conditions to components within a physical network.Variant Connector (Simscape)
Simulink Function blocksSpecify or inherit variant conditions on Simulink Function blocks.Variant Condition Propagation with Simulink Function block
Initialize, Reset, and Terminate blocksPropagate conditions to Initialize, Reset, and Terminate blocks.Variant Condition Propagation with Initialize, Reset, and Terminate Blocks
Variant modelsStop propagation of variant conditions in a model.Control Variant Condition Propagation

Related Topics