DSP Exp 2
DSP Exp 2
TECHNOLOGY
Department of Electrical & Electronic Engineering
Course Code: EEE 366
Course Title: Digital Signal Processing Sessional
Experiment 2
Submitted By:
Name: Omar Abdullah
ID: 2002095
Section: B
Group: 2
Department of Electrical and Electronic Engineering
Chittagong University of Engineering & Technology (CUET)
Submitted To:
Mr. Kamrul Hasan Hira
Lecturer
Department of Electrical and Electronic Engineering
Chittagong University of Engineering & Technology (CUET)
‘‘This lab work was assigned by Mr. Kamrul Hasan Hira (Lecturer , Department of Electrical and Electronic Engineering,CUET’’
ABSTRACT An overview of time shifting, signal folding, signal addition, and the convolution sum—a key
function in discrete-time signal processing—is given in this paper. By defining a function and signal to add
two random discrete signals, we start by defining the time-shifting property of a discrete signal with the
subsequent signal reversal. The convolution sum is thus mathematically calculated using these properties,
and its importance in a variety of applications, including image processing, system analysis, and filtering, is
discussed. Next, we show how to use MATLAB, a potent signal processing tool, to implement the convolution
sum. To walk readers through the useful features of convolution in MATLAB, the paper provides illustrative
examples and code snippets.
I. OBJECTIVE y2=y1;
y1(find((n>=n1(1))&(n<=n1(end))))=x1;
T .he main objective here is to use and illustrate the
convolution sum using time shifting, signal folding, and
signal addition.The response y(n) is given by the following
y2(find((n>=n2(1))&(n<=n2(end))))=x2;
y=y1+y2;
relation, end
P∞
y(n) = n=−∞ x(k)h(nk) = x(n) ∗ h(n)
4) Function declaration for convolution
II. CODE AND GRAPH PLOT function [y,n] = conv_sig(x,nx,h,nh)
A. FUNCTION DECLARATION y = conv(x,h)
1) function declaration code for time shifting nys = nx(1) + nh(1);
function [y,n] = sigshift(x,m,n0) nye = nx(length(x))+nh(length(h));
n=m+n0; n = [nys:nye];
y=x end
end
2) Graph
FIGURE 3. Graphical representation of y[n] = x[-2n+1] FIGURE 4. Graphical representation of y[n] = x[-n/2+3]
clc 1) Code
close all
clc
clear all
close all
x = [-2 1 4 3]
clear all
n = -2:1; x = [-2 1 4 3];
x1 = upsample(x,2);
n = -2:1;
n1 = []; x1 = downsample(x,2);
delta = n(2)-n(1);
n1=n;
for i = 1:length(n)
[x2 n2] = sigfold(x1,n1);
n1 = [n1,n(i),n(i)+delta/2]
[x3 n3] = sigshift(x2,n2,1);
end
n1 = n1(1:end) [y ny] = conv_sig(x3,n3,x,n)
[y ny] = sigshift(x1,n1,3) stem(ny,y,’filled’,’square’,’MarkerSize’,8)
stem(ny,y,’filled’) title(’Discrete plot of y[n] = x[-2n+1]*x[n]’,’FontSize’,20);
title(’Discrete plot of y[n] = x[-n/2+3]’); xlim([-3 3])
xlim([0 6]) xlabel(’ny’,’FontSize’,14,’FontName’,’Calibri’)
xlabel(’ny’,’FontSize’,14,’FontName’,’Calibri’) ylabel(’y[n]’,’FontSize’,14,’FontName’,’Calibri’)
ylabel(’y[n]’,’FontSize’,14,’FontName’,’Calibri’)
ylim([-10 15])
ylim([-3 5])
set(gca,’xgrid’,’on’,’ygrid’,’on’) set(gca,’xgrid’,’on’,’ygrid’,’on’)
legend(’Discrete Sample’,’location’,’northeast’) legend(’Discrete Sample’,’location’,’northeast’)
print(’dsp_exp2_classtask_4.jpeg’,’-djpeg’,’-r314’) print(’dsp_exp2_classtask_5.jpeg’,’-djpeg’,’-r314’)
grid on
III. DISCUSSION
Time-shifting, signal folding, and signal addition are only a
few of the essential discrete-time signal processing processes
that we have seen in detail. The convolution sum, a basic pro-
cess obtained by combining time-shifting and signal folding,
is the main emphasis. The paper lays forth the mathematical
underpinnings of convolution and illustrates its importance in
a variety of applications, including filtering, system analysis,
and image processing. The work includes a practical compo-
nent utilizing MATLAB, a potent signal-processing tool, in
recognition of the significance of practical implementation.
Readers are led through the efficient use of convolution in
MATLAB through instructive examples and code snippets,
improving their comprehension of the theoretical and prac-
tical facets of this essential discrete-time signal processing
procedure.
REFERENCES
[1] Alan V Oppenheim. Discrete-time signal processing. Pearson Education
India, 1999.
[2] John G Proakis. Digital signal processing: principles, algorithms, and
applications, 4/E. Pearson Education India, 2007.