connect
Connect two or more component ports of the same type
Parent Section: connections
Syntax
connect(n1, n2); connect(s, d1);
Description
The connect
constructs describe both the conserving connections
(between nodes
) and the physical signal connections (between the
inputs
and outputs
). You can place a
connect
construct only inside the connections
block in a composite component file.
For a conserving connection, the syntax is
connect(n1, n2);
The construct can have more than two arguments. n1
,
n2
, n3
, and so on are nodes
declared in the composite component or in any of the member component files. The only
requirement is that these nodes are all associated with the same domain. The order of
arguments does not matter. The connect
construct creates a physical
conserving connection between all the nodes listed as arguments.
The *
symbol indicates a connection to an implicit reference
node:
connect(n1, *);
For more information, see Connections to Implicit Reference Node.
For a physical signal connection, the syntax is
connect(s, d1);
The construct can have more than two arguments. All arguments are
inputs
and outputs
declared in the composite
component or in any of the member component files. The first argument,
s
, is the source port, and the remaining arguments,
d1
, d2
, d3
, and so on, are
destination ports. The connect
construct creates a directional
physical signal connection from the source port to the destination port or ports. For
example,
connect(s, d1, d2);
means that source s
is connected to two destinations,
d1
and d2
. A destination cannot be connected
to more than one source. If a signal connect statement has more than one destination,
the order of destination arguments (d1
, d2
, and so
on) does not matter.
The following table lists valid source and destination combinations.
Source | Destination |
---|---|
External input port of composite component | Input port of member component |
Output port of member component | Input port of member component |
Output port of member component | External output port of composite component |
If a member component is itself a composite component, the connect
constructs can only access its external nodes, not the internal nodes of its underlying
members. For example, consider the following diagram.
You are defining a composite component a
, which consists of member
components b
and c
. Component c
is in turn a composite component containing members d
and
e
. Each component has nodes n1
and
n2
.
The following constructs are legal:
connect(n1, c.n1);
connect(b.n1, c.n1);
However, the following constructs
connect(n1, c.d.n1);
connect(b.n1, c.d.n1);
are illegal because they are trying to access an underlying member component within
the member component c
.
You can also use for
loops to declare an array of member components
and specify the component connections. For more information, see Component Arrays.
Examples
Version History
Introduced in R2012b