fft: significant peak in 0 Hz component

59 visualizaciones (últimos 30 días)
Ashkan
Ashkan el 4 de Abr. de 2014
Editada: Ashkan el 13 de Abr. de 2014
I'm recently dealing with a problem about finding the frequencies of a data vector using fft. I've read in some sources that the 0 Hz component comes from the mean so I need to detrend the data.but there is no visible change in my output. the 0 Hz component still dominates significantly. If it helps, the vector contains velocity values over time and MY SAMPLE FREQUENCY IS 1HZ. (I've attached my sample data)
load file.txt;
Data=file(:,2);
Time=file(:,1);
N = length(Data(:,1));
Ts = 1;
W = 0:2*pi/N:2*pi*(1-1/N);
X = W / Ts;
Data=Data-mean(Data);
Fx = fft(Data);
plot(X,abs(Fx));ylabel('fft of V_x');xlabel('Ferq(HZ)')

Respuestas (3)

Greg Heath
Greg Heath el 4 de Abr. de 2014
One of the basic assumptions is that that your data is a finite window sample of an infinitely periodic function. Very often there is a polynomial trend to the data which violates this assumption. The function detrend can, in general, remove linear trends
help detrend
doc detrend
However, sometimes I find it necessary to remove quadratic trends (especially in the acceleration data of a tumbling and spinning radar target which is undergoing gravitational acceleration).
Sometimes you can plot and "see" a polynomial trend. Sometimes looking at the differences in the plots and spectra of x, diff(x) and diff(diff(x) are helpful.
I have never dealt with a trend higher than quadratic.
The importance of removing significant trends is that their spectral sidelobes contaminate, often overwhelmingly, the low frequency spectra of the true periodic components.
Hope this helps.
Greg

Carlos
Carlos el 4 de Abr. de 2014
Editada: Carlos el 4 de Abr. de 2014
From your code and the file uploded I can see ypur sampling frequency is 1000 Hz and you are trying to represent frequencies up to 6000Hz.
>> NFFT = 2^nextpow2(N); % Next power of 2 from length of y
Y = fft(Data,NFFT)/N;
f = (1/Ts)/2*linspace(0,1,NFFT/2+1);
% Plot single-sided amplitude spectrum.
plot(f,2*abs(Y(1:NFFT/2+1)))
title('Single-Sided Amplitude Spectrum of y(t)')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')
The DC component has disappeared as you can see in the attached file
  5 comentarios
Carlos
Carlos el 4 de Abr. de 2014
I have thought about aliasing too, but aliasing tends to appear in spectrum as distortion at frequencies close to the maximum frequency of the signal.
Aliasing appears because the effects of sampling in frequency spectrum are scaling and periodic repetition of the spectra. The problem comes when the periodic repetitions intersect. That happens if the the maximum frequency of the signal W satisfies W<fs-W.From this we can infere that the lowest aliased frequency is fs-W, which is not close to 0.
Ashkan
Ashkan el 13 de Abr. de 2014
Today I found out my sample frequency is 1Hz. do you think it helps ?

Iniciar sesión para comentar.


Carlos
Carlos el 4 de Abr. de 2014
Editada: Carlos el 4 de Abr. de 2014
You are right, the 0 Hz component is DC mean component
Try something like
x=x-mean(x);
y = detrend(x,'constant')
And see what happens with your fft.
Are you sure you are plotting and calculating your fft correctly?
  1 comentario
Ashkan
Ashkan el 4 de Abr. de 2014
Editada: Ashkan el 4 de Abr. de 2014
Thanks for your answer Alex. I've tried both codes you mentioned but no visible change happened. Here is my code: (I've attached my sample data)
load file.txt;
Data=file(:,2);
Time=file(:,1);
N = length(Data(:,1));
Ts = 10^-3;
W = 0:2*pi/N:2*pi*(1-1/N);
X = W / Ts;
Data=Data-mean(Data);
Fx = fft(Data);
plot(X,abs(Fx));ylabel('fft of V_x');xlabel('Ferq(HZ)')

Iniciar sesión para comentar.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by