Experiment No: 2: Date
Experiment No: 2: Date
THEORY:
If the sequence to be represented is of finite duration, i.e. has only a finite number
of non zero values, the transform used is Discrete Fourier Transform
(DFT).DFT finds its applications in digital signal processing including linear
filtering, correlation analysis and spectrum analysis.
Definition:
Let x[n] be a finite duration sequence. The N-DFT of the sequence is expressed by
[] = []/
=
for k=0,1,2,3......N-1.
[] =
[] /
=
for n=0,1,2,3......N-1.
PROGRAM:
clc;
clear all;
close all;
% DFT
x = input('(dft) enter the sequence : ');
N = length(x);
axis = 0 : N - 1;
d = zeros(1, N);
for k = 0 : N - 1
for n = 0 : N - 1
d(k+1) = d(k+1) + x(n+1)*exp((-1*sqrt(-1)*2*pi*k*n)/N) ;
end
end
mag = abs(d);
theta = angle(d);
subplot(2,2,1);
stem(axis, x);
xlabel('n-->');
ylabel('x(n)');
title('Input');
grid on;
subplot(2,2,2);
stem(axis, mag);
xlabel('k-->');
ylabel('|X(k)|')
title('Magnitude');
grid on;
subplot(2,2,3);
stem(axis, theta);
xlabel('k-->');
ylabel('Radians');
title('Phase');
grid on;
% IDFT
d1 = d;
x1 = zeros(1, N);
for n = 0 : N - 1
for k = 0 : N - 1
x1(n+1) = x1(n+1) + (1/N) * (d1(k+1)*exp((1*sqrt(-1)*2*pi*k*n)/N)) ;
end
end
subplot(2,2,4);
stem(axis, x1);
xlabel('n-->');
ylabel('x(n)');
title('Inverse');
grid on;
CONCLUSION: The program for DFT & IDFT was implemented using matlab
and appropriate o/p was obtained.
QUESTIONAIRE:
1) Differentiate between DTFT and DFT. Why it is advantageous to use DFT in computers
rather than DTFT??
Ans: