Reputation: 1613
I am interpolating variables from quarterly to monthly frequency in MATLAB. However, when I use retime
it doesn't go as far as the end of the sample but it stops 2 months before.
Let me give you an example:
T = datetime(2002,01,01):calquarters:datetime(2019,12,01);
TT = timetable(T', randn(72,1))
x = retime(TT, 'monthly', 'spline') % interpolate
As you can see it gives me back 214 observations rather than 216, November and December 2019 are missing. How can I fix it?
Thanks!
Upvotes: 0
Views: 130
Reputation: 166
I don't have enough reputation to add a comment, but TT
having 72 quarters instead of 73 means that you are actually storing dates from 1st January 2002 to 1st October 2019 - as the next quarter would start from 1st January 2020, which is then not included in your original array (you can check this by printing TT
and checking if this date is included or not).
If this is the case, there is no way for retime
to interpolate the missing months, as they aren't in the original matrix (that is, retime
cannot interpolate from October to January, since there is no such thing in TT
).
Replacing datetime(2019,12,01)
with datetime(2020,01,01)
, as well as replacing randn(72,1)
with randn(73,1)
, might solve your issue.
Upvotes: 1