As a model increases in size and complexity, you can simplify it by grouping blocks into subsystems. A subsystem is a set of blocks that you group into a single Subsystem block.
Establishes a hierarchical block diagram where a Subsystem block is on one layer and the blocks that make up the subsystem are on another.
Keeps functionally related blocks together.
Helps reduce the number of blocks displayed in your model window.
Establishes an interface with inputs and outputs.
When you make a copy of a subsystem, that copy is independent of the source subsystem. To reuse the contents of a subsystem across a model or across models, consider referenced subsystems, referenced models, or subsystems linked to a block in a custom library. For more information, see Choose Among Types of Model Components.
A subsystem can be virtual or nonvirtual. A virtual subsystem provides graphical hierarchy in a model and does not impact the execution of a model. A nonvirtual subsystem executes as a single unit within a model.
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.
Simulink® classifies nonvirtual subsystems into these types:
|Type of Subsystem||Description|
Subsystem that executes as a single unit.
Subsystem whose execution is enabled by external input.
Subsystem whose execution is triggered by external input.
Subsystem whose execution is controlled by an external function-call input.
|Enabled and Triggered Subsystem|
Subsystem whose execution is enabled and triggered by external inputs.
Subsystem whose block states reset with an external trigger.
|If Action Subsystem|
Subsystem whose execution is enabled by an If block.
|Switch Case Action Subsystem||Subsystem whose execution is controlled by a Switch Case block.|
|While Iterator Subsystem|
Subsystem that repeats execution during a simulation time step while a logical condition is true.
|For Iterator Subsystem||Subsystem that repeats execution during a simulation time step for a specified number of iterations.|
|For Each Subsystem|
Subsystem that repeats execution on each element or subarray of input signal and concatenates results.
To create a subsystem, you can:
In the Simulink Editor, double-click and start typing the subsystem type, then select the corresponding block from the menu.
In the Simulink Editor, drag a selection box to outline the subsystem that you want to create, then select the subsystem type.
Drag a Subsystem block from the Library Browser.
Copy and paste a Subsystem block from a model.
When you create a subsystem from a selection box, the selection can be empty or can contain multiple blocks in one area of the model.
From the action bar, select the type of subsystem that you want to create.
When the selection contains blocks that correspond to input and output ports, the new subsystem includes copies of those blocks. The new subsystem does not contain copies of blocks that correspond to control ports.
You can change the type of subsystem after creation.
To make a subsystem execute as a unit, click the Subsystem block. On the Subsystem tab, select Is Atomic Subsystem.
To make a subsystem execute conditionally, add a block that corresponds to a control port.
To make a subsystem execute unconditionally, remove blocks that correspond to control ports.
The ports on a Subsystem block correspond to blocks inside the subsystem.
For example, this Subsystem block has two input ports and one output port.
The subsystem contains two Inport blocks (
In2) and one Outport block (
that correspond to the ports on the Subsystem block.
To add ports to a subsystem:
Click the edge of the Subsystem block, then select the type of port to create.
Drag a line to the edge of the Subsystem block.
Open the subsystem by double-clicking the Subsystem block, then add the corresponding blocks to the subsystem.
|Type of Port||Corresponding Block|
|Signal port, input||Inport block|
|Signal port, output||Outport block|
|Bus port, input||In Bus Element block|
|Bus port, output||Out Bus Element block|
|Control port, enabled||Enable block|
|Control port, triggered||Trigger block|
|Control port, function-call||Trigger block with
Trigger type set to
|Control port, reset||Reset block|
|Control port, action||Action Port block|
|Connection port||Connection Port (Simscape) block|
To change the location of a port on a Subsystem block, drag the port to a new location on any side of the Subsystem block.
By default, Simulink labels the ports on a Subsystem block. To specify how Simulink labels the ports of a subsystem:
Select the Subsystem block.
On the Format tab of the Simulink Toolstrip, select one of the labeling options from the Port Labels menu. For more information, see Show port labels.
You can change the name of the Subsystem block and modify the block the way that you do with any other block. For example, you can:
Apply block masks to hide the subsystem content, making it appear as an atomic block with its own icon and parameter dialog box. For more information, see Masking Fundamentals.
Use block callbacks to perform actions in response to subsystem modeling actions such as handling an error, deleting a block or line in a subsystem, or closing a subsystem. For more information on block properties, such as callbacks, see Specify Block Properties.
The Read/Write permissions parameter of a Subsystem block controls the level of access allowed for the subsystem.
Restricting read or write access does not prevent the access restrictions from being changed. To hide proprietary information, consider using a protected model. For more information, see Protected Models for Model Reference.
When a subsystem is stored in a custom library, you can use the Read/Write permissions parameter on the parent library block to control access for the linked instances of the block. As long as the library link remains intact, the restricted access can prevent people from viewing or modifying the contents of the subsystem while still allowing them to employ it in a model. For more information, see Linked Blocks.