% Script to show the effects of the width of the Gaussian in 1-d functions %The data will be random: numcenters=15; ridx=randperm(numcenters); x=2*randn(1,numcenters*4); %centers=x(ridx(1:numcenters)); centers=x; y=sin(3*x)+0.2*randn(size(x)); t=linspace(-2,2); yt=sin(3*t); widths=5:-0.1:0.1; for j=1:length(widths) A=edm(x',centers'); Phi=rbf1(A,1,widths(j)); Phi=[Phi, ones(length(x),1)]; W=pinv(Phi)*y'; Yout1=Phi*W; %Get predicted values: A=edm(t',centers'); Phi=rbf1(A,1,widths(j)); Phi=[Phi, ones(length(t),1)]; Yout=Phi*W; figure(1) plot(x,y,'k*',t,yt,'b-',t,Yout,'r-',centers,zeros(size(centers)),'b^'); axis([-2 2 -2 2]); pause(0.1); figure(2) plot(t,abs(yt-Yout')); axis([-2 2 0 1]) pause(0.1); % M(j)=getframe; end