Main Content

Simulink.BlockDiagram.expandSubsystem

Replace subsystem with subsystem contents

Description

Simulink.BlockDiagram.expandSubsystem(subsys) replaces the specified subsystem with its contents in the block diagram that contains it. The file that contains the subsystem must be open or loaded.

You can expand virtual subsystems that are not masked, linked, or commented. For details, see What Subsystems Can You Expand?.

example

Simulink.BlockDiagram.expandSubsystem(subsys,'CreateArea',specifier) provides the option of not creating an area around the expanded subsystem contents.

example

Examples

collapse all

Replace a subsystem with its contents.

Open the example model, which contains a subsystem that separates functionally related blocks.

open_system('SubsystemExpansionModel')

The model contains a Subsystem block with three output ports. The output ports connect to a Sum block that connects to a Gain block that connects to an Integrator, Second-Order block. The Integrator, Second Order block has two output ports that connect to a Scope block and to the two input ports of the Subsystem.

Expand the subsystem.

Simulink.BlockDiagram.expandSubsystem('SubsystemExpansionModel/Subsystem')

An area that contains the subsystem contents replaces the Subsystem block.

The Subsystem block in the model is replaced by an area with the label "Subsystem" that contains a Step block and two Gain blocks. The output ports of all three blocks connect to the Sum block outside the area. The input ports of the Gain blocks connect to the Scope block outside the area.

Replace a subsystem with its contents without creating an area that surround the contents.

Open the example model, which contains a subsystem that separates functionally related blocks.

open_system('SubsystemExpansionModel')

The model contains a Subsystem block with three output ports. The output ports connect to a Sum block that connects to a Gain block that connects to an Integrator, Second-Order block. The Integrator, Second Order block has two output ports that connect to a Scope block and to the two input ports of the Subsystem.

Expand the subsystem.

Simulink.BlockDiagram.expandSubsystem(...
    'SubsystemExpansionModel/Subsystem','CreateArea','Off')

The subsystem contents replace the Subsystem block.

The Subsystem block in the model is replaced by a Step block and two Gain blocks. The output ports of all three blocks connect to the Sum block. The input ports of the Gain blocks connect to the Scope block.

Input Arguments

collapse all

Subsystem block path or handle, specified as a character vector, string scalar, or numeric scalar.

Data Types: double | char | string

Option to create area around contents, specified as 'on' to create the area or 'off' to not create the area.

Data Types: char | string

Version History

Introduced in R2014a