Main Content

Conditionally Executed Subsystems Overview

A conditionally executed subsystem is a nonvirtual subsystem that allows you to control its execution with an external signal. The external signal, called the control signal, is attached to the control input port. Conditional subsystems are useful when you create complex models that contain components whose execution depends on other components.

Simulink canvas with Conditionally Executed Subsystem block. Subsystem block has control input port at the top and data input port at the left, both connected to Inport blocks. Subsystem block has data output port at the right, connected to an Outport block.

Simulink® supports these types of conditional subsystems:

  • Enabled Subsystem — Executes at each time step while the control signal is positive. Execution starts at the time step when the control signal crosses zero from the negative to the positive direction. See Using Enabled Subsystems.

  • Triggered Subsystem — Executes at each time step when the control signal rises or falls to zero or crosses zero. See Using Triggered Subsystems.

  • Enabled and Triggered Subsystem — Executes at the time step when the enable control signal has a positive value and the trigger control signal rises or falls to zero. See Using Enabled and Triggered Subsystems.

  • Function-Call Subsystem — Executes when the control signal receives a function-call event. Events can occur one or more time during a time step. A Stateflow® chart, Function-Call Generator block, S-Function block, or Hit Crossing block can provide function-call events. See Using Function-Call Subsystems.

A conditionally executed subsystem or conditionally executed referenced model runs:

  • Once at the current time step when enabled by a control block. A control block implements control logic similar to that expressed by a programming language statement such as if-then-else or switch.

  • Once at the current time step when enabled or triggered by a control signal or an action signal.

  • One or more times during a time step when receiving a function-call event.

Simulink canvas with If block with 2 output ports, each of which is connected by dotted lines to the action port of a separate If Action subsystem block. Output of each If Action subsystem block is connected to a Merge block, whose output is connected to an Outport block. Inputs of the If block and both If Action Subsystem blocks are connected to Inport blocks.

Simulink canvas showing 2 models. In the first model, there are 2 Enabled Subsystem blocks. An Inport block lableled "Enable Signal" is connected to the control port of one Enabled Subsystem block, and to a Not block whose output is connected to the other Enabled Subsystem block. The outputs of both Enabled Subsystem blocks are connected to a Merge block. In the second model, an Inport block labeled "Function-Call Event" is connected to the control port of a Model block labeled "Enabled_Model".

Model Examples

See Also

Blocks

Related Examples

More About