主要内容

updatePosition

Update position of adapter based on destination port

Since R2026a

    Description

    updatePosition(adapter,TargetPort=target) updates the position of the adapter specified by adapter according to a target port target.

    example

    Examples

    collapse all

    Create and connect an adapter to four components in System Composer™.

    Create a model and get the root architecture.

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

    Create four new components.

    names = ["Component1","Component2","Component3","Component4"];
    newComponents = addComponent(rootArch,names);

    Add ports to the components.

    comp1 = getComponent(rootArch,"Component1");
    comp2 = getComponent(rootArch,"Component2");
    comp3 = getComponent(rootArch,"Component3");
    comp4 = getComponent(rootArch,"Component4");
    outPort1 = addPort(comp1.Architecture,"p1","out");
    outPort2 = addPort(comp2.Architecture,"p2","out");
    inPort1 = addPort(comp3.Architecture,"p3","in");
    inPort2 = addPort(comp4.Architecture,"p4","in");

    Extract the component ports.

    srcPort1 = getPort(comp1,"p1");
    srcPort2 = getPort(comp2,"p2");
    destPort1 = getPort(comp3,"p3");
    destPort2 = getPort(comp4,"p4");

    Create an adapter.

    adapter = rootArch.addAdapter(InputName=["p1","p2"],OutputName=["p3"]);

    Connect the adapter to the first three components.

    adapter.connectTo(SourcePort=[srcPort1,srcPort2],TargetPort=[destPort1]);

    Improve the model layout.

    Simulink.BlockDiagram.arrangeSystem("archModel")

    Update the position of the adapter to connect to the fourth component.

    adapter.updatePosition(TargetPort=destPort2)

    Improve the model layout.

    Simulink.BlockDiagram.arrangeSystem("archModel")

    Input Arguments

    collapse all

    Adapter, specified as a systemcomposer.arch.Adapter object.

    Target port to connect adapter outputs, specified as a data input systemcomposer.arch.ComponentPort object or a data output systemcomposer.arch.ArchitecturePort object.

    Example: adapter.updatePosition(TargetPort=destPort2)

    More About

    collapse all

    Version History

    Introduced in R2026a