Angle Representations and Angular Units
This topic describes the angular units that Mapping Toolbox™ functions use, how to convert between common angle representations, and how to format latitude and longitude angles as text.
Use angles in mapping applications to indicate absolute positions, relative positions along reference ellipsoids, and relative positions in 3-D:
Absolute positions are latitudes and longitudes.
Relative positions on reference ellipsoids are azimuths along geodesics, great circles, and rhumb lines. Find these relative positions by using the
distance
function.Relative positions in 3-D are both azimuths and elevations. Find these relative positions by using the
geodetic2aer
function.
Degrees and Radians
The most common angular units are degrees and radians. Many Mapping Toolbox functions perform angle computations in degrees. If your data is in radians,
you can convert to degrees by using the rad2deg
function.
Many Mapping Toolbox functions, such as distance
and
azimuth
, use degrees by default and allow you to choose radians. Some
functions, such as unwrapMultipart
and
meridianarc
, use radians by default or require you to work in
radians.
Degree Representations
Angles are commonly represented using degrees (–35.2625°), degrees-minutes (–35° 15.75'), and degrees-minutes-seconds (–35° 15' 45"). Minutes are 1/60 of a degree and seconds are 1/60 of a minute.
Because Mapping Toolbox functions perform angle computations using only degrees, if your data has
values in degrees-minutes (DM) or degrees-minutes-seconds (DMS), you must convert the values
to degrees before using them as input. Convert numeric values from DM or DMS to degrees by
using the dm2degrees
or dms2degrees
function. You can also convert text values from DM or DMS to
degrees by using the str2angle
function.
If you want to publish coordinate values or format data for use with other applications,
then you can convert degrees to DM or DMS. Convert degrees to DM or DMS by using the
degrees2dm
or degrees2dms
function.
Degrees
Degrees represent angles using a sign or direction and a nonnegative decimal number. For example, you can represent a longitude of 35.2625 degrees west of the prime meridian as –35.2625° or 35.2625° W.
Note
Decimal degrees is a common way to refer to noninteger latitude and longitude values. The term is appropriate for angles formatted in text using decimal notation, such as when printed in a document or displayed at the MATLAB® command line. However, the term is inaccurate for angles in degrees that are stored in computer memory, such as in MATLAB variables. Angles are stored in memory as single or double precision floating-point numbers, which are binary representations, not decimal representations. Therefore, the term degrees is more accurate than decimal degrees for angles stored in memory, even when the angles have noninteger values.
Degrees-Minutes
Degrees-minutes represent angles using a sign or direction and two numbers:
Degrees (°) — A signed or unsigned integer
Minutes (') — A nonnegative decimal number in the range [0 60)
For example, a longitude of –35.2625 in degrees is –35° 15.75' or 35° 15.75' W in DM.
This code shows how to convert numbers in DM to degrees by using the
dm2degrees
function.
dm2degrees([-35 15.75])
ans = -35.2625
Degrees-Minutes-Seconds
Degrees-minutes-seconds represent angles using a sign or direction and three numbers:
Degrees (°) — A signed or unsigned integer
Minutes (') — A nonnegative integer in the range [0 59]
Seconds (") — A nonnegative decimal number in the range [0 60)
For example, a longitude of –35.2625 in degrees is –35° 15' 45" or 35° 15' 45" W in
DMS. This code shows how to convert numbers in DMS to degrees by using the
dms2degrees
function.
dms2degrees([-35 15 45])
ans = -35.2625
Latitude and Longitude Formats
You can format latitudes and longitudes by using letters or symbols:
Degrees — d or °
Minutes — m or '
Seconds — s or "
You can also indicate the sign of the angle by using letters:
Positive latitude — N
Negative latitude — S
Positive longitude — E
Negative longitude — W
For example, you can format 35 degrees, 15 minutes, 45 seconds west of the prime meridian as 35d15m45sW, 35° 15' 45" W, or –35° 15' 45".
Convert latitudes and longitudes in degrees to character arrays in DM or DMS for use
with LaTeX by using the angl2str
function. This code shows how to
convert a longitude of -36.2625
degrees to a character array that uses
DMS.
angl2str(-35.2625,"ew","degrees2dms")
ans = ' 35^{\circ} 15' 45.00" W '
If you want to format angles in ways that the angl2str
function
does not support, first convert the angle from decimal degrees to numbers in DM or DMS by
using the degrees2dms
or degrees2dm
function. Then, format the numbers into a string or character
vector by using the sprintf
function.
This code shows how to convert the same longitude to a character array that uses Unicode® instead of LaTeX.
dm = degrees2dms(-35.2625);
sprintf('%d\x00B0 %u\x0027 %.2f\x0022 W',dm)
ans = '-35° 15' 45.00" W'