This functions finds distance (in km) between two points on Earth using latitude-longitude coordinates of the two points. Distance is calculated using two distance funstions: Haversine and Pythagoran. The first output is based on Haversine function, which is more accurate especially for longer distances.
latlon1: latlon of origin point [lat lon]
latlon2: latlon of destination point [lat lon]
d1km: distance calculated by Haversine formula
d2km: distance calculated based on Pythagoran theorem
--Example 1, short distance:
%d1km approximately equal to d2km
--Example 2, longer distance:
d1km is significantly different from d2km (d2km is not able to work for longer distances).
M Sohrabinia (2022). LatLon distance (https://www.mathworks.com/matlabcentral/fileexchange/38812-latlon-distance), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!