Matlab - 在2条垂直曲线之间遮挡表面

时间:2014-03-10 22:34:41

标签: matlab

我尝试(到目前为止没有成功)在两条曲线之间着色或遮蔽表面但是在垂直方向上。 更具体地说,我希望在红色和蓝色曲线之间遮挡表面,因为它们有时会相互交叉。

这样做的最终目的是显示不确定的范围(标称曲线是黑色曲线),由红色和蓝色曲线表示。

我不知道这是否有帮助,我为每条曲线设置了100个值的向量。 你对如何做到了吗?

Image

非常感谢,

致以最诚挚的问候,

安托

编辑: 感谢您及时回复 !

我试过你的方法,但不幸的是它似乎不起作用..

这是我的代码:

filename = '/Users/Antoine/Dropbox/TFE/Post-processing/100planes_Z_HT/case1/HT_tip_int.dat';
delimiterIn = ' ';
case1_int = importdata(filename,delimiterIn);

filename = '/Users/Antoine/Dropbox/TFE/Post-processing/100planes_Z_HT/case4/HT_tip_int.dat';
delimiterIn = ' ';
case4_int = importdata(filename,delimiterIn);

filename = '/Users/Antoine/Dropbox/TFE/Post-processing/100planes_Z_HT/case5/HT_tip_int.dat';
delimiterIn = ' ';
case5_int = importdata(filename,delimiterIn);

figure
HT_tip_int1=plot(case1_int.data,Z2,'k-','Linewidth',1);
hold on;
HT_tip_int4=plot(case4_int.data,Z2,'r');
HT_tip_int5=plot(case5_int.data,Z2,'c');

area( [case4_int.data fliplr(case5_int.data)], [Z2 fliplr(Z2)],'FaceColor','red'); hold off

这是正确的方法吗?

感谢您的帮助!

安托

1 个答案:

答案 0 :(得分:1)

如何以下列方式使用area

获取第一个数据集及其参数向量,并将其与第二个数据集反向连接。这样你就得到了一个封闭的多边形。

% example data
t  = 1:100;
x1 = sin(pi*t/10).*t
x2 = 0.1*sin(pi*t/10).*t*2 + 25

plot(x1,t, x2, t,'linewidth',5); hold on
area( [x1 x2(end:-1:1)], [t t(end:-1:1)],'FaceColor','red'); hold off
% or
% area( [x1 fliplr(x2)], [t fliplr(t)],'FaceColor','red'); hold off

给出:

enter image description here