View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Savitzky-Golay Smoothing Filter

Be the first to rate this file! 30 Downloads (last 30 days) File Size: 1.75 KB File ID: #45420 Version: 1.2
image thumbnail

Savitzky-Golay Smoothing Filter



06 Feb 2014 (Updated )

Very simple function for Savitzky-Golay Smoothing

| Watch this File

File Information

After looking at a lot of the Savitzky-Golay implementations on File Exchange, I could not find one as simple but as effective as this one. savGol is from the Book, "Solving Problems in Scientific Computing Using Maple and Matlab" by Walter Gander and others. Gander cites Teukolsky from Computers in Physics from 1990. Here is a link to the book website:
g = savGol(f, nl, nr, M)

f: noisy data

nl: number of points to left of reference point

nr: number of points to right of reference point

M: Order of least squares polynomial

x = [0:1000-1]'/(1000-1);
signal = exp (- 100*(x - 1/5).^2) + exp (- 500*(x - 2/5).^2) + exp (-2500*(x - 3/5).^2) + exp (-12500*(x - 4/5).^2);
randn ('seed', 0);
noisySignal = signal + 0.1* randn (size (x));

smoothSignal = savGol(noisySignal, 16, 16, 4);

hold on;
plot(x, smoothSignal,'r','LineWidth',3)
legend('Noisy Signal', 'Smooth Signal')

Required Products MATLAB
MATLAB release MATLAB 8.2 (R2013b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (1)
07 Jan 2017 Roberto Paolinelli

Hi Jason,
very good job!
I need to filter with an asymmetrical window and that fits for me.
But I also need 1st derivative of smoothed signal.
Using diff operator does not produce good results compared to using differentiator coefficients as explained in sgolay help.
But sgolay is for symmetrical windows... :(

Thanks a lot
Best Regards

Comment only
06 Feb 2014 1.1

Change MATLAB version information.

16 Jun 2014 1.2

Changed to the economy QR decomposition when calling QR. This increases speed and allows calculating more coefficients for the same amount memory.

Contact us