user2264645
user2264645

Reputation: 1

extracting frequency of signal from FFT

I am new to Matlab and FFT.
I need to extract the dominant frequency from a signal which is varying in magnitude and frequency. I tried to perform a detrend and then an FFT to obtain the frequency but couldn't get rid of the large peak at 0Hz (DC component?). I used diff function on the signal and the resulting signal was processed through FFT. In this case, the FFT output didn't have the peak at zero. I compared the two FFT curves and it seems that except the peak at zero, the two show similar (not same) spectrum. I am wondering if diff function is a valid (and very effective) detrending method or am I losing some information here? In other words, does differentiating a signal have any effect on its frequency: [diff(sin(omega.t))= cos(omega.t) - no change in frequency]?

Thanks a lot!

Upvotes: 0

Views: 3913

Answers (2)

Chris Taylor
Chris Taylor

Reputation: 47392

The discrete fourier transform X of a signal x is defined (up to scaling) by

X(k) = Sum[ exp(2*pi*i*k*n/N) * x(n) ]

If we take first differences of the signal you get

Sum[ exp(2*pi*i*k*n/N) * (x(n) - x(n-1)) ]

which you can rearrange to give

(1 - exp(2*pi*i*k/N)) * Sum[ exp(2*pi*i*k*n/N) * x(n) ]

i.e. it is a multiple of the original fourier transform. In the k = 0 case (i.e. the zero frequency component) the multiplier is zero, which explains why this removes the spike at k = 0.

Note however that the multiplier depends on the value of k, so you won't get the same signal out - you can't just take first differences to remove a spike. There is a comparison to be made with the continuous fourier transform, where if g = F(f) and h = F(df/dx) then

h(k) = i * k * g(k)

i.e. the fourier transform of the derivative is the fourier transform of the original function, multiplied by ik.

Upvotes: 1

BioSP
BioSP

Reputation: 518

By differentiating the signal you actually apply a a type of a highpass filter, a not so smart highpass which corrupts your signal. Instead you could try some other filter such as the following:

b=fir1(32,2*0.01/fs,'high');
a=1;
FilteredX=filtfilt(x,a,b)

where:

x is your original signal,

FilteredX is the filtered signal.

fs - your sample frequency.

This way you will filter out any frequencies lower then 0.01 and will almost not hurt the rest of the spectrum allowing you to detect peaks as you wished.

Upvotes: 2

Related Questions