Search code examples
matlabmatlab-figure

Duplicate figure(1) and assign the duplicate to figure(2)


I have created the following figure (figure(1)) in Matlab.

figure(1)

I am trying to create a figure(2), which is going be exactly the same as figure(1) - in other words duplicate the figure(1) and the duplicate version I want to assign it as figure(2).

The reason for that is that I want to be able to present the figure(1) as it is and then in figure(2) I want to present only part of the figure(1) (for example the part for which the x is between 0.333 and 0.666).

Any ideas?


Solution

  • You can use

    copyobj(gcf, groot)
    

    This creates a copy (copyobj) of the current figure (gcf), including its children, as a new child of the graphics root object (groot).