How to extract area using inpolygon

3 ビュー (過去 30 日間)
IMC
IMC 2021 年 6 月 23 日
編集済み: IMC 2021 年 6 月 24 日
Hello everyone,
I need to do analysis on just rectangular part of my figure. Therefore, I tried to extract that area using inpolygon. My data is lat = 406x270 and lon = 406x270. I have plotted temperature which is 2030x1354.
Using the code below:
xv= [104.61, 102.98, 109.37, 109.52];
yv = [19.93, 25.03, 25.01, 19.98];
in = inpolygon(lon,lat,xv,yv);
figure
plot(xv,yv) % polygon
axis equal
hold on
plot(lon(in),lat(in),'r+') % points inside
plot(lon(~in),lat(~in),'bo') % points outside
hold off
I just can't figure out what is wrong in my code. Kindly tell me what's wrong here? Thank you.

採用された回答

KSSV
KSSV 2021 年 6 月 23 日
Check your polygon coordinates. They are not up to the mark as shown in the first figure.
xv= [104.61, 102.98, 109.37, 109.52];
yv = [19.93, 25.03, 25.01, 19.98];
patch(xv,yv,'r')
  2 件のコメント
IMC
IMC 2021 年 6 月 23 日
Thank you for your reply.
But I have one question here about this statement 'Check your polygon coordinates' . Does this mean I have not selected the coordinates correctly?
KSSV
KSSV 2021 年 6 月 24 日
Yes.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by