주요 콘텐츠

getComponent

Get component by name

Description

comp = getComponent(arch,compName) gets the component on the architecture arch with a specified name compName.

example

Examples

collapse all

Create and connect two components 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(getComponent(rootArch,"Component1"),"testSig");
destPort = getPort(getComponent(rootArch,"Component2"),"testSig");

Connect the ports.

conns = connect(srcPort,destPort);

Improve the model layout.

Simulink.BlockDiagram.arrangeSystem("archModel")

Input Arguments

collapse all

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

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

Example: "Component1"

Data Types: char | string

Output Arguments

collapse all

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

More About

collapse all

Version History

Introduced in R2019a