fitSingle.m 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. function fv=fitSingle(globalPar, par, cax)
  2. %par is a nfunc x npar matrix of coefficients
  3. %globalPar is a row vector of global coefficients
  4. %cax is a column vector of time instances
  5. %cay are the function values
  6. %oneVector=ones(1,size(cax,1));%column vector
  7. A=globalPar(1);
  8. tau=globalPar(2);
  9. alpha=globalPar(3);
  10. k1=par(1);
  11. B=par(2);
  12. k2=par(3);
  13. dt=par(4);
  14. cax1=cax-dt;
  15. kt=k1./(k2-1/tau);
  16. ka=k1./(k2-alpha);
  17. e0=exp(-cax1/tau);
  18. e1=exp(-cax1*alpha);
  19. ek=exp(-cax1*k2);
  20. if alpha==1/tau
  21. fv=cax1.*e0;
  22. if k2==1/tau
  23. r0=k1.*cax1.*cax1.*ek;
  24. else
  25. r0=kt*(cax1.*e0-(e0-ek)/(k2-1/tau));
  26. end
  27. else
  28. q=tau/(alpha*tau-1);
  29. fv=q*(e0-e1);
  30. r0=zeros(size(cax1));
  31. if k2==1/tau
  32. r0=r0+q*k1*cax1;
  33. else
  34. r0=r0+q*kt*(e0-ek);
  35. end
  36. if k2==alpha
  37. r0=r0-q*k1*cax1;
  38. else
  39. r0=r0-q*ka*(e1-ek);
  40. end
  41. end
  42. fv=B*fv+(1-B)*r0;
  43. fv=fv*A;
  44. sel=cax1<0;
  45. fv(sel)=0;
  46. end
  47. %par=ones(2,