在Matlab中排除时间序列图中的日期间隔 [英] Exclude Date Gaps in Time Series Plot in Matlab

查看:260
本文介绍了在Matlab中排除时间序列图中的日期间隔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在绘制高频价格数据的时间序列图.我的时间序列在上午8点至下午4点之间有每秒的报价,但跳过了晚上和周末.我该如何从情节中忽略这些差距,以使每天的价格系列似乎被粘合"在一起.

I'm making a time series plot of high frequency price data. My time series has quotes for each second between 8am and 4pm but skips evenings and weekends. How can I omit these gaps from my plot such that each day's price series appears to be "glued" together.

回答:

谢谢@Shai!我喜欢这样的东西:

Thanks, @Shai! I went with something like this:

% price, year, month, day, hour, minute, second are all column vectors of equal length
% exactly N price quotes per trading day (8am-4pm, excluding weekends)
date = datenum([year, month, day, hour, minute, second]);
price = price;
figure;
plot(price);
tick_index = 1:N:length(date); % my ticks are placed at the start of each trading day
tick_label = datestr(date(tick_index), 6);
set(gca, 'XTick', tick_index);
set(gca, 'XTickLabel', tick_label);

我刚开始回答问题-如果我违反礼节,请告诉我!

I'm very new to answering questions -- if I've violated etiquette please let me know!

推荐答案

您可以控制图的XTick来隐藏差距.请参阅此文档.

You can control the XTicks of your plot to hide the gaps. See this doc.

这篇关于在Matlab中排除时间序列图中的日期间隔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆