メインコンテンツ

copy

Copy factor graph

Since R2026a

    Description

    copyfg = copy(fg) creates a deep copy of the specified factor graph with the same properties.

    example

    Examples

    collapse all

    Create factor graph and add factors to the graph.

    fg = factorGraph;
    ids = generateNodeID(fg,5,"factorTwoPoseSE2");
    poseFactors = factorTwoPoseSE2(ids,Measurement=repmat([1 0 0],5,1));
    addFactor(fg,poseFactors);

    Optimize factor graph and get the node states.

    optimize(fg);
    stateFG = nodeState(fg,unique(ids))
    stateFG = 6×3
    
       -2.5000         0         0
       -1.5000         0         0
       -0.5000         0         0
        0.5000         0         0
        1.5000         0         0
        2.5000         0         0
    
    

    Create a deep copy of the factor graph and display the node states of the factor graph copy.

    fgCopy = copy(fg);
    stateFGCopy = nodeState(fg,unique(ids))
    stateFGCopy = 6×3
    
       -2.5000         0         0
       -1.5000         0         0
       -0.5000         0         0
        0.5000         0         0
        1.5000         0         0
        2.5000         0         0
    
    

    Input Arguments

    collapse all

    Factor graph, specified as a factorGraph object.

    Output Arguments

    collapse all

    Factor graph, returned as a factorGraph object. This copies all property values, node states, factors, and calculated covariances from fg.

    Extended Capabilities

    expand all

    C/C++ Code Generation
    Generate C and C++ code using MATLAB® Coder™.

    Version History

    Introduced in R2026a

    See Also