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.
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.
Amériques
- 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)