0% found this document useful (0 votes)
4 views

Lab_8

Uploaded by

Be Educate
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)
4 views

Lab_8

Uploaded by

Be Educate
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

LAB EXPERIMENT # 08

Implementation of DFT on MATLAB

Name: Konain Mazhar Reg#CPEN-211101045

Instructor: Engr. Sir Aqeel Subject: DSP

Signature:______________ Date:

Introduction:
The DFT is the most important discrete transform, used to perform Fourier analysis in many
practical applications. In digital signal processing, the function is any quantity or signal that
varies over time, such as the pressure of a sound wave, a radio signal, or
daily temperature readings, sampled over a finite time interval (often defined by a window
function). In image processing, the samples can be the values of pixels along a row or column of
a raster image. The DFT is also used to efficiently solve partial differential equations, and to
perform other operations such as convolutions or multiplying large integers.

THEORY:
The discrete Fourier transform, or DFT, is the primary tool of digital signal processing. The
foundation of Signal Processing Toolbox™ product is the fast Fourier transform (FFT), a method
for computing the DFT with reduced execution time. Many of the toolbox functions (including z-
domain frequency response, spectrum and cepstrum analysis, and some filter design and
implementation functions) incorporate the FFT.
The MATLAB® environment provides the functions fft and ifft to compute the discrete
Fourier transform and its inverse, respectively. For the input sequence x and its transformed
version X (the discrete-time Fourier transform at equally spaced frequencies around the unit
circle), the two functions implement the relationships

and

In these equations, the series subscripts begin with 1 instead of 0 because of the MATLAB
vector indexing scheme, and
Program for DFT:
xn=input('Enter the values of X[n] ='); % input from user
ln = length(xn); % length of input signal
xk= zeros(1,ln);% initial DFT vector
ixk=zeros(1,ln);
%calculate the DFT
for k=0:ln-1
for n=0:ln-1
xk(k+1)=xk(k+1)+(xn(n+1)*exp((-1i)*2*pi*k*n/ln));
end
end
%ploting the input signal
t=0:ln-1;
subplot(2,2,1)
stem(t,xn)
grid
title('input signal')
% ploting the magnitude plot
magnitude=abs(xk)
t=0:ln-1;
subplot(2,2,2)
stem(t,magnitude)
grid
title('imagnitude plot')
%ploting the phase plot
phase=angle(xk)
t=0:ln-1;
subplot(2,2,3)
stem(t,phase)
grid
title('phase plot')

% inverse DFT
for n=0:ln-1
for k=0:ln-1
ixk(k+1)=ixk(k+1)+(xk(n+1)*exp((1i)*2*pi*k*n/ln));
end
end
ixk=ixk./ln;
% ploting the inverse DFT
t=0:ln-1;
subplot(2,2,4)
stem(t,ixk)
grid
title('ploting inverse DFT')
Command window:
Enter the values of X[n] =[1 2 3]

magnitude =

6.0000 1.7321 1.7321

phase =

0 2.6180 -2.6180

Output waveform:

input signal imagnitude plot


3 6

2 4

1 2

0 0
0 0.5 1 1.5 2 0 0.5 1 1.5 2

phase plot ploting inverse DFT


4 3

2
2
0
1
-2

-4 0
0 0.5 1 1.5 2 0 0.5 1 1.5 2

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy