0% found this document useful (0 votes)
7 views2 pages

Lab Activity 2

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)
7 views2 pages

Lab Activity 2

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/ 2

Lab Activity 2: Convolution Properties in Digital Signal Processing

(DSP) Using Python

I. Objective
a. To understand and verify the properties of convolution (associative, commutative,
distributive, and delta property) using Python in the context of Digital Signal
Processing (DSP).
II. Lab Activity Procedures

Associative

Commutative

Distributive

Delta Property

A. Import necessary libraries


a. numpy as np and matplotlib.pyplot as plt
b.
B. Define 3 dicrete signals x(n), h(n) and g(n) and delta function δ(n)
x = np.array([1, 2, 3, 4])
h = np.array([0, 1, 0.5])
g = np.array([2, 1, 0])

delta = np.zeros(len(x))
delta[0] = 1

C. Implement convolution function, use NumPy’s convolve function to perform convolution.


def convolve_signals(a, b):
return np.convolve(a, b)

D. Verify Associative Property


y1 = convolve_signals(x, h)
y1 = convolve_signals(y1, g)

y2 = convolve_signals(h, g)
y2 = convolve_signals(x, y2)

print("Associative Property Check: ", np.array_equal(y1, y2))


E. Verify Commutative Property
y1 = convolve_signals(x, h)
y2 = convolve_signals(h, x)

print("Commutative Property Check: ", np.array_equal(y1, y2))

F. Verify Distributive Property


y1 = convolve_signals(x, h + g)
y2 = convolve_signals(x, h) + convolve_signals(x, g)

print("Distributive Property Check: ", np.array_equal(y1, y2))

G. Verify Delta Property


y = convolve_signals(x, delta)

print("Delta Property Check: ", np.array_equal(y, x))

H. Plot Results
plt.figure(figsize=(12, 8))
plt.subplot(2, 2, 1)
plt.stem(y1, use_line_collection=)
plt.title("Convolution Result 1")

plt.subplot(2, 2, 2)
plt.stem(y2, use_line_collection=)
plt.title("Convolution Result 2")

plt.show()

III. Analysis (Discuss the results obtained from the experiments and verify that the
properties hold true for the given signals.)
IV. Save the soft copy of the Python code used in the lab and have a brief explanation on
each property and how it was verified using the code.
V. Reminders:
a. Progress Report Hierarchy (A, C, D, DP)
i. Associative
1. Code
2. Output
3. Plot
4. Analysis
5. Explanation on verification

You might also like