Synthesis Equation Analysis Equation
Final Project Fall 2021 Part 1: Fourier Series Analysis of the Signal
Explaining FFT in Matlab
Synthesis Equation Analysis Equation
Continuous Time Fourier Series
π(π) = π(π + π»)
= β πππππ(
ππ
π» )π
+β
π=ββ
ππ = β« π(π)πβππ(
ππ
π» )ππ
π
π»
Discrete Time Fourier Series
π[π] = π[π + π΅]
= β πππππ(ππ
/π΅)π π=<π΅>
ππ =
π π΅
β π[π]πβππ(
ππ
π΅ )π
π=<π΅>
In Matlab, there are commands fft(x) and ifft(X) that performs Discrete Fourier Transform (DFT) and inverse DFT.
- Unfortunate naming history: DFT is NOT DTFT (discrete time Fourier Transform). It is rather a numerically method that performs fast Fourier Transform (fft) so that Fourier Series coefficient of a (periodic) signal (sequence) can be obtained. We can thus use these commands to compute ππ with the given the x[n].
- In MATLAB a signal can only be stored in discrete in nature. So the analysis is based on Discrete Time Fourier Series (DTFS) analysis.
- In MATLAB DFT analysis, we treat the signal duration N as the fundamental period. So fundamental frequency or frequency resolution is given by ππ Μ = 2π π or π π Μ = 1 π .
- In MATLAB a vector starts with index 1.
- Fourier Series coefficients are periodic with N, and Matlab outputs N coefficients. You can use one-sided spectrum (take the first π/2) or two-sided spectrum (the last π/2 coefficients are the same as the negative frequenciesβ coefficients). You can use command fftshift for the purpose of re-arranging needed in two-sided spectrum representation.
- The scaling definition in MATLAB is not the same as how we define our FS coefficients (see table) for a discrete time sequence. So, you must take care of the scaling for fft and ifft to match the definition in the table.
- To conveniently plot the two-sided spectrum, we provide fdomain.m and tdomain.m. The script fdomain.m is a function that takes a time-domain sequence, and output/plot
the two-sided spectrum of the signal in the frequency domain. The script tdomain.m can be used to reconstruct the time domain sequence from a given set of coefficients.
function [X,f]=fdomain(x,Fs) % FDOMAIN computes the Fourier coefficients from vector x % and the corresponding frequencies (two-sided) % usage: [X,f]=fdomain(x,Fs) N=length(x); if mod(N,2)==0 k=-N/2:N/2-1; % N even else k=-(N-1)/2:(N-1)/2; % N odd end T=N/Fs; f=k/T; %create a vector for two sided frequencies (for the given resolution) X=fft(x)/N; X=fftshift(X); - DFT/FFT implies the periodic assumption during the analysis. In order to avoid artificial frequency due to discontinuity of the beginning of the data and end of the data, a window often times are multiplied to taper off the large jump in the edge. A Hanning window is a commonly used window [2]. You may want to use this in your data spectrum analysis.
w = hann(L)
w = hann(L) returns an L-point symmetric Hann window in the column vector w. L must be a positive integer. The coefficients of a Hann window are computed from the following equation.
π€[π] = 0.5(1 β cos(2π
π π )) 0 β€ π β€ π
The window length is L=N+1.
Additional References: (1)https://www.mathworks.com/help/matlab/ref/fft.html?searchHighlight=fft&s_tid= doc_srchtitle (2) https://www.mathworks.com/help/signal/ref/hann.html
(3) https://www.mathworks.com/help/signal/windows.html
