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.
Seleziona un sito web
Seleziona un sito web per visualizzare contenuto tradotto dove disponibile e vedere eventi e offerte locali. In base alla tua area geografica, ti consigliamo di selezionare: .
Puoi anche selezionare un sito web dal seguente elenco:
Come ottenere le migliori prestazioni del sito
Per ottenere le migliori prestazioni del sito, seleziona il sito cinese (in cinese o in inglese). I siti MathWorks per gli altri paesi non sono ottimizzati per essere visitati dalla tua area geografica.