两组数据之间的 Matlab 日期不匹配.帮助!两组、不匹配、日期、数据

2023-09-07 08:40:36 作者:你的床总是人来人往

Matlab Dates mismatch between two sets of data. Help!

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

Matlab下载 matlab官方下载 Matlab破解版32位 64位 win7 win8通用版

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