%
% Spline Interpolation
%
a = 0;
b = 2*pi;
k = input('Degree of polynomial? ');
k = k + 1; % order = degree + 1
n = input('How many basis functions? ');
knots = augknt( linspace(a,b,n-k+2), k );      % number of knots = n+k
x = linspace(a,b,n); % Need n function samples
y = target(x);
sp = spapi(knots,x,y);
xx = linspace(a,b,100);  % Plot 100 points
yy = target(xx);
yt = fnval(sp,xx);
plot(xx,yy,xx,yt)    % Plot original and interpolant
pause                % Press any key to continue
plot(xx,yy-yt)       % Plot error: orginal minus interpolant
