Main Content

Variant Condition Propagation Overview

Automatically Identify Variant Regions Using Variant Condition Propagation

金宝app®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 intoVariant Sourceblocks. A specific variant condition activates each variant choice.

To view the Variant Conditions Legend, on theDebugtab, selectInformation Overlays>Variant Legend.

Note

IfVariant Legendis not available, on theDebugtab, selectInformation 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, selectShow generated code conditions.

The variant conditions on the blocks are annotated asv:C, wherevis the variant semantic indicator andCrepresents 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 clickv:3, the parts of the model that have the conditionV==3are highlighted as shown in this image.

当你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, theVariant Conditionoption 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.

Note

With theVariant activation timeparameter set toupdate 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 theVariant Condition Legendprogrammatically, use thevariantLegendfunction 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 aVariant Sourceblock, 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 tofalseif the blocks associated with that condition are never active.

    For example, theInport4block is connected to theVariant Source1block, whose condition isV==1.Variant Source1is connected to theVariant Source2block, which activatesVariant Source1only whenV==4. Therefore,Inport4can only be active whenV==1 && V==4, a condition that is alwaysfalse.

  • 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.

Block Scenario Topic
Variant Subsystemblock

公关opagate conditions outside aVariant Subsystemblock.

Adaptive interface capability of aVariant Subsystemblock.

公关opagate Variant Conditions Outside Variant Subsystems

传播条件conditionally executed subsystem blocks such asEnable,Trigger,Reset, andFunction-Call Subsystemwhen they are used as variant choices within aVariant Subsystemblock.

UseVariant Subsystemblock to create an export-function model.

Use Variant Subsystem Blocks with Conditionally Executed Subsystems
Output variant function-call signals at the outports of aVariant Subsystem. Variant Function-Call Signals on Variant Subsystem Outport
Variant SourceandVariant Sinkblocks 公关opagate conditions fromVariant SourceandVariant Sinkblocks. Variant Condition Propagation with Variant Sources and Sinks
Variant Sourceblock 传播条件conditionally executed subsystem blocks such asEnable,Trigger,Reset, andFunction-Call Subsystem. 公关opagate Variant Conditions from Variant Source Blocks to Conditionally Executed Subsystems
Output variant function-call signals at the outport of aVariant Source. Use Variant Source Block to Receive or Output Function-Call Signals for Simulation and Code Generation
传播条件virtual and nonvirtual subsystems. 公关opagate Variant Conditions from Variant Source Blocks to Subsystem Blocks
传播条件Modelblocks. Variant Condition Propagation with Model Block
传播条件bus element blocks. Variant Condition Propagation with Bus
Variant Connectorblock 传播条件components within a physical network. Variant Connector(Simscape)
金宝app仿真软件的功能blocks Specify or inherit variant conditions on金宝app仿真软件的功能blocks. Variant Condition Propagation with Simulink Function block
Initialize,Reset, andTerminateblocks 传播条件Initialize,Reset, andTerminateblocks. Variant Condition Propagation with Initialize, Reset, and Terminate Blocks
Variant models Stop propagation of variant conditions in a model. 控制变异条件下传播

Related Topics