필터 지우기
필터 지우기

Calculating combinations of dates with empty cells

조회 수: 1 (최근 30일)
antonet
antonet 2012년 7월 1일
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
antonet
antonet 2012년 7월 2일
편집: antonet 2012년 7월 2일
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 2012년 7월 2일
is there a better approach?
Thank you very much

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Files and Folders에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by