| Signal Processing Toolbox | ![]() |
Syntax
Description
y applies a Savitzky-Golay FIR smoothing filter to the data in vector = sgolayfilt(x,k,f)
x. If x is a matrix, sgolayfilt operates on each column. The polynomial order k must be less than the frame size, f, which must be odd. If k = f-1, the filter produces no smoothing.
y specifies a weighting vector = sgolayfilt(x,k,f,w)
w with length f, which contains the real, positive-valued weights to be used during the least-squares minimization. If w is not specified or if it is specified as empty, [], w defaults to an identity matrix.
y specifies the dimension, = sgolayfilt(x,k,f,w,dim)
dim, along which the filter operates. If dim is not specified, sgolayfilt operates along the first non-singleton dimension; that is, dimension 1 for column vectors and nontrivial matrices, and dimension 2 for row vectors.
Remarks
Savitzky-Golay smoothing filters (also called digital smoothing polynomial filters or least-squares smoothing filters) are typically used to "smooth out" a noisy signal whose frequency span (without noise) is large. In this type of application, Savitzky-Golay smoothing filters perform much better than standard averaging FIR filters, which tend to filter out a significant portion of the signal's high frequency content along with the noise. Although Savitzky-Golay filters are more effective at preserving the pertinent high frequency components of the signal, they are less successful than standard averaging FIR filters at rejecting noise.
Savitzky-Golay filters are optimal in the sense that they minimize the least-squares error in fitting a polynomial to frames of noisy data.
Examples
Smooth the mtlb signal by applying a cubic Savitzky-Golay filter to data frames of length 41:
load mtlb % Load the data.
smtlb = sgolayfilt(mtlb,3,41);% Apply the 3rd-order filter.
subplot(2,1,1)
plot([1:2000],mtlb(1:2000)); axis([0 2000 -4 4]);
title('mtlb'); grid;
subplot(2,1,2)
plot([1:2000],smtlb(1:2000)); axis([0 2000 -4 4]);
title('smtlb'); grid;
See Also
medfilt1, filter, sgolay, sosfilt
References
[1] Orfanidis, S.J., Introduction to Signal Processing, Prentice-Hall, Englewood Cliffs, NJ, 1996.
| sgolay | sigwin | ![]() |
© 1994-2005 The MathWorks, Inc.