num = ruler2num(data,ruler)
converts the values in data to numeric values. The
ruler input indicates the ruler associated with
data, which determines how to map the values to the
corresponding numeric values. The output num is the same size as
the input data.
Convert a date value to the equivalent numeric value in order to set the Position property of a text object.
Create a plot with dates along the x-axis. Add a text description to the fourth data point and return the text object.
t = datetime(2015,1,1:10);
y = [.2 .3 .5 .2 .8 .2 .3 .1 .3 .4];
plot(t,y,'-o')
txt = text(t(4),y(4),'My text');
Change the position of the text to the sixth data point by setting the Position property of the text object. Since the Position property accepts only numeric values, convert the datetime value at the sixth data point to the equivalent numeric value.
Input array, specified as a scalar, vector, or matrix. If
data is already numeric, then the output
num is equal to the input
data.
Ruler associated with the input data, specified as one of these types of
ruler objects:
DurationRuler object — Convert the
duration values in data to numeric
values.
DatetimeRuler object — Convert the
datetime values in data to numeric values. To
control how datetime values are converted to
double values, set the ReferenceDate property of the ruler to a
datetime value with the desired time zone.
NumericRuler object — No conversion
in most cases. However, if the input data is not numeric, then
the output is num =
full(double(data)).
CategoricalRuler object — Convert
the categorical values in data to numeric
values. To control the order of the categories, set the
Categories property of the ruler.
GeographicRuler object — No
conversion. The output is equal to the input.
Specify the ruler object as the XAxis,
YAxis, or ZAxis property of
the Axes object. For example:
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.