%
% Main script to generate G matrix
%
load data.txt
t = data(1,:);			% Extract measurement times.
y = data(2,:);			% Extract measurement values.
m = length(t);			% Number of design points.
fprintf('There are %g design points.\n',m)
%
order = 4;			% Use cubic splines.
%
%
% This is the part you get to control.
%
knots = linspace(0,1,5);	% Equally spaced knots.
%
%
knots = augknt(knots,order);	% Adjust endpoint knots.
n = length(knots) - order;	% Compute number of basis functions.
fprintf('There are %g basis functions.\n',n)
%
% Generate matrix of  int_0^1 kernel(t_i,tau) B_j(tau) d tau
%
G = Ggen('kernel',t,knots,order);
%
c = pinv(G)*y';			% Remember that y is a ROW vector.
%
% Plot solution
%
sp = spmak(knots,c');		% spmak needs a ROW vecter here.
t0 = linspace(0,1,100);
plot(t0,fnval(sp,t0))
