Calculating combinations of dates with empty cells

1 visualizzazione (ultimi 30 giorni)
Dear all,
I have the following cell vector of dates
jji= ' '
'28/12/08'
'25/01/09'
that corresponds to the cell vector of values
values
''
[0.6034]
[0.5943]
[0.4567 ]
and I want to create the following new vector of values
''
(28*0.6034+3*0.5943)/31
(25*5943+6*0.456)/31
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
clc
jji={ '23/11/08'
'28/12/08'
'25/01/09'};
values ={
0.5637
0.6034
0.5943
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?
thanks
  8 Commenti
antonet
antonet il 2 Lug 2012
Modificato: antonet il 2 Lug 2012
Is it ok now?
clear all
clc
jji={ '23/11/08'
'28/12/08'
'25/01/09'};
values ={
0.5637
0.6034
0.5943
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;
antonet
antonet il 2 Lug 2012
is there a better approach?
Thank you very much

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Files and Folders in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by