Savitzky-Golay

Design an FIR Savitzky-Golay lowpass smoothing filter. Savitzky-Golay (polynomial) smoothing filters or least-squares smoothing filters are generalizations of the FIR average filter that can better preserve the high-frequency content of the desired signal, at the expense of not removing as much noise as an FIR average (see movaver for more information). In general, Savitzky-Golay filters should be used for data requiring peak enhancement or smoothing, such as biomedical ECG and PPG applications.

Savitzky-Golay filter

Syntax
Hd = savgolay(Order, Polyfit, DFormat)

Description
Order: may be specified up to 499 (professional) and up to 128 (educational) edition.

Polyfit: Polynomial fit, which must be < Order+1

Hd: the savgolay method designs an FIR Savitzky-Golay lowpass smoothing filter based on the entered specifications and places the transfer function (i.e. numerator and gain) into a digital filter object, Hd. The digital filter object can then be combined with other methods if so required. For a digital filter object, Hd, calling getnum(Hd) and getgain(Hd) will extract the numerator and gain coefficients respectively – see below.

DFormat: allows you to specify the display format of resulting digital filter object.

symbolic Display a symbolic representation of the filter object. If the order > 10, the symbolic display option will be overridden and set to numeric.
numeric Display a matrix representation of the filter object
void Create a filter object, but do not display output

Examples

ClearH1;  // clear primary filter from cascade

interface L = {2, 50,2,24};
interface P = {2, 10,1,4};

Main()

Hd=savgolay(L,P,"numeric");  // Design Savitzky-Golay lowpass filter
Num=getnum(Hd);
Den={1};
Gain=getgain(Hd);

See also:

movaver / firwin / firarb / firkaiserfirgaussfirlp2notchsavgolaydiff