メインコンテンツ

getPortElement

Find port element by name

Since R2026a

    Description

    portElement = getPortElement(name) finds a port element or child port element by partial 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: ''

    Input Arguments

    collapse all

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

    If name is specified as "a.b", the getPortElement function looks for the port element "a" and then looks for the child port element "b" inside of "a".

    Example: "a.b"

    Data Types: char | string

    Output Arguments

    collapse all

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

    More About

    collapse all

    Version History

    Introduced in R2026a