function c = fitfunexpc(lam, t, y) % FITFUNEXPC - Used by PRCPRR to return optimized fitted c. % FITFUNEXPC 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. % % Use as: % lam = leastsq('fitfunexp', [1 0]', [0 1e-3 0 0 1], [], x, y); % c = fitfunexpc(lam, x, y); % yf = funexp(lam, c, xf); A = zeros(length(t),length(lam)); for j = 1:size(lam) A(:,j) = exp(-lam(j)*t); end c = A\y;