How to find period of a signal using fft?

116 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Star Strider
Star Strider il 17 Gen 2021
Modificato: Star Strider il 12 Gen 2022
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.
EDIT — (12 Jan 2021 at 18:40)
Corrected typographical error (replaced ‘-’ in findpeaks call line with ‘=’).
.
  4 Commenti
Qifa
Qifa il 12 Gen 2022
I couldn't run this line due to unknown variable of pks. I wanted to find period of the signal.
[pks,locs] - findpeaks(abs(FTs(Iv)));
Sam Pasti
Sam Pasti il 20 Mar 2022
Code returns period as Perd as a vector, what then is the actually period? sorry if this is obvious. Thanks

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by