Main Content

Conditionally Executed Subsystems and Models

Control when subsystem or model executes

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

Simulink® supports these types of conditional subsystems:

  • Action Subsystem — Executes at each time step when a logical condition is true in an If Action Subsystem or when a signal has one of a specified set of values in a Switch Case Action Subsystem. See Select Subsystem Execution.

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

  • Message Triggered Subsystem and Message Polling Subsystem — Uses messages as a control signal, and executes based on whether a message is available at the control port. See Using Message Polling and Message Triggered Subsystems.

  • Function-Call Subsystem — Executes when the control port receives a function-call event. Events can occur one or more time during a time step. See Using Function-Call Subsystems.

Simulink also supports the Resettable Subsystem, which executes at each time step but resets all blocks within the subsystem to their initial condition when the control signal rises or falls to zero or crosses zero. See Using Resettable Subsystems.

You can configure a referenced model for conditional execution like a subsystem. See Conditionally Execute Referenced Models.

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

Blocks

expand all

IfSelect subsystem execution using logic similar to if-else statement
If Action SubsystemSubsystem whose execution is enabled by If block
Switch CaseSelect subsystem execution using logic similar to switch statement
Switch Case Action SubsystemSubsystem whose execution is enabled by Switch Case block
Enabled SubsystemSubsystem whose execution is enabled by external input
Triggered SubsystemSubsystem whose execution is triggered by external input
Enabled and Triggered SubsystemSubsystem whose execution is enabled and triggered by external inputs
Message Triggered SubsystemSubsystem whose execution is controlled by message input (Since R2022a)
EnableAdd enable port to subsystem or model
TriggerAdd trigger or function port to subsystem or model
Function-Call SubsystemSubsystem whose execution is controlled by external function-call input
Function-Call GeneratorProvide function-call events to control execution of subsystem or model
Function-Call SplitProvide junction for splitting function-call line
Function-Call Feedback LatchBreak feedback loop involving data signals between function-call blocks
TriggerAdd trigger or function port to subsystem or model
Resettable Subsystem Subsystem whose block states reset with external trigger

Functions

Simulink.getOutportInheritsInitialValueDetermine if conditional subsystem Outport block inherits initial output value (Since R2021a)

Topics

Basics of Conditionally Executed Subsystems

Types of Conditionally Executed Subsystems

Subsystem Output Initialization