observations every 8 or 9 weeks-interpolation
Show older comments
I have the cell matrix
A={
'28/12/08' [2.3187] [1.1517]
'01/03/09' [2.2314] [1.1540]
'03/05/09' [2.2094] [1.1702]
'28/06/09' [2.2666] [1.1762]
'30/08/09' [2.2240] [1.1860]
'01/11/09' [2.2387] [1.1741]
'03/01/10' [2.3229] [1.1729]
'07/03/10' [2.2253] [1.1559]
'09/05/10' [2.2504] [1.1678]
'04/07/10' [2.2673] [1.1810]
'05/09/10' [2.1828] [1.1816]
'07/11/10' [2.1271] [1.1660]
'02/01/11' [2.3143] [1.1674]
'06/03/11' [2.1860] [1.1544]
'08/05/11' [2.1770] [1.1704]
'03/07/11' [2.1832] [1.1758]
'04/09/11' [2.1578] [1.1766]
'06/11/11' [2.1612] [1.1710]}
the observations represent a 8 or 9 week average. And I want to convert these values to estimated monthly averages via interpolation.My thought is the following
%convert the mm/yy to number dates
xi=datenum(A(:,1),'mm/yy')
B=cell2mat(A(:,[2,3]));
for c = 2:3
B(:,c-1) = interp1(xi(1:2:end),cell2mat(A(:,c)),xi);
end
But I have the feeling that my approach is not correct. Any suggestions?
thank you in advance
Accepted Answer
More Answers (1)
Walter Roberson
on 14 Aug 2012
0 votes
Note that cell2mat(A(:,c)) is going to be the same as B(:,c-1)
You need to have another look at how many x and y values you are passing into interp1()
2 Comments
salva
on 14 Aug 2012
Walter Roberson
on 14 Aug 2012
xi(1:2:end) is half the length of cell2mat(A(:,c)) but interp1() requires the first two arguments to be the same length.
Categories
Find more on Dates and Time 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!