【发布时间】:2019-12-08 18:44:52
【问题描述】:
下面的代码在 Zlevel 指定的 Z 轴上的不同位置绘制多个等高线图。但是,我有多个感兴趣的 Z 数据点,因此我想使用 for 循环。
Zlevel=[0 1];
figure(1)
hold on
[~,h1]=contourf(xx,yy,zz(:,:,1)); h1.ContourZLevel=Zlevel(1);
hold on
[~,hh1]=contour(xx,yy,yy); hh1.ContourZLevel=h1.ContourZLevel;
hold on
[~,h2]=contourf(xx,yy,zz(:,:,2)); h2.ContourZLevel=Zlevel(2);
hold on
[~,hh2]=contour(xx,yy,yy);hh2.ContourZLevel=h2.ContourZLevel;
hold off
我在想我可以有这样的东西:
figure(1); hold on;
for i=1:length(Zlevel)
[~,h(i)]=contourf(xx,yy,zz(:,:,i)); h(i).ContourZLevel=Zlevel(i);
hold on
[~,hh(i)]=contour(xx,yy,yy); hh(i).ContourZLevel=Zlevel(i);
hold on
end
hold off
我已经尝试过了,但我无法让它工作。我可能不了解 matlab 的对象处理。因此,如果有人可以帮助我并向我解释为什么我不能做我想做的事情并指出正确的方向,我将不胜感激!
谢谢!
【问题讨论】:
-
什么不起作用?结果不是你预期的吗?你有错误吗?您能否edit您的问题并详细说明您希望情节如何,以及哪些内容无法按您的意愿工作。 '我可能不了解 matlab 的对象处理。' 您应该能够将图形句柄放在一个数组中,并像您一样设置属性,所以这可能不是问题。跨度>
-
你得到什么错误?
标签: matlab matlab-figure contourf