Main Content

Simulink.BlockDiagram.copyContentsToSubsystem

Copy graphical contents from system to empty subsystem

Description

Simulink.BlockDiagram.copyContentsToSubsystem(sys,subsys) copies the blocks, lines, and annotations of the specified system to the specified subsystem. It does not affect non-graphical information such as configuration sets.

Use this function to convert a referenced model derived from an atomic subsystem into an atomic subsystem that is equivalent to the original subsystem.

To use this function:

  • The specified system must be loaded in memory.

  • The specified subsystem must be loaded in memory.

  • The specified system must not contain the specified subsystem.

  • The specified subsystem must not contain any blocks or lines. Other types of information can exist in the subsystem and are unaffected by the function. To delete the graphical content of the destination subsystem, use Simulink.SubSystem.deleteContents.

example

Examples

collapse all

Copy the contents of a referenced model to an empty subsystem.

Open the sldemo_mdlref_basic model.

openExample('sldemo_mdlref_basic')

Add an empty subsystem to the model.

add_block('built-in/Subsystem','sldemo_mdlref_basic/Subsystem')

Load the sldemo_mdlref_counter referenced model that contains the contents to copy.

load_system('sldemo_mdlref_counter')

Copy the graphical contents from the sldemo_mdlref_counter referenced model to the empty subsystem.

Simulink.BlockDiagram.copyContentsToSubsystem...
('sldemo_mdlref_counter','sldemo_mdlref_basic/Subsystem')

Input Arguments

collapse all

System name or handle, specified as a numeric scalar, character vector, or string scalar.

The system name must not include a path or extension.

Example: 'model1'

Data Types: double | char | string

Path or handle of the Subsystem block or subsystem file, specified as a numeric scalar, character vector, or string scalar.

Example: 'model2/Subsystem'

Data Types: double | char | string

Version History

Introduced in R2007a