Recently, a friend gave me a very handy MATLAB plotting tip - it’s possible to undo the last n plotting operations for a given figure. So, if you’ve already plotted several data series, and you then, for example, plot the wrong series by mistake, you can ‘roll back’ your changes. The simple function below illustrates how to do this:
function undo_plot(h, n) % UNDO_PLOT Undo last 'n' plotting operations. if nargin == 1 n = 1; end if n < 1 error('Can''t undo < 1 plotting operation!'); end figure(h); children = get(gca, 'children'); for i = 1 : n delete(children(i)); end
Note that the function requires the handle of an existing figure. To grab the most recent figure, use:
for example. This call will undo the last two plotting operations.
- 1 comment // // Add to...