Documentation Center

  • Trial Software
  • Product Updates


Convert strings to angles in degrees


angles = str2angle(strings)


angles = str2angle(strings) converts strings containing latitudes and/or longitudes, expressed in one of four different formats of degree-minutes-seconds, to numeric angles in units of degrees.

Format DescriptionExample
Degree Symbol, Single/Double Quotes'123°30''00"W'
'd', 'm', 's' Separators'123d30m00sW'
Minus Signs as Separators'123-30-00W'
"Packed DMS"'1233000W'

Input must conform closely to the examples provided; in particular, the seconds field must be included, even if it is not significant. Except in Packed DMS format, the seconds field can contain a fractional component. Sign characters are not supported; terminate each string with 'N' for positive latitude, 'S' for negative latitude, 'E' for positive longitude, or 'W' for negative longitude. strings is string or a cell array of strings. For backward compatibility, strings can also be a character matrix. If more than one angle is represented, strings can either contain homogeneous or heterogeneous formatting (see example). angles is a column vector of class double.


strs = {'23°30''00"N', '23-30-00S', '123d30m00sE', '1233000W'}

strs = 
    '23°30'00"N'    '23-30-00S'    '123d30m00sE'    '1233000W'


ans =

See Also

Was this topic helpful?