Contenuto principale

removeMapping

Remove mapping entries for input elements in adapter

Since R2026a

    Description

    removeMapping(adapter,inputElements) removes mapping entries on the adapter specified by adapter using the array of input elements in inputElements.

    example

    Examples

    collapse all

    Create and connect an adapter to three components in System Composer™. Then, add and remove mappings.

    Create a model and get the root architecture.

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

    Create three new components.

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

    Add ports to the components.

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

    Extract the component ports.

    srcPort1 = getPort(comp1,"p1");
    srcPort2 = getPort(comp2,"p2");
    destPort = getPort(comp3,"p3");

    Create an adapter.

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

    Connect the adapter to the three components.

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

    Improve the model layout.

    Simulink.BlockDiagram.arrangeSystem("archModel")

    Create two interfaces with two elements each.

    interface1 = addInterface(model.InterfaceDictionary,"interface1");
    element1a = addElement(interface1,"elem1a",DataType="double");
    element1b = addElement(interface1,"elem1b",DataType="double");
    
    interface2 = addInterface(model.InterfaceDictionary,"interface2");
    element2a = addElement(interface2,"elem2a",DataType="double");
    element2b = addElement(interface2,"elem2b",DataType="double");

    Assign the interfaces to ports.

    srcPort1.setInterface(interface1);
    srcPort2.setInterface(interface1);
    destPort.setInterface(interface2);

    Remove default mapping in the adapter.

    adapter.removeMapping("p1");

    Add mapping through the adapter.

    adapter.addMapping(["p1.elem1a","p2.elem1b"],["p3.elem2a","p3.elem2b"]);

    Remove mapping through the adapter.

    adapter.removeMapping("p1.elem1a");

    Input Arguments

    collapse all

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

    Qualified input port element names to remove mapping, specified as a string or array of strings.

    Example: adapter.removeMapping(["p1.elem1","p1.elem2"])

    Data Types: string

    More About

    collapse all

    Version History

    Introduced in R2026a