Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Am I correct in my approach regarding interpolation?

1 Ansicht (letzte 30 Tage)
tzaloupas
tzaloupas am 14 Feb. 2013
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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

Antworten (1)

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

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by