str2angle
Convert strings to angles in degrees
Syntax
Description
Examples
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
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
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.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.
América
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- 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)