Smooth a curve using sgolayfilt

16 次查看(过去 30 天)
navan
navan 2015-5-31
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
  3 个评论
navan
navan 2015-5-31
Dear Salaheddin, I am talking about a matrix of data(not image). can you now say me what is the meaning of sgolayfilt(x,k,f,w,dim) now?
Image Analyst
Image Analyst 2015-5-31
What does that mean? The meaning is that that expression is a function call to smooth x. k is the polynomial order, and f is the window width. You can ignore the other two. Did you see my answer? Just play around with the parameters and learn how their values affect the output signal.

请先登录,再进行评论。

回答(2 个)

Jan
Jan 2015-5-31
编辑:Jan 2015-5-31
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:
sgolayfilt(x,k,f,w,dim)
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.

Image Analyst
Image Analyst 2015-5-31
  2 个评论
Salaheddin Hosseinzadeh
编辑:Salaheddin Hosseinzadeh 2015-6-5
Like always I become the beneficiary!
Thanks for sharing Image Analyst.
I wish we could directly download the files, rather than view them in the browser and and copy paste them. That's how it works for me at least.
Image Analyst
Image Analyst 2015-6-5
I agree. Also nice would be a button on code blocks in the answers where we could click it and all the code in the code block would go into the clipboard, and then we could simply go to MATLAB and paste it in. It would make it easier to test code that people posted.

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by