How to find period of a signal using fft?

117 Ansichten (letzte 30 Tage)
Chatzistylianos Evangelos
Chatzistylianos Evangelos am 17 Jan. 2021
Kommentiert: Sam Pasti am 20 Mär. 2022
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.

Akzeptierte Antwort

Star Strider
Star Strider am 17 Jan. 2021
Bearbeitet: Star Strider am 12 Jan. 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 Kommentare
Qifa
Qifa am 12 Jan. 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 am 20 Mär. 2022
Code returns period as Perd as a vector, what then is the actually period? sorry if this is obvious. Thanks

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by