本文介绍了Matlab:替换一个地块并维护其他地块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个图,其中我绘制了一些分散点,然后绘制了轨迹.我想在不同的轨迹之间切换,方法是将它们绘制在与点相同的图形中,但又不创建新图形,即先擦除"第一个轨迹,然后绘制新轨迹.
I have a figure in which I plot some disperse points and then a trajectory. I want to switch between different trajectories by plotting them in the same figure as the points, but without creating new figures, i.e., "erasing" the first trajectory and then plotting the new one.
有没有办法做到这一点?
Is there a way of doing this?
推荐答案
也许这个小演示会有所帮助:
Perhaps this little demo will be helpful:
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和 get
和 set
函数.
You should read up on handle graphics in Matlab and the get
and set
functions.
这篇关于Matlab:替换一个地块并维护其他地块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!