This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.


Convert text to angles in degrees


angles = str2angle(strings)


angles = str2angle(strings) converts character vectors containing latitudes 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. Instead, terminate each value with 'N' for positive latitude, 'S' for negative latitude, 'E' for positive longitude, or 'W' for negative longitude. strings is character vector or a cell array of character vectors. 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

Introduced before R2006a

Was this topic helpful?