I'm trying to do a nearest neighbor search that yields a single point as the single "nearest neighbor" to another point in matlab.
I've got the following data:
- A longitude grid that is size 336x264 "lon"
- some random point within the bounds of the longitude grid "dxf"
I've tried using MATLAB's "knnsearch" function
https://www.mathworks.com/help/stats/knnsearch.html
But sadly when I use the command:
idx = knnsearch(lon, dxf)
I am met with the error:
"Y must be a matrix with 264 columns."
Is there an alternative nearest neighbor search I can use to find the nearest neighbor to a single point within MATLAB? Is there a simpler solution I can implement?
I literally just want to find the closest point within the "lon" matrix to point "dxf".
Thanks! Taylor
dxf
? – beaker