# can't find out the period of my signal

I've a noisy signal, which is the sound of motor with a constant speed, so the sound "should" be periodic, I know that there is a way to use the autocorrelation function to get the period,I did it, but I can't figure out the period. Any idea how to do that bellow the signal and the result of the autocorrelation : the signal

the autocorrelation result :

• If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From Review – MBaz Feb 16 '17 at 18:11

Here's an attempt to do what you need in scilab.

The top plot shows some data that I synthesized. The second plot shows the auto-correlation of the raw data (zoomed in around the central peak of the auto-correlation). The red circles show the peaks found using this find_peaks function.

The final plot shows the difference between all the peak locations. This will be an estimate of the period. Because you're not really guaranteed that the underlying period will be an integer number of samples, you should probably find the mean of these values.

In this case, the "true" period is 1/f0 = 11.191996, and taking diffs = diff(peaks); and then mean(diffs(10:173)) yields 11.195122.

Code below.

N = 1000;
f0 = 0.0893495634;
phi = rand(1,1,'uniform')*2*%pi;
sigma = 0.5;

x = sin(2*%pi*[0:N-1]*f0 + phi) + sigma*rand(1,N,'normal');
XC = xcorr(x);

clf
subplot(311)
plot(x);

subplot(312)
plot(XC);

peaks=peak_detect(XC,0);

plot(peaks,XC(peaks),'ro')

a = get('current_axes');
a.data_bounds=[950 1050 -500 800];

subplot(313)
plot(diff(peaks));


it seems that are you applying some window function in your signal (autocorrelation Plot seems windowed) !

To do its work, split your signal in a constant framed data overlaped or not, apply autocorrelation function:

$$y(k)=\sum_{n=0}^{N-1}x(k) * x(n+k)$$

At the end find the peak position and congrats you found the period !

How do it in matlab here

• No I don't , and talking about peaks wich one do you mean ? – Engine Mar 19 '14 at 20:12
• the peak is the maximum value in your autocorrelation vector ! – ederwander Mar 19 '14 at 20:32
• my period can'T be 10000 my vector has 10000 elements ? – Engine Mar 19 '14 at 20:36
• There does not need to be a window function applied. The standard (biased) autocorrelation estimator will produce a triangular envelope to the autocorrelation. Also, the peak of the auto correlation will always be in the centre, so you need to explain a little more what you mean by "find the peak position". I suspect you mean find the main peak, and then find the next-largest peak closest to it; the distance between the two will be an estimate of the period. – Peter K. Mar 19 '14 at 20:36
• you're right, the plot from @Engine seems be a standard autocorrelantion :-) I did it using matlab here – ederwander Mar 19 '14 at 21:07

My preferred way to figure out the "period" of your signal is to look at the spectrum. It looks like your signal has a strong sinewave with some noise on it. If you take the FFT and plot the magnitude, you'll be able to see what frequencies are strongest (they will probably correspond to the RPM that the motor is running at). The "period" of your signal will be 1 divided by the signal frequency. If you have a 10Hz sinewave, its period will be 0.1 seconds.