Connect pairs of components


connectors = connect(srcComponent,destComponent) connects the unconnected output ports of srcComponent to the unconnected input ports of destComponent based on matching port names, and returns a handle to the connector.

connectors = connect(srcComponent,destComponent,'Stereotype',stereotypes) additionally applies the specified stereotype to the connector.

connectors = connect(srcComponent,destComponent,'Rule',rule) specifies a rule for establishing connections.

connectors = connect(architecture,srcPorts,destPorts,stereotypes,rule) connects pairs of ports in the architecture.


collapse all

This example shows how to create and connect two components.

Create the top level architecture model.

modelName = "archModel";
arch = systemcomposer.createModel(modelName);
rootArch = get(arch,'Architecture');                  

Create two new components.

names = {'Component1','Component2'};
newcomponents = addComponent(rootArch,names);

Add ports to these components.

outport1 = addPort(newcomponents(1).Architecture,'testsig','out'); 
inport1 = addPort(newcomponents(2).Architecture,'testsig','in');

Connect the components.

conns = connect(newcomponents(1),newcomponents(2));

View the model.


Improve the layout.


Input Arguments

collapse all

Interface and the underlying structural definition of a model or component, specified as an Architecture object.

Data Types: systemcomposer.arch.Architecture

Array of source ports. Must be the same length as destPorts and must consist of all output ports.

Data Types: systemcomposer.arch.Port

Array of destination ports. Must be the same length as srcPorts and must consist of all source ports.

Data Types: systemcomposer.arch.Port

Source component.

Data Types: systemcomposer.arch.Component

Destination component.

Data Types: systemcomposer.arch.Component

Stereotypes to apply to the connections, specified as an array.

Data Types: systemcomposer.profile.Stereotype

Rule to match ports for connection.

Data Types: systemcomposer.arch.Component

Output Arguments

collapse all

Array of connections.

Introduced in R2019a