DTFT, DFT, ZT, and FFT 515
Example 5.4Given the discrete sequence f(n) = [1 2 3],
a. Evaluate by hand the DTF coeffi cients of f(n)
b. Create the script fi le DFT_IDFT that returns the DTF of f(n)
c. Recover the sequence f(n) by evaluating the IDTF of part bANALYTICAL SolutionFk f nejNnk
nN
() ()
201
∑Ffn
n() ()01236
02
∑
Ffne e e i
j n
n() 1 ( ) 1 2 jj 3 1 5000. 0 8660.2
3
02
^2343
∑ Ffne ee i
j n
n() 2 () 1 2 jj 3 1 5000. 0 8660.4
3
02
^4383
∑ MATLAB Solution
% Script file: DFT _ IDFT
fn = [1 2 3]
DTF _ fn = fft(fn);
disp(‘**************** R E S U L T S **************** ’)
disp(‘The given time sequence is f(n) = [1 2 3]’)
disp(‘The DTF of f(n)=[1 2 3] using fft is given by :’)
disp(DTF _ fn)
fnn = ifft(DTF _ fn);
disp(‘The IDTF of the DFT of f(n)=[1 2 3] using ifft is given by:’)
disp(fnn)
disp(‘**************************************************** ’)The script fi le DFT_IDFT is executed and the results are as follows:******************* R E S U L T S ***********************
The given time sequence is f(n) = [1 2 3]
The DTF of f(n) = [1 2 3] using fft is given by:
6.0000 -1.5000 + 0.8660i -1.5000 - 0.8660i
The IDTF of the DFT of f(n) = [1 2 3] using ifft is given by:
1 2 3
************************************************************Example 5.5Create the script fi le DTFT_DFT that returns the magnitude and phase plots of DTFT as
well as DFT of the following discrete-time sequence:fn
n
N
N
nk
()cos
3
16
0(^1)
∑ for