I have a piece of raw accelerometer data consisted of 10,000 samples to be processed offline. Since the movement or rotation of the object is moderately slow and smooth, I would think that I can apply a strong filter to filter out as much noise as I could, and if necessary, I can re-apply the same filter to the already filtered data to further smoothen the curve.
I tested out a moving average filter by first filtering the raw data before re-filtering the output again (with n=100). As expected, the first filtering removes a significant amount of noise; the second filtering also smoothens the curve further. With MAF, I loose tracking performance so I want to check if a low-pass filter can achieve the same level of noise removal with lesser time delay.
My moving average filter:
% Moving average filter function avg = MAF_IMU(Nsamples,n,x) xbuf = x(1)*ones(n,1); avg = zeros(Nsamples,1); for k=1:Nsamples if(k==1) xbuf = x(1)*ones(n,1); end for m=1:n-1 xbuf(m)=xbuf(m+1); end xbuf(n)=x(k); avg(k) = sum(xbuf)/n; end
I did the same with a LPF. I also applied my $ \alpha $ to be as large as 0.9. A large $ \alpha $ should supposedly put less weight on newer data resulting in a longer time delay in exchange for the better noise filtering. But the result from my LPF is far off from that out of a simple MAF: the first LPF filtering removes so much less noise than that of a MAF. The second LPF filtering barely smoothens the curve, unlike that of a MAF. If I haven't zoomed in far enough, I would notice no difference between the first and second LPF filtering.
My low-pass filter:
% Low-pass filter function [x_est] = LFP_IMU(ALPHA,Nsamples,x) x_est = zeros(Nsamples,1); % initialize estimate prev_x_est = x(1); % initialize previous estimate for k=1:Nsamples if(k==1) prev_x_est = x(1); end x_est(k) = ALPHA*prev_x_est + (1-ALPHA)*x(k); % saved to matrix prev_x_est = x_est(k); % saved for next iteration end
Why couldn't I remove as much noise in a LPF even with a large $ \alpha $? And why couldn't I re-apply the LPF to reduce the noise further?