function [] = cp_9_2_10()
% Generates a plot of a parametrised natural cubic spline through five
% points (0,0), (1,1), (0,2), (0,-1) and (2,1).
% 
% USAGE: cp_9_2_10

% Time axis
t = 1:5;
% Set x and y-values
x = [0 1 0  0 2];
y = [0 1 2 -1 1];

% We use Matlab's built-in spline function
p = spline(t,[x;y]);

% And then the 'ppval' function to evalueate the piecewise polynomials
% generated by 'spline'. We use 100 points in the range 1...5 as evaluation
% points.
Y = ppval(p, linspace(1,5,100));

% Now the x-values are stored in Y(1,:) amd the y-values in Y(2,:). We now
% plot our parametrised spline along with the interpolation nodes.
plot(Y(1,:),Y(2,:),'b',x,y,'or','LineWidth',2);


