Zero out sensor drift
10 views (last 30 days)
Show older comments
I am trying to write some signal processing code and am noticing some load cell drift over time. I feel like I should be able to take the dft, throw out the zero frequency term, then take the inverse dft of the signal to account for this. Another way of saying this is can I use the fftshift command for the y axis (of a load vs. time signal) instead of the x axis?
0 Comments
Answers (2)
Walter Roberson
on 18 Aug 2021
Taking the dft, throwing out the zero frequency, and then taking the inverse dft, is equivalent (to within round-off error) to subtracting mean() of the signal from the original signal -- unless, that is, your number of points for the fft or ifft is not the same as the original number of points.
N = 100;
t = 1 : N;
A = randn(1,N);
B = A - mean(A);
Af = fft(A);
Af(1) = 0;
Arec = ifft(Af);
max(abs(B - Arec))
plot(t, B, '-k', t, Arec, 'b.--');
legend({'A minus mean', 'reconstructed via ifft'})
You cannot see the black line (A minus mean) because the reconstructed line (zero fft bin) is identical to within round-off.
Star Strider
on 18 Aug 2021
If you have R2018a or later, use the highpass function to eliminate both the d-c offset and any low-frequency baseline drift. Ideally, take the fft of the signal first to see what the best cutoff frequency is, and also to determine if there are signal components of sufficiently low frequency that filtering would not be appropriate, since it could eliminate parts of them. In that instance the detrend function would be the best option.
.
0 Comments
See Also
Categories
Find more on Fourier Analysis and Filtering in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
