clear all; close all;

load velocity.dat
xd=velocity(:,1);
yd=velocity(:,2);
plot(xd,yd,'O:')

n=length(xd);
xp=linspace(xd(1),xd(n),100);

% use our natural cubic spline
yp=spline3natural(xd,yd,xp);
figure(1)
plot(xd,yd,'k*',xp,yp,'r')
hold on

% Matlab's spline command (with default not-a-knot BCs)
yp=spline(xd,yd,xp);
plot(xd,yd,'k*',xp,yp,'b')

% use our clamped spline with zero slopes at the ends
yp=spline3clamped(xd,yd,xp,0,0);
plot(xd,yd,'k*',xp,yp,'g')

% Matlab's spline command with clamped (zero) BCs
yp=spline(xd,[0;yd;0],xp);
figure(2)
plot(xd,yd,'k*',xp,yp,'r')

% Matlab's interp1 command
yp=interp1(xd,yd,xp,'spline'); % cubic spline with not-a-knot BCs
plot(xd,yd,'k*',xp,yp,'b')

yp=interp1(xd,yd,xp); % piecewise linear interpolant
plot(xd,yd,'k*',xp,yp,'b')

yp=interp1(xd,yd,xp,'pchip'); % piecewise cubic Hermite interpolant
% does not require continuous second derivatives at the knots
plot(xd,yd,'k*',xp,yp,'r')




