global exp_data sd_intensity
load peaka.o1
exp_data = peaka;
for(i=1:length(exp_data(:,1)))
	sd_intensity(i) = 0.5e-7;
end;

X = [1.6e-6 13118.5 0.5 1.8e-6 13123 0.5 1e-7];

for(j=1:10)

Xfit = fmins('calc_chi',X)

%fplot('fit_fn',[13110 13130], [], Xfit)
for(i=1:length(exp_data(:,1)))
	fit(i)=fit_fn(exp_data(i,1), Xfit);
end;

plot(exp_data(:,1),exp_data(:,2),'+');
hold on;
plot(exp_data(:,1), fit);

calc_chi(Xfit)
X=Xfit;
hold off;
end;                      
