You can have the Simulink® software connect blocks automatically. This eliminates the need to draw the connecting lines yourself. When connecting blocks, Simulink routes the lines around intervening blocks to avoid cluttering the diagram.
When connecting two blocks with multiple ports, Simulink draws as many connections as possible between the two blocks.
To autoconnect two blocks:
Select the source block. In this example, the Sine Wave block is the source block.
Hold down Ctrl and left-click the destination block. In this example, the Integrator block is the destination block.
The source block is connected to the destination block, and the lines are routed around intervening blocks if necessary.
Note: On Macintosh platforms, use the command key instead of Ctrl.
To connect a group of source blocks to a destination block:
Select the source blocks.
Hold down Ctrl and left-click the destination block.
To connect a source block to a group of destination blocks:
Select the destination blocks.
Hold down Ctrl and left-click the source block.
You can draw lines manually between blocks or between lines and blocks. You might want to do this if you need to control the path of the line or to create a branch line.
Position the cursor over the output port of the Constant block. You do not need to position the cursor precisely on the port.
The cursor shape changes to crosshairs.
Hold down the left mouse button.
Drag the cursor to the input port of the Gain block. Position the cursor on or near the port or in the block. If you position the cursor in the block, the line connects to the closest input port.
Release the mouse button. A connecting line with an arrow showing the direction of the signal flow replaces the port symbol.
The arrow appears at the appropriate input port, and the signal is the same.
A branch line is a line that starts from an existing line and carries its signal to the input port of a block. Both the existing line and the branch line represent the same signal. Use branch lines to connect a signal to more than one block.
This example shows how to connect the Product block output to both the Scope block and the To Workspace block.
To add a branch line:
Position the cursor on the line where you want the branch line to start.
While holding down the Ctrl key, press and hold down the left or right mouse button.
Drag the cursor to the input port of the target block, then release the mouse button and the Ctrl key.
Line segments differently than autoconnect feature draws the lines
A line, before you copy the block to which the line connects
Draw a line from the block port to an unoccupied area of the canvas. Release the mouse button where you want the line segment to end.
The cursor turns into a circle, and blue arrow guides appear.
For each additional line segment, position the cursor over the blue arrow guide that points in the direction in which you want to draw a line segment. The cursor turns into an empty arrowhead.
Tip To reroute the whole line instead of extending it, select the end of the line itself when the circle cursor is displayed and drag the line end to a new location.
Drag the cursor to draw the second line segment and release the mouse button to finish drawing the line.
Position the cursor on the segment that you want to move.
Press and hold down the left mouse button.
Drag the cursor to the desired location and release the mouse button.
You cannot draw a single diagonal line between two ports. You can draw very short line segments connecting to each port, with a longer diagonal segment in the middle. For example, suppose you position two blocks as shown below:
To approximate a diagonal line:
Draw a short line segment from the output port of the Constant block.
At the end of the first line segment, draw a second line segment.
Draw a third line segment to connect to the Scope block.
Position the cursor at the bend of the second and third line segments. The cursor turns into a circle.
Hold the Shift key down and drag the cursor to make the second line segment a diagonal.
Position the cursor on the vertex, then press and hold down the left mouse button.
The cursor changes to a circle.
Drag the vertex to the desired location.
Release the mouse button.
You can insert a block in a line, if the block has only one input and one output.
Drag the block over the line in which you want to insert the block.
Release the mouse button. Simulink inserts the block for you at the point where you drop the block.