function f = fitfunexp(lam, t, y) %FITFUNEXP Used by PRCPRR to return errors in fitting data to a function. % FITFUNEXP is used by PRCPRR. FITFUNEXP(lam,Data) returns the error % between the data and the values computed by the current % function of lam. FITFUNEXP assumes a function of the form % % y = c(1)*exp(-lam(1)*t) + ... + c(n)*exp(-lam(n)*t) % % with n linear parameters and n nonlinear parameters. A = zeros(length(t),length(lam)); for j = 1:size(lam) A(:,j) = exp(-lam(j)*t); end c = A\y; z = A*c; f = z-y;