How can I use the inpolygon function for 3 dimensions?

I have plotted the chlorophyll monthly climatology of a specific region of a world map. I want to place a polygon on a specific region and plot time series for just that region. The chlorophyll data is in 3 dimensions of longitude, latitude, and dates (109x97x280). I'm confused on how to use the inpolygon function for 3 dimensions. I want to be able to make the polygon, determine which points are within that polygon, then average those points for each date to ultimately plot a time series. Any suggestions are helpful, thank you!

댓글 수: 2

DGM
DGM 2021년 6월 28일
편집: DGM 2021년 6월 28일
It sounds to me like your constraint region isn't a polygon, but a polygonal prism. To clarify, what is the time range? Is it a single specific time? Is it a range of times? Is it all time? It sounds like it's one of the latter two.
Yes, that's correct I believe. It's a range of times (spanning 23 years).

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

 채택된 답변

KSSV
KSSV 2021년 6월 28일
You need not to use a 3D inpolygon. You are supposed to use inpolygon only once. Get your closed polygon coordinates(xv,yv); let X, Y be your grid coordinates.
idx = inpolygon(X,Y,xv,yv) ;
You got the indices, the same indices can be used for all the time steps.

댓글 수: 5

I'm confused -- X and Y would be longitude and latitude, what would my closed polygon coordinates be? Where is the chlorophyll data in that syntax?
You said you want to to place a polygon on a specific region....so the region also should have lon and lats.
I'm getting this error:
Arrays have incompatible sizes for this operation.
Error in inpolygon (line 76)
mask = (x >= min(xv)) & (x <= max(xv)) & (y>=min(yv)) &
(y<=max(yv));
Share your data and show us your code.
Walter Roberson
Walter Roberson 2021년 6월 28일
편집: Walter Roberson 2021년 6월 28일
Your xv and yv are 2d but do not have the same number of columns.

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

추가 답변 (0개)

제품

릴리스

R2021a

질문:

2021년 6월 28일

편집:

2021년 6월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by