Main Content

distance

Distance between sites

Description

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

example

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

d = distance(___,Name,Value) returns the distance with additional options specified by name-value pairs.

Examples

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)
dme = 2.1504e+04
dkm = dme / 1000
dkm = 21.5037

Get the great circle distance between the two sites.

dmg = distance(tx,rx,'greatcircle')
dmg = 2.1451e+04

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.

  • 'greatcircle': 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 a spherical Earth model.

Data Types: char

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'Map','siteviewer1'

Map for visualization or surface data, specified as the comma-separated pair consisting of 'Map and one of the following depending on the coordinate system:

Coordinate SystemValid map valuesDefault map value
'geographic'
  • siteviewer[a]

  • A terrain name may be specified if the function is called with an output argument. Valid terrain names are 'none', 'gmted2010', or the name of the custom terrain data added using addCustomTerrain

  • current siteviewer or new siteviewer if none are open.

  • 'gmted2010' if called with an output.

'cartesian''none', triangulation object or name of an STL file.'none'

[a] Alignment of boundaries and region labels are a presentation of the feature provided by the data vendors and do not imply endorsement by MathWorks®.

Data Types: char | string

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