do_plot.m 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. function ff=do_plot(bins,aux,col,col2)
  2. % aux=aux/max(aux);
  3. %
  4. % sel=bins>0.015 & bins<0.3;
  5. %
  6. %
  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,10,8,0,0]);
  11. % % ft = fittype('a-b*x+c*cos(2*pi*f*x)*exp(-d*x)','options',fo);
  12. % ft = fittype('a*exp(-b*x)+c*cos(2*pi*f*x)*exp(-d*x)+g+h*x','options',fo);
  13. % aux=aux/max(aux);
  14. [curve2, ~] = do_fit(bins,aux);
  15. aux=aux/feval(curve2,0);
  16. [curve2, gof2] = do_fit(bins,aux);
  17. subplot(2,2,1)
  18. p1=plot(curve2);
  19. set(p1,'Color',col2,'LineWidth',2);
  20. hold on;
  21. plot(bins,aux,'Color',col);
  22. plot(bins,curve2.a*exp(-curve2.b*bins)+curve2.g+curve2.h*bins,'c');
  23. legend off;
  24. axis([0 .3 0 1.2])
  25. subplot(2,2,2)
  26. plot(bins,curve2.c.*cos(2*pi*curve2.f.*bins).*exp(-curve2.d.*bins),'Color',col2,'LineWidth',2);
  27. hold on;
  28. plot(bins,aux-feval(curve2,bins)'+curve2.c.*cos(2*pi*curve2.f.*bins).*exp(-curve2.d.*bins),'Color',col);
  29. % disp(curve2.f);
  30. % curve2
  31. % gof2
  32. disp(['freq: ' trunc(curve2.f,3) ' R^{2}: ' trunc(gof2.rsquare,3)]);
  33. ff=curve2.f;
  34. axis([0 .3 -.2 .2])
  35. % plot(bins,.2+.9*exp(-6*bins).*(1+.1*cos(2*pi*bins*9)),'b');