basecorr
Introduced in 2.0
Synopsis

Polynomial baseline correction.

CorrSpec = basecorr(Spec,Dim,Ord)
[CorrSpec,BLine] = basecorr(Spec,Dim,Ord)
Description

This function computes and applies polynomial baseline corrections to the input data array Spec. It returns the baseline corrected data in CorrSpec and the polynomial baseline itself in BLine. The baseline is computed by least-squares fitting polynomials of required order to the data along specified dimensions.

Dim is a vector giving all dimensions along which one-dimensional baseline corrections should be applied. E.g. if Dim=[2 1], then a correction is applied along dimension 2, and after that another one along dimension 1. If Dim is set to [], a single all-dimensional baseline fit is applied instead.

Ord gives the orders for the polynomial fits listed in Dim, so it must have the same number of elements as Dim. If Dim=[], Ord must have one entry for each dimension of Spec.

Examples

To fit a single third-order surface to 2D data, use

data = peaks(100);
cdata = basecorr(data,[],[3 3]);

To apply corrections separately along each dimension, use

cdata = basecorr(data,[1 2],[3 3]);

If you want to apply a linear baseline correction along the second dimension only, use

cdata = basecorr(data,2,1);

To subtract the mean from the data array, use

cdata = basecorr(data,[],[0 0]);
Algorithm

1D and nD polynomial least-square fits are computed by constructing the Vandermonde matrix associated with the problem and using MATLAB's \ operator to solve the resulting system of linear equations.

See also

apowin, exponfit, smooth