필터 지우기
필터 지우기

Filling in a polygon

조회 수: 6 (최근 30일)
YM
YM 2019년 3월 18일
편집: Stephan 2019년 3월 18일
x8=[0 5 1 2.5 5];
y8=[2 2 5 0 5];
figure(7)
plot(x8,y8)
fill(x8,y8,'Red')
I used the above in the hopes of having a (red) filled polygon. Instead, triangle sections in the corners are filled, but not the entire polygon. Any advice so as to fill the entire polygon?

답변 (1개)

Stephan
Stephan 2019년 3월 18일
편집: Stephan 2019년 3월 18일
Hi,
it depends on the order you enter the single points. See this:
x8=[0, 2, 2.5, 3.5, 5, 4, 5, 3, 1, 1.5];
y8=[2, 2, 0, 2, 2, 3, 5, 3.5, 5, 3];
figure(7)
plot(x8,y8)
fill(x8,y8,'Red')
It starts at the first point P1(0,2) and goes counter-clockwise through the figure. Everytime there is a change of direction, the corresponding coordinates are entered.
Result is:
Best regards
Stephan

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by