'spline' -逐段三次样条函数插值
M ATLAB程序设计:
clear all;
x=[0 1 4 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23];
y=[0.6901855 1.6815597 5.299577 7.041801 5.814596167 4.7441155 ...
3.571560333 1.828765917 1.306175 2.892687917 2.295350407 1.18981955 ...
1.107627675 1.044059833 0.967896115 0.856998138 0.6182064 0.896658793 ...
0.699924733 0.505555894 0.780169717];
xi=0:1:23;
y0=vpa(interp1(x,y,xi,'linear'),7)%线性插值
y1=vpa(interp1(x,y,xi,'spline'),7) %三次样条插值
y2=vpa(interp1(x,y,xi,'cubic'),7)%三次多项式插值(又叫“立方插值”)
plot(x,y,'o',xi,y0,'*--r',xi,y1,'*-y',xi,y2,'*-.c');
legend('j-d','y_linear','y_spline','y_cubic','location','northeast'); 插值与拟合算法在测量数据分析中的应用(3):http://www.youerw.com/shuxue/lunwen_39846.html