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.
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.
For some blocks, you can enter the number of input ports when you add the block to the model.
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.
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.
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.
To connect these blocks or change an existing connection, use connect mode.
To enter connect mode:
If you are in design mode, exit by clicking the X in the upper-right corner of the Simulink canvas.
Click the dashboard block in the canvas. If the dashboard block is not connected, the Connect button and an ellipsis appear over the dashboard block. If the dashboard block is already connected, only the ellipsis appears.
If the dashboard block is not connected, click Connect. If the dashboard block is connected, pause on the ellipsis. In the action bar that expands, click Connect. Either way, a list of signals that are available for connection appears.
To connect the dashboard block in connect mode:
From the list select the signal, block parameter, or variable, you want to connect.
To exit bind mode, click Done Connecting over the dashboard block.
For more information on how to connect indicator blocks from the Dashboard and Customizable Blocks libraries, see the Connect Dashboard Blocks section in Circular Gauge. For more information on how to connect control blocks, see the Connect Dashboard Blocks section in Knob.
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.
These Simulink blocks do not support the Comment Out and Comment Through commands:
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.
Alternatively, select the block and press:
Ctrl+Shift+X to comment out
Ctrl+Shift+Y to comment through