在MATLAB中,如何清除绘制在图形上的最后一件事? [英] In MATLAB, how does one clear the last thing plotted to a figure?
本文介绍了在MATLAB中,如何清除绘制在图形上的最后一件事?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在MATLAB中,我将许多不同的向量绘制到一个图形上.现在,我想做的就是简单地撤消绘制到该图的 last 向量,而不清除其他所有内容.如何做到这一点?能做到吗?
In MATLAB, I plot many different vectors to a figure. Now, what I would like to do is simply undo the last vector that I plotted to that figure, without clearing everything else. How can this be accomplished? Can it be accomplished?
谢谢
figure(1); clf(1);
N = 100;
x = randn(1,N);
y = randn(1,N);
z = sin(1:N);
plot(x); hold on;
plot(y,'r');
plot(z,'k');
现在,在这里,我想删除绘图z,这是我制作的最后一个绘图.
Now here, I would like to remove the plot z, which was the last plot I made.
推荐答案
如果在打印之前知道要稍后再次删除它,则可以保存plot
返回的句柄,然后delete
返回. >
If you know before plotting that you want to remove it again later, you can save the handle returned by plot
and delete
it afterwards.
figure;
h1 = plot([0 1 2], [3 4 5]);
delete(h1);
这篇关于在MATLAB中,如何清除绘制在图形上的最后一件事?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文