Explore Types of Subsystems
Subsystems can be virtual or nonvirtual.
Virtual subsystems help visually organize a block diagram. When you group blocks in a virtual subsystem or expand a virtual subsystem, you can affect the execution order of blocks because of the changes to the block paths.
Nonvirtual subsystems, also known as atomic subsystems, help functionally organize a block diagram. When you group blocks in a nonvirtual subsystem or expand a nonvirtual subsystem, you change the model behavior. Each nonvirtual subsystem executes as a single block, or atomic unit, when the parent model executes. The blocks in a nonvirtual subsystem execute consecutively.
Tip
For controllers and other standalone components, define a hard boundary around the related blocks by using a nonvirtual subsystem or referenced model. Defining a hard boundary upfront avoids costly refactoring when you want to generate code for the component.
To determine whether a subsystem is virtual or nonvirtual, use either of these strategies:
Check the border of the block. A virtual subsystem has a thin border. A nonvirtual subsystem has a thick border.
Use the
get_param
function to query the Boolean block parameterIsSubsystemVirtual
. For an example, see Determine Whether Subsystem Is Virtual.
This table classifies some of the types of nonvirtual subsystems.
Basis of Subsystem Execution | Subsystem Description | Subsystem Block Name | More Information |
---|---|---|---|
Control signal value | Subsystem whose execution is enabled by external input. | Enabled Subsystem | Using Enabled Subsystems |
Subsystem whose execution is triggered by external input. | Triggered Subsystem | Using Triggered Subsystems | |
Subsystem whose execution is enabled and triggered by external inputs. | Enabled and Triggered Subsystem | Using Enabled and Triggered Subsystems | |
Subsystem whose block states reset with an external trigger. | Resettable Subsystem | Using Resettable Subsystems | |
If-else logic | Subsystem whose execution is enabled by an If block. | If Action Subsystem | Select Subsystem Execution |
Switch logic | Subsystem whose execution is controlled by a Switch Case block. | Switch Case Action Subsystem | Select Subsystem Execution |
Function-call event | Subsystem whose execution is controlled by an external function-call input. | Function-Call Subsystem | Using Function-Call Subsystems |
Number of iterations | Subsystem that repeats execution during a simulation time step for a specified number of iterations. | For Iterator Subsystem | Iterate Subsystem Execution with While Iterator and For Iterator Subsystems |
Subsystem that repeats execution during a simulation time step while a logical condition is true. | While Iterator Subsystem | Iterate Subsystem Execution with While Iterator and For Iterator Subsystems | |
Number of elements | Subsystem that repeats execution on each element or subarray of input signal and concatenates results. | For Each Subsystem | Repeat an Algorithm Using a For-Each Subsystem |
Message | Subsystem that executes conditionally at each time step based on whether a message is available at the control port. | Message Polling Subsystem | Using Message Polling and Message Triggered Subsystems |
Subsystem that executes whenever a message is available at the control port, independent of sample time. | Message Triggered Subsystem | Using Message Polling and Message Triggered Subsystems | |
Execution order only | Subsystem that executes as a single block, or atomic unit, when the parent model executes. | Atomic Subsystem | Specify Whether Subsystem Is Atomic |