MATLAB Help Center
Copy factor graph
Since R2026a
copyfg = copy(fg)
copyfg = copy(fg) creates a deep copy of the specified factor graph with the same properties.
copyfg
fg
example
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
factorGraph
Factor graph, specified as a factorGraph object.
Factor graph, returned as a factorGraph object. This copies all property values, node states, factors, and calculated covariances from fg.
expand all
Introduced in R2026a
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
Europe
Asia Pacific
Contact your local office