How can I fill the area or create a patch object between two lines in a plot in MATLAB R2016a?

2 views (last 30 days)

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 2 Jan 2018
Assuming you have a set of data in the 1-by-n vectors "x1" and "y1", and another set of data in the 1-by-m vectors "x2" and "y2", the following code will fill the area between the plots generated by the two sets of data.
 
X = [x1 fliplr(x2)];
Y = [y1 fliplr(y2)];
fill(X,Y,'r');

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!