两组数据之间的 Matlab 日期不匹配.帮助! [英] Matlab Dates mismatch between two sets of data. Help!

查看:27
本文介绍了两组数据之间的 Matlab 日期不匹配.帮助!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Matlab Dates mismatch between two sets of data. Help!

Please forgive the simplicity of the question but its my first day;

I am working with two sets of time series: 1) Price of S&P 500 since 1977 (daily close & date) and 2) Bond Yield since 1977 (daily close & date).

The problem is that after a few months the the dates are no longer aligned with each other (maybe the bond market was closed one day and the stock market was opened etc) so I have two data sets that are no longer correctly aligned. Before I even start asking about how to replace the gaps (I will use averages when I get to that bridge), I need to know how to get matlab to align the dates for both securities so that I at least know where the gaps are are for each security i.e at which date is one security missing the price. I was thinking of creating a my own (or using the dates from one of the securities) calendar column and then use that as the base date column to stardedise the final output and match the prices to the new data... maybe this is the wrong way of thinking about it but any help would be much appreciated :)

解决方案

You might have a problem if you just use the dates from either one of the series because each of them might have dates that are missing in the other. What I would do is start with a clean 3-column matrix that contains all the weekdays in the date range. This post on the Mathworks blog can offer some insight on how to do it. Then fill in the two other columns with the values from your two data series. This way you will be sure all your values are in the matrix and will make your life simpler if you decide to add more data.

As for filling in the missing dates, you can just use : the 1-D interpolate function

这篇关于两组数据之间的 Matlab 日期不匹配.帮助!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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