Main Content

Configure Model Layout

You can organize block diagrams by changing the position and orientation of model elements.

  • You can move signal lines by dragging them.

  • You can move, rotate, and flip blocks.

  • For some blocks, such as the Subsystem block, you can change the port order.

You can change the block diagram layout manually, or you can have the software can arrange it for you.

For information about how to organize blocks into subsystems, see Group Blocks into Subsystems. For information about how to bundle signal lines, see Group Signals or Messages into Virtual Buses.

Improve Model Layout with Auto Arrange

To improve your diagram layout and appearance, on the Format tab, click Auto Arrange.

Tip

Alternatively, press Ctrl+Shift+A.

This option:

  • Aligns blocks in your block diagram from left to right, starting with inputs and ending with outputs

  • Resizes blocks, such as the Constant block, to display long parameter values

  • Standardizes block size among similar blocks

  • Straightens signal lines by moving blocks

You can also auto arrange the block diagram in a model programmatically.

  1. Load the model using the load_system function.

  2. Auto arrange the block diagram using the Simulink.BlockDiagram.arrangeSystem function.

Alternatively, you can try improving the shapes of individual signal lines. Select the signal line and, from the action bar, select Auto-route Line. The line redraws if a better route between model elements is possible.

You can try to improve multiple lines by using Auto-route Lines. To access Auto-route Lines from the action bar, select a block or select multiple model elements by dragging a box around the elements.

Move Multiple Model Elements Simultaneously

To move multiple model elements while maintaining their spatial relationships:

  1. Select the model elements by dragging a selection box around them.

  2. Move the model elements by dragging an edge of the selection box to a new position.

The contents of the selection box move as a unit. The relationship among lines, blocks, and other elements in the selection box remains the same as you move them. Line segments outside of the selection box reroute.

For example, consider this model.

The model contains two subsystems that connect to two Outport blocks with multiple signal lines. The signal lines pass through Bus Creator blocks. Two of the lines have bends.

When you drag a selection box that includes line bends, the included line bends remain the same when you move the selection.

A selection box is drawn around two Bus Creator blocks, two Outport blocks, and part of the signal lines entering these blocks, including multiple line bends. The content of the selection box is moved to the right, but the line routing inside the selection box is unchanged.

When you drag a selection box that excludes line bends, the excluded line bends may change when you move the selection.

The selection box is drawn around the same blocks as before, but not around the bends in the signal lines entering the blocks. The content of the selection box is moved to the right. The line bends are changed.

To move multiple lines together, drag the selection box around the line segments you want to move.

A selection box is drawn around two line segments in the model.

Flip or Rotate Blocks

You can change the orientation of a block or a group of blocks by rotating blocks in 90-degree increments or by flipping the blocks. Rotating or flipping blocks can help them fit better in the block diagram, such as in feedback loops, where the blocks are connected to each other in a loop. You might also need to rotate a block so that the block input ports align with output ports or to make better use of the model canvas.

The figure shows a Gain block flipped to simplify a feedback loop diagram.

Feedback loop diagram with one of the gain blocks flipped horizontally

To rotate a block, select the block. On the Format tab, click Rotate 90 clockwise or Rotate 90 counterclockwise .

Tip

Alternatively:

  • To rotate a block clockwise, press Ctrl+R.

  • To rotate a block counterclockwise, press Ctrl+Shift+R

Blocks automatically rotate when you place them on a signal line that has an orientation other than left to right. For example, if the signal goes from bottom to top and you place a block on it, the block rotates to align with the signal.

To flip a block, select the block and, on the Format tab, click Flip left-right or Flip up-down . You can flip a block horizontally or vertically based on the orientation of the block ports. For example, if the ports are on the sides, the block flips left to right.

Tip

Alternatively, to flip a block horizontally, press Ctrl+I.

To rotate or flip a group of blocks, select multiple blocks before rotating or flipping them. You can only flip groups of blocks to the left or right.

After you rotate or flip a group of blocks, you can improve the readability of the block diagram by editing the signal lines. The Auto Arrange option might improve the appearance of signals. (For information on rotation with multiple ports, see Identify Port Location on Rotated or Flipped Block.)

For example, suppose you rotate these selected blocks clockwise.

The model contains two rows of blocks, each consisting of a Constant block connected to a Subsystem block connected to a Gain block. Both Gain blocks connect to a Scope block. The top row of blocks is selected.

After you rotate the blocks, some model elements might overlap.

The selected row of blocks has rotated and become a vertical column of blocks. The Constant block is at the top in its original orientation. Below the Constant block is the Subsystem block. The Subsystem block is rotated 90 degrees counterclockwise. Below the Subsystem block is the Gain block. The gain block is rotated 90 degrees clockwise. The signal line from the selected Subsystem block to the selected Gain block crosses over the block icon of the unselected Subsystem block.

With the blocks and signals selected, on the Format tab, click Auto Arrange.

The block diagram is rearranged such that the signal line from the selected Subsystem block to the selected Gain block no longer crosses over the block icon of the unselected Subsystem block.

Identify Port Location on Rotated or Flipped Block

Rotating moves block ports from the sides to top and bottom or the reverse, depending on the placement of the ports. The resulting positions of the block ports depend on the block port rotation type.

Rotating can reposition the ports on some blocks to maintain left-to-right or top-to-bottom port numbering order. A block whose ports are reordered after a rotation has the default port rotation type. This policy helps to maintain the left-right and top-down block diagram orientation convention used in control system modeling applications. The figure shows the effect of clockwise rotation on a block with the default port rotation policy.

A Subsystem block has two output ports on the left and two input ports on the right. The top input and output ports are labeled with the number 1 on the block icon, and the bottom input and output ports are labeled with the number 2.

A masked block can specify that ports keep their order after rotation (see Icon drawing commands). These blocks have a physical port rotation type. This policy helps when designing blocks to use when modeling physical systems and other applications where diagrams do not have a preferred orientation. The figure shows the effect of clockwise rotation on a block with a physical port rotation type.

A Subsystem block with a mask has two output ports on the left and two input ports on the right. The top input and output ports are labeled with the number 2 on the block icon, and the bottom input and output ports are labeled with the number 1.

Flipping a block moves the ports to the opposite side of the block, creating a mirror image, regardless of port rotation type.

Move Ports

You can put ports in any order on any side of these blocks:

You can move ports by clicking and dragging the port.

For Subsystem blocks, the port index will automatically be renumbered after each move. For port label editing on Subsystem blocks, see Edit Port Labels on Subsystem Blocks.

You can drag a port to any side of a Subsystem block.

You cannot drag ports on masked or linked Subsystem blocks.

The video shows a Subsystem block with three input ports and three output ports. From top to bottom along the left edge of the block, the input ports are labeled 1, 2, and 3. From top to bottom along the right edge of the block, the input ports are labeled 1, 2, and 3. The pointer moves input port 1 between input ports 2 and 3. When the pointer releases the port, the port labels update so that from top to bottom along the left edge of the block, they again read 1, 2, and 3. The pointer drags what is now input port 2 to the top of the block. When the pointer releases the port, the port labels update so that the top port label is 3, and the two ports along the left edge from top to bottom are 1 and 2. The pointer drags input port 2 to the right edge of the block. The port labels do not change.

Related Topics