How to find period of a signal using fft?

115 次查看(过去 30 天)
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.

采纳的回答

Star Strider
Star Strider 2021-1-17
编辑:Star Strider 2022-1-12
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 个评论
Qifa
Qifa 2022-1-12
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 2022-3-20
Code returns period as Perd as a vector, what then is the actually period? sorry if this is obvious. Thanks

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Spectral Measurements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by