This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Create a Subsystem

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.

Create a Subsystem Block

Add a Subsystem block to the model, and then add the blocks that make up the subsystem.

  1. Create a Subsystem block from the Ports & Subsystems library.

  2. Double-click the block to open it.

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

Create Subsystem from Selection

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

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

    Tip

    Resize the Subsystem block so that port labels are readable.

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.

Related Examples

More About