PLS_Toolbox Documentation: savgol< rwb savgolcv >

savgol

Purpose

Savitzky-Golay smoothing and differentiation.

Synopsis

 

[y_hat,cm] = savgol(y,width,order,deriv,options)

Description

SAVGOL performs Savitzky-Golay smoothing on a matrix of row vectors y. At each increment (column) a polynomial of order order is fitted to the number of points width surrounding the increment. An estimate for the value of the function (deriv = 0) or derivative of the function (deriv > 0) at the increment is calulated from the fit resulting in a smoothed function y_hat. E.g. see A. Savitzky and M.J.E. Golay, Anal. Chem. 36, 1627 (1964).

[y_hat,cm] = savgol(y,width,order,deriv) allows the user to select the number of points in the filter width {default = 15}, the order of the polynomial to fit to the points order {default = 2}, and the order of the derivative deriv {default = 0}.

Output cm allows the user to apply smoothing to additional matrices of the same size as y, e.g. y_hat2 = y2*cm where y2 is the same size as y used to determine cm.

Note: width must be ≥ 3 and odd, and and deriv must be ≤ order.

Options

             options =   a structure array with the following fields:

      useexcluded:  [ {'true'} | 'false' ], governs how excluded data is handled by the algorithm. If 'true', excluded data is used when handling data on the edges of the excluded region (unusual excluded data may influence nearby non-excluded points). When 'false', excluded data is never used and edges of excluded regions are handled like edges of the spectrum (may introduce edge artifacts for some derivatives).

      useexcluded:  [ {'fast'} | 'polyinterp' ], governs how edges of data and excluded regions are handled. 'fast' is standard SavGol approach. 'polyinterp' uses slower, but more stable polynomial interpolation algorithm.

Examples

If y is 3 by 100 then

 

y_hat = savgol(y,11,4,2);

yields a 3 by 100 matrix y_hat that contains row vectors of the second derivative of rows of y resulting from an 11-point quartic Savitzky-Golay  smooth of each row of y.

See Also

baseline, baselinew, deresolv, lamsel, mscorr, polyinterp, savgolcv, stdfir, wlsbaseline


< rwb savgolcv >