1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
x = 0 : pi/4 : 2 * pi; y = sin(x); xx = 0 : 0.5 : 2 * pi;
y1 = interp1(x,y,xx); subplot(2,2,1);plot(x,y,'o',xx,y1,'r'); title('分段线性插值')
y2 = interp1(x,y,xx,'nearnest'); subplot(2,2,2);plot(x,y,'o',xx,y2,'r'); title('邻近插值')
y3 = interp1(x,y,xx,'spline'); subplot(2,2,3);plot(x,y,'o',xx,y3,'r'); title('球面线性插值')
y4 = interp1(x,y,xx,'PCHIP'); subplot(2,2,4);plot(x,y,'o',xx,y4,'r'); title('三次多项式插值')
|