As your model increases in size and complexity, you can simplify it by grouping blocks into subsystems. Use subsystems to:
Establish a hierarchical block diagram, where a Subsystem block is in one layer and the blocks that make up the subsystem are in another.
Keep functionally related blocks together.
Reduce the number of blocks displayed in your model window.
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 models, use either a model reference or library.
You can create a subsystem using these approaches:
Add a Subsystem block to your model, and then open the block and add blocks to the subsystem window.
Select blocks and enclose them in a subsystem.
Copy a model to a subsystem. In the Simulink® Editor, copy and paste the model into a subsystem window, or use Simulink.BlockDiagram.copyContentsToSubsystem
.
Copy an existing Subsystem block to a model.
Add a Subsystem block to the model, and then add the blocks that make up the subsystem.
Create a Subsystem block from the Ports & Subsystems library.
Double-click the block to open it.
In the empty subsystem window, create the subsystem contents. Use Inport blocks to represent input from outside the subsystem and Outport blocks to represent external output.
For example, this subsystem includes a Sum block and Inport and Outport blocks to represent input to and output from the subsystem.
When you close the subsystem window, the Subsystem block includes a port for each Inport and Outport block.
You can alternatively create input and output ports by clicking the edge of the subsystem block or dragging to the edge from another block. The port appears on the block and the corresponding input or output block is added inside the subsystem.
Drag a box to outline the subsystem that you want to create.
You can use the action bar with blocks selected or with no selection to create a subsystem. To select multiple blocks in one area of the model, drag a box around the blocks and connecting lines that you want to include in the subsystem.
From the action bar, select the subsystem that you want to create.
When your selection contains blocks, you can create virtual, enabled, triggered, and function-call subsystems.
Creating the subsystem adds Inport and Outport blocks within the subsystem that represent the input and output ports of the Subsystem block.
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 mask the subsystem.