do_fit.m 417 B

123456789101112131415161718
  1. function [c,g]=do_fit(bins,aux)
  2. c={};
  3. c.f=nan;
  4. g=nan;
  5. if ~any(isnan(aux))
  6. sel=bins>0.015 & bins<0.3;
  7. fo = fitoptions('Method','NonlinearLeastSquares',...
  8. 'Lower',[0.2,0,0,0,6,-1,-1],...
  9. 'Upper',[2,20,1,Inf,12,1,1],...
  10. 'StartPoint',[1,3,.2,1,8,0,0]);
  11. ft = fittype('a*exp(-b*x)+c*cos(2*pi*f*x)*exp(-d*x)+g+h*x','options',fo);
  12. [c, g] = fit(bins(sel)',aux(sel)',ft);
  13. end