# Frequency of a periodic signal with distortions

I would like to evaluate frequency of some unstable periodic signal coming from a detector:

The signal is registered continuously and may or may not be present (i.e. be periodic). The frequency and amplitude of the periodic signal can change but stays in some certain range. The shape of the periodic signal is more or less the same as shown on the second image. It may sometimes have distortions of higher amplitude and frequency.

I need to check 1) if there is a periodic signal and 2) what frequency it has.

Is there any good way to do it?

## Edit 1:

I am not sure if FFT is reliable in this case. What do you think?

Frequency spectrum for all data points:

Spectrum with last 512 points

The spectra were calculated using Octave (online) based on example from Matlab site

N = 512; % length(all_data)
x = all_data(1:N);
Fs = N;
xdft = fft(x);
xdft = xdft(1:N/2+1);
psdx = (1/(Fs*N)).*abs(xdft).^2;
psdx(2:end-1) = 2*psdx(2:end-1);
freq = 0:Fs/length(x):Fs/2;
plot(freq,10*log10(psdx));

-
try to fourier transform it and see if there is a stronger harmonic or it has different contributions of the same amplitude –  Nivalth Jan 17 at 9:49
Yes, that was my first idea too, but it doesn't look so good (see updated question). I could probably get better spectrum knowing signal frequency range... –  Andrei Jan 17 at 10:43
There seem to be some frequency components in the range 20-60 on your first plot. You could try a bit of frequency domain averaging to see if it makes them any clearer. –  twistor59 Jan 17 at 12:53
Lookup "peridogram" –  daaxix Jan 18 at 20:34

Yes, Fourier transforming the data is certainly the best way of finding what the frequency of the periodic signal is.

I'm not sure what the units of the y axis are on your graph above - it looks like the might be in dB. Change the scale to linear (not logarithmic) and you should see much, much clearer indications of what the frequency is (if it exists).

Finally, you might also benefit from multiplying your raw data by a window function before the Fourier transform (see this: http://en.wikipedia.org/wiki/Window_function). I'm not exactly sure how sensitive your results will be to it, but it's worth examining quickly at least. Doing so basically reduces the effects of not having an infinitely long data set to do the transform with.

-