I used median filtering in Matlab to reduce noise in arrays. I was calculating the velocity and acceleration of an object. The velocity part worked fine, and the result I got was exactly what I expected.
I stumbled in to problems regarding the acceleration. I noticed the acceleration was not behaving well; I noticed rectangular shapes instead of the expected smooth shapes.
The plot for acceleration should be a sinusoidal wave for cam and follower in an engine but the problem is that the edges of the wave are not smooth but in form of straight lines.
For velocity I used vavg=medfilt2(v, [1 5])
For accel I used aavg=medfilt2(a, [1 5 ])
Is there any other filter that I should use to get accurate edges?
Are there other filter functions that could be useful?
Taking the derivative of something amplifies the noise, so it's not surprising that you're having problems when you're looking at the acceleration of a signal. You can use a noise-resistant method for taking the derivative. See this page for details:
It sounds like people use Savitz-Golay filters for this frequently - try the sgolay
and sgolayfilt
functions in Matlab.
In general, though, you should think about the characteristics of your signal and your noise. If you know that the signal is going to be something really smooth, then why not approximate it first enforcing its smoothness? It seems like splines could be appropriate for you (spline
in matlab).