evaluateCenters.m 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. function fv=evaluateCenters(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. oneVector=ones(1,size(cax,1));
  6. cx2=ones(1,size(par,1))'*cax';
  7. oneMatrix=ones(size(cx2));
  8. A=globalPar(1);
  9. tau=globalPar(2);
  10. alpha=globalPar(3);
  11. t0=globalPar(5);
  12. t1=globalPar(6);
  13. k1=par(:,1)*oneVector;
  14. B=par(:,2)*oneVector;
  15. k2=par(:,3)*oneVector;
  16. dt=par(:,4)*oneVector;
  17. kt=k1./(k2-oneMatrix/tau);
  18. ka=k1./(k2-oneMatrix*alpha);
  19. cx2p=cx2-dt;
  20. e0=exp(-cx2p/tau);
  21. e1=exp(-cx2p*alpha);
  22. ek=exp(-cx2p.*k2);
  23. r0=zeros(size(cx2));
  24. if alpha==1/tau
  25. fv=e0.*cx2p;
  26. rsel=oneMatrix/tau==k2;
  27. r0(rsel)=k1(rsel).*cx2p(rsel).*cx2p(rsel)*ek(rsel);
  28. r0(~rsel)=kt.*(fv-(e0-ek)./(k2-oneMatrix/tau));
  29. else
  30. q=tau/(alpha*tau-1);
  31. fv=q*(e0-e1);
  32. rsel=oneMatrix/tau==k2;
  33. r0(rsel)=r0(rsel)+q*k1(rsel).*cx2p(rsel);
  34. r0(~rsel)=r0(~rsel)+q*kt(~rsel).*(e0(~rsel)-ek(~rsel));
  35. rsel=alpha==k2;
  36. r0(rsel)=r0(rsel)-q*k1(rsel).*cx2p(rsel);
  37. r0(~rsel)=r0(~rsel)-q*ka(~rsel).*(e1(~rsel)-ek(~rsel));
  38. B1=oneMatrix-B;
  39. fv=B.*fv+B1.*r0;
  40. fv=fv*A;
  41. sel=cx2p<0;
  42. fv(sel)=0;
  43. end
  44. %par=ones(2,