Submitted To: Course Title: Digital Signal Processing Course Code: ICE322 Topic: Lab Report #04 Section: 01
Submitted To: Course Title: Digital Signal Processing Course Code: ICE322 Topic: Lab Report #04 Section: 01
Section: 01
Submitted To
Dr. Mohammed Moseeur Rahman (DMMUR)
Submitted By
Name: Joy Chandra Gope
ID: 2017-3-50-004
ID: 2017-3-50-002
ID: 2015-1-50-016
Department of ECE
Semester: Summer-2020
Objective:
Task 1: Computation of N point DFT of a given sequence and plot magnitude and phase
spectrum:
% clc
% close all
% clear all
%N = input('Enter the value of N in N-Point DFT');
x = [0 1 2 3 4 3 2 1 0 1 2 3 4 3 2 1 0 1 2 3 4 3 2 1 0]; %input('Enter the
sequence');
N = length (x);
n=[0:1:N-1];
k=[0:1:N-1];
WN=exp(-1j*2*pi/N);
nk=n'*k;
WN_nk=WN.^nk;
Xk=x*WN_nk;
Mag_X=abs(Xk) % Magnitude of the calculated DFT
Phase_X=angle(Xk)*180/pi % Phase
disp('DFT coefficients are')
disp(Xk)
figure(1);
subplot(2,1,1);
stem(k,Mag_X);
subplot(2,1,2);
plot(k,Phase_X);
Figure:
Task 2: Perform linear convolution of two sequences using DFT:
clc;
clear all;
x1= [1 1 1 1 1 1 1 1 1 1]; %input('Enter the first sequence');
x2= [0 1 2 3 4 0 1 2 3 4]; %input('Enter the second sequence');
%n=input('Enter the number of points of the DFT');
subplot(3,1,1);
stem(x1,'filled');
title('Plot of first sequence');
subplot(3,1,2);
stem(x2,'filled');
title('Plot of second sequnce');
n1 = length(x1);
n2 = length(x2);
m = n1+n2-1; % Length of linear convolution
x = [x1 zeros(1,n2-1)]; % Padding of zeros to make it of
% length m
y = [x2 zeros(1,n1-1)];
x_fft = fft(x,m);
y_fft = fft(y,m);
dft_xy = x_fft.*y_fft;
y=ifft(dft_xy,m);
disp('The linear convolution result is ');
disp(y);
subplot(3,1,3);
stem(y,'filled');
title('Plot of convoluted sequences');
Figure: