How to find period of a signal using fft?
116 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Chatzistylianos Evangelos
il 17 Gen 2021
Commentato: Sam Pasti
il 20 Mar 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.
0 Commenti
Risposta accettata
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 ‘=’).
.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Spectral Measurements in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!