MATLAB: FFT issue with near 0Hz. Mean subtracted and detrend used.

fftfrequency analysissuspension

As the title states I have subtracted the mean value and the detrend function has been used. This helped a lot, however I still have a spike just after the 0 no matter how many samples I choose and it gets worse with more samples.
My data is from suspension position for a drag car. I thought maybe the inconsistency of equilibrium position through out the run might have had an effect and tried to take samples as it was trundling off the track after the run, but results were not much different.
What can I do to remedy the near 0hz spike besides what has been done? Can some data simply create poor results? Does data that doesn't consistently center around a constant point cause this?
Code is as follows for one suspension corner:
clear all clc
filename = 'Latest Run.xlsx'; sheet = 1; xlRangeRR = 'B2000:B2070'; %xlRangeLR = 'E3:E53'; %xlRangeRF = 'H3:H53'; %xlRangeLF = 'K3:K53';
Fs=50; %Hz Ts=.02; %per sec %length(xlRange) xRR = xlsread(filename,sheet,xlRangeRR); xRR=xRR-mean(xRR); xRR=detrend(xRR); XRR=fft(xRR); abs(XRR); plot(abs(XRR))
70 samples
1000 samples

Best Answer

Eliminating the d-c (or constant) offset by subtracting the mean is a good first step. The detrend function is definitely useful, but not always appropriate for signal processing, and probably not at all for your application. It will not eliminate low-frequency periodic baseline variations. For that, you need a highpass (or better, bandpass) filter. A highpass filter will eliminate the low-frequency baseline variation. A bandpass filter will also eliminate any high frequency noise.
A prototype FIR bandpass filter design (using kaiserord and fir1) is here:
Fs = 44100; % Sampling frequency
fcuts = [10 20 20E+3 21E+3]; % Frequency Vector (Frequencies in Hz) For All Passbands And Stopbands
mags = [0 1 0]; % Magnitude (Defines Passbands & Stopbands)
devs = [0.05 0.01 0.05]; % Allowable Deviations
[n,Wn,beta,ftype] = kaiserord(fcuts,mags,devs,Fs);
n = n + rem(n,2);
hh = fir1(n,Wn,ftype,kaiser(n+1,beta),'scale');
figure(1)
freqz(hh, 1, 2^14, Fs)
Change the frequencies in ‘fcuts’ and sampling frequency (‘Fs’) to be appropriate to your signal. See the documentation for kaiserord (link) for details.
I also suggest that you use the code between the first (top) two plot figures in the fft (link) function. That will help you plot and understand your original and plotted signals.