How to get period and frequency components of a signal?

64 次查看(过去 30 天)
Hi!
I am not a maths student nor a physics student but I would need some help with understanding an exercise and how I can do it in matlab.
I have a file that contains my signal (sound signal), which I use and load in Matlab. This signal contains "periodic disturbance".
The exercise is: "Determine the period and frequency components of the periodic disturbance."
I don't really understand how to do this, also I don't really understand what the frequency components are?
From what I have understood so far my signal is in the time domain and I can use fft to convert the signal into the frequency domain. If I first do FFT on my signal and the plot it with abs() I can see that same peak occurs twice, but I am probably thinking of this all wrong? Since comparing the peaks in the abs FFT graph would just be comparing the frequency between those intensities?
This is my code so far
% Ex 1B
% Load the file
load("xp.dat");
f_s = 8192; %sample frequency
%Fast fourier transform the signal
XP = fft(xp);
%Plot original signal using abs() to see the peaks
figure('Name','Original version','NumberTitle','off');
plot(abs(XP))

回答(1 个)

Star Strider
Star Strider 2019-9-12
A one-sided Fourier transform is a bit easier to interpret:
% Ex 1B
% Load the file
load("xp.dat");
f_s = 8192; %sample frequency
f_n = f_s/2; % Nyquist Frequency
%Fast fourier transform the signal
L = numel(xp); % Assumes ‘xp’ Is A Vector
XP = fft(xp)/L; % Normalised Result
Fv = linspace(0, 1, fix(L/2)+1)*f_n; % Frequency Vector (One-Sided Transform)
Iv = 1:numel(Fv); % Index Vector
figure
plot(Fv, abs(XP(Iv))*2)
grid
The easiest way to determine the frequencies is to use the Signal Processing Toolbox findpeaks funciton with the Fourier transform. This will give you to peak amplitudes and frequencies. From those you can determine the period.
This is all in the online documentation for fft, and findpeaks has several name-value pair arguments to allow you to specify what it returns. I am simply making it a bit easier for you to find.
  10 个评论
Matheos Mattsson
Matheos Mattsson 2019-9-15
Thanks again! My mistake not including the abs(). I don't quite understand the one-sided FFT though and at least for the moment find the version I am using, less confusing :P
Star Strider
Star Strider 2019-9-15
My pleasure!
The result produced by the fft function is a two-sided Fourier transform, defined on frequencies from -Fn to +Fn (where ‘Fn’ is the Nyquist frequency). For this reason, it is best displayed after using the fftshift function.
The one-sided fft uses on the positive frequencies (from 0 to +Fn). It tends to be easier to understand and work with. And since you are getting the peaks, it will return only one at each frequency, rather than two — one each at the postive frequencies and one each at the negative frequencies.

请先登录,再进行评论。

类别

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