Connecting Blocks

Automatically Connecting Blocks

You can command the Simulink software to connect blocks automatically. This eliminates the need for you to draw the connecting lines yourself. When connecting blocks, the lines are routed around intervening blocks to avoid cluttering the diagram.

Connecting Two Blocks

To autoconnect two blocks:

  1. Select the source block.

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

    The source block is connected to the destination block, and the lines are routed around intervening blocks if necessary.

When connecting two blocks, the Simulink software draws as many connections as possible between the two blocks as illustrated in the following example.

Connecting Groups of Blocks

The Simulink software can connect a group of source blocks to a destination block or a source block to a group of destination 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 Connecting 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.

Drawing a Line Between Blocks

To connect the output port of one block to the input port of another block:

  1. Position the cursor over the first block's output port. It is not necessary to position the cursor precisely on the port.

    The cursor shape changes to crosshairs.

  2. Press and hold down the mouse button.

  3. Drag the pointer to the second block's input port. You can position the cursor on or near the port or in the block. If you position the cursor in the block, the line is connected to the closest input port.

    The cursor shape changes to double crosshairs.

  4. Release the mouse button. The port symbols are replaced by a connecting line with an arrow showing the direction of the signal flow. You can create lines either from output to input, or from input to output.

    The arrow appears at the appropriate input port, and the signal is the same.

The Simulink software draws connecting lines using horizontal and vertical line segments. To draw a diagonal line, hold down the Shift key while drawing the line.

Drawing 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. Using branch lines enables you to connect a signal to more than one block.

This example demonstrates the connecting of the Product block output to both the Scope block and the To Workspace block.

To add a branch line:

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

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

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

You can also use the right mouse button instead of holding down the left mouse button and the Ctrl key.

Drawing a Line Segment

You might want to draw a line with segments exactly where you want them instead of where the Simulink software draws them. Or you might want to draw a line before you copy the block to which the line is connected. You can do either by drawing line segments.

To draw a line segment, you draw a line that ends in an unoccupied area of the diagram. An arrow appears on the unconnected end of the line. To add another line segment, position the cursor over the end of the segment and draw another segment. The segments area drawn as horizontal and vertical lines. To draw diagonal line segments, hold down the Shift key while you draw the lines.

Moving a Line Segment

To move a line segment:

  1. Position the pointer on the segment you want to move.

  2. Press and hold down the left mouse button.

  3. Drag the pointer to the desired location.

  4. Release the mouse button.

To move the segment connected to an input port, position the pointer over the port and drag the end of the segment to the new location. You cannot move the segment connected to an output port.

Moving a Line Vertex

To move a vertex of a line:

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

    The cursor changes to a circle that encloses the vertex.

  2. Drag the pointer to the desired location.

  3. Release the mouse button.

Inserting Blocks in a Line

You can insert a block in a line by dropping the block on the line. The Simulink software inserts the block for you at the point where you drop the block. The block that you insert can have only one input and one output.

To insert a block in a line:

  1. Position the pointer over the block and press the left mouse button.

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

  3. Release the mouse button to drop the block on the line.

    The block is inserted where you dropped it.

Disconnecting Blocks

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

To disconnect a line from a block's input port, position the mouse pointer over the line's arrowhead. The pointer turns into a circle. Drag the arrowhead away from the block.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS