Savitzky-Golay smoothing

Syntax: | `ys = SAVGOL(n,m,y)`

The `SAVGOL` function calculates a smooth curve through the data contained in vector `y`, the dependent variable, using the Savitzky-Golay smoothing filter method. The order of the filter is given in scalar `n`, which currently can only be `2` or `4`. The filter width is given in scalar `m`. These filters preserve the area under the data, the zeroth moment, but also the higher moments.

There is no input independent variable, as the data is assumed to be equally spaced.

As a rough guideline, best results are obtained when the filter width of the order `4` Savitzky-Golay filter is between one and two times the full width half maximum (FWHM) of desired features in the data.

For more information on Savitzky-Golay filters, see:
Computers in Physics, volume 4, number 6, November/December 1990, pages 669–672.

Method