Main Content

dm2degrees

Convert degrees-minutes to degrees

Description

angleInDegrees = dm2degrees(DM) converts angles from degrees-minutes representation to values in degrees which may include a fractional part (sometimes called “decimal degrees”).

example

Examples

collapse all

dm = [ ...
      30  44.78012; ...
     -82  39.90825; ...
       0 -17.12345; ...
       0  14.82000];
format long g
angleInDegrees = dm2degrees(dm)
angleInDegrees = 4×1

          30.7463353333333
               -82.6651375
        -0.285390833333333
                     0.247

Input Arguments

collapse all

Angle in degrees-minutes representation, specified as an n-by-2 real-valued matrix. Each row specifies one angle, with the format [D M]:

  • D contains the “degrees” element and must be integer-valued.

  • M contains the “minutes” element and may have a fractional part. The absolute value of M must be less than 60.

For an angle that is positive (north latitude or east longitude) or equal to zero, all elements in the row must be nonnegative. For a negative angle (south latitude or west longitude), the first nonzero element in the row must be negative and the remaining value, if any, is nonnegative.

Output Arguments

collapse all

Angle in degrees, returned as an n-element column vector. The kth element corresponds to the kth row of DM.

Algorithms

For an input row with value [D M], with integer-valued D and real M, the output value will be

SGN * (abs(D) + abs(M)/60)
where SGN is 1 if D and M are both nonnegative and -1 if the first nonzero element of [D M] is negative. An error results if a nonzero D is followed by a negative M.

Version History

Introduced in R2007a