Main Content

公关opagate Variant Conditions from Variant Source Blocks to Subsystem Blocks

A Subsystem block can represent a virtual subsystem or a nonvirtual subsystem. A virtual subsystem provides graphical hierarchy in a model and does not impact the execution of a model. A nonvirtual subsystem executes as a single unit within a model. Simulink propagates variant conditions differently to these subsystems. This example shows the propagation of variant conditions from a Variant Source block to Subsystem blocks.

Explore the Model

Open the model,slexVariantCondPropToSubsystems.

ClickSimulation>Runto simulate this model and see the variant conditions being propagated from the Variant Source blocks to the blocks connected to it.

The variant condition annotation helps you visualize the propagated conditions. To be able to view the variant condition annotation, clickDisplay>Blocks>Variant Condition Legend.

The model contains three Variant Source blocks:Variant Source1,Variant Source2, andVariant Source3, respectively.

Variant Source1contains conditionsV = 1andV = 2at inport. The variant conditionV = 1propagates toGainA1whileV = 2propagates toSine2. TheSine1block does not get any propagated variant conditions because it is connected to a block, which is always consumed irrespective of the variant condition. If theTo Workspace block1did not exist or was commented-out before simulating the model, variant conditionV = 1propagates toSine1.

Variant Source2is connected to virtual subsystemsSubsystem1andSubsystem2that have identical contents, aSine Waveblock connected to aTo Workspaceand anOutputblocks.Subsystem1is a grouped virtual subsystem (Treat as grouped when propagating variant conditionsis selected) while Subsystem2 (Treat as grouped when propagating variant conditionsis clear) is an ungrouped virtual subsystem.

A Subsystem block becomes a grouped virtual subsystem when you select theTreat as grouped when propagating variant conditionscheck box in the block parameters dialog box. When theTreat as grouped when propagating variant conditionscheck box is clear, the subsystem is an ungrouped virtual subsystem.

A grouped subsystem represents a system of equation and hence the propagated conditions also apply to the blocks within this system. A grouped subsystem has a continuous boundary line. An ungrouped subsystem does not represent a system of equation and the blocks within it have ungrouped semantics. An ungrouped subsystem has a dotted boundary line and the conditions are propagated into the subsystem.

The variant conditionV = 1propagates toSubsystem1and further to the blocks within it asSubsystem1is a grouped virtual subsystem (represents a system of equation). Since Subsystem1 is a system, the condition also applies the blocks within the system.

Subsystem2that is an ungrouped virtual subsystem (does not represent a system of equation) also receivesV = 1as the propagated condition, and the propagated variant conditionV = 1propagates intoSubsystem 2as if the subsystem were expanded. The dotted lines on the Subsystem 2 icon indicates that it is flattened during Simulink compilation and hence you can see variant condition for those blocks inside it.

Variant Source3is connected to a nonvirtual (atomic) subsystem withV = 1as the propagated variant condition. A nonvirtual (atomic) subsystem always represents a system of equations. An atomic subsystem has a continuous solid boundary line. The variant condition does not propagate inside the nonvirtual subsystem. Instead, it stays on the boundary. However, all blocks inside that subsystem get same variant condition as the Subsystem. The nonvirtual subsystem behaves as an entity.

Virtual subsystems by default works like a grouped collection of blocks where all the blocks contained inside the subsystem have the same variant condition. This is true when theTreat as grouped when propagating variant conditionsparameter is selected. Virtual subsystems behave like an ungrouped collection of blocks when theTreat as grouped when propagating variant conditionsparameter is cleared. In this example, the behavior of the Subsystem2 (Ungrouped) may not be as expected as the block never becomes conditional. Nonvirtual subsystems always behave like an entity and the contents only execute when the condition assigned to the subsystem is satisfied. Nonvirtual subsystems, Model blocks, and grouped virtual subsystems behave the same.

Virtual Subsystems with Treat as Grouped when Propagating Variant Conditions

Treat as grouped when propagating variant conditionsoption is On: Consider an example with Variant Source block:Variant Source5and a virtual subsystemSubsystem4. TheVariant Source5has a conditionV = 1.Subsystem4has a Sine Wave connected to aTo Workspace1andOutportblocks.

Subsystem4 gets conditionV = 1asV = 1is propagated fromVariant Source5. The blocks insideSubsystem4间接继承的条件Subsystem4.Subsystem4is conditional as its inports/outports are conditional. To make theSubsystem4as unconditional, add a new outport or clear theTreat as grouped when propagating variant conditionsoption.

Treat as grouped when propagating variant conditionsoption is Off: Consider an example with a Variant Source block:Variant Source4and a virtual subsystemSubsystem3. TheVariant Source4has conditionV = 1.Subsystem3has a Sine Wave connected to aTo WorkspaceandOutportblocks.

Subsystem3gets the conditionV = 1asV = 1propagates fromVariant Source4. However due to unconditional blockTo Workspace1, the propagation stops and the conditionV = 1is set only to theOut1port. Now theSubsystem3is also unconditional due to presence of unconditional blocks within.

More About