str = angl2str(angles)
converts numeric angles in degrees to a character array that represents the angles. This
function is useful for displaying angles as text on maps.
str = angl2str(angles,signcode,format)
returns a character array that formats the angles as degrees, degrees-minutes,
degrees-minutes-seconds, or radians. The function does not convert degrees to radians or
vice-versa.
Angles in degrees or radians, specified as a numeric array.
signcode — Signs or directions to use in character array "none" (default) | "ew" | "ns" | "pm"
Signs or directions to use in the character array, specified as one of these options:
"ew" — Input angles are longitudes. The character array
indicates positive longitudes using E and negative longitudes
using W.
"ns" — Input angles are latitudes. The character array
indicates positive latitudes using N and negative latitudes
using S.
"pm" — The character array indicates positive angles using
a plus sign (+) and negative angles using a minus sign
(-).
"none" — The character array indicates negative angles
using a minus sign (-) and does not use a plus sign
(+) for positive angles.
Data Types: char | string
format — Format to use in character array "degrees" (default) | "degrees2dm" | "degrees2dms" | "radians"
Format to use in the character array, specified as one of these
options.
Option
Format
Example
"degrees"
Degrees
angl2str(31.26,"none","degrees")
ans =
' 31.26^{\circ} '
"degrees2dm"
Degrees-minutes (DM)
angl2str(31.26,"none","degrees2dm")
ans =
' 31^{\circ} 15.60' '
"degrees2dms"
Degrees-minutes-seconds (DMS)
angl2str(31.26,"none","degrees2dms")
ans =
' 31^{\circ} 15' 36.00" '
"radians"
Radians
angl2str(pi/6,"none","radians",-5)
ans =
' 0.52360 R '
The value ^{\circ} is the LaTeX representation of
°.
Data Types: char | string
n — Number of digits to include in character array -2 (default) | scalar integer
Number of digits to include in the character array, specified as an integer. When
you specify n, the angl2str function rounds
angles to the nearest multiple of
10n.
The sign convention for this argument is opposite to the one used by the round function.
Example: angl2str(31.467,"none","degrees",-2) returns '
31.47^{\circ} ', which is 31.467 rounded to the nearest
hundredth.
Example: angl2str(31.467,"none","degrees",0) returns '
31^{\circ} ', which is 31.467 rounded to the nearest
integer.
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.