1

How to use Matlab to shade the area between the upper line and the lower line? thank you!

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);
matrix
  • 11
  • 1

1 Answers1

1

You can simply define a polygon:

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

Here we just "stick" the two sequences of points together so that we go from left to right for the lower part, than left to right for the upper part which creates a nice polygon that is bounded by the two curves.

flawr
  • 10,814
  • 3
  • 41
  • 71