Convert degrees-minutes-seconds to degrees
angleInDegrees = dms2degrees(DMS)
angleInDegrees = dms2degrees(DMS) converts angles from degree-minutes-seconds representation to values in degrees which may include a fractional part (sometimes called "decimal degrees"). DMS should be N-by-3 and real-valued, with one row per angle. The output will be an N-by-1 column vector whose kth element corresponds to the kth row of DMS. The first column of DMS contains the "degrees" element and should be integer-valued. The second column contains the "minutes" element and should be integer-valued. The third column contains the "seconds" element and may have a fractional part. For an angle that is positive (north latitude or east longitude) or equal to zero, all elements in the row need to be nonnegative. For a negative angle (south latitude or west longitude), the first nonzero element in the row should be negative and the remaining values should be positive. Thus, for an input row with value [D M S], with integer-valued D and M, and real D, M, and S, the output value will be
SGN * (abs(D) + abs(M)/60 + abs(S)/3600)
where SGN is 1 if D, M, and S are all nonnegative and -1 if the first nonzero element of [D M S] is negative (an error results if a nonzero element is followed by a negative element). Any fractional parts in the first (degrees) and second (minutes) columns of DMS are ignored. An error results unless the absolute values of all elements in the second (minutes) and third (seconds) columns are less than 60.
dms = [ ... 30 50 44.78012; ... -82 2 39.90825; ... 0 -30 17.12345; ... 0 0 14.82000]; format long g angleInDegrees = dms2degrees(dms) angleInDegrees = 30.8457722555556 -82.0444189583333 -0.504756513888889 0.00411666666666667