diff(x) is different to diff(fit)

Technical Source
2 min readFeb 5, 2021

--

Hi there. I have got some data from a wheel speed sensor on a motorcycle and i am trying to process it to get the driving force. This is simple as it just requires F=ma after deriving acceleration but the noise in the data makes it very difficult. The onboard computer is sampling every 100Hz and is varying only small amounts but when i differentiate it it gives a correct but useless graph of the acceleration against time after plotting it.

I have tried smoothing the data using smooth(v,50) which gives a more general trend but when differentiating it, it gives accelerations of around 0.4m/s². however if i curve fit the time vs velocity data after smoothing and differentiate the cfit then it gives me acceleration values of around 2–10 m/s² which is what is expected and backed up by the accelerometers.

So why is differentiating the fit different to differentiating the data? is it because it is differentiating from data point to data point? What can i do to fix this?

ANSWER

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

Differentiation has the effect of high-pass filtering your data. This amplifies the noise, because the step-by-step differences produced by the diff function include the differences of the noise. Doing the fit first essentially low-pass filters your data, eliminating much of the noise and the noise effects), so the numerical derivative is of the ‘de-noised’ signal.

To determine if your noise is largely band-limited, use the fft (link) function. If it is, you might be able to get the same result by first using a lowpass filter (instead of doing the fit), and then taking the derivative of the filtered data. A Savitzky-Golay filter (the sgolayfilt (link) function) is another option.

--

--

Technical Source
Technical Source

Written by Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.

No responses yet