why the first and second differential is not right after interpolation

1 vue (au cours des 30 derniers jours)
Stanley Cheng
Stanley Cheng le 23 Juin 2014
Commenté : Stanley Cheng le 23 Juil 2014
Hi everyone,
the following code shows that after an interpolation with time interval 0.01s, the first and second differential are obviously changed compared with the original countparts. the attached figures exhibit the original and interpolated data. I think after interpolation, the deviation should be small, but especially for the second differential, the variation is quite large. Could anyone show me how to make a right one? THX very much!
t1=0:0.1:2*pi;
dt1=0:0.1:2*pi-0.1;
ddt1=0:0.1:2*pi-0.2;
y1=sin(t1);
v1=diff(y1)./diff(t1);
a1=diff(v1)./diff(dt1);
t2=0:0.01:2*pi;
dt2=0:0.01:2*pi-0.01;
ddt2=0:0.01:2*pi-0.02;
y2=interp1(t1,y1,t2);
v2=diff(y2)/0.01;
a2=diff(v2)/0.01;
H1=figure;
subplot(2,3,1)
plot(t1,y1);
subplot(2,3,2)
plot(dt1,v1);
subplot(2,3,3)
plot(ddt1,a1);
subplot(2,3,4)
plot(t2,y2);
subplot(2,3,5)
plot(dt2,v2);
subplot(2,3,6)
plot(ddt2,a2);

Réponse acceptée

Jian Wei
Jian Wei le 23 Juil 2014
Please use the following command to generate the interpolated data.
y2 = interp1(t1,y1,t2,'spline');
Using the "spline" method, the interpolated data at the query point is based on a cubic interpolation. Please refer to the following documentation for more information.
  1 commentaire
Stanley Cheng
Stanley Cheng le 23 Juil 2014
Yes, that is right! the reason why the above phenomenon was found! THX very much!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Interpolating Gridded Data dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by