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)
Show older comments
MathWorks Support Team
on 27 Jun 2009
Edited: MathWorks Support Team
on 18 Jul 2016
I want to fill the area or create a patch object between two lines in a plot in MATLAB.
Accepted Answer
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');
0 Comments
More Answers (0)
See Also
Categories
Find more on Polygons in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!