Create subsystem containing specified set of blocks




Simulink.BlockDiagram.createSubsystem(blocks) creates a new subsystem and moves the specified blocks into the subsystem. All of the specified blocks must originally reside at the top level of the model or in the same existing subsystem within the model.

If any of the blocks have unconnected input ports, the command creates input port blocks for each unconnected input port in the subsystem and connects the input port block to the unconnected input port. The command similarly creates and connects output port blocks for unconnected output ports on the specified blocks. If any of the specified blocks is an input port, the command creates an input port block in the parent system and connects it to the corresponding input port of the newly created subsystem. The command similarly creates and connects output port blocks for each of the specified blocks that is an output port block.

Simulink.BlockDiagram.createSubsystem() creates a new subsystem in the currently selected model and moves the currently selected blocks in the current model to the new subsystem.

Input Arguments


An array of block handles

Default: []


This function converts the contents of a model or subsystem into a subsystem.

function convert2subsys(sys)
  blocks = find_system(sys, 'SearchDepth', 1);
  bh = [];
  for i = 2:length(blocks)
    bh = [bh get_param(blocks{i}, 'handle')];

For example, suppose you create this model and save it as initial_model.slx.

Execute this code to convert the model to create a subsystem:


Introduced in R2009a