Lab 9
Lab 9
Lab 9
Experiment # 8
Equipment Required: Personal computer (PC) with windows operating system and
MATLAB software
Theory:
The Discrete Fourier Transform (DFT) is one of the most important tools in Digital Signal
Processing. Firstly, the DFT can calculate a signal's frequency spectrum. This is a direct
examination of information encoded in the frequency, phase, and amplitude of the component
sinusoids. For example, human speech and hearing use signals with this type of encoding. Secondly,
the DFT can find a system's frequency response from the system's impulse response, and vice versa.
This allows systems to be analyzed in the frequency domain, just as convolution allows systems to
be analyzed in the time domain. Third, the DFT can be used as an intermediate step in more
elaborate signal processing techniques. The classic example of this is FFT convolution, an
algorithm for convolving signals that is hundreds of times faster than conventional methods.
In Lab Experiment 6, we have discussed in detail the Discrete Time Fourier Transform (DTFT) for
the analysis of signals. While DTFT is very useful analytically, it usually cannot be exactly
evaluated on a computer because equation requires an infinite sum and evaluation of an integral.
The discrete Fourier transform (DFT) is a sampled version of the DTFT, hence it is better suited to
numerical evaluation on computers.
03
OH
Where X(k) is an N-point DFT of x[n]. Note that X(k) is a function of a discrete integer k, where k
ranges from 0 to N-1.
Using the matrix vector multiplication technique used to compute the DTFT, we can calculate the
DFT:
DFT Function
n = -1:3; x = 1:5;
k = 0:500; w =(pi/500)*k;
X = x * (exp(-j*pi/500)) .^ (n'*k);
magX = abs(X); angX = angle(X);
realX = real(X); imagX = imag(X);
plot(k/500,magX);grid
xlabel('frequency in pi units');
title('Magnitude');
Simulation
x=[1,2,3,4,5];
N= 5;
k= [0:1:N-1];
X=dft(x,N);
mag= abs(X);
magX = abs(X); angX = angle(X);
realX = real(X); imagX = imag(X);
plot(k,magX);grid
xlabel('k'); title('Magnitude');
Simulation
Zero-Padding:
It is an operation in which more zeros are appended to the original sequence. The resulting longer
DFT provides closely spaced samples of the discrete time Fourier transform of the original
sequence. In MATLAB zero padding is implemented using the zeros function. The zero padding
gives high-density spectrum and provides a better displayed version for plotting. But it does
not give a high resolution spectrum because no new information is added to the signal: only
additional zeros are added in the data.
Example 2:
Determine and plot x(n) and its discrete time Fourier transform for appropriate value of n.
c) High density Spectrum (100 samples) based on the first 10 samples of x(n)
n=[0:1:99];
x=cos(0.48*pi*n)+cos(0.52*pi*n); subplot(2,1,1);stem(n,x);
title('signal x(n), 0 <= n <= 99');
xlabel('n')
axis([0, 100,-2.5,2.5])
X=dft(x, 100); magX=abs(X(1: 1:51)); k=0:1:50;w=2*pi/100*k;
subplot(2,1 ,2);plot(w/pi,magX);
title('DTFT Magnitude');xlabel('frequency in pi units')
axis([0,1,0,60])
Simulation:
If x1(n) and x2(n) have N1-points and N2 -points respectively, then N3= max(N1, N2)
Circular Folding: If an N point sequence is folded, then the result x(-n) would not be an N
point sequence, and it would not be possible to compute its DFT. Therefore, we use modulo-N
operation on the argument(-n) and define the folding by
This a called a circular folding. To visualize it, imagine that the sequence x(n) is wrapped around
a circle in the counterclockwise direction that n= 0 and n=N overlap. Then x((-n))N can be viewed
as a clockwise wrapping of x(n) around the circle. That’s why it is called circular folding.
In MATLAB the circular folding can be achieved by 𝑥 = 𝑥(𝑚𝑜𝑑(−𝑛, 𝑁) + 1.
MATLAB Script
a.
n=0:100; x= 10*(0.8).^n;
y=x(mod(-n,11)+1);
subplot(2,1,1);
stem(n,x); title('original sequence')
xlabel('n'); ylabel('x(n)');
subplot(2,1,2); stem(n,y); title('circularly folded sequence')
xlabel('n'); ylabel('x(-n) mod 10')
b.
n=0:10;
x= 10*(0.8).^n; X= fft(x,11);
Y=fft(x(mod(-n,11)+1), 11);
subplot(2,2,1); stem(n, real(X));
title('Real {DFT of x(n)}'); xlabel('k')
subplot(2,2,2); stem(n, imag(X));
title('Imag {DFT of x(n)}'); xlabel('k')
subplot(2,2,3); stem(n, real(Y));
title('Real {DFT of x(-n)11}'); xlabel('k')
subplot(2,2,4); stem(n, imag(Y));
title('Imag {DFT of x(-n)11}'); xlabel('k')
Simulation
Circular Shift property: If an N-point sequence is shifted in either direction, then the result is
no longer between 0 ≤n ≤ N-1. Therefore, we first convert x(n) into its periodic extension, and
then shift it by m samples to obtain
This is called periodic shift. then this periodic shift is converted into N point sequence. Resulting
sequence is
Tasks:
1. Determine the DFT and IDFT of following signals.
𝑎. 𝑥(𝑛) = {1, 𝑗, 𝑗, 1} 𝑁 = 4
𝑏. 𝑥(𝑛) = {𝑆𝑖𝑛(0.5𝜋𝑛)} 0 ≤ 𝑛 ≤ 100
2. Let 𝑥(𝑛) be a 4 point sequence
1 0≤𝑛≤3
𝑥(𝑛) = { }
0 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
a. 𝐶𝑜𝑚𝑝𝑢𝑡𝑒 𝑠𝑎𝑚𝑝𝑙𝑒𝑠 𝑜𝑓 𝐷𝐹𝑇 𝑓𝑜𝑟
𝑛 = 10,
𝑛 = 40,
𝑛 = 100.
3. The first five values of the 8-point DFT of a real-valued sequence x(n) are given by
{0.25, 0.125 − 𝑗0.3, 0, 0.125 − 𝑗0.06, 0.5}
Determine the DFT of
a. 𝑥(𝑛) = 𝑥((𝑛 + 5))10
b. 𝑦(𝑛) = 𝑐𝑖𝑟𝑠𝑢𝑙𝑎𝑟𝑐𝑜𝑛𝑣𝑜𝑙𝑣𝑒 𝑥(𝑛) 𝑎𝑛𝑑 𝑥((−𝑛))8 𝑤𝑖𝑡ℎ 𝑛 = 8,