0% found this document useful (0 votes)
44 views4 pages

%experiment 3: DFT/IDFT Computation %Author:Arun P S Te:2/7/2015

The document describes an experiment to compute the discrete Fourier transform (DFT) and inverse discrete Fourier transform (IDFT) of a sample input sequence both with and without using built-in MATLAB functions. The input sequence is transformed to the frequency domain using a custom DFT calculation and the built-in FFT function, and the results are plotted and compared. The sequence is then recovered from the frequency domain using a custom IDFT and the built-in IFFT function.

Uploaded by

karthika sudheer
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)
44 views4 pages

%experiment 3: DFT/IDFT Computation %Author:Arun P S Te:2/7/2015

The document describes an experiment to compute the discrete Fourier transform (DFT) and inverse discrete Fourier transform (IDFT) of a sample input sequence both with and without using built-in MATLAB functions. The input sequence is transformed to the frequency domain using a custom DFT calculation and the built-in FFT function, and the results are plotted and compared. The sequence is then recovered from the frequency domain using a custom IDFT and the built-in IFFT function.

Uploaded by

karthika sudheer
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/ 4

%Experiment 3: DFT/IDFT computation

%Author:Arun P S
%Date:2/7/2015

clc
clear all
close all

x=input('enter the input sequence ');


L=length(x);
N=input('enter the value of N to compute DFT ');
xnew=[x zeros(1,N-L)];

for k=1:N
for n=1:N
w(k,n)=exp(-j*2*pi*(n-1)*(k-1)/N);
end
end

Xk=w*xnew';

f=0:N-1;
subplot(221)
stem(f,xnew)
xlabel('n--->')
ylabel('x(n)')
title('Input sequence with zeros appended')
subplot(222)
stem(f,abs(Xk))
xlabel('k--->')
ylabel('X(k)')
title('Magnitude plot of DFT without using fft() ')
subplot(223)
stem(f,angle(Xk))
xlabel('k--->')
ylabel('angle (X(k)) in radians')
title('Phase plot of DFT without using fft() ')

for n=1:N
for k=1:N
winv(n,k)=exp(j*2*pi*(n-1)*(k-1)/N);
end
end
xcap=winv*Xk/N;
subplot(224)
stem(f,xcap);
xlabel('n--->')
ylabel('xcap(n)')
title('Input sequence recovered without using ifft() ')

% using built in function

Xk=fft(x,N);
figure
subplot(221)
stem(f,xnew)
xlabel('n--->')
ylabel('x(n)')
title('Input sequence with zeros appended')
subplot(222)
stem(f,abs(Xk))
xlabel('k--->')
ylabel('X(k)')
title('Magnitude plot of DFT using fft() ')
subplot(223)
stem(f,angle(Xk))
xlabel('k--->')
ylabel('angle (X(k)) in radians')
title('Phase plot of DFT using fft() ')

xcap=ifft(Xk,N);
subplot(224)
stem(f,xcap);
xlabel('n--->')
ylabel('xcap(n)')
title('Input sequence recovered using ifft() ')
Input sequence with zeros appended Magnitude plot of DFT without using fft()
5 15

10
3

X(k)
x(n)

2
5

0 0
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
n---> k--->

Phase plot of DFT without using fft() Input sequence recovered without using ifft()
3 5

2 4
angle (X(k)) in radians

1 3

xcap(n)
0 2

-1 1

-2 0

-3 -1
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
k---> n--->

Input sequence with zeros appended Magnitude plot of DFT using fft()
5 15

10
3
X(k)
x(n)

2
5

0 0
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
n---> k--->

Phase plot of DFT using fft() Input sequence recovered using ifft()
3 5

2 4
angle (X(k)) in radians

1 3
xcap(n)

0 2

-1 1

-2 0

-3 -1
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
k---> n--->
Observations:

enter the input sequence [1 2 3 4 5]

enter the value of N to compute DFT 8

Result

DFT and IDFT of the given sequence have been computed and plotted, with and without using built in
function.

You might also like