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.
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.