Contenuto principale

systemcomposer.arch.PortElement

Element of port in System Composer model

Since R2026a

    Description

    The PortElement class represents System Composer™ port elements. This class is derived from systemcomposer.arch.Element.

    Creation

    Create a systemcomposer.arch.PortElement object by assigning interfaces with hierarchy to a port. Access port elements using the PortElements property of the systemcomposer.arch.ArchitecturePort object.

    Properties

    expand all

    Name of port element, specified as a character vector.

    Example: 'portElement'

    Data Types: char

    Interface element associated with port element, specified as a systemcomposer.interface.DataElement or systemcomposer.interface.FunctionElement object.

    Port elements owned by this port element, specified as an array of systemcomposer.arch.PortElement objects.

    Owned port or port element, specified as a systemcomposer.arch.ArchitecturePort or systemcomposer.arch.PortElement object.

    Parent System Composer model, specified as a systemcomposer.arch.Model object.

    Simulink® handle, specified as a double.

    This property is necessary for several Simulink workflows and for using Requirements Toolbox™ programmatic interfaces.

    Example: handle = get(object,'SimulinkHandle')

    Data Types: double

    Simulink handle to parent System Composer model, specified as a double.

    This property is necessary for several Simulink workflows and for using Requirements Toolbox programmatic interfaces.

    Example: handle = get(object,'SimulinkModelHandle')

    Data Types: double

    Unique external identifier, specified as a character vector. The external ID is preserved over the lifespan of the element and through all operations that preserve the UUID.

    Data Types: char

    Universal unique identifier, specified as a character vector.

    Example: '91d5de2c-b14c-4c76-a5d6-5dd0037c52df'

    Data Types: char

    Object Functions

    getSubElementGet child port element by name
    getQualifiedNameGet model element qualified name
    destroyRemove model element

    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: ''

    More About

    expand all

    Version History

    Introduced in R2026a