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.


collapse all

  1. Use this function to set up the conversion of 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')];
  2. Create a model and save it as initial_model.slx.

  3. Execute this code to convert the model to create a subsystem.


Input Arguments

collapse all

An array of block handles.

Introduced in R2009a