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. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Lengths and Angles

Convert between different angle and length units and perform longitude wrapping; convert units of distances along the surface of the Earth

On a perfect sphere, the distance between points on the surface of the sphere can be represented by angles. For spherical models of the Earth, Moon, and other planetary bodies, Mapping Toolbox™ allows spherical distance conversion between common units of angles and length.


expand all

deg2radConvert angle from degrees to radians
rad2degConvert angle from radians to degrees
degrees2dm Convert degrees to degrees-minutes
degrees2dms Convert degrees to degrees-minutes-seconds
dm2degrees Convert degrees-minutes to degrees
dms2degrees Convert degrees-minutes-seconds to degrees
toDegrees Convert angles to degrees
toRadians Convert angles to radians
fromDegrees Convert angles from degrees
fromRadians Convert angles from radians
wrapTo180Wrap angle in degrees to [-180 180]
wrapTo360Wrap angle in degrees to [0 360]
wrapToPiWrap angle in radians to [−pi pi]
wrapTo2PiWrap angle in radians to [0 2*pi]
unwrapMultipartUnwrap vector of angles with NaN-delimited parts
km2nmConvert kilometers to nautical miles
km2smConvert kilometers to statute miles
nm2kmConvert nautical miles to kilometers
nm2smConvert nautical to statute miles
sm2kmConvert statute miles to kilometers
sm2nmConvert statute to nautical miles
deg2kmConvert spherical distance from degrees to kilometers
deg2nmConvert spherical distance from degrees to nautical miles
deg2smConvert spherical distance from degrees to statute miles
km2degConvert spherical distance from kilometers to degrees
km2radConvert spherical distance from kilometers to radians
nm2degConvert spherical distance from nautical miles to degrees
nm2radConvert spherical distance from nautical miles to radians
rad2kmConvert spherical distance from radians to kilometers
rad2nmConvert spherical distance from radians to nautical miles
rad2smConvert spherical distance from radians to statute miles
sm2degConvert spherical distance from statute miles to degrees
sm2radConvert spherical distance from statute miles to radians
str2angleConvert text to angles in degrees
map.geodesy.isDegree True if input matches 'degree' and false if 'radian'
validateLengthUnitValidate and standardize length unit
unitsratioUnit conversion factors



Angle Representations and Angular Units

You can represent angles as a single number in degrees or radians. You can also use alternative notation and units, such as a triplet of numbers with degree-minute-second angular units.

Angles as Binary and Formatted Numbers

Angles are traditionally formatted in decimal degrees for mapping applications.


Length and Distance Units

Linear measurements of arc lengths and distances on spheroids use the same units as on the plane, such as feet, meters, miles, and kilometers.

Compute Conversion Ratio Between Units of Length

This example shows how to create a conversion factor that facilitates conversion between units of length, such as inches to centimeters.

Spherical Distance

Distances on the Sphere

You can represent distances on the sphere using angles or linear arc lengths.

Relationship Between Points on Sphere

There are many ways to define the 2-D spatial relationship between two points on a perfect sphere, including azimuth, heading, spherical distance, linear distance, and range.

Convert from Linear Measurements to Spherical Measurements

This example shows how to convert distances along the surface of the Earth from linear units to angular units.