0% found this document useful (0 votes)
103 views3 pages

DFT and Idft of A Sequence

The document discusses the discrete Fourier transform (DFT) and inverse discrete Fourier transform (IDFT) of a sequence. It provides the mathematical formulas for the DFT and IDFT. It also includes a Matlab code that demonstrates calculating the DFT and IDFT of a sample sequence both using a for loop and built-in FFT function. The code generates magnitude and phase plots of the DFT and verifies the IDFT returns the original sequence.

Uploaded by

Sanju Sebastian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
103 views3 pages

DFT and Idft of A Sequence

The document discusses the discrete Fourier transform (DFT) and inverse discrete Fourier transform (IDFT) of a sequence. It provides the mathematical formulas for the DFT and IDFT. It also includes a Matlab code that demonstrates calculating the DFT and IDFT of a sample sequence both using a for loop and built-in FFT function. The code generates magnitude and phase plots of the DFT and verifies the IDFT returns the original sequence.

Uploaded by

Sanju Sebastian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

DFT AND IDFT OF A SEQUENCE

Aim: To find out the DFT and IDFT of a sequence

Theory:

DFT:

 
N 1 N 1
X ( k )   x ( n )e  j 2kn / N
  x(n) e  j 2 / N
nk

n 0 n 0

WN  e j 2 / N
N 1
X (k )   x(n)WN nk
n0

Inverse DFT:
N 1
1
x ( n) 
N
 X ( k )e
k 0
j 2nk / N

Matlab code:
%find the DFT and IDFT of the sequence

clear all;
close all;

x=input('enter the sequence');


N=input('enter N-point DFT');
for k=1:N
X(k)=0;
for n=1:N
X(k)=X(k)+x(n)*exp(-j*2*pi*(k-1)*(n-1)/N)
end
end
X=double(X);
figure(1);
subplot(3,2,1)
stem(abs(X));
xlabel('k')
ylabel('Magnitude |X(k)|')
title('Magnitude plot of DFT X(k) (without using function)')
subplot(3,2,3)
stem(angle(X));
xlabel('k')
ylabel('Angle of X(k)')
title('Phase plot of DFT X(k)')

for n=1:N
x1(n)=0;
for k=1:N
x1(n)=x1(n)+X(k)*exp(j*2*pi*(k-1)*(n-1)/N)/N;
end
end
subplot(3,2,5)
stem(real(x1));
xlabel('n')
ylabel('Amplitude')
title('IDFT of X(k)')

X1=fft(x,N);
subplot(3,2,2)
stem(abs(X1));
xlabel('k')
ylabel('Magnitude |X(k)|')
title('Magnitude plot of DFT X(k) (Using fucntion)')

subplot(3,2,4)
stem(angle(X1));
xlabel('k')
ylabel('Angle of X(k)')
title('Phase plot of DFT X(k)')

x2=ifft(X1,N)
subplot(3,2,6)
stem(x2);
xlabel('n')
ylabel('Amplitude')
title('IDFT of X(k)')

Output:

enter the sequence[1 2 3 1 0 0 0 0]


enter N-point DFT 8

X =

Columns 1 through 4

7.0000 1.7071 - 5.1213i -2.0000 - 1.0000i 0.2929 + 0.8787i

Columns 5 through 8

1.0000 + 0.0000i 0.2929 - 0.8787i -2.0000 + 1.0000i 1.7071 + 5.1213i


x2 =

1.0000 2.0000 3.0000 1.0000 0 -0.0000 0 -

0.0000

You might also like