Create a Subsystem

Subsystem Advantages

Subsystems allow you to create a hierarchical model comprising many layers. A subsystem is a set of blocks that you replace with a single Subsystem block. As your model increases in size and complexity, you can simplify it by grouping blocks into subsystems. Using subsystems:

  • 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

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, use either model referencing or a library.

Ways to Create a Subsystem

You can create a subsystem using these approaches:

Create a Subsystem in a Subsystem Block

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

  1. Copy the Subsystem block from the Ports & Subsystems library into your model.

  2. Open the Subsystem block by double-clicking 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.

Create a Subsystem from Selected Blocks

  1. Select the blocks that you want to include in a subsystem. To select multiple blocks in one area of the model, drag a bounding box that encloses the blocks and connecting lines that you want to include in the subsystem.

    The figure shows a model that represents a counter. The bounding box selects the Sum and Unit Delay blocks.

  2. Select Diagram > Subsystems & Model Reference > Create Subsystem from Selection.

    A Subsystem block appears, which encloses the selected blocks.


    Resize the Subsystem block so the port labels are readable.

To edit the subsystem contents, open the Subsystem block. For example:

adds Inport and Outport blocks to represent input from and output to blocks outside the subsystem.

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

Create a Subsystem Using Context Options

  1. Drag a box around the blocks you want in your subsystem.

  2. View the subsystems you can create with these blocks by hovering over the first context option that appears.

  3. Select the type of subsystem you want to create from these options.

A Subsystem block appears, which encloses the selected blocks.


You can create only enabled, triggered, virtual, and function-call subsystems using this method.

Related Examples

More About

Was this topic helpful?