Hauptinhalt

getPort

Get port by name

Description

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

example

port = getPort(arch,portName) gets the port on the architecture arch with a specified name portName.

example

Examples

collapse all

Create and connect two ports in System Composer™.

Create a model and get the root architecture.

model = systemcomposer.createModel("archModel");
systemcomposer.openModel("archModel");
rootArch = get(model,"Architecture");

Create two new components.

names = ["Component1","Component2"];
newComponents = addComponent(rootArch,names);

Add ports to the components.

comp1 = getComponent(rootArch,"Component1");
comp2 = getComponent(rootArch,"Component2");
outPort1 = addPort(comp1.Architecture,"testSig","out"); 
inPort1 = addPort(comp2.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("archModel")

Input Arguments

collapse all

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

Architecture, specified as a systemcomposer.arch.Architecture object.

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

Example: "testSig"

Data Types: char | string

Output Arguments

collapse all

More About

collapse all

Version History

Introduced in R2019a