如何在Matlab中2个图形之间的阴影区域? [重复]

问题描述 投票:1回答:1

如何使用Matlab着色上线和下线之间的区域?谢谢!

clc; clear
upper=[54.48 62.83  46.53   44.11   46.33   49.95   53.68   58.03   62.99 69.33];
lower=[54.48 45.65  40.37   40.87   42.38   44.99   47.65   50.70   53.92 57.89];
t=[0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5];
plot(t,upper);
hold on;
plot(t,lower);
matlab plot matlab-figure
1个回答
1
投票

您可以简单地定义多边形:

t_area = [t, t(end:-1:1)];
y_area= [lower, upper(end:-1:1)];
fill(t_area, y_area, 'y');

在这里,我们只是将两个点序列“粘在一起”,以便我们从左到右依次为下部,而不是从左至右为上部,这创建了一个由两条曲线所包围的多边形。

© www.soinside.com 2019 - 2024. All rights reserved.