function y=gafit(x0) % this function is the sum inside the mean squared error between % the gaussfit data and a Gaussian with parameter % vector x0 load gaussfit.dat x=gaussfit(:,1); y=gaussfit(:,2); sum1=0; for j=1:length(x) sum1=sum1+ ( x0(1)*exp(-x0(2)*x(j)^2)-y(j))^2; end y=sum1;