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);
댓글 수: 0
채택된 답변
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Interpolating Gridded Data에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!