| Simulink® | ![]() |
| On this page… |
|---|
Why Subsystems are Advantageous Creating a Subsystem by Adding the Subsystem Block Creating a Subsystem by Grouping Existing Blocks Controlling Access to Subsystems |
A subsystem is a set of blocks that have been replaced by a single block called a Subsystem block. As your model increases in size and complexity, you can simplify it by grouping blocks into subsystems. Using subsystems has these advantages:
It helps reduce the number of blocks displayed in your model window.
It allows you to keep functionally related blocks together.
It enables you to establish a hierarchical block diagram, where a Subsystem block is on one layer and the blocks that make up the subsystem are on another.
You can create a subsystem in two ways:
Add a Subsystem block to your model, then open that block and add the blocks it contains to the subsystem window.
Add the blocks that make up the subsystem, then group those blocks into a subsystem.
A subsystem can be execute conditionally or unconditionally. An unconditionally executed subsystem always executes. A conditionally executed subsystem may or may not execute, depending on the value of an input signal. For information about conditionally executed subsystems, see Creating Conditional Subsystems.
To create a subsystem before adding the blocks it contains, add a Subsystem block to the model, then add the blocks that make up the subsystem:
Copy the Subsystem block from the Ports & Subsystems library into your model.
Open the Subsystem block by double-clicking it.
The subsystem is opened in the current or a new model window, depending on the model window reuse mode that you selected (see Window Reuse).
In the empty Subsystem window, create the subsystem. Use Inport blocks to represent input from outside the subsystem and Outport blocks to represent external output.
For example, the subsystem shown includes a Sum block and Inport and Outport blocks to represent input to and output from the subsystem.

If your model already contains the blocks you want to convert to a subsystem, you can create the subsystem by grouping those blocks:
Enclose the blocks and connecting lines that you want to include in the subsystem within a bounding box. You cannot specify the blocks to be grouped by selecting them individually or by using the Select All command. For more information, see Selecting Multiple Objects Using a Bounding Box.
For example, this figure shows a model that represents a counter. The Sum and Unit Delay blocks are selected within a bounding box.

When you release the mouse button, the two blocks and all the connecting lines are selected.
Choose Create Subsystem from the Edit menu. The selected blocks are replaced with a Subsystem block.
This figure shows the model after you choose the Create Subsystem command (and resize the Subsystem block so the port labels are readable).

If you open the Subsystem block, the underlying system is displayed, as shown below.

Notice that the Simulink® software adds Inport and Outport blocks to represent input from and output to blocks outside the subsystem.
As with all blocks, you can change the name of the Subsystem block. You can also use the masking feature to customize the block's appearance and dialog box. See Creating Block Masks.
To undo creation of a subsystem by grouping blocks, select Undo from the Edit menu. You can undo creation of a subsystem that you have subsequently edited. However, the Undo command does not undo any nongraphical changes that you made to the blocks, such as changing the value of a block parameter or the name of a block. The Simulink software alerts you to this limitation by displaying a warning dialog box before undoing creation of a modified subsystem.
Subsystems allow you to create a hierarchical model comprising many layers. You can navigate this hierarchy using the Model Browser (see The Model Browser) and/or the following model navigation commands:
The Open Block command opens the currently selected subsystem. To execute the command, select Open Block from either the Edit menu or the subsystem's context (right-click) menu, press Enter, or double-click the subsystem.
Open Block In New Window
Opens the currently selected subsystem regardless of the window reuse settings (see Window Reuse). To execute the command, select Open Block In New Window from the subsystem's context (right-click) menu.
The Go To Parent command displays the parent of the subsystem displayed in the current window. To execute the command, press Esc or select Go To Parent from the the Simulink software View menu.
You can specify whether the Simulink software model navigation commands use the current window or a new window to display a subsystem or its parent. Reusing windows avoids cluttering your screen with windows. Creating a window for each subsystem allows you to view subsystems side by side with their parents or siblings. To specify your preference regarding window reuse, select Preferences from the File menu and then select one of the following Window reuse type options listed in the Preferences dialog box.
| Reuse Type | Open Action | Go to Parent (Esc) Action |
|---|---|---|
none | Subsystem appears in a new window. | Parent window moves to the front. |
reuse | Subsystem replaces the parent in the current window. | Parent window replaces subsystem in current window |
replace | Subsystem appears in a new window. Parent window disappears. | Parent window appears. Subsystem window disappears. |
mixed | Subsystem appears in its own window. | Parent window rises to front. Subsystem window disappears. |
Simulink labels ports on a Subsystem block. The labels are the names of Inport and Outport blocks that connect the subsystem to blocks outside the subsystem through these ports.
You can hide (or show) the port labels by
Selecting the Subsystem block, then choosing Hide Port Labels (or Show Port Labels) from the Format menu
Selecting an Inport or Outport block in the subsystem and choosing Hide Name (or Show Name) from the Format menu
Selecting the Show port labels option in the Subsystem block's parameter dialog
This figure shows two models.

The subsystem on the left contains two Inport blocks and one Outport block. The Subsystem block on the right shows the labeled ports.
You can control user access to subsystems. For example, you can prevent a user from viewing or modifying the contents of a library subsystem while still allowing the user to employ the subsystem in a model.
To restrict access to a library subsystem, open the subsystem's parameter dialog box and set its Read/Write permissions parameter to either ReadOnly or NoReadOrWrite. The first option allows a user to view the contents of the library subsystem but prevents the user from modifying the reference subsystem without first disabling its library link or changing its Read/Write permissions parameter to ReadWrite. The second option prevents the user from viewing the contents of the library subsystem, modifying the reference subsystem, and changing the reference subsystem's permissions. Note that both options allow a user to use the library subsystem in models by creating links (see Working with Block Libraries). See the Subsystem block in the Simulink® Reference guide for more information on subsystem access options.
Note You will not receive a response if you attempt to view the contents of a subsystem whose Read/Write permissions parameter is set to NoReadOrWrite. For example, when double-clicking such a subsystem, the Simulink software neither opens the subsystem nor displays any messages. |
These functions are provided that you can use to interconvert subsystems and block diagrams:
Copies the contents of a subsystem to an empty block diagram.
Copies the contents of a block diagram to an empty subsystem.
For more information, see the reference documentation for these functions.
These functions are provided to empty subsystems and block diagrams:
Deletes the contents of a subsystem.
Deletes the contents of a block diagram.
For more information, see the reference documentation for these functions.
![]() | Annotating Diagrams | Modeling Control Flow Logic | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |