Why is it that if I try to fill a strange polygon it comes out of the edges?
1 view (last 30 days)
Show older comments
Hi, I have a somewhat strange polygon with overlaps and in this case I am experiencing problems, which in all other cases I don't, in filling it. Could you guys help me solve it?
x0 = [45;45;50;50;50;50;50;55;55;55;55;55;55;55;55;55;55;55;55;55;55;55;55;50;50;50;50;50;45;45];
y0 = [1.6;2.2;1.9;1.9;2.1;2.2;2.2;1.6;1.6;1.6;1.6;1.6;1.6;1.9;2.1;2.3;2.1;2;2;2;2;2;2;2.4;2.4;2.3;2.1;2.1;2.4;2];
plot(x0,yo)
fill(x0,y0,'r')
3 Comments
Accepted Answer
Star Strider
on 22 Nov 2022
x0 = [45;45;50;50;50;50;50;55;55;55;55;55;55;55;55;55;55;55;55;55;55;55;55;50;50;50;50;50;45;45];
y0 = [1.6;2.2;1.9;1.9;2.1;2.2;2.2;1.6;1.6;1.6;1.6;1.6;1.6;1.9;2.1;2.3;2.1;2;2;2;2;2;2;2.4;2.4;2.3;2.1;2.1;2.4;2];
ps = polyshape(x0,y0);
figure
plot(x0,y0)
hold on
plot(ps, 'FaceColor','r')
hold off
Experiment to get different results.
.
2 Comments
More Answers (0)
See Also
Categories
Find more on Elementary Polygons 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!