MATLAB: Identify polygons enclosing a point in a shapefile

polygonshapefile

I have a shapefile containing many polygons that I read in Matlab. Now, I would like to identify which of the polygons in the shapefile interestc/enclose specific points. I have the x and y coordinates of the points. I'm trying to do something like the 'select by location' feature in arcmap.

Best Answer

To get the locations/ points lying inside the polygon use inpolygon.
To get the nearest points close to a given point use knnsearch.