Propagate Variant Conditions to Define Variant Regions with Variant Blocks - MATLAB & Simulink (original) (raw)

Main Content

Variant condition propagation is the process whereby Simulink® determines which model components are active during simulation. This process evaluates the variant controls specified on the variant blocks and propagates the conditions of blocks using variant conditions. Variant conditions can propagate through signal lines, buses, and function calls to reach other blocks in the model. This process deactivates the model components associated with the inactive choices, and they are not included in the simulation. You can control the condition propagation to define the variant regions in the model. Simulink uses the variant activation time to determine when it chooses the active variant choice. For more information on variant activation time, see Activate Variant During Different Stages of Simulation and Code Generation Workflow.

Propagating the conditions of the blocks can:

Variant condition propagation

Visualize Propagated Variant Conditions in 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 the Variant Source blocks. A specific variant condition activates each variant choice.

To view the Variant Conditions Legend, on the Debug tab, select > . If Variant Legend is not available, on theDebug tab, select > . Alternatively, to view the programmatically, use the variantLegend function in the MATLAB® Command Window.

Note

Variant Conditions Legend does not display the variant conditions for variant parameters. Use the Variant Parameters tab in the Variant Manager window to view the values and variant conditions for choices of variant parameters.

By default, the Variant Conditions Legend displays these fields:

To view the variant condition in the generated code, select Show generated code conditions.

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, you must select the Variant Condition option.

Variant condition annotations have these properties:

Propagate Variant Conditions from Variant Blocks Upstream and Downstream

You can expand the variability control to any region of your model by automatically propagating variant conditions from variant blocks to other blocks upstream and downstream. Variant conditions can propagate through signal lines, buses, and function calls to reach blocks in a model affected by variant selection. For information on how variant conditions are constructed, see Assemble Variant Conditions Propagated from Variant Blocks.

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

Limitations

Signals from variant blocks to a Mux, Demux, or Vector Concatenate block must have the same variant condition.