MATLAB: Compare two excel sheets that contain coordinates (latitudes&Longitudes)

excel sheetslatitudes-longitudesminimun distanceoutput

I have two excel sheets, the first one has two columns (Latitudes & Longitudes) and the second one has four columns (Location_ID, Location_NAME, Latitudes, Longitudes), the two sheets have different row numbers.
I want to compare the two sheets and find the nearest 10 locations in sheet two with Location_ID&Location_NAME to each row in sheets one with distance in meter and the heading (bearing) Then put the result in table one, by attach each row in the first sheet with nearest 10 (locations(ID&NAMES)) from sheet two with Distances & headings(bearing)).
For example, row one sheet one should have in the first two columns compared (Latitude&Longitude), then in the subsequent four columns the location (ID, Name, Distance, Heading) of the first nearest location, and after that the second nearest location with the same details………………….the tenth nearest location
So, I should compare each row in sheet one with all the rows in sheet two by calculating the distance then find the nearest (Minimum distance) 10 locations with headings

Best Answer

    1. Read excel files into MATLAB using xlaread, readtable.
    2. You can get the nearest points and distance using knnsearch. Read about that.
    3. You can write the data into excel file using xlswrite, writetable.