Matlab: replace one plot maintaining others

廉价感情. 提交于 2019-12-02 08:21:52

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

You should read up on handle graphics in Matlab and the get and set functions.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!