【问题标题】:Matlab: replace one plot maintaining othersMatlab:替换一个情节维持其他情节
【发布时间】:2014-02-01 18:04:07
【问题描述】:

我有一个图,我在其中绘制了一些分散点,然后是轨迹。我想通过将它们绘制在与点相同的图形中来在不同的轨迹之间切换,但不创建新图形,即“擦除”第一个轨迹,然后绘制新的轨迹。

有没有办法做到这一点?

【问题讨论】:

  • 如果您至少提供一个小例子说明您现在如何在不擦除的情况下进行绘图,这将对我们有所帮助。

标签: matlab plot matlab-figure


【解决方案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 中的 handle graphics 以及 getset 函数。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多