num2ruler
转换数值数据以用于特定标尺
说明
示例
将数值转换为等效的日期值
将 ginput
的输出从数值转换为等效的日期值。
创建 x 轴为日期值的绘图。然后点击坐标区上的某个点,并使用 ginput
函数返回该选定点的位置。
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
ginput
函数以数值形式返回该位置。使用 num2ruler
确定与 x
的返回数值等效的日期值。
xdate = num2ruler(x,ax.XAxis)
xdate = 06-Jan-2015 19:36:13
输入参数
num
— 数值数据
数组
数值数据,指定为数组。
示例: num = [1 2 3]
ruler
— 决定数据映射的标尺
DurationRuler
对象 | DatetimeRuler
对象 | NumericRuler
对象 | CategoricalRuler
对象 | GeographicRuler
对象
决定数据映射的标尺,指定为下列类型的标尺对象之一:
DurationRuler
对象 - 将num
中的值转换为持续时间值。DatetimeRuler
对象 - 将num
中的值转换为日期时间值。要控制如何将数值转换为datetime
值,请将标尺的ReferenceDate
属性设置为具有所需时区的日期时间值。NumericRuler
对象 - 不转换。输出等于输入。CategoricalRuler
对象 - 将num
中的值转换为分类值。要控制类别的顺序,请设置标尺的Categories
属性。GeographicRuler
对象 - 不转换。输出等于输入。
将标尺对象指定为 Axes
对象的 XAxis
、YAxis
或 ZAxis
属性。例如:
ax = gca; data = num2ruler(num,ax.XAxis)
版本历史记录
在 R2016b 中推出
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
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)