% Approximation of functions script

% Set up basis function shifts and scale factors
m = [4:8];
sigma = .7;
s = 1./sigma;
fprintf('%g basis functions\n',length(m))

% Generate Gram matrix
c = ones(size(m));
tsamp = linspace(5,10,5)'; % makes yfun a column
[ydummy,W] = lincmb(tsamp,c,'normpdf',m,s);
plot(tsamp,W)
pause

G = W'*W;
yfun = sin(pi/2*tsamp);
b = W'*yfun;
c = (G\b).'; % make c a row

t=linspace(5,10,200);
yaprx = lincmb(t,c,'normpdf',m,s);
plot(t,sin(pi/2*t),t,yaprx,'--')
