How to shade the area between two curves? [duplicate]
How to shade the area between two curves? [duplicate]
This question already has an answer here:
I tried the following code to shade the area between two curves.
x=1:1:216;
y1=upper
y2=lower
% plot the line edges
hold on
plot(x', y1, 'LineWidth', 1);
plot(x', y2, 'LineWidth', 1);
% plot the shaded area
fill([x' fliplr(x')], [y2 fliplr(y1)], 'r');
But it doesn't work, I get the following output:
Do you have any suggestions as to what may have gone wrong?
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
fill
I think I just addressed your problem in an answer on a duplicate question: you are using column vectors in the call to
fill
.– gnovice
Sep 12 '18 at 16:11