connect - Create architecture model connections - MATLAB (original) (raw)

Create architecture model connections

Syntax

Description

[connectors](#mw%5Fe8bfbd73-1267-4b7b-b445-6a31279d4049%5Fsep%5Fmw%5F6d04df0a-97d5-4b05-9d28-bf6ac0db83c4) = connect([srcComponent](#mw%5F0c26f0db-e9fd-4663-934c-4e01d8a6aeb2),[destComponent](#mw%5F873ab974-e7c4-452b-ad03-91a1dc6c36e8)) connects the unconnected output ports of the source componentsrcComponent to the unconnected input ports of the destination component destComponent based on matching port names, and returns a handle to the connector. For physical connections, the connectors are nondirectional so the source and destination components can be interchanged.

To remove a connector, use the destroy function.

example

[connectors](#mw%5Fe8bfbd73-1267-4b7b-b445-6a31279d4049%5Fsep%5Fmw%5F6d04df0a-97d5-4b05-9d28-bf6ac0db83c4) = connect([arch](#mw%5Fe8bfbd73-1267-4b7b-b445-6a31279d4049%5Fsep%5Fmw%5Feac4bd99-f7ec-4b2d-8753-44a4fc3f47d4),[[srcComponent](#mw%5F0c26f0db-e9fd-4663-934c-4e01d8a6aeb2),[srcComponent](#mw%5F0c26f0db-e9fd-4663-934c-4e01d8a6aeb2),...],[[destComponent](#mw%5F873ab974-e7c4-452b-ad03-91a1dc6c36e8),[destComponent](#mw%5F873ab974-e7c4-452b-ad03-91a1dc6c36e8),...]) connects arrays of components in the architecture.

[connectors](#mw%5Fe8bfbd73-1267-4b7b-b445-6a31279d4049%5Fsep%5Fmw%5F6d04df0a-97d5-4b05-9d28-bf6ac0db83c4) = connect([arch](#mw%5Fe8bfbd73-1267-4b7b-b445-6a31279d4049%5Fsep%5Fmw%5Feac4bd99-f7ec-4b2d-8753-44a4fc3f47d4),[],[destComponent](#mw%5F873ab974-e7c4-452b-ad03-91a1dc6c36e8)) connects a parent architecture input port to a destination child component.

[connectors](#mw%5Fe8bfbd73-1267-4b7b-b445-6a31279d4049%5Fsep%5Fmw%5F6d04df0a-97d5-4b05-9d28-bf6ac0db83c4) = connect([arch](#mw%5Fe8bfbd73-1267-4b7b-b445-6a31279d4049%5Fsep%5Fmw%5Feac4bd99-f7ec-4b2d-8753-44a4fc3f47d4),[srcComponent](#mw%5F0c26f0db-e9fd-4663-934c-4e01d8a6aeb2),[]) connects a source child component to a parent architecture output port.

[connectors](#mw%5Fe8bfbd73-1267-4b7b-b445-6a31279d4049%5Fsep%5Fmw%5F6d04df0a-97d5-4b05-9d28-bf6ac0db83c4) = connect([srcPort](#mw%5Ff66a9cd0-78a0-4eb7-9d35-f4dba2e84602),[destPort](#mw%5F298006ea-37ba-4d31-98b2-da552ed123be)) connects a source port and a destination port, or connects two nondirectional physical ports.

example

[connectors](#mw%5Fe8bfbd73-1267-4b7b-b445-6a31279d4049%5Fsep%5Fmw%5F6d04df0a-97d5-4b05-9d28-bf6ac0db83c4) = connect([srcPort](#mw%5Ff66a9cd0-78a0-4eb7-9d35-f4dba2e84602),[destPort](#mw%5F298006ea-37ba-4d31-98b2-da552ed123be),[stereotype](#mw%5Fb3e0a928-702a-4a35-862a-a67ab313b706)) connects two ports and applies a stereotype to the connector.

[connectors](#mw%5Fe8bfbd73-1267-4b7b-b445-6a31279d4049%5Fsep%5Fmw%5F6d04df0a-97d5-4b05-9d28-bf6ac0db83c4) = connect(___,[Name=Value](#namevaluepairarguments)) specifies options using one or more name-value arguments in addition to the input arguments in previous syntaxes.

example

Examples

collapse all

Create and connect two components.

Create a 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 the components.

outPort1 = addPort(newComponents(1).Architecture,"testSig","out"); inPort1 = addPort(newComponents(2).Architecture,"testSig","in");

Connect the components.

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

Improve the model layout.

Simulink.BlockDiagram.arrangeSystem(modelName)

Create and connect two ports.

Create a 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 the components.

outPort1 = addPort(newComponents(1).Architecture,"testSig","out"); inPort1 = addPort(newComponents(2).Architecture,"testSig","in");

Extract the component ports.

srcPort = getPort(newComponents(1),"testSig"); destPort = getPort(newComponents(2),"testSig");

Connect the ports.

conns = connect(srcPort,destPort);

Improve the model layout.

Simulink.BlockDiagram.arrangeSystem(modelName)

Create and connect a destination architecture port interface element to a component.

Create a top-level architecture model.

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

Create a new component.

newComponent = addComponent(rootArch,"Component1");

Add destination architecture ports to the component and the architecture.

outPortComp = addPort(newComponent.Architecture,"testSig","out"); outPortArch = addPort(rootArch,"testSig","out");

Extract corresponding port objects.

compSrcPort = getPort(newComponent,"testSig"); archDestPort = getPort(rootArch,"testSig");

Add an interface and an interface element, and associate the interface with the architecture port.

interface = arch.InterfaceDictionary.addInterface("interface"); interface.addElement("x"); archDestPort.setInterface(interface);

Select an element on the architecture port and establish a connection.

conns = connect(compSrcPort,archDestPort,DestinationElement="x");

Improve the model layout.

Simulink.BlockDiagram.arrangeSystem(modelName)

Input Arguments

collapse all

Stereotype to apply to the connection, specified in the form"<profile>.<stereotype>".

Data Types: char | string

Name-Value Arguments

collapse all

Specify optional pairs of arguments asName1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: connect(archPort,compPort,SourceElement="a")

Option to apply stereotype to connector, specified in the form"<profile>.<stereotype>".

This name-value argument applies only when you connect components.

Example: conns = connect(srcComp,destComp,Stereotype="GeneralProfile.ConnStereotype")

Data Types: char | string

Option to specify rule for connections, specified as either"name" based on the name of ports or"interface" based on the interface name on ports.

This name-value argument applies only when you connect components.

Example: conns = connect([srcComp1,srcComp2],[destComp1,destComp2],Rule="interface")

Data Types: char | string

Option to allow multiple destination components for the same source component, specified as 1 (true) or 0 (false).

This name-value argument applies only when you connect components.

Example: conns = connect(srcComp,[destComp1,destComp2],MultipleOutputConnectors=true)

Data Types: logical

Option to select source element for connection, specified as a character vector or string of the name of the data element.

This name-value argument applies only when you connect ports.

Example: conns = connect(archSrcPort,compDestPort,SourceElement="x")

Data Types: char | string

Option to select destination element for connection, specified as a character vector or string of the name of the data element.

This name-value argument applies only when you connect ports.

Example: conns = connect(compSrcPort,archDestPort,DestinationElement="x")

Data Types: char | string

Option to specify type of automatic line routing, specified as one of the following:

Example: conns = connect(srcPort,destPort,Routing="on")

Data Types: char | string

Output Arguments

More About

collapse all

Term Definition Application More Information
Architecture A System Composer™ architecture represents a system of components and how they interface with each other structurally and behaviorally. Different types of architectures describe different aspects of systems. You can use views to visualize a subset of components in an architecture. You can define parameters on the architecture level using the Parameter Editor. Compose Architectures VisuallyAuthor Parameters in System Composer Using Parameter Editor
Root A root is at the top of an architecture hierarchy. A root architecture has a boundary defined by its architecture ports that surround the system of interest. The root architecture has a system boundary surrounding your architecture model. You can add architecture ports that define interfaces across the boundary. Compose Architectures Visually
Model A System Composer model is the file that contains architectural information, such as components, ports, connectors, interfaces, and behaviors. Perform operations on a model including extracting root-level architecture, applying profiles, linking interface data dictionaries, or generating instances from model architecture. A System Composer model is stored as an SLX file. Create Architecture Model with Interfaces and Requirement Links
Component A component is a replaceable part of a system that fulfills a clear function in the context of an architecture. A component defines an architectural element, such as a function, another system, hardware, software, or other conceptual entity. A component can also be a subsystem or subfunction. Represented as a block, a component is a part of an architecture model that can be separated into reusable artifacts. Transfer information between components with port interfaces using the Interface Editor, and parameters using the Parameter Editor. Compose Architectures Visually
Port A port is a node on a component or architecture that represents a point of interaction with its environment. A port permits the flow of information to and from other components or systems. Component ports are interaction points on the component to other components. Architecture ports are ports on the boundary of the system, whether the boundary is within a component or the overall architecture model. The root architecture has a boundary defined by its ports. Compose Architectures Visually
Connector Connectors are lines that provide connections between ports. Connectors describe how information flows between components or architectures. A connector allows two components to interact without defining the nature of the interaction. Set an interface on a port to define how the components interact. Compose Architectures Visually
Term Definition Application More Information
Physical subsystem A physical subsystem is a Simulink® subsystem with Simscape™ connections. A physical subsystem with Simscape connections uses a physical network approach suited for simulating systems with real physical components and represents a mathematical model. Implement Component Behavior Using Simscape
Physical port A physical port represents a Simscape physical modeling connector port called a Connection Port (Simscape). Use physical ports to connect components in an architecture model or to enable physical systems in a Simulink subsystem. Define Physical Ports on Component
Physical connector A physical connector can represent a nondirectional conserving connection of a specific physical domain. Connectors can also represent physical signals. Use physical connectors to connect physical components that represent features of a system to simulate mathematically. Architecture Model with Simscape Behavior for a DC Motor
Physical interface A physical interface defines the kind of information that flows through a physical port. The same interface can be assigned to multiple ports. A physical interface is a composite interface equivalent to a Simulink.ConnectionBus object that specifies a number of Simulink.ConnectionElement objects. Use a physical interface to bundle physical elements to describe a physical model using at least one physical domain. Specify Physical Interfaces on Ports
Physical element A physical element describes the decomposition of a physical interface. A physical element is equivalent to a Simulink.ConnectionElement object. Define the Type of a physical element as a physical domain to enable use of that domain in a physical model. Describe Component Behavior Using Simscape

Version History

Introduced in R2019a

See Also

Functions

Objects

Blocks

Topics