필터 지우기
필터 지우기

FFT: Detrend not removing 0 Hz component?

조회 수: 2 (최근 30일)
Desiree Phillips
Desiree Phillips 2013년 4월 15일
댓글: Wayne King 2013년 12월 30일
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
Wayne King
Wayne King 2013년 12월 30일
Can you attach the data, or is it too big? How about just one column.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by