Connect Blocks
Establish relationships between the blocks in your model by connecting them.
You can connect most blocks using signal lines.
Signal lines connect to ports on blocks. During simulation, signals travel from output ports to connected input ports.
You can send the signal from the output port of one block to the input ports of multiple blocks by branching the signal line.
For some blocks you can change the number of input ports on the block. For example, to plot multiple signals on the same graph, you can increase the number of input ports on the Scope block.
For information about changing signal line layout, see Configure Model Layout.
You can simplify your block diagrams by bundling signals. For information about bundling signals, see Group Signals or Messages into Virtual Buses.
Related blocks connect without signal lines. For information about how to connect related blocks, see Connect Blocks Without Signal Lines.
Connect Blocks with Signal Lines
To connect two blocks with a signal line, click and drag the port symbol at the output port of one block to the input port of the other block.
You can use these shortcuts to connect blocks:
To connect the blocks without dragging the signal line:
Vertically line up the output port and input port you want to connect with no other components between them. If the ports are already lined up, move one of the blocks to break the alignment, then line them up again. When you release the block that you moved to align the ports, a preview of the connection appears.
To make the connection, click the preview.
To connect the blocks without dragging the signal line or lining up the ports:
Click the port symbol of the output port you want to connect. The port hint symbol appears on the input ports of other components that you can connect to.
To see a preview of the connection, pause on the port hint symbol of the input port that you want to connect to.
To make the connection, click the preview.
To connect multiple blocks to a single block without dragging the signal line or lining up the ports:
Left-click and drag a selection box around the blocks whose output ports you want to connect.
Press Ctrl and right-click the block whose input ports you want to connect.
To connect both the input port and output port of a block to an existing signal line, click and drag the block onto the signal line. Position the block such that the port symbols are on the signal line. When the output port symbol disappears and the input port symbol turns into a solid arrowhead, release your pointer.
To make a signal line segment diagonal, press Shift and drag a vertex that connects to another signal line segment.
Connect Single Output Port to Multiple Input Ports
To connect an output port to multiple input ports, connect one input port to the output port, then branch the signal line to connect to the other input ports.
To branch the signal line, press Ctrl, then click and drag the existing signal line to the input port of the block to which you want to connect.
Tip
To branch the line, you can also click and drag the port symbol of the unconnected input port onto the existing signal line.
Connect Output Ports of Multiple Blocks to Single Block
Some blocks can connect multiple signal lines on their input port side. For example, to plot multiple signals on one graph, you can connect the output ports of multiple blocks to a single Scope block.
To connect the output ports of multiple blocks to a single block, from each output port you want to connect, drag a signal line over the input port side (left edge) of the single block. When the block icon turns blue and the port number appears, release your pointer. An input port is created automatically to connect the signal line.
If the blocks whose output ports you want to connect are not in the model yet, to increase the number of input ports on the single block:
Pause on the input port side (the left edge) of the block until a plus sign appears next to the pointer.
Then, click and drag your pointer away from the block. A dashed signal line appears that you can connect to the output port of another block.
To delete an input port, click its port symbol and press Delete.
To specify the number of input ports a block has, use the Block Parameters dialog box or the Parameters tab of the Property Inspector.
Tip
For some blocks, you can enter the number of input ports when you add the block to the model.
Connect Subsystems
To send signals into a subsystem, the subsystem must contain as many input ports as signals that you want to send into the subsystem.
To receive signals from a subsystem, the subsystem must contain as many output ports as signals that you want to receive from the subsystem.
When you add a blank subsystem to the model, the subsystem contains an input port and an output port by default.
To connect a subsystem:
To enter the subsystem, double-click the Subsystem block.
Inside the subsystem, add the required number of input ports and output ports.
Inside the subsystem, connect the input ports and output ports to the subsystem.
To navigate up a level in the model hierarchy, in the Explorer Bar at the top of the Simulink® canvas, click the name of the level to the left of the name of the Subsystem block.
Connect the signal lines of the signals that you want to send into the subsystem to the input ports of the Subsystem block.
Each input port on the Subsystem block corresponds to an Inport block inside the subsystem. You can tell which input port on the Subsystem block corresponds to which Inport block inside the subsystem by the port number.
Connect the signal lines of the signals that you want to receive from the subsystem to the output ports of the Subsystem block.
Each output port on the Subsystem block corresponds to an Outport block inside the subsystem.
Tip
To avoid manually connecting subsystems, build the contents of the subsystem in the level of the model hierarchy where you want to add the Subsystem block. Then, convert the contents into a subsystem:
Select the subsystem components by clicking and dragging your pointer across the canvas to draw a rectangle that encompasses the components.
Pause on the ellipsis that appears.
In the action bar that expands, click Create Subsystem.
The conversion to a subsystem automatically adds and connects the subsystem input ports and output ports.
Connect Blocks Without Signal Lines
Related blocks connect to each other without signal lines.
For example, the Goto and From blocks are related blocks that you can use to send a signal without a signal line. The signal that enters the Goto block exits the From block without passing through a signal line.
To connect related blocks, use the Block Parameters dialog box or the Parameters tab of the Property Inspector.
Tip
To check whether two or more related blocks are connected, select one. All related blocks that connect to the selected block highlight in purple.
Some related blocks connect using tags. For example, all Goto and From blocks with the same tag are connected.
You can set the tag for these blocks in the Block Parameters dialog box or in the Property Inspector, on the Parameters tab.
Blocks from the Dashboard and Customizable Blocks libraries are also related blocks. You can connect display blocks from these libraries to signals. You can connect control blocks to block parameters or variables. For information about how to connect dashboard blocks, see Connect Dashboard Blocks to Simulink Model.
Convert Signal Lines to Goto and From Block Sets
You can simplify your model diagrams by replacing lengthy signal lines with Goto and From blocks. However, when you want to trace a signal path, seeing the signal lines can be useful.
You can convert signal lines and virtual buses to Goto and From block sets, and you can convert Goto and From block sets to signal lines. A Goto and From block set is a connected group of Goto and From blocks that have the same tag.
To perform the conversion, the signal lines, buses, or Goto and From blocks you want to convert must meet these conditions:
The lines, buses, or blocks are fully connected.
The lines, buses, or blocks are all in the same location in the model hierarchy, meaning on the same level and inside the same component.
If you want to convert lines or buses to blocks, the lines or buses are not connected to any Goto or From blocks.
You can perform the conversion regardless of whether the block tags are visible.
To convert a Goto block and all From blocks to which it connects or a From block and the Goto block to which it connects to a signal line, select the block. Pause on the ellipsis that appears above the selected block. In the action menu that expands, select Convert to signal.
To convert a signal line or bus to a Goto and From block set, select the signal line or bus. Pause on the ellipsis that appears. In the action menu that expands, select Convert to Goto and From blocks.
Tip
Alternatively, perform one of these actions.
Select the block, and in the Simulink Toolstrip, on the Goto or From tab, click Convert to Signal.
Select the signal line or bus, and in the toolstrip, on the Signal tab, click Convert to Goto/From.
To convert multiple Goto and From block sets to signal lines simultaneously, press Shift and select the Goto blocks of all the sets you want to convert. In the Simulink Toolstrip, on the Signal tab, click Convert to Signal.
If a Goto block has multiple From blocks with the same tag, to convert a subset of the From blocks to signal lines, press Shift and select the From blocks you want to convert. In the toolstrip, on the Signal tab, click Convert to Signal. The selected From blocks convert to signal lines connected to the signal line coming out of the corresponding Goto block. The Goto block does not convert to a signal line.
To convert multiple signal lines or buses to Goto and From block sets simultaneously, press Shift and select the signal lines or buses. In the toolstrip, on the Signal tab, click Convert to Goto/From.
Comment Out and Comment Through Blocks
You can exclude blocks from simulation without physically removing the blocks from the model by commenting out or commenting through the blocks.
Comment Out: Excludes the selected block from simulation. The signals are terminated and grounded.
Comment Through: Excludes the selected block from simulation. The signals are passed through. To comment through, a block must have the same number of input and output ports and no control or connection ports.
Note
These Simulink blocks do not support the Comment Out and Comment Through commands:
Inport
Outport
Connection ports
Argument Inport
Argument Outport
Data Store Memory
Goto Tag Visibility
The Signal Generator block does not support the Comment Through command.
To comment out a block, select the block. In the action bar that appears, click Comment Out.
To comment through a block, right-click the block and select Comment Through.
Tip
Alternatively, select the block and press:
Ctrl+Shift+X to comment out
Ctrl+Shift+Y to comment through