Smooth a curve using sgolayfilt
조회 수: 16 (최근 30일)
이전 댓글 표시
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
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
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.
댓글 수: 1
Image Analyst
2015년 5월 31일
Attached see 1D and 2D Savitzky-Golay filter demos.
댓글 수: 2
Salaheddin Hosseinzadeh
2015년 6월 5일
편집: 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
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!