Savitzky-Golay smoothing and differentiation filter (closed-formed solutions)

explicit (closed-formed) solutions of the Savitzky-Golay smoothing and differentiation filter
2.4K Downloads
Updated 15 Oct 2004

No License

Obtain the explicit (closed-formed) solutions of the Savitzky-Golay smoothing and differentiation filter using the Gram polynomials.

Here only the filters for the central point (midpoint) are considered. However, the solutions for the initial or end points can be easily obtained by slightly revising the rounte.

Input:
n: polynomial degree
s: derivative(differentiation) order (0=smoothing)

Output:
h: filter coefficients(convoluction weights)
it is a closed-formed formula with the following parameters:
i:
2*m+1: data point number
i: convolution weight of the i-th point (-m<=i<=m)

Author:
Jianwen Luo,Ph.D Candidate
Email:luojw@bme.tsinghua.edu.cn, luojw@ieee.org
Date: Oct 14,2004
Department of Biomedical Engineering
Tsinghua University, Beijing 100084, P. R. China

References:
[1]A. Savitzky and M. J. E. Golay, "Smoothing and Differentiation of Data by Simplified Least Squares Procedures," Analytical Chemistry, vol. 36, pp. 1627-1639, 1964.
[2]P. A. Gorry, "General Least-Squares Smoothing and Differentiation by the Convolution (Savitzky-Golay) Method," Analytical Chemistry, vol. 62, pp. 570-573, 1990.
[3] H. H. Madden, "Comments on Savitzky-Golay Convolution Method for Least-Squares Fit Smoothing and Differentiation of Digital Data," Analytical Chemistry, vol. 50, pp. 1383-1386, 1978.

Examples:
for n=0:5 %Equ. I-II in Ref. [3]
s=0;
disp(sprintf('%d-th th polynomial,%d-th derivatie:',n,s));
sgsdf_explicit(n,s)
disp('press any key to continue...');
pause
end

for n=1:6 %Equ. III-V in Ref. [3]
s=1;
disp(sprintf('%d-th th polynomial,%d-th derivatie:',n,s));
sgsdf_explicit(n,s)
disp('press any key to continue...');
pause
end

for n=2:6 %Equ. VI-VII in Ref. [3]
s=2;
disp(sprintf('%d-th th polynomial,%d-th derivatie:',n,s));
sgsdf_explicit(n,s)
disp('press any key to continue...');
pause
end

for n=3:6 %Equ. VIII-IX in Ref. [3]
s=3;
disp(sprintf('%d-th th polynomial,%d-th derivatie:',n,s));
sgsdf_explicit(n,s)
disp('press any key to continue...');
pause
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Note the typo in Equ. IX of Ref. [3].
The term -50m should read +50m.
See http://listserv.umd.edu/cgi-bin/wa?A2=ind0201&L=ics-l&F=&S=&P=2994
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

for n=4:5 %Equ. X in Ref. [3]
s=4;
disp(sprintf('%d-th th polynomial,%d-th derivatie:',n,s));
sgsdf_explicit(n,s)
disp('press any key to continue...');
pause
end

for n=5:6 %Equ. XI in Ref. [3]
s=5;
disp(sprintf('%d-th th polynomial,%d-th derivatie:',n,s));
sgsdf_explicit(n,s)
disp('press any key to continue...');
pause
end

Cite As

Jianwen Luo (2024). Savitzky-Golay smoothing and differentiation filter (closed-formed solutions) (https://www.mathworks.com/matlabcentral/fileexchange/6047-savitzky-golay-smoothing-and-differentiation-filter-closed-formed-solutions), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R14SP1
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0