Info

此问题已关闭。 请重新打开它进行编辑或回答。

Am I correct in my approach regarding interpolation?

1 次查看(过去 30 天)
Dear all
I have the vector
A={
[ NaN]
[ NaN]
[1.0877]
[1.0909]
[ NaN]
[ NaN]
[ NaN]
[ NaN]
[ NaN]
[ NaN]
[ NaN]
[ NaN]
[ NaN]
[ NaN]
[ NaN]
[ NaN]
[ NaN]
[ NaN]
};
and the date vector
D={'10/2008'
'11/2008'
'12/2008'
'1/2009'
'2/2009'
'3/2009'
'4/2009'
'5/2009'
'6/2009'
'7/2009'
'8/2009'
'9/2009'
'10/2009'
'11/2009'
'12/2009'
'1/2010'
'2/2010'
'3/2010'
'4/2010'
'5/2010'
'6/2010'
'7/2010'
'8/2010'
'9/2010'
'10/2010'
'11/2010'
'12/2010'
'1/2011'
'2/2011'
'3/2011'
'4/2011'
'5/2011'
'6/2011'
'7/2011'
'8/2011'
'9/2011'
};
and I am doing interpolation
xi = datenum(D, 'mm/yyyy');
z = interp1(xi(1:2:end),cell2mat(A(:,1)),xi);
Equivalently,
idx = ~isnan(cell2mat(A(:,1)));
z= interp1(xi(idx),cell2mat(A(idx,1)),xi);
Could you please verify that I am correct in my approach ?
thanks

回答(1 个)

Azzi Abdelmalek
Azzi Abdelmalek 2013-2-14
v=cell2mat(A)
xi = datenum(D, 'mm/yyyy');
z = interp1(xi(3:4),v(3:4),xi,'spline');
  2 个评论
tzaloupas
tzaloupas 2013-2-14
Hi Azzi. thanks What is the difference between your approach and mine?Is this linear interpolation?
Satyam Gaba
Satyam Gaba 2018-8-24
No it's not a linear function. Spline interpolation can be used for polynomial interpolation for low degree polynomials as well as higher degrees.

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by