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

1 view (last 30 days)
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);

Accepted Answer

Adam Danz
Adam Danz on 10 Feb 2020
Edited: Adam Danz on 11 Feb 2020
fliplr() flips the vector left to right.
patch() plots the colored patch between the lines.
x = [t, fliplr(t)]; % t is a row vector
y = [lower, fliplr(upper)]; % lower and upper are row vectors
patch(x,y,'green')

More Answers (0)

Categories

Find more on Surfaces, Volumes, and Polygons in Help Center and File Exchange

Tags

Products


Release

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!