why the first and second differential is not right after interpolation
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Stanley Cheng
il 23 Giu 2014
Commentato: Stanley Cheng
il 23 Lug 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 Commenti
Risposta accettata
Jian Wei
il 23 Lug 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.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Interpolating Gridded Data in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!