주요 콘텐츠

getSubElement

Get child port element by name

Since R2026a

Description

subElement = getSubElement(portElement,name) gets the child port element subElement according to the name specified by name.

example

Examples

collapse all

Create a model and get the root architecture.

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

Add a component and add a port to the component.

newComponent = addComponent(rootArch,"newComponent");
newPort = addPort(newComponent.Architecture,"newPort","in");

Add a first data interface with a data element.

newInterface = addInterface(model.InterfaceDictionary,"newInterface");
newElement = addElement(newInterface,"newElement",DataType="double");

Add a second data interface with a second data element.

newInterface2 = addInterface(model.InterfaceDictionary,"newInterface2");
newElement2 = addElement(newInterface2,"newElement2",DataType="double");

Type the first data element with the second data interface.

newElement.setType(newInterface2)

Set the first interface on the port.

setInterface(newPort,newInterface)

Access the data element from a port element.

portElement = getPortElement(newPort,'newElement')
portElement = 

  PortElement with properties:

                   Name: 'newElement'
                 Parent: [1×1 systemcomposer.arch.ArchitecturePort]
            SubElements: [1×1 systemcomposer.arch.PortElement]
       InterfaceElement: [1×1 systemcomposer.interface.DataElement]
                  Model: [1×1 systemcomposer.arch.Model]
         SimulinkHandle: -1
    SimulinkModelHandle: 149.0002
                   UUID: '40b38418-76b2-4a96-9da7-d6c6f237cf56'
            ExternalUID: ''

Get a child of the first port element.

childElement = getSubElement(portElement,'newElement2')
childElement = 

  PortElement with properties:

                   Name: 'newElement2'
                 Parent: [1×1 systemcomposer.arch.PortElement]
            SubElements: []
       InterfaceElement: [1×1 systemcomposer.interface.DataElement]
                  Model: [1×1 systemcomposer.arch.Model]
         SimulinkHandle: -1
    SimulinkModelHandle: 149.0001
                   UUID: 'f37144f3-6db3-4cfc-ac0a-833bfcf0c282'
            ExternalUID: ''

Input Arguments

collapse all

Port element, specified as a systemcomposer.arch.PortElement object.

Partial name of child port element, specified as a character vector or string.

Example: "a"

Data Types: char | string

Output Arguments

collapse all

Child port element, returned as a systemcomposer.arch.PortElement object.

More About

collapse all

Version History

Introduced in R2026a