Contenuto principale

getConnectorTo

Find connector between ports

    Description

    connectors = getConnectorTo(port,otherPort) finds connectors between the port specified by port and another port specified by otherPort.

    example

    connectors = getConnectorTo(port,otherPort,Name=Value) finds connectors between one port and another port, with additional options specified by one or more name-value arguments.

    Examples

    collapse all

    Create and connect two ports.

    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.

    outPort1 = addPort(newComponents(1).Architecture,"testSig","out"); 
    inPort1 = addPort(newComponents(2).Architecture,"testSig","in");

    Extract the component ports.

    srcPort = getPort(newComponents(1),"testSig");
    destPort = getPort(newComponents(2),"testSig");

    Connect the ports.

    conns = connect(srcPort,destPort);

    Improve the model layout.

    Simulink.BlockDiagram.arrangeSystem("archModel")

    Find the connection between the ports.

    conn = getConnectorTo(srcPort,destPort)
    conn = 
    
      Connector with properties:
    
                 SourcePort: [1×1 systemcomposer.arch.ComponentPort]
            DestinationPort: [1×1 systemcomposer.arch.ComponentPort]
                       Name: 'Conn'
                     Parent: [1×1 systemcomposer.arch.Architecture]
                      Ports: [1×2 systemcomposer.arch.ComponentPort]
                      Model: [1×1 systemcomposer.arch.Model]
             SimulinkHandle: 211.0002
        SimulinkModelHandle: 149.0001
                       UUID: '3f09b902-8a5a-4078-9296-52849f22b019'
                ExternalUID: ''

    Input Arguments

    collapse all

    Name-Value Arguments

    collapse all

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: conn = getConnectorTo(srcPort,destPort,SourceElement='x',DestinationElement='y')

    Source element for connection, specified as a character vector or string.

    Data Types: char | string

    Destination element for connection, specified as a character vector or string.

    Data Types: char | string

    Output Arguments

    collapse all

    Connectors, returned as an array of systemcomposer.arch.Connector or systemcomposer.arch.PhysicalConnector objects.

    More About

    collapse all

    Version History

    Introduced in R2019a