Calculating combinations of dates with empty cells

1 view (last 30 days)
antonet on 1 Jul 2012
Dear all,
I have the following cell vector of dates
jji= ' '
that corresponds to the cell vector of values
[0.4567 ]
and I want to create the following new vector of values
where in the second row of this vector the numerator (28*0.6034+3*0.5943) is the sum of two products.
In the first product which is 28*0.6034 the number 28 is actually the first two digits from '28/12/08'
In the second product which is 3*0.5943 the number 3 is actually the distance in days between 28/12/08' and the end date of that month, that is the difference '28/11/08-31/11/08
The denominator in the second row (31) is the total number of days for month November 2008
Similar analysis holds for the last raw.
In my previous question Andrei gave a very nice code that worked for the case that I do not have empty cells.
That is,
clear all
jji={ '23/11/08'
values ={
0.4567 };
[Y M D] = datevec(jji,'dd/mm/yyyy');
ED = eomday(Y, M);
n = numel(values);
awe=cell2mat(values(hankel(1:n-1,n+[-1 0])));
out = sum([D, ED-D].*awe,2)./ED;
How could I modify that code for the case of empty cells?
antonet on 2 Jul 2012
is there a better approach?
Thank you very much

Sign in to comment.

Answers (0)


Community Treasure Hunt

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

Start Hunting!

Translated by