Main Content

Simulink.BlockDiagram.arrangeSystem

Improve layout of block diagram

Description

Simulink.BlockDiagram.arrangeSystem(bd) improves the layout of the specified block diagram by realigning, resizing, and moving blocks and straightening signal lines.

Note

Running the Simulink.BlockDiagram.arrangeSystem function with any syntax changes the line handles.

example

Simulink.BlockDiagram.arrangeSystem(bd,FullLayout=tf) specifies whether to apply the automated layout even when the automated layout might not improve upon the original layout.

example

Examples

collapse all

You can use Simulink.BlockDiagram.arrangeSystem with any open model, and it is particularly useful with models you populate programmatically.

Blocks in the model ex_arrange_system are poorly arranged.

open_system('ex_arrange_system')

The model contains a Sine Wave block, a Pulse block, a Subsystem block, and a Scope block. The Scope block is on top of the Subsystem block, and none of the blocks are lined up. The Sine Wave and Pulse blocks connect to the Subsystem block, and the Subsystem block connects to the Scope block. The blocks are connected with diagonal signal lines. Two of the signal lines overlap.

Blocks in its subsystem are also poorly arranged.

open_system('ex_arrange_system/Subsystem')

The subsystem contains two input port blocks, a Sum block, and an output port block. None of the blocks are lined up. The two input ports connect to the Sum block, and the Sum block connects to the output port block. The blocks are connected with diagonal signal lines. Two of the signal lines overlap.

Programmatically arrange blocks in the top layer of the specified system.

Simulink.BlockDiagram.arrangeSystem('ex_arrange_system')

The blocks in the top layer of the model are neatly arranged, with the Sine Wave and Pulse blocks at the left, the Subsystem block in the middle, and the Scope block on the right. The connecting signal lines are exclusively composed of orthogonal line segments. No blocks or signal lines overlap.

Simulink.BlockDiagram.arrangeSystem('ex_arrange_system/Subsystem')

The blocks in the subsystem are neatly arranged, with the input port blocks blocks at the left, the Sum block in the middle, and the output port block on the right. The connecting signal lines are exclusively composed of orthogonal line segments. No blocks or signal lines overlap.

By default, Simulink.BlockDiagram.arrangeSystem applies an automated layout only when the automated layout is expected to improve upon the original layout. You can force this function to apply the layout even when the automated layout might not improve upon the original layout.

Blocks in the model ForceArrangeSystem are arranged well.

open_system('ex_arrange_system2')

The model contains a Sine Wave block and a Pulse block that connect to a Subsystem block. The Subsystem block connects to a Scope block. The blocks are neatly arranged, with the Sine Wave and Pulse blocks at the left, the Subsystem in the middle, and the Scope block at the right. The blocks are connected with signal lines that consist exclusively of orthogonal line segments.

The automated layout might not improve upon the original layout because the blocks are already arranged well.

Suppose you want to apply the automated layout regardless of whether the automated layout is an improvement. To force the automated layout, set FullLayout to true.

Simulink.BlockDiagram.arrangeSystem('ex_arrange_system2',FullLayout='true')

The model has the same layout as before.

Input Arguments

collapse all

Block diagram of system, specified as a character vector, string scalar, or numeric scalar.

Specify one of the following options:

  • System name (must not include a path or extension)

  • System handle

  • Subsystem block path

Data Types: double | char | string

Option to force automated layout, specified as 'true' or 'false'.

  • 'true' — Applies the automated layout even when the automated layout might not improve upon the original layout

  • 'false' — Applies the automated layout only when the automated layout is expected to improve upon the original layout.

Version History

Introduced in R2018a