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

Lab Report 2: Abu Sayeed Lecturer

This lab report describes performing convolution on two discrete signals, x(n) and h(n), using both the built-in conv function and a manually written convolution function. The user provides the sequences for x(n) and h(n), and the program plots the original signals and the results of convolving them using each method side by side for comparison.

Uploaded by

AddaPrioAkash
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)
50 views

Lab Report 2: Abu Sayeed Lecturer

This lab report describes performing convolution on two discrete signals, x(n) and h(n), using both the built-in conv function and a manually written convolution function. The user provides the sequences for x(n) and h(n), and the program plots the original signals and the results of convolving them using each method side by side for comparison.

Uploaded by

AddaPrioAkash
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/ 3

Lab report 2

Course No: CSE 4103.


Course title: Sessional based on CSE 4103.

Submitted to:
Abu sayeed
Lecturer,
Department of Computer Science & Engineering
Rajshahi University of Engineering & Technology.

Submitted by:
Arun kundu
Department of Computer Science & Engineering.
Roll: 143045
Section: A
4th Year, Odd Semester.
TASK : Convolution using conv function and manually written conv function.
CODE:
clear all;
clc;
% Convolution using conv function.
xn = input('Enter the sequence for x(n): ');
hn = input('Enter the sequence for h(n): ');
lx = length(xn);
lh = length(hn);
px = (0:1:lx-1);
ph = (0:1:lh-1);
subplot(2,2,1);
stem(px, xn);
title('Discrete signal : x(n)'); xlabel('n'); ylabel('x[n]');
subplot(2,2,2);
stem(ph, hn);
title('Discrete signal : h(n)'); xlabel('n'); ylabel('h[n]');
n = (0:1:lx+lh-2);
subplot(2,2,3);
c = conv(xn,hn);
stem(n, c);
title('Convolution : Using conv function.'); xlabel('n'); ylabel('y[n]');

%Convolution in manually written code.


m = lx + lh -1;
z = zeros(1,m);
xn11 = [xn, zeros(1,lh-1)];
hn11 = [hn, zeros(1,lx-1)];
for i = 1 : m
for j = 1 : i
z(i) = z(i)+ xn11(j) * hn11(i-j+1);
end;
end;
subplot(2,2,4);
stem(n, z);
title('Convolution : Manually written conv function.'); xlabel('n'); ylabel('y[n]');
INPUT :
Enter the sequence for x(n): [3 4 5 6 6]
Enter the sequence for h(n): [2 3 4 6]

OUTPUT :

You might also like