Smooth a curve using sgolayfilt
20 views (last 30 days)
I would like to smoothen my curve using Savitzky-Golay filtering.That is y = sgolayfilt(x,k,f,w,dim)
1)Can anyone say what is (x,k,f,w,dim) indicates in sgolayfilt smoothing ? (I read the matlab link but didn't understand) (<http://in.mathworks.com/help/signal/ref/sgolayfilt.html>)
I appreciate an answer with an example.
2)My matrix dimension is very big (200000*100),is there any other smoothing method, which someone can use in a simple way
Jan on 31 May 2015
Edited: Jan on 31 May 2015
Your matrix is not "very big" because it matchs in the memory of modern computers without any problems.
The documentation of sgolayfilt is exhaustive. The statement that you did not understand it does not allow to be more precise at any specific point. I'm very sure that you do understand e.g. the first argument, which is simply the input signal. So it would be much more efficient, if you ask a specific question. Repeating the text of the documentation in other words does not seem to be useful. But let me try it:
x: Your signal
k: Order of the polynomial used for smothing, e.g. for 2 a parabola is used.
f: number of points used to fit the local polynomial
w: Optional, used for weighting
dim: If your data is a matrix, you can smooth over the 1st or 2nd dimension
The Savitzki-Goplay filter uses f neighboring elements and fit a polynomial of order k to these points. Then the point at the center of the f pointa is replaced by the value of the polynomial of this point. Therefore the smoothing is stronger for higher f and smaller k.
Example: k=1, f=21: A straight line is fit to neighboring 21 points in a least-square sense. Then the 11th point is replaced by the center of this line. This is performed for each point, except for the margins, where you cannot find 21 neighboring points and a weaker smothing must be applied.
The weighting w can be applied to modify the fit, e.g. to consider the points near to the center with a higher priority.
You will find many other locations in the net where this filtering is explained with examples and animations etc. Simply ask your favorite internet search engine.