y = sgolayfilt (x, p, n [, m [, ts]]) Smooth the data in x with a Savitsky-Golay smoothing filter of polynomial order p and length n, n odd, n > p. By default, p=3 and n=p+2 or n=p+3 if p is even. y = sgolayfilt (x, F) Smooth the data in x with smoothing filter F computed by sgolay. These filters are particularly good at preserving lineshape while removing high frequency squiggles. Particularly, compare a 5 sample averager, an order 5 butterworth lowpass filter (cutoff 1/3) and sgolayfilt(x, 3, 5), the best cubic estimated from 5 points: [b, a] = butter(5,1/3); x=[zeros(1,15), 10*ones(1,10), zeros(1,15)]; plot(sgolayfilt(x),"r;sgolayfilt;",... filtfilt(ones(1,5)/5,1,x),"g;5 sample average;",... filtfilt(b,a,x),"c;order 5 butterworth;",... x,"+b;original data;"); See also: sgolay