distance
Distance between points on sphere or ellipsoid
Syntax
Description
[
calculates the arc length arclen
,az
] = distance(lat1
,lon1
,lat2
,lon2
)arclen
and azimuth
az
of the great circle arc from the starting point with
coordinates lat1
and lon1
to the
ending point with coordinates lat2
and
lon2
. The function uses the shorter (minor) great
circle arc. This syntax references the coordinates to a sphere and returns
arclen
and az
as spherical
distances in degrees.
Examples
Input Arguments
Output Arguments
Tips
You can convert spherical distances to linear distances by using conversion functions
such as deg2km
and deg2nm
.
Algorithms
The accuracy of geodesic azimuth calculations decreases as the distance between the points increases. Additionally, the calculations can break down when the points are nearly antipodal or close to the equator.
When you specify a reference ellipsoid and two points that are both close to the
equator and nearly antipodal, the distance
function issues a
warning and returns both arclen
and az
as values
of NaN
.
Version History
Introduced before R2006a