How to get period and frequency components of a signal?

57 views (last 30 days)
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))

Answers (1)

Star Strider
Star Strider on 12 Sep 2019
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 Comments
Star Strider
Star Strider on 15 Sep 2019
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.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!