inpolygon command for multiple areas2 (not using mapping toolbox)
2 次查看(过去 30 天)
显示 更早的评论
Hi all,
In part of my code I am intrested in realizing whether a point = (x,y) is withing multiple areas or not. Here, each area is a polygon (simply a square) that have the coordination of its center locater which I can calcuate the corner points.
I learnt that by using "inpolygon" comman I can realize whether my point is withing that polygon(or on its edge). Hoever, I am interested to recognize what area whose the point is withing.
i.e. I have area1, area2 and area3.
I set following variables:
% definig all the areas coordination xv = [1 2 2 1 1 NaN 4 4 5 5 4 NaN 6 6 7 7 6]; yv = [0 0 3 3 0 NaN 1 2 2 1 1 NaN 4 5 5 4 4]; x = 1.5; y = 3; in = inpolygon(x,y,xv,yv); I can find that my point is within one of the three defined areas (Here is within the area1). But how can I say the point is within what area specifically?
I also tried this: http://www.mathworks.com/matlabcentral/fileexchange/7187-inpolygons but I do not have the "mpping toolbox" hence I can not use the inpolygons function.
I would appreciate if get some help in this,
Best
0 个评论
采纳的回答
Matt J
2012-12-4
If area1, area2, and area3 are each a polygon, then call inpolygon() on each one separately.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Elementary Polygons 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!