projecting values to future dates

1 view (last 30 days)
antonet
antonet on 25 Jun 2012
Dear all,
I have the following sequence of dates
Dates=['02/11/08'
'30/11/08'
'28/12/08'
'25/01/09'
'22/02/09'
'22/03/09'];
The prices corresponding to these dates are given by the following cell vector
values =[
[8.0486]
[8.4678]
[8.1981]
[8.1123]
[7.9911]
[8.1159]]
Each price represents a 4-week average. For instance, the first price is 8.0486. This price is not the price recorded at the date '02/11/08' but the average of the prices in the previous 4 weeks before the '02/11/08' date.
I want to interpolate each of these prices to all the dates that are included in the time interval that starts from the date immediately following the reported dates in the “dates” vector up to the end date of the corresponding month.
To be more precise, the end dates corresponding to the “dates “ vector are given by
Datesend=['30/11/08'
'30/11/08'
'31/12/08'
'31/01/09'
'28/02/09'
'31/03/09'];
So, I want to interpolate the first value 8.0486 to the dates that are included in the time-interval [‘3/11/08' - '30/11/08']
For the second value, 8.4678, no interpolation is needed as the reported date coincides with the end date of that month.
For the third value, 8.1981, I want to interpolate it to the dates that are included in the time-interval ['29/12/08'-'31/12/08'] and so forth.
My question is whether I could use the interp1() function as follows
Prices2 = interp1(datenum(Dates), values, datenum(Datesend) , 'linear')
The problem is by applying this function I obtain
NaN
NaN
NaN
NaN
NaN
NaN
So, my questions are
1) Could I use the interp1() when I use this frequency of data (4-week average prices)? Clearly the dates at which I want to interpolate the value 7.9911 are included in the interval ['23/02/09'- '28/02/09'] . But the prices recorded on the dates of this interval were also used for calculating the next value 8.1159. So there is this overlapping
2) Is there any other approach that you be used so as to notify Matlab that my sequence of dates has these peculiarities?
Thanks a lot
  8 Comments
antonet
antonet on 25 Jun 2012
thanks. I will follow your guidelines and get back to you for advice, albeit I am trying 3 weeks with no success.
Thank you again

Sign in to comment.

Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by