Main Content

getPort

Get port from component

Description

port = getPort(compObj,portName) gets the port on the component compObj with a specified name portName.

example

Examples

collapse all

Create and connect two ports in System Composer™.

Create a top-level architecture model.

modelName = "archModel";
arch = systemcomposer.createModel(modelName);
systemcomposer.openModel(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);

View the model.

systemcomposer.openModel(modelName);

Improve the model layout.

Simulink.BlockDiagram.arrangeSystem(modelName)

Input Arguments

collapse all

Component to get port from, specified as a systemcomposer.arch.Component or systemcomposer.arch.VariantComponent object.

Name of port, specified as a character vector or string.

Example: "testSig"

Data Types: char | string

Output Arguments

collapse all

Component port, returned as a systemcomposer.arch.ComponentPort object.

More About

collapse all

Version History

Introduced in R2019a