function fv=fitSingle(globalPar, par, cax) %par is a nfunc x npar matrix of coefficients %globalPar is a row vector of global coefficients %cax is a column vector of time instances %cay are the function values %oneVector=ones(1,size(cax,1));%column vector A=globalPar(1); tau=globalPar(2); alpha=globalPar(3); k1=par(1); B=par(2); k2=par(3); dt=par(4); cax1=cax-dt; kt=k1./(k2-1/tau); ka=k1./(k2-alpha); e0=exp(-cax1/tau); e1=exp(-cax1*alpha); ek=exp(-cax1*k2); if alpha==1/tau fv=cax1.*e0; if k2==1/tau r0=k1.*cax1.*cax1.*ek; else r0=kt*(cax1.*e0-(e0-ek)/(k2-1/tau)); end else q=tau/(alpha*tau-1); fv=q*(e0-e1); r0=zeros(size(cax1)); if k2==1/tau r0=r0+q*k1*cax1; else r0=r0+q*kt*(e0-ek); end if k2==alpha r0=r0-q*k1*cax1; else r0=r0-q*ka*(e1-ek); end end fv=B*fv+(1-B)*r0; fv=fv*A; sel=cax1<0; fv(sel)=0; end %par=ones(2,