Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Date: 06/08/2019
AIM: (a) Compute 4-point DFT and IDFT for sequence x(n) = {1,2,3,4} using
MATLAB.
(b) Compute N point DFT and IDFT for the above sequence if frequency
resolution is 0.25π using MATLAB.
THEORY:
Discrete Fourier Transform (DFT) is the transform that deals with a finite discrete
time signal and a finite or discrete number of frequencies.
The N-point DFT of any signal x[n] is defined as follows:
Inverse Discrete Fourier Transform (IDFT) is inverse of DFT and N-point IDFT is
defined as follows:
DFT and IDFT algorithm takes time to execute. To minimise the time or
operation FFT algorithm was introduced which is Fast Fourier Transform (FFT) .
FFT takes .
)
e. Finally, plot its stem plot of magnitude and phase response.
Magnitude plot is plotted using function and phase plot using
.
PROGRAM:
clc
close all
clear all
x=[1,2,3,4]
xk=zeros(1,length(x))
n=length(x)
tic
for j=1:1:n
sum=0
for p=1:1:n
sum=sum+x(p)*exp(-1i*((2*pi)/n)*(j-1)*(p-1))
end
xk(j)=round(sum,4)
EC303 – Digital Signal Processing, Electronics engineering Department, SVNIT, Surat-07 2
end
toc
disp(xk)
subplot(4,2,1)
stem(xk)
xlabel('f')
ylabel('amp')
title('4 point dft')
idft=zeros(1,n)
for j=1:1:n
sum=0
for p=1:1:n
sum=sum+xk(p)*exp(1i*((2*pi)/n)*(p-1)*(j-1))
end
idft(j)=(1/n)*sum
end
disp(idft)
subplot(4,2,2)
stem(idft)
xlabel('f')
ylabel('amp')
title('4 point idft')
x1=[1,2,3,4,0,0,0,0]
xk1=zeros(1,length(x1))
n=length(x1)
for j=1:1:n
sum=0
for p=1:1:n
sum=sum+x1(p)*exp(-1i*((2*pi)/n)*(j-1)*(p-1))
end
xk1(j)=round(sum,4)
end
disp(xk1)
subplot(4,2,3)
stem(xk1)
xlabel('f')
ylabel('amp')
title('8 point dft')
idft1=zeros(1,n)
for j=1:1:n
sum=0
for p=1:1:n
EC303 – Digital Signal Processing, Electronics engineering Department, SVNIT, Surat-07 3
sum=sum+xk1(p)*exp(1i*((2*pi)/n)*(p-1)*(j-1))
end
idft1(j)=(1/n)*sum
end
disp(idft1)
subplot(4,2,4)
stem(idft1)
xlabel('f')
ylabel('amp')
title('8 point idft')
tic
y=fft(x)
toc
xaxis=[0,1,2,3]
subplot(4,2,5)
stem(xaxis,abs(xk))
xlabel('f')
ylabel('amp')
title('4 point dft mag')
subplot(4,2,6)
stem(xaxis,abs(fft(x)))
xlabel('f')
ylabel('amp')
title('4 point dft mag inbuilt')
subplot(4,2,7)
stem(xaxis,angle(xk))
xlabel('f')
ylabel('amp')
title('4 point dft ang')
subplot(4,2,8)
stem(xaxis,angle(fft(x)))
xlabel('f')
ylabel('amp')
title('4 point dft ang inbuilt')
y1=fft(x1)
xaxis=[0,1,2,3,4,5,6,7]
figure;
subplot(2,2,1)
stem(xaxis,abs(xk1))
xlabel('f')
ylabel('amp')
title('8 point dft mag')
subplot(2,2,2)
EC303 – Digital Signal Processing, Electronics engineering Department, SVNIT, Surat-07 4
stem(xaxis,abs(fft(x1)))
xlabel('f')
ylabel('amp')
title('8 point dft mag inbuilt')
subplot(2,2,3)
stem(xaxis,angle(xk1))
xlabel('f')
ylabel('amp')
title('8 point dft ang')
subplot(2,2,4)
stem(xaxis,angle(fft(x1)))
xlabel('f')
ylabel('amp')
title('8 point dft ang inbuilt')