Jalpaiguri Government Engineering College: Dept: Electrical Engineering Year: 4 Year SEM: 7 DATE OF SUBMISSION: 2/05/2021

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Jalpaiguri Government Engineering college

SL NAME ROLL NO. REG. NO


NO.

1. SUTAPA HALDER 18101102086 181010120104

2. SUBHAJIT BEJ 18101102087 181010120103

3. ABHIJIT GHOSH 18101102090 181010120092

DEPT: ELECTRICAL ENGINEERING


YEAR: 4TH YEAR
SEM: 7TH
DATE OF SUBMISSION: 2/05/2021
Name of Experiment: Write a MATLAB code to find DFT of the sequence [1 2 3 4 5].
Objective:
➢ Develop a MATLAB code to find the DFT of the given sequence
➢ Plot Response (magnitude and phase).
THEORY:
The discrete Fourier transform (DFT) is the primary transform used for numerical computation
in digital signal processing. It is very widely used for spectrum analysis, fast convolution, and
many other applications.

Basic equation to find the DFT of a sequence is given Below

Where = is called [TWIDDEL FACTOR]

STEPS TO BE FOLLOWED :
Step I. Get the input sequence
Step II. Find the DFT of the input sequence using direct equation of DFT

Step III. Plot magnitude and phase response using stem command

Step IV. Display the above outputs

CODE THE DFT PROGRAM


ENTER THE GIVEN OF THE GIVEN INPUT RUN THE
START STOP
DFT SEQUENCE SEQUENCE AND CODE FOR PROGRAM & PLOT
RESPONCES RESPONCES
Program:
clc;
close all;
clear all;
xn=input('Enter the sequence x(n)='); %Get the sequence from
user
ln=length(xn); %find the length of the sequence
xk=zeros(1,ln); %initialize an array of same size as that of
input sequence
%DFT of the sequence
%-----------------------------------------------------
for k=0:ln-1
for n=0:ln-1
xk(k+1)=xk(k+1)+(xn(n+1)*exp((-i)*2*pi*k*n/ln));
end
disp(xk(k+1))
end
%------------------------------------------------------
%Plotting input sequence
%-----------------------------------------------------
t=0:ln-1;
subplot(221);
stem(t,xn);
ylabel ('Amplitude');
xlabel ('Time Index');
title('Input Sequence');
%---------------------------------------------------------------
magnitude=abs(xk); % Find the magnitudes of individual DFT
points
% plot the magnitude response
%------------------------------------------------------------
t=0:ln-1;
subplot(222);
stem(t,magnitude);
ylabel ('Amplitude');
xlabel ('K');
title('Magnitude Response');
%------------------------------------------------------------
phase=angle(xk); % Find the phases of individual DFT points
% plot the magnitude sequence
%------------------------------------------------------------
t=0:ln-1;
subplot(223);
stem(t,phase);
ylabel ('Phase');
xlabel ('K');
title ('Phase Response');
Result Out Put:
Enter the sequence x(n)=[1 2 3 4 5]
Sequence=[1 2 3 4 5]

X(k)=[ 15

-2.5000 + 3.4410i

-2.5000 + 0.8123i

-2.5000 - 0.8123i

-2.5000 - 3.4410i ]

Output plots:
CONCLUSION :-
It offers a way to represent a time-‐based periodic signal in the frequency
domain.IT helps us to take signals in the “time domain” and see their breakdown
or “frequency domain” components. The Discrete Fourier Transform is a good
way to analyze discrete time signals in the frequency domain in theory, but in
application the infinite range of time and frequency in the conversion formula can
make analysis difficult, especially on the computer. The Discrete Fourier
Transform uses a finite time signal, allowing its formula to be finite sums which a
computer can easily calculate. Signals must be discrete and time-limited (or
truncated) for use with the DFT. A discrete periodic signal can be used when only
one period of the signal is analyzed. The DFT of a signal will be discrete and have a
finite duration.

------------------------------------------X---------------------------------------------

You might also like