| Products & Services | Industries | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Simulink |
| Contents | Index |
| Learn more about Simulink |
Simulink.BlockDiagram.createSubSystem(blocks)
Simulink.BlockDiagram.createSubSystem()
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 within the current model to the new subsystem.
blocks |
An array of block handles Default: [] |
The following 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')];
end
Simulink.BlockDiagram.createSubSystem(bh);
endConsider, for example, the following model:

Executing
convert2subsys('example');converts this model to:

Simulink.BlockDiagram.copyContentsToSubSystem | Simulink.BlockDiagram.deleteContents | Simulink.SubSystem.convertToModelReference | Simulink.SubSystem.copyContentsToBlockDiagram

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2010- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |