Format angle strings


str = angl2str(angle)
str = angl2str(angle,signcode)
str = angl2str(angle,signcode,units)
str = angl2str(angle,signcode,units,n)


str = angl2str(angle) converts a numerical vector of angles in degrees to a string matrix.

str = angl2str(angle,signcode) uses the string signcode to specify the method for indicating that a given angle is positive or negative. signcode may be one of the following:

'ew'east/west notation; trailing 'e' (positive longitudes) or 'w' (negative longitudes)
'ns'north/south notation; trailing 'n' (positive latitudes) or 's' (negative latitudes)
'pm'plus/minus notation; leading '+' (positive angles) or '-' (negative angles)
'none'blank/minus notation; leading '-' for negative angles or sign omitted for positive angles (the default value)

str = angl2str(angle,signcode,units) uses the string units to indicate both the units in which angle is provided and to control the output format. units can be 'degrees' (the default value), 'radians', 'degrees2dm', or 'degrees2dms'. units may be abbreviated and is case-insensitive. The interpretations of units are as follows:

UnitsUnits of AngleOutput Format
'degrees'degreesdecimal degrees
'degrees2dm'degreesdegrees + decimal minutes
'degrees2dms'degreesdegrees + minutes + decimal seconds
'radians'radiansdecimal radians

str = angl2str(angle,signcode,units,n) uses the integer n to control the number of significant digits provided in the output. n is the power of 10 representing the last place of significance in the number of degrees, minutes, seconds, or radians -- for units of 'degrees', 'degrees2dm', 'degrees2dms', and 'radians', respectively. For example, if n = -2 (the default), angl2str rounds to the nearest hundredth. If n = -0, angl2str rounds to the nearest integer. And if n = 1, angl2str rounds to the tens place, although positive values of n are of little practical use. In all cases, the interpretation of the parameter n is consistent between angl2str and roundn.


Create a string matrix to represent a series of values in DMS units, using the north-south format:

a = -3:1.5:3;
str = angl2str(a,'ns','degrees2dms',-3)

str =
 3^{\circ} 00' 00.000" S 
 1^{\circ} 30' 00.000" S 
 0^{\circ} 00' 00.000"   
 1^{\circ} 30' 00.000" N 
 3^{\circ} 00' 00.000" N 

These LaTeX strings are displayed (using either text or textm) as

3º 00' 00.000" S
1º 30' 00.000" S
0º 00' 00.000"  
1º 30' 00.000" N
3º 00' 00.000" N

More About

collapse all


The purpose of this function is to make angular-valued variables into strings suitable for map display. In general, the interpretation of the parameter n by angl2str is consistent with that of roundn.

See Also


Was this topic helpful?