Fourier Transform peaking at 0

I have the following code that finds the FFT of a complex, time-dependent astronomical signal. "FileArr" is an array I've used to store several signal files.
NumVec = [69, 70, 86, 87, 88, 93, 98, 99]; %not important here - for naming figures only
L = 4096; %number of entries in each raw signal
NFFT = 1024;
test_freq = 29.9396258
fs = 1000; %sampling frequency
t_int = 10.24; %time interval, in seconds
time = (0:t_int:L*t_int - 1); %time axis
for count = 1:length(NumVec)
x = abs(FileArr(:,count));
%plotting raw data against time
subplot(2,1,1)
plot(time,x); %plot graph
fVals=fs*(0:NFFT/2 - 1)/NFFT; %time transform
%plotting FT
X = fft(x, NFFT);
PX = X.*conj(X)/(NFFT*L);
subplot(2,1,2)
plot(fVals,PX(1:NFFT/2));
%saving graphs
name = sprintf('AbsCombT486%d', NumVec(count));
saveas(gcf, name);
end
Every graph is peaking at 0 Hz and not ~30, as expected. Would be grateful for an explanation as to why this is happening, and a solution. Thanks.

Answers (1)

The 0 Hz signal is a constant (or d-c) offset. Changing your fft call to:
X = fft(x-mean(x), NFFT);
will remove the constant offset. (This works for ‘x’ as a vector or matrix.)

Categories

Find more on Fourier Analysis and Filtering in Help Center and File Exchange

Asked:

on 31 Jan 2017

Answered:

on 31 Jan 2017

Community Treasure Hunt

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

Start Hunting!