 
%SAMPLE SPLINE CODE

%MODEL DATA (TRAINING DATA)
x = 0:10%define the domain of the function
y = sin(x)%compute the range of the function at these points

%PREDICTED VALUES 
xx = 0:.25:10%domain values where we seek predictions

%The spline function returns the predicted values yy
%at the domain values xx.  The data x, y is used to build the model.
yy = spline(x,y,xx);
        

plot(x,y,'o',xx,yy,'x',xx,sin(xx),'v')
legend('given data','predicted data','actual values') 

%compute residuals
yy-sin(xx)