필터 지우기
필터 지우기

filling between two curve by patch

조회 수: 28 (최근 30일)
Effat Behboudi
Effat Behboudi 2021년 12월 11일
댓글: Voss 2021년 12월 11일
Hi every one,
I'm trying to use the patch function to fill the gap between two curves with differing X values. However, it seems the function connects first and last values (please see attached image) . also, it doesn't change the color of each curve (to green and black indicated in the code ) when using patch function. could you please to help me with solving this ? (I'm using Matlab 2020b)
Thanks in advance
figure; hold on;
plot(X1,Y, 'g');
plot(X2,Y, 'K');
patch([X1; X2], [Y ;Y], 'B');
axis ij
hold off

채택된 답변

Voss
Voss 2021년 12월 11일
Change your patch command to this:
patch([X1; X2(end:-1:1)], [Y ;Y(end:-1:1)], 'B', 'EdgeColor', 'none');
Reversing the X2 and second Y makes the second half of the patch vertices start at the end and go up for the second curve, rather than starting at the top and going down. Setting the EdgeColor to 'none' will not draw black edges for the patch, allowing the curves beneath the patch to be seen.
  댓글 수: 2
Effat Behboudi
Effat Behboudi 2021년 12월 11일
This works perfectly! thank you so much for your explanation
Voss
Voss 2021년 12월 11일
You're welcome! Glad it's working

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Polygons에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by