How do I shade the area between two curves on a plot that is generated by arrays?
4 views (last 30 days)
Show older comments
Rowan Quintero
on 2 Aug 2023
Commented: Rowan Quintero
on 2 Aug 2023
For example:
x1 = [ 1 2 3 ];
y1 = [2 5 8];
x2 = [1 2.5 3.5];
y2 = [1 6 3];
plot(x1, y1)
hold on
plot(x2, y2)
Thanks for the help!
0 Comments
Accepted Answer
Davide Masiello
on 2 Aug 2023
Edited: Davide Masiello
on 2 Aug 2023
x1 = [1 2 3];
y1 = [2 5 8];
x2 = [1 2.5 3.5];
y2 = [1 6 3];
hold on
patch([x1 flip(x2)], [y1 flip(y2)],'y','EdgeColor','none')
plot(x1, y1,'b')
plot(x2, y2,'r')
box on
axis padded
4 Comments
More Answers (0)
See Also
Categories
Find more on Scatter Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!