Main Content

deg2km

Convert spherical distance from degrees to kilometers

Description

km = deg2km(deg) converts distances from degrees to kilometers, as measured along a great circle on a sphere with a radius of 6371 km, the mean radius of the Earth.

example

km = deg2km(deg,radius) converts distances from degrees to kilometers, as measured along a great circle on a sphere having the specified radius.

km = deg2km(deg,sphere) converts distances from degrees to kilometers, as measured along a great circle on a sphere approximating an object in the Solar System.

example

Examples

collapse all

Find the circumference of the Earth in kilometers. By default, the deg2km function assumes your input is a measurement of the Earth, which is represented as a sphere with a radius of 6371 kilometers.

km = deg2km(360)
km = 
4.0030e+04

Find the circumference of Mars in kilometers.

km = deg2km(360,'mars')
km = 
2.1300e+04

Input Arguments

collapse all

Distance in degrees, specified as a numeric array.

Data Types: single | double

Radius of sphere in units of kilometers, specified as a numeric scalar.

Sphere approximating an object in the Solar System, specified as one of the following values: 'sun', 'moon', 'mercury', 'venus', 'earth', 'mars', 'jupiter', 'saturn', 'uranus', 'neptune', or 'pluto'. The value of sphere is case-insensitive.

Output Arguments

collapse all

Distance in kilometers, returned as a numeric array.

Data Types: single | double

Version History

Introduced in R2007a