num2ruler
Convert numeric data for use with specific ruler
Description
Examples
Convert Numeric Value to Equivalent Date Value
Convert the output of ginput
from
a numeric value to the equivalent date value.
Create a plot with dates along the x-axis.
Then, click a point in the axes and use the ginput
function
to return the location of the selected point.
t = datetime(2015,1,1:10); y = rand(10,1); plot(t,y) ax = gca; [x,y] = ginput(1)
x = 5.8168 y = 0.6458
The ginput
function returns the location as numeric values. Use
num2ruler
to determine the date value that is
equivalent to the numeric value returned for
x
.
xdate = num2ruler(x,ax.XAxis)
xdate = 06-Jan-2015 19:36:13
Input Arguments
num
— Numeric data
array
Numeric data, specified as an array.
Example: num = [1 2 3]
ruler
— Ruler that determines data mapping
DurationRuler
object | DatetimeRuler
object | NumericRuler
object | CategoricalRuler
object | GeographicRuler
object
Ruler that determines data mapping, specified as one of these types of ruler objects:
DurationRuler
object — Convert the values innum
to duration values.DatetimeRuler
object — Convert the values innum
to datetime values. To control how numeric values are converted todatetime
values, set theReferenceDate
property of the ruler to a datetime value with the desired time zone.NumericRuler
object — No conversion. The output is equal to the input.CategoricalRuler
object — Convert the values innum
to categorical values. To control the order of the categories, set theCategories
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:
ax = gca; data = num2ruler(num,ax.XAxis)
Version History
Introduced in R2016b
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.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- 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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)