sgolay
Savitzky-Golay filter design
Description
Examples
Input Arguments
Output Arguments
Algorithms
Savitzky-Golay filters are used to smooth out noisy signals with a large frequency span. Savitzky-Golay smoothing filters tend to filter out less of the signal's high-frequency content than standard averaging FIR filters. However, they are less successful at rejecting noise when noise levels are particularly high.
In general, filtering consists of replacing each point of a signal by some combination of the signal values contained in a moving window centered at the point, on the assumption that nearby points measure nearly the same underlying value. For example, moving average filters replace each data point with the local average of the surrounding data points. If a given data point has k points to the left and k points to the right, for a total window length of L = 2k + 1, the moving average filter makes the replacement
Savitzky-Golay filters generalize this idea by least-squares fitting an nth-order polynomial through the signal values in the window and taking the calculated central point of the fitted polynomial curve as the new smoothed data point. For a given point, xs,
or, in terms of matrices,
To find the Savitzky-Golay estimates, use the pseudoinverse of H to compute a and then premultiply by H:
To avoid ill-conditioning, sgolay
uses the qr
function to compute an economy-size decomposition of H as H = QR, in terms of which B = QQT.
It is necessary to compute B only once. The Savitzky-Golay estimates for most signal points result from
convolving the signal with the center row of B. The result is the steady-state portion of the filtered signal. The first
k rows of B yield the initial transient, and the final k rows of B yield the final transient. See sgolayfilt
for an example. It is possible to improve noise suppression by
increasing the window length, but this introduces ringing analogous to the Gibbs phenomenon
near any transients.
References
[1] Orfanidis, Sophocles J. Introduction to Signal Processing. Englewood Cliffs, NJ: Prentice Hall, 1996.
[2] Press, William H., Saul A. Teukolsky, William T. Vetterling, and Brian P. Flannery. Numerical Recipes in C: The Art of Scientific Computing. New York: Cambridge University Press, 1992.
[3] Schafer, Ronald W. “What Is a Savitzky-Golay Filter? [Lecture Notes].” IEEE Signal Processing Magazine Vol. 28, Number 4, July 2011, pp. 111–117. https://doi.org/10.1109/MSP.2011.941097.
Extended Capabilities
Version History
Introduced before R2006a