str = dist2str(dist)
converts numeric distances in kilometers to a character array that represents the distances.
This function is useful for displaying distances as text on maps.
str = dist2str(dist,format)
specifies whether to add a plus sign (+) as a prefix to positive
distances. To add a plus sign (+) as a prefix, specify
format as "pm". The default for
format is "none", which does not add a plus sign
(+).
str = dist2str(dist,format,n)
specifies the number of decimal places to use in the character array. This syntax assumes
the distances are in kilometers.
str = dist2str(dist,format,unit,n)
specifies the unit and the number of decimal places to use in the character array.
Plus sign for positive distances, specified as one of these options:
"pm" — Add a plus sign (+) as a prefix
to positive distances.
"none" — Do not add a plus sign (+) as a
prefix to positive distances.
Data Types: char | string
Unit text to include in the character array, specified as one of these
options.
Option
Unit Text
"kilometers" or
"km"
km
"feet" or "ft"
ft
"meters" or
"m"
m
"nauticalmiles" or
"nm"
nm
"statutemiles", "miles", or
"mi"
mi
Note that other Mapping Toolbox™ functions use mi to indicate international
miles rather than statute miles.
"degrees" or
"deg"
^{\circ}, which is the LaTeX representation of
°
"radians" or
"rad"
R
Data Types: char | string
Number of digits to include in the character array, specified as an integer. When
you specify n, the dist2str function rounds
dist to the nearest multiple of
10n.
The sign convention for this argument is opposite to the one used by the round function.
Example: dist2str(3132.467,"none",-2) returns '3132.47
km', which is 3132.467 rounded to the nearest
hundredth.
Example: dist2str(3132.467,"none",0) returns '3132
km', which is 3132.467 rounded to the nearest
integer.
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.