Mapping Toolbox | ![]() ![]() |
Angles, Times, and Distances - Units and Notation
Angular Notation
Angles can be represented as variables in the Mapping Toolbox in three ways: degrees, radians, and degrees-minutes-seconds. The toolbox provides functions for converting between these formats.
Degrees
This is the default angular unit notation for the toolbox. Although for most scientific applications, radians are more commonly used, in geographic usage, degrees are much more convenient.
Degree notation is simply decimal notation in terms of degrees. Forty-three and one-half degrees would be 43.5.
Radians
Radian notation is simply decimal notation in terms of radians. Two radians would be 2.0.
Degrees-Minutes-Seconds
Degrees-minutes-seconds, or dms, notation is a little more complicated. In text, a dms angle would be ddd° mm' ss''. For example, 142°15'27'' is 142 degrees, 15 minutes, and 27 seconds. There are 60 seconds in a minute and 60 minutes in a degree. In the Mapping Toolbox, when "dms" angles are represented by a single number, the format is dddmm.ss. For example, 142°15'27'' is 14215.27.
The real value of this notation is for the input of data already in this format. The toolbox includes the mat2dms
function for easily entering dms data.
A special case of the dms format is the dm format, in which seconds are not included.
If you have a three-column matrix in which the columns are degrees, minutes, and seconds, respectively, mat2dms
will convert it to dms format:
dmsmatrix = [45 13 46; 156 45 01; -7 34 12.1] dmsmatrix = 45.0000 13.0000 46.0000 156.0000 45.0000 1.0000 -7.0000 34.0000 12.1000 dmsformat = mat2dms(dmsmatrix) dmsformat = 1.0e+04 * 0.4513 1.5645 -0.0734
Converting Between Angle Unit Formats
The toolbox includes a variety of angle unit conversion functions. For example, to convert the dms format values to degrees or to radians, you can use dms2deg
and dms2rad
, respectively:
degformat = dms2deg(dmsformat) degformat = 45.2294 156.7503 -7.5700 radformat = dms2rad(dmsformat) radformat = 0.7894 2.7358 -0.1321
Similar functions include deg2rad
, rad2deg
, deg2dms
, etc. There is also a more general function, angledim
, which will convert from one format to another. For example, how many degrees are in radians?
Converting Formatted Angle Strings to Numbers
Many sources of geographic data consist of text with the angles in degrees-minutes-seconds format such as ddd° mm' ss''. These formatted angle strings may include the characters for degrees, minutes and seconds, as well as letters for north, south, east, and west or other special characters. These kinds of angle strings cannot be converted to numbers by using the MATLAB num2str
command. However, you can convert many of these string formats to numeric decimal degrees using the str2angle
command. The str2angle
command accepts string matrices or cell arrays of strings containing values formatted in a number of commonly used angle formats:
strs = {'123°30''00"S','123-30-00S','123d30m00sS','1233000S'} strs = '123°30'00"S' '123-30-00S' '123d30m00sS' '1233000S' str2angle(strs) ans = -123.5 -123.5 -123.5 -123.5 strs = strvcat(strs{:}) strs = 123°30'00"S 123-30-00S 123d30m00sS 1233000S » str2angle(strs) ans = -123.5 -123.5 -123.5 -123.5
![]() | Measuring the Planets | Time Notation | ![]() |