This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Courses and distances between navigational waypoints


[course,dist] = legs(lat,lon)
[course,dist] = legs(lat,lon,method)
[course,dist] = legs(pts,___)
mat = legs(___)


[course,dist] = legs(lat,lon) returns the azimuths (course) and distances (dist) between navigational waypoints, which are specified by the column vectors lat and lon.

[course,dist] = legs(lat,lon,method) specifies the logic for the leg characteristics. If the method is 'rh' (the default), course and dist are calculated in a rhumb line sense. If method is 'gc', great circle calculations are used.

[course,dist] = legs(pts,___) specifies waypoints in a single two-column matrix, pts.

mat = legs(___) packs up the outputs into a single two-column matrix, mat.

This is a navigation function. All angles are in degrees, and all distances are in nautical miles. Track legs are the courses and distances traveled between navigational waypoints.


Imagine an airplane taking off from Logan International Airport in Boston (42.3ºN,71ºW) and traveling to LAX in Los Angeles (34ºN,118ºW). The pilot wants to file a flight plan that takes the plane over O'Hare Airport in Chicago (42ºN,88ºW) for a navigational update, while maintaining a constant heading on each of the two legs of the trip.

What are those headings and how long are the legs?

lat = [42.3; 42; 34]; 
long = [-71; -88; -118];
[course,dist] = legs(lat,long,'rh')
course =
dist =
  1.0e+003 *

Upon takeoff, the plane should proceed on a heading of about 269º for 756 nautical miles, then alter course to 251º for another 1495 miles.

How much farther is it traveling by not following a great circle path between waypoints? Using rhumb lines, it is traveling

totalrh = sum(dist)

totalrh =

For a great circle route,

[coursegc,distgc] = legs(lat,long,'gc'); totalgc = sum(distgc)

totalgc =

The great circle path is less than one-half of one percent shorter.

See Also

| | |

Was this topic helpful?