Smooth a curve using sgolayfilt
17 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Image Analyst
el 31 de Mayo de 2015
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.
Respuestas (2)
Jan
el 31 de Mayo de 2015
Editada: Jan
el 31 de Mayo de 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:
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 comentario
Image Analyst
el 31 de Mayo de 2015
Attached see 1D and 2D Savitzky-Golay filter demos.
2 comentarios
Salaheddin Hosseinzadeh
el 5 de Jun. de 2015
Editada: Salaheddin Hosseinzadeh
el 5 de Jun. de 2015
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
el 5 de Jun. de 2015
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.
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!