why the first and second differential is not right after interpolation
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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);
0 commentaires
Réponse acceptée
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.
Plus de réponses (0)
Voir également
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!