Professional Documents
Culture Documents
Lab # 6 Discrete Fourier Transform and Fast Fourier Transform
Lab # 6 Discrete Fourier Transform and Fast Fourier Transform
DFT is the computable version of discrete time Fourier transform (DTFT). Despite being the
Fourier transform of a discrete signal x[n], DTFT X(ejw) is function of a continuous variable w.
In order to compute DTFT, infinite summations are required, which is not possible, hence DFT is
computed for the knowledge of frequency response.
DFT and Inverse discrete Fourier transform (IDFT) is given by:
Figure 1 below presents DFT as the discretized version of discrete time Fourier transform
(DTFT) in frequency domain.
DFT can become DTFT if we consider N→∞. For visualization consider the following figure:
Example 1:
x[n] = [2 3 -1 4] ; n = [0 1 2 3]
for k = 0:N-1
for n = 0:N-1
X(k+1) = X(k+1) + x(n+1)*exp(-1j*2*pi/N*n*k);
end
end
% finding DFT
X= dft(x,4)
x = [2 3 -1 4];
N = length(x);
X = zeros(1,N);
% finding DFT
X= fft(x)
N = 8;
n = 0:N-1; % sampling period
X = fft(x,N);
%Note: both command gives same result(dft function & fft built-in command)
subplot(2,2,[1,3]); plot(real(x),imag(x),'o','MarkerFaceColor','b')
axis equal; ylim([-3 3])
xlabel('Real {x}','Fontsize',8)
ylabel('Im {x}','Fontsize',8)
title(['e^{(j2\pi/N kn)}, k = ',num2str(k)],'Fontsize',8)
Example:
Let's look at a simple rectangular pulse, x[n]=1 for 0≤n<M. The DTFT of x[n] is:
M = 8;
w = linspace(-2*pi, 2*pi, 800);
X_dtft = (sin(w*M/2) ./ sin(w/2)) .* exp(-1j * w * (M-1) / 2);
plot(w, abs(X_dtft))
title('|X(\omega)|')
The MATLAB function fft computes the DFT. Here's the 8-point DFT of our 8-point rectangular
pulse:
x = ones(1, M);
X = fft(x)
X =
8 0 0 0 0 0 0 0
One 8 and a bunch of zeros?? That doesn't seem anything like the DTFT plot above. But when
you superimpose the output of fft in the right places on the DTFT plot, it all becomes clear.
x = ones(1, M);
X = fft(x)
P = 8;
w_k = (0:P-1) * (2*pi/P);
X = fft(x);
plot(w, abs(X_dtft))
hold on
plot(w_k, abs(X), 'o')
hold off
x16 =
Columns 1 through 13
1 1 1 1 1 1 1 1 0 0 0 0 0
Columns 14 through 16
0 0 0
P = 16;
X16 = fft(x16);
w_k = (0:P-1) * (2*pi/P);
X = fft(x);
plot(w, abs(X_dtft))
hold on
plot(w_k, abs(X16), 'o')
hold off
P = 50;
Xp = fft(x, P);
w_k = (0:P-1) * (2*pi/P);
X = fft(x);
plot(w, abs(X_dtft))
hold on
plot(w_k, abs(Xp), 'o')
hold off
Code:
In-Lab Task 02: Compute DFT (using DFT function) of a following signal:
x[n]= sin(2*pi/N*k*n)
Post-Lab Task 02: Find DTFT and DFT of following signal and verify that DFT is just equally-
spaced samples of the DTFT.
Execute above code for 5 and 30 DFT samples. Your output graph with 30 DFT samples should
look like as given in figure below: