Filter löschen
Filter löschen

FFT: Detrend not removing 0 Hz component?

2 Ansichten (letzte 30 Tage)
Desiree Phillips
Desiree Phillips am 15 Apr. 2013
Kommentiert: Wayne King am 30 Dez. 2013
I have a data vector that I am trying to use fft on. I've read in other answers that the 0 Hz component comes from the mean so I need to detrend the data. The following lines should work:
detrend(data,0) or detrend(data,'constant')
but there is no visible change in my output: the 0 Hz component still dominates significantly. If it helps, the vector contains electrical grid frequency values over time. Here is my code:
% FFT Variable Initializations
Fs = 10; % 10 Hz sampling frequency
[nrows,ncols]=size(data); % Data size
NFFT = 2^nextpow2(nrows); % Next power of 2 from nrows of data
% Perform FFT Analysis on each column
linespec = {'r' 'g' 'b' 'c' 'm' 'y' 'k' '-k'};
for i =1:length(linespec)
% Detrend the data
dtr_data = detrend(data(~isnan(data(:,i)),i),'constant');
% Perform FFT on detrended data
fft_data = fft(dtr_data,NFFT)/nrows;
f = Fs/2*linspace(0,1,NFFT/2+1);
plot(f,2*abs(fft_data(1:NFFT/2+1)),linespec{i})
hold on
end
Thanks in advance for all the help.
  1 Kommentar
Wayne King
Wayne King am 30 Dez. 2013
Can you attach the data, or is it too big? How about just one column.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Fourier Analysis and Filtering finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by