COMPUTATION OF DISCRETE FOURIER TRANSFORM (DFT)
Program Code: Example Problem 1
clc;
close all;
x=input('Enter the Input Sequence:');
N=input('Enter the Length of the Sequence:');
y=fft(x,N);
display('The DFT of a Sequence:');
y
Output:
Enter the Input Sequence: [0,2,4,6]
Enter the Length of the Sequence: 4
The DFT of a Sequence:
y = 12.0000 + 0.0000i -4.0000 + 4.0000i -4.0000 + 0.0000i
-4.0000 - 4.0000i
Program Code: Example Problem 2
clc;
close all;
x=input('Enter the Input Sequence:');
N=input('Enter the Length of the Sequence:');
y=fft(x,N);
display('The DFT of a Sequence:');
y
m=abs(y);
display('The Magnitude value of the DFT Sequence:');
m
p=angle(y);
ph=rad2deg(p);
display('The Phase Angle value of the DFT Sequence:');
ph
k=0:1:N-1;
subplot(2,1,1);
stem(k,m);
xlabel('k');
ylabel('Magnitude');
title('Magnitude Response of DFT');
subplot(2,1,2);
stem(k,ph);
xlabel('k');
ylabel('Phase Angle');
title('Phase Response of DFT');
Output:
Enter the Input Sequence: [1,1,1,0]
Enter the Length of the Sequence: 4
The DFT of a Sequence:
y = 3.0000 + 0.0000i 0.0000 - 1.0000i 1.0000 + 0.0000i
0.0000 + 1.0000i
The Magnitude value of the DFT Sequence:
m = 3 1 1 1
The Phase Angle value of the DFT Sequence:
ph = 0 -90 0 90
COMPUTATION OF DISCRETE FOURIER TRANSFORM (DFT): OUTPUT GRAPH
Example Problem 2:
Program Code: Example Problem 3
clc;
close all;
x=input('Enter the Input DFT Sequence:');
N=input('Enter the Length of the Sequence:');
y=ifft(x,N);
display('The Inverse DFT of a Sequence:');
y
Output:
Enter the Input DFT Sequence: [1,0,1,0]
Enter the Length of the Sequence: 4
The Inverse DFT of a Sequence:
y = 0.5000 0 0.5000 0
Program Code:
clc;
close all;
x=[1,1,1];
N=50;
y=fft(x,N);
m=abs(y);
p=angle(y);
ph=rad2deg(p);
k=0:1:N-1;
subplot(2,1,1);
stem(k,m);
xlabel('k');
ylabel('Magnitude');
title('Magnitude Response of DFT');
subplot(2,1,2);
stem(k,ph);
xlabel('k');
ylabel('Phase Angle');
title('Phase Response of DFT');
OUTPUT GRAPH: