Main Content

getSourceElement

Gets data elements selected on source port for connection

Since R2020b

    Description

    selectedElems = getSourceElement(connector) gets the selected data elements on a source port for a connection.

    example

    Examples

    collapse all

    Get the selected data element on the source port for a connection.

    Create a model and get its root architecture.

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

    Add a component, create an input port on the component, create an input port on the architecture. and extract both component port objects.

    newComponent = addComponent(rootArch,"Component1");
    inPortComp = addPort(newComponent.Architecture,...
    "testSig1","in");
    inPortArch = addPort(rootArch,"testSig1","in");
    compDestPort = getPort(newComponent,"testSig1");
    archSrcPort = getPort(rootArch,"testSig1");

    Add data interface, create data element, and set the data interface on the architecture port.

    interface = arch.InterfaceDictionary.addInterface("interface1");
    interface.addElement("x");
    archSrcPort.setInterface(interface);

    Connect the ports and get the source element of the connector.

    conns = connect(archSrcPort,compDestPort,SourceElement="x");
    elem = getSourceElement(conns)
    elem =
    
      1×1 cell array
    
        {'x'}

    Input Arguments

    collapse all

    Connection between ports, specified as a systemcomposer.arch.Connector object.

    Output Arguments

    collapse all

    Selected data element names, returned as a character vector.

    Data Types: char

    More About

    collapse all

    Version History

    Introduced in R2020b