function ShowMatSplineTools()
% Illustrates the Matlab functions spline, ppval, mkpp, unmkpp

close all

% Set Up Data:
n = 9;
x = linspace(-5,5,n);
y = atan(x);

% Compute the spline interpolant and its derivative:
S = spline(x,y);
[x,rho] = unmkpp(S);
drho = [3*rho(:,1) 2*rho(:,2) rho(:,3)];
dS = mkpp(x,drho);

% Evaluate S and dS:
z = linspace(-5,5);
Svals = ppval(S,z);
dSvals = ppval(dS,z);

% Plot:
atanvals = atan(z);
figure
plot(z,atanvals,z,Svals,x,y,'*');
title(sprintf('Spline Interpolant s(x) of atan(x) (n = %2.0f) ',n),'fontsize',14)

datanvals = ones(size(z))./(1 + z.*z);
figure
plot(z,datanvals,z,dSvals)
title(sprintf('Derivative of Spline Interpolant of atan(x) (n = %2.0f) ',n),'fontsize',14)