Professional Documents
Culture Documents
EXPERIMENT 3
Aim: To perform convolution of two discrete signals using the graphical method
and tabular method.
Theory:
Convolution is a mathematical operation used to express the relation between
input and output of an LTI system. It relates input, output and impulse response
of an LTI system as
y(t)=x(t)∗h(t)
Where y (t) = output of LTI
● Continuous convolution
y(t)=x(t)∗h(t)
=∫∞−∞x(τ)h(t−τ)dτ
● Discrete convolution
y(n)=x(n)∗h(n)
=Σ∞k=−∞x(k)h(n−k)
Linear convolution
Code:
L = len(xn)
M = len(hn)
N = L+M-1
lx = - xo
lh = - ho
ly = lx + lh
hx = L - 1 - xo
hh = M - 1 - ho
hy = hx + hh
yn = [0]*N
multiplication =[]
print("Tabular form:")
print(" ")
print("\t\t",xn)
multiplication.append(value*val)
print("{}".format(value),"\t|","\t",multiplication)
multiplication=[]
for i in range(L):
for j in range(M):
yn[i+j]+=xn[i]*hn[j]
Output:
Plot:
Code:
L = len(x_n)
M = len(h_n)
K = max(L, M)
for i in range(L,K):
x_n.append(0)
for i in range(M,K):
h_n.append(0)
circular_mat = list()
rotate = 0
for i in range(K):
row = list()
for j in range(K):
rotate += 1
circular_mat.append(row)
print("\nTable : ")
y_n = dict()
for i in range(K):
y_n[i] = 0
for i in range(K):
row = circular_mat[i]
for j in range(len(row)):
y_n[j] += row[j] * h_n[i]
y_n = list(y_n.values())
Output:
Plot
Circular convolution – Matrix Multiplication
Code:
# Circular Convolution
MAX_SIZE = 10;
for j in range(MAX_SIZE)] ;
if(n > m ):
maxSize = n;
else:
maxSize = m;
for i in range(maxSize):
if (i >= n):
row_vec[i] = 0;
else:
row_vec[i] = x[i];
for i in range(maxSize):
if (i >= m):
col_vec[i] = 0;
else:
col_vec[i] = h[i];
k = 0;
d = 0;
for i in range(maxSize):
curIndex = k - d;
for j in range(maxSize):
curIndex += 1;
k = maxSize;
d += 1;
for i in range(maxSize):
for j in range(maxSize):
x = [ 5, 7, 3, 2 ];
n = len(x);
h = [ 1, 5 ];
m = len(h);
convolution(x, h, n, m);
Output:
Plot:
Conclusion: