在matlab中,我使用accumarray()来创建一个包含3列整数的新向量。第1栏:日期(仅当天);第2栏:小时;第3栏:样本值。
19.0000 9.0000 25.6937
19.0000 10.0000 30.2616
19.0000 11.0000 32.2840
19.0000 12.0000 28.4867
19.0000 14.0000 35.4055
19.0000 16.0000 48.3377
现在我绘制图表的代码涉及以下内容;
xdate = datenum(year,month,day,hourVector,minutes,seconds);
plot(xdate,sampleValue,'-x','MarkerSize',10)
datetick('x','ddd HHPM')
我找不到每小时(或2小时)标记一次x轴的方法。感谢
答案 0 :(得分:1)
我猜你只想让x刻度间隔1小时,与数据间距无关?从您的示例中,我没有看到您每小时必须有一个数据点。
如果我的理解是正确的,请尝试替换
datetick('x','ddd HHPM')
以下内容:
hr_step = 0.0417; % increasing datenum by this amount will advance date by 1 hour
tick_xdate = min(xdate):hr_step:max(xdate);
set(gca,'XTick',tick_xdate)
datetick('x','ddd HHPM','keepticks') % 'keepticks' option forces the use of tick_xdate