Main Content

Variant Function-Call Signals on Variant Subsystem Outport

This example shows how the Variant Subsystem block allows function-call signals from its choice blocks to be merged on its outports.

NOTE: A Variant Subsystem block with more than one variant choice does not support function-call signals on its outports when the variant activation time is set to startup.

Explore the Model

Open the model slexVariantSubsystemFunctionCall.

open_system('slexVariantSubsystemFunctionCall.slx');

The model contains a Variant Subsystem block with two Chart blocks, Chart1 and Chart2, as variant choices. The variant control variable A is defined in the PreLoadFcn model callback. The variant conditions on Chart1 and Chart2 are A==1 and A==2 respectively. A Pulse Generator block is connected to the Variant Subsystem block and all its choices. Chart1 and Chart2 are configured with port names that match the corresponding port names of the Variant Subsystem block.

open_system('slexVariantSubsystemFunctionCall/Variant Subsystem');

The Output function call parameter is selected on the Signal Attributes tab of the Block Parameters dialog box of the Outport block named activate(). This allows the Outport block of the variant subsystem to emit function-call signals. To enable this option programmatically, use this command:

set_param('slexVariantSubsystemFunctionCall/Variant Subsystem/activate()','OutputFunctionCall','on');

Simulate the Model

To simulate the model, on the Simulation tab, click Run. Variant condition propagation determines the active and inactive variant choices.

  • When A==1, Chart1 is active.

  • When A==2, Chart2 is active.

The outport activate() gets function-call signal from the choices Chart1 and Chart2. When the Function-Call Subsystem block is triggered, there is a sine wave output at Out2.

sim('slexVariantSubsystemFunctionCall.slx');

More About