fft: significant peak in 0 Hz component

조회 수: 108 (최근 30일)
Ashkan
Ashkan 2014년 4월 4일
편집: Ashkan 2014년 4월 13일
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)')

답변 (3개)

Greg Heath
Greg Heath 2014년 4월 4일
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 2014년 4월 4일
편집: Carlos 2014년 4월 4일
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
Carlos
Carlos 2014년 4월 4일
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 2014년 4월 13일
Today I found out my sample frequency is 1Hz. do you think it helps ?

댓글을 달려면 로그인하십시오.


Carlos
Carlos 2014년 4월 4일
편집: Carlos 2014년 4월 4일
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
Ashkan
Ashkan 2014년 4월 4일
편집: Ashkan 2014년 4월 4일
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)')

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Signal Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by