Clearing axis data from a GUIDE-generated figure

1 回表示 (過去 30 日間)
fsgeek
fsgeek 2013 年 7 月 3 日
Hi folks,
I'm having some difficulty processing data on a figure generated in GUIDE. The first task is to plot some data from a text file, as you can see below:
When the forward (play) button is pressed, I would like the plot data on the axes titled "Hysteresis Loop" to be cleared, but I can't seem to find a way to achieve this. There is no handle property that seems to do this, and using cla does not work either.
Trying to manually plot over the current data to clear the axes doesn't work properly either:
Here we can see that, instead of clearing the graph and re-plotting the new data, it only plots a single point.
Is there a way of simply getting rid of the old plot data without having to replace it with anything else so that I can just have a blank set of axes?
Thanks!
Louis Vallance

採用された回答

David Sanchez
David Sanchez 2013 年 7 月 3 日
The following code, given by one of the contributors long ago, will help you to undo the last plotting step:
function undo_plot(h, n)
% Undo_plot(h, n) undo last 'n' plotting operations from figure(h).
% n is optional and must be a positive integer since it denotes the number of
% steps to go back in the plotting process.
if nargin == 1
n = 1;
end
if n < 1
str = sprintf('It is not humanly/machinely possible to undo %s plotting operations ! ',num2str(n));
errordlg(str,'UNDO_PLOT ERROR');
return
end
figure(h);
children = get(gca, 'children');
for i = 1 : n
delete(children(i));
end
  1 件のコメント
fsgeek
fsgeek 2013 年 7 月 3 日
This works perfectly and solves my problem. Thank you, Mr. Sanchez.
Louis Vallance

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by