str2angle
Convert strings to angles in degrees
Syntax
Description
Examples
Convert String Arrays to Degrees
Create a string array containing these latitudes and longitudes. Specify each angle using a different format.
23 degrees, 30 minutes, 0 seconds north of the equator
23 degrees, 30 minutes, 0 seconds south of the equator
123 degrees, 30 minutes, 0 seconds east of the prime meridian
123 degrees, 30 minutes, 0 seconds west of the prime meridian
str = ["23°30'00""N" "23-30-00S" "123d30m00sE" "1233000W"];
Convert the string array to a numeric array in degrees.
angle = str2angle(str)
angle = 4×1
23.5000
-23.5000
123.5000
-123.5000
Input Arguments
str
— Text that represents latitude or longitude angles
character vector | string scalar | cell array of character vectors | string array
Text that represents latitude or longitude angles, specified as a character vector, a string scalar, a cell array of character vectors, or a string array.
Specify angles in degrees-minutes-seconds using one of the formats in this table.
Specify positive latitudes using N
, negative latitudes using
S
, positive longitudes using E
, and negative
longitudes using W
.
Format | Example |
---|---|
Use ° for degrees, ' for minutes, and
" for seconds. | "123°30'00""W" |
Use d for degrees, m for minutes, and
s for seconds. | "123d30m00sW" |
Use - to separate degrees, minutes, and seconds. | "123-30-00W" |
Omit symbols that separate degrees, minutes, and seconds (packed DMS). This format does not support fractional seconds. | "1233000W" |
When str
contains more than one angle, you can use more than
one angle format.
Specifying directions by using positive (+
) or negative
(-
) signs is not supported.
Data Types: char
| string
| cell
Output Arguments
angle
— Angles in degrees
numeric scalar | numeric column vector
Angles in degrees, returned as a numeric scalar or numeric column vector. If
str
is a character vector or string scalar, then
angle
is a numeric scalar. If str
is a cell
array of character arrays or a string array, then angle
is a
numeric column vector with the same number of elements as
str
.
Data Types: double
Version History
Introduced before R2006a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)