Function File: [dist, az] = distance(pt1, pt2)
Function File: [dist, az] = distance(pt1, pt2,units)
Function File: [dist, az] = distance(lat1, lon1, lat2, lon2)
Function File: [dist, az] = distance(lat1, lon1, lat2, lon2, units)

Calculates the great circle distance dist between pt1 and pt2 and optionally the azimuth az.

pt1 and pt2 are two-column matrices of the form [latitude longitude]. The coordinates can also be given by the parameters lat1, lon1, lat2 and lon2. Units can be either "degrees" (the default) or "radians", just the first character(s) will do.

>> distance ([37, -76], [37, -9])
ans = 52.309
>> distance ([37, -76], [67, -76])
ans = 30.000
>> distance (0, 0, 0, pi, "radians")
ans = 3.1416

See also: azimuth, elevation, geodeticarc.

Package: mapping