Propagate Variant Condition to Conditional Subsystem

A conditional subsystem (also known as a conditionally executed subsystem) is a type of subsystem where you can control the execution using an external signal.

Enabled, Triggered, and Function-Call Subsystems are examples of conditional subsystems. The signal that controls a conditional subsystem is called the control signal and the port from which the signal enters the block is called the control port. For more information on conditional subsystems, see Conditional Subsystems.

You can use a Variant block to control the execution of a conditional subsystem blocks.

Consider this model.

Variant Source1 is a single-input/single-output Variant Source block with variant condition as V==1. When you simulate this model, the variant condition from the Variant Source1 block propagates to the control port of the Subsystem block and then to the blocks connected to its inports and outports.

For example, when V=1, Variant Source1 is active and the Variant condition propagates to the control port of the Subsystem block. Therefore, the Subsystem block is also active and the variant condition propagates to the blocks connected to the input and output ports of the Subsystem block.

Propagate Variant Condition to Function-Call Subsystem

A Function-Call Subsystem block is a subsystem that another block can invoke directly during simulation. The Function-Call Subsystem block is analogous to a function in procedural programming language. For more information, see Using Function-Call Subsystems.

You can use a single-input/single-output variant block to make the Function-Call Subsystem block conditional.

The Variant Source block has condition V==1, where V is a Simulink.Parameter.

When you simulate this model, the variant condition from the Variant Source block propagates to the control port of the SubA subsystem block and further propagates to the blocks connected to its inports and outports.

For example, when V=1, the SubA block is active and the variant condition propagates backward and forward to the blocks connected to the input (In1) and output (Out1) ports.

When V~=1 (for example, V=0), SubA becomes inactive, making Out1 to be inactive. In2 remains active as it is connected to SubB, which is active.

If In2 is not connected to SubB, In2 becomes inactive when V~=1.

Note: If the Function-Call Subsystem is placed inside a virtual grouped subsystem, the variant condition triggering the Function-Call Subsystem must match the corresponding condition on the input of the higher level subsystem block.