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

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.

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

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

Topics

Basics of Conditionally Executed Subsystems

Conditionally Executed Subsystems Overview

Overview of conditionally executed subsystems.

Conditionally Execute Referenced Models

Execute referenced models conditionally, similar to conditionally executed subsystems.

Ensure Outport is Virtual

Prevent buffering of conditional subsystem or model output.

Types of Conditionally Executed Subsystems

Select Subsystem Execution

Execute subsystem once during a time step in response to an action signal.

Using Enabled Subsystems

Create a subsystem that executes when a control signal has a positive value.

Using Triggered Subsystems

Create a subsystem that executes with a trigger signal.

Using Enabled and Triggered Subsystems

Create a subsystem that executes with a trigger signal or control signal with a positive value.

Using Function-Call Subsystems

Create a subsystem that executes with a function call.

Using Resettable Subsystems

Create a subsystem that resets all block states with a trigger signal.

Subsystem Output Initialization

Conditional Subsystem Initial Output Values

Specify initial output values for a conditional subsystem.

Conditional Subsystem Output Values When Disabled

Specify output behavior when conditional subsystem is disabled.

Simplified Initialization Mode

Control initial values for conditional subsystems.

Featured Examples