Quantcast

Documentation Center

  • Trial Software
  • Product Updates

Connect Blocks

Automatically Connect Blocks

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.

Autoconnect Two Blocks

When connecting two blocks with multiple ports, Simulink draws as many connections as possible between the two blocks.

To autoconnect two blocks:

  1. Select the source block. In this example, the Sine Wave block is the source block.

  2. 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.

Connect Groups of Blocks

To connect a group of source blocks to a destination block:

  1. Select the source blocks.

  2. Hold down Ctrl and left-click the destination block.

To connect a source block to a group of destination blocks:

  1. Select the destination blocks.

  2. Hold down Ctrl and left-click the source block.

Manually Connect Blocks

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.

Draw a Line Between Blocks

You can create lines either from output to input ports, or from input to output ports. For example, to connect the output port of a Constant block to the input port of Gain block:

  1. 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.

  2. Hold down the left mouse button.

  3. 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.

  4. 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.

Draw a Branch Line

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:

  1. Position the cursor on the line where you want the branch line to start.

  2. While holding down the Ctrl key, press and hold down the left or right mouse button.

  3. Drag the cursor to the input port of the target block, then release the mouse button and the Ctrl key.

Draw Line Segments

Manually draw line segments when you want to draw:

  • Line segments differently than autoconnect feature draws the lines

  • A line, before you copy the block to which the line connects

To draw a line segment:

  1. 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.

  2. 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.

  3. Drag the cursor to draw the second line segment and release the mouse button to finish drawing the line.

Move a Line Segment

To move a line segment:

  1. Position the cursor on the segment that you want to move.

  2. Press and hold down the left mouse button.

  3. Drag the cursor to the desired location and release the mouse button.

Draw a Diagonal Line

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:

  1. Draw a short line segment from the output port of the Constant block.

  2. At the end of the first line segment, draw a second line segment.

  3. Draw a third line segment to connect to the Scope block.

  4. Position the cursor at the bend of the second and third line segments. The cursor turns into a circle.

  5. Hold the Shift key down and drag the cursor to make the second line segment a diagonal.

Move a Line Vertex

To move a vertex of a line:

  1. Position the cursor on the vertex, then press and hold down the left mouse button.

    The cursor changes to a circle.

  2. Drag the vertex to the desired location.

  3. Release the mouse button.

Insert a Block in a Line

You can insert a block in a line, if the block has only one input and one output.

  1. Drag the block over the line in which you want to insert the block.

  2. Release the mouse button. Simulink inserts the block for you at the point where you drop the block.

Disconnect Blocks

To disconnect a block from its connecting lines, hold down the Shift key, then drag the block to a new location.

Was this topic helpful?