Matlab:替换一个绘图并维护其他绘图
我画了一个图,画了一些分散的点,然后画了一条轨迹。我想通过在与点相同的图形中绘制不同的轨迹来在不同的轨迹之间切换,但不创建新的图形,即“擦除”第一条轨迹,然后绘制新的轨迹Matlab:替换一个绘图并维护其他绘图,matlab,plot,matlab-figure,Matlab,Plot,Matlab Figure,我画了一个图,画了一些分散的点,然后画了一条轨迹。我想通过在与点相同的图形中绘制不同的轨迹来在不同的轨迹之间切换,但不创建新的图形,即“擦除”第一条轨迹,然后绘制新的轨迹 有办法做到这一点吗?也许这个小演示会有帮助: 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
有办法做到这一点吗?也许这个小演示会有帮助:
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中的和函数。如果您至少提供一个小示例,说明您现在如何在不删除的情况下进行绘图,这将对我们有所帮助。