0% found this document useful (0 votes)
4 views5 pages

Program Code

The document provides MATLAB code examples for computing the Discrete Fourier Transform (DFT) and its inverse (IDFT) using the fft and ifft functions. It includes example problems with input sequences, outputs of the DFT, magnitude, and phase angle calculations, as well as graphical representations of the magnitude and phase responses. The examples demonstrate the process of obtaining and visualizing the DFT of various input sequences.

Uploaded by

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

Program Code

The document provides MATLAB code examples for computing the Discrete Fourier Transform (DFT) and its inverse (IDFT) using the fft and ifft functions. It includes example problems with input sequences, outputs of the DFT, magnitude, and phase angle calculations, as well as graphical representations of the magnitude and phase responses. The examples demonstrate the process of obtaining and visualizing the DFT of various input sequences.

Uploaded by

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

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:

You might also like