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

    %% Spline Interpolation of Angular Data

% Copyright 2015 The MathWorks, Inc.


%%
% The statements  
x = pi*[0:.5:2]; 
y = [0  1  0 -1  0  1  0; 
     1  0  1  0 -1  0  1];
pp = spline(x,y);
yy = ppval(pp, linspace(0,2*pi,101));
plot(yy(1,:),yy(2,:),'-b',y(1,2:5),y(2,2:5),'or'), axis equal

%%%
% generate the plot of a circle, with the five data points |y(:,2),...,y(:,6)| marked
% with o's. Note that this |y| contains two more values
% (i.e., two more columns) than does |x|, hence |y(:,1)| and |y(:,end)| are
% used as endslopes.