Products & Services Solutions Academia Support User Community Company

Learn more about Mapping Toolbox   

str2angle - Convert strings to angles in degrees

Syntax

angles = str2angle(strings)

Description

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.

Example

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

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

str2angle(strs)

ans =
         23.5
        -23.5
        123.5
       -123.5

strs = strvcat(strs{:})

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

str2angle(strs)

ans =
         23.5
        -23.5
        123.5
       -123.5

See Also

angl2str

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS