www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/DataInterpolationUsingSplineAndPchipExample.m

    %% Data Interpolation Using |spline| and |pchip|

% Copyright 2015 The MathWorks, Inc.


%%
x = -3:3; 
y = [-1 -1 -1 0 1 1 1]; 
t = -3:.01:3;
p = pchip(x,y,t);
s = spline(x,y,t);
plot(x,y,'o',t,p,'-',t,s,'-.')
legend('data','pchip','spline','Location','SouthEast')