why the first and second differential is not right after interpolation

조회 수: 1 (최근 30일)
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);

채택된 답변

Jian Wei
Jian Wei 2014년 7월 23일
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
Stanley Cheng
Stanley Cheng 2014년 7월 23일
Yes, that is right! the reason why the above phenomenon was found! THX very much!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interpolating Gridded Data에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by