Filter löschen
Filter löschen

Cellfun couple inpolygon?

1 Ansicht (letzte 30 Tage)
Xh Du
Xh Du am 2 Mär. 2017
Kommentiert: Xh Du am 3 Mär. 2017
Hi all,
I have a cell denoting 4 grid blocks like this:
parameter{:}
ans =
1.5000 1.5000
1.7500 1.5000
1.7500 1.7500
1.5000 1.7500
ans =
1.5000 1.7500
1.7500 1.7500
1.7500 2.0000
1.5000 2.0000
ans =
1.7500 1.5000
2.0000 1.5000
2.0000 1.7500
1.7500 1.7500
ans =
1.7500 1.7500
2.0000 1.7500
2.0000 2.0000
1.7500 2.0000
My question is, if now I have a x-y coordinate, say x = 1.63, y = 1.05, how can I loop through these 4 cells to determine whether x-y is in polygon or not? I think this can be solved by apply inpolygon using cellfun for all cell elements, but I'm not too sure about how to do it.
Many thanks!

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 2 Mär. 2017
query_x = 1.63;
query_y = 1.05;
does_it_match = cellfun(@(poly) inpolygon(query_x, query_y, poly(:,1), poly(:,2)), parameter)
  1 Kommentar
Xh Du
Xh Du am 3 Mär. 2017
Many thanks! This is really helpful!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by