我有一个图,其中我画了一些离散点,然后画了一条轨迹。我想要在不同的轨迹之间切换,将它们绘制在与点相同的图形中,但不创建新的图形,即“擦除”第一个轨迹,然后绘制新的轨迹。
有没有办法做到这一点?
发布于 2014-02-02 02:27:27
也许这个小演示会对你有所帮助:
xy = rand(20,2);
figure
% Plot first iteration and output handles to each
h = plot(xy(:,1),xy(:,2),'b.',xy(1:2,1),xy(1:2,2),'r-');
axis([0 1 0 1])
% Update second plot by setting the XData and YData properties of the handle
for i = 2:size(xy,1)-1
set(h(2),{'XData','YData'},{xy(i:i+1,1),xy(i:i+1,2)})
drawnow
pause(0.1);
end
您应该阅读Matlab语言中的handle graphics以及get
和set
函数。
https://stackoverflow.com/questions/21501586
复制相似问题