simscape.addConnection
Syntax
Description
simscape.addConnection(
adds a connection line between two ports that belong to Simscape™ blocks. Supported block types include:block1
,port1
,block2
,port2
)
Simscape blocks in Foundation and Utilities libraries and in add-on product libraries
Custom Simscape blocks
Simscape Multibody™ blocks
Subsystems containing Simscape or Simscape Multibody blocks
Connection rules are the same as for connecting ports on the model canvas. For example, you can connect:
Conserving ports that belong to the same domain.
Untyped conserving ports, such as a connection port on a Solver Configuration block or Connection Port block that does not have prior connections, to any conserving port on another block. Once a conserving port becomes typed, that is, connected to another port of a specific domain type, you can connect it only to other ports of the same type.
Physical signal output and input ports. The signal sizes must be the same.
Bus ports of two different Simscape Bus blocks with matching sizes and types, for example, when both ports have the same rigid interface type.
The connection order does not matter. Conserving connections are nondirectional. Physical signal connections establish a connection line from the output to the input port regardless of the order that you specify them in the command syntax.
The ports being connected must be either both at the top level of the model hierarchy or both in the same subsystem. There is also a special syntax option for Connection Port blocks that simplifies adding connections across subsystem boundaries. For more information, see Connect Blocks Across Subsystem Boundaries.
Examples
Input Arguments
Limitations
Simscape Electrical™ Specialized Power Systems block ports and two-way connection ports are not supported.
Version History
Introduced in R2025a