MATLAB: How to find period of a signal using fft

finding periodfourier transformationsignal period

I have a strange signal which looks like this:
I got it in a form of a matrix (a=[value,value,value,…..])
The x-axis represents time per hour for one year (8760 hours)
As you can see, this is a periodical function with a lot of noise. I need to find the period of that function!
I've seen that using fourier transformation is the best way, but I can not find out how to use it correctly.
If anybody has an idea, i would be greatful to know it! Using fourier transformation isn't necessary.
Thank you in advance.

Best Answer

Prototype fft code:
t = ...; % Time Vector
s = ...; % signal Vector
L = numel(t); % Signal Length
Ts = mean(diff(t)); % Sampling Interval
Fs = 1/Ts; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
FTs = fft(s)/L; % Normalised Fourier Transform
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:numel(Fv); % Index Vector
figure
plot(Fv, abs(FTs(Iv))*2)
grid
title('Fourier Transform')
xlabel('Frequency (units)')
ylabel('Amplitude (units)')
To calculate the period (the inverse of frequency) of a signal:
[pks,locs] - findpeaks(abs(FTs(Iv)));
Perd = 1./Fv(locs);
I did not test this, however that should work. The units are the inverse of the frequency units, so if the frequency is in Hz, the period will be in seconds/cycle.