This is machine translation

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

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


Distance between sites


d = distance(site1,site2)
d = distance(site1,site2,path)


d = distance(site1,site2) returns the distance in meters between site1 and site2.


d = distance(site1,site2,path) returns the distance using a specified path type, either Euclidean or geodesic.


collapse all

Create transmitter and receiver sites.

tx = txsite('Name','MathWorks','Latitude',42.3001,'Longitude',-71.3504);
rx = rxsite('Name','Fenway Park','Latitude',42.3467,'Longitude',-71.0972);

Get the Euclidean distance in km between the sites.

dme = distance(tx,rx)
dkm = dme / 1000
dme =


dkm =


Get the geodesic distance between the two sites.

dmg = distance(tx,rx,'geodesic')
dmg =


Input Arguments

collapse all

Transmitter or receiver site, specified as a txsite or rxsite. You can use array inputs to specify multiple sites.

Measurement path type, specified as one of the following:

  • 'euclidean': Uses the shortest path through space that connects the antenna center positions of the site 1 and site 2.

  • 'geodesic': Uses the shortest path on the surface of the earth that connects the latitude and longitude locations of site 1 and site 2. This path uses Earth ellipsoid model WGS-84.

Data Types: char

Output Arguments

collapse all

Distance between sites, returned as M-by-N arrays in degrees. M is the number of sites in site 2 and N is the number of sites in site 1.

See Also

Introduced in R2017b

Was this topic helpful?