exponfit

Single- and multi-exponential fitting.

Syntax
[k,c] = exponfit(x,y)
...   = exponfit(x,y,nExps)
...   = exponfit(x,y,nExps,'noconst')
[k,c,yFit] = exponfit(...)
k = exponfit(...)
Description

This function computes least-squares fits of single or double exponential decays or recoveries to 1D or 2D data. The data are specified in x (abscissa) and y (ordinate). nExps specifies the number of exponents to fit (1 or 2, default is 1).

The fitting model is of the form

y = c(1) + c(2)*exp(-k(1)*x) + c(3)*exp(-k(2)*x)

If 'noconst' is given, the constant c(1) is set to 0 and not included in the fitting.

The rate constants are returned in k, the linear combination coefficients in c. yFit contains the fitted function.

If y is a matrix, exponfit works along the columns and returns vectors for k and c and a matrix for yFit.

Examples

For noisy data

x = linspace(0,1,301);
y = 7*exp(-7*x) + 0.5*rand(size(x));

the exponential fit gives

[k,c] = exponfit(x,y)
k =
    6.9973
c =
    0.2421
    7.0258
Algorithm

exponfit implements an efficient hybrid algorithm: For the rate constants, a nonlinear least-squares algorithm is used, whereas the linear combination coefficients are obtained by a simple linear least-squares fit.

See also

apowin, basecorr, datasmooth