我打开了多个图形,我想在运行时独立更新它们。下面的玩具示例应该可以阐明我的意图:
clf;
figure('name', 'a and b'); % a and b should be plotted to this window
hold on;
ylim([-100, 100]);
figure('name', 'c'); % only c should be plotted to this window
a = 0;
b = [];
for i = 1:100
a = a + 1;
b = [b, -i];
c = b;
xlim([0, i]);
plot(i, a, 'o');
plot(i, b(i), '.r');
drawnow;
end
这里的问题是当我打开第二个figure
,我无法告诉plot
函数绘制第一个而不是第二个(并且仅c
应绘制到第二个)。
你可以使用类似的东西
figure(1)
plot(x,y) % this will go on figure 1
figure(2)
plot(z,w) % this will go on another figure
该命令还将设置图形可见并位于所有内容之上。
您可以根据需要通过发出相同的命令在数字之间来回切换figure
命令。或者,您也可以使用图形的句柄:
h=figure(...)
然后发出figure(h)
而不是使用数字索引。使用此语法,您还可以使用以下命令来防止图形在顶部弹出
set(0,'CurrentFigure',h)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)