Calculating combinations of dates
Show older comments
Dear all,
I have the following cell vector of dates
jji= '23/11/08'
'28/12/08'
'25/01/09'
that corresponds to the cell vector of values
values
[0.5637]
[0.6034]
[0.5943]
[0.4567 ]
and I want to create the following new vector of values
(23*0.5637+7*0.6034)/30
(28*0.6034+3*0.5943)/31
(25*5943+6*0.4567)/31
where in the first row of this vector the numerator (23*0.5637+7*0.6034) is the sum of two products.
In the first product which is 23*0.5637 the number 23 is actually the first two digits from '23/11/08'
In the second product which is 7*0.6034 the number 7 is actually the distance in days between '23/11/08' and the end date of that month, that is the difference
'23/11/08-30/11/08
The denominator in the first row (30) is the total number of days for month November 2008
Similar analysis holds for the rest of the rows.
In my case I have a huge vector of dates and values. is there any way to construct the new vector of values?
My proposal is this:
jji={ '23/11/08'
'28/12/08'
'25/01/09'
};
values ={
0.5637
0.6034
0.5943
0.4567 };
for i = 1:length(jji)
jjii{i,1} = jji{i,1}(1:2);
end
that produces
jjii =
'23'
'28'
'25'
TO find the end dates of each month i use
[Y, M] = datevec(jji,'dd/mm/yy'); enddates = datestr(datenum(Y,M+1,1)-1,'dd/mm/yy')
and I obtain
30/11/08 31/12/08 31/01/09
but then I need to calculate the differences between the jji and "endndates"
Any suggestions?
thank you
Accepted Answer
More Answers (0)
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!