Lab2
Lab2
508518
Name
Registration Number
Instructor’s Name
Lab # 02 Convolution of Discrete-Time Sequences
Objective:
By the end of this lab, students will be able to understand even and odd component
decomposition of signal. Also, they will be familiarized to get output from LTI systems by
convolving input x(n) with impulse response h(n). This will add to their understanding of LTI
system and its operation.
6. Decomposition of signals:
Let’s have a look at how to decompose a signal into its even and odd components.
Any arbitrary real-valued sequence x(n) can be decomposed into its even and odd component
• Recall the “conv” command you used in your signals and systems course. Try performing
convolution using conv command.
>> y = conv(x,h)
• You will see there is a limitation in conv command. Can you find a solution to it?
Convolution:
There are two widely used methods to compute convolution. We will discuss both methods before
performing Lab tasks.
Method 1:
Convolution as sum of shifted and scaled impulse response:
– Step 3: multiply x(k) and h(n-k) for each k and then take the summation over k
Note
Example:
Method 2:
Convolution as sum of shifted and scaled unit impulses.
y(n) = ∑k x(n)h(n-k)
x(n) = ∑k ak δ(n-k)
y(n)= ∑ a0 δ(n) h(n)+ ∑a1 δ(n-1) h(n-1)+ ∑ a2 δ(n-2) h(n-2)+ ∑a3 δ(n-3) h(n-3)+ ……..
Example:
y(n)= ∑ (a0 δ(n) h(n)+ a1 δ(n-1) h(n-1)+ a2 δ(n-2) h(n-2)+ a3 δ(n-3) h(n-3)
δ(n) h(n) y0
1 1 1
X =
0 n 0 1 n 0 1 n
-1 -1
δ(n-1) h(n-1) y1
2 1 2
1 n X 1 2 n = 1 2 n
-1 -2
δ(n-2) X h(n-2) = y2
3 1 3
2 n 2 3 n 2 3 n
-1 -3
δ(n-3) h(n-3) y3
4 1 4
X =
3 n 3 4 n 3 4 n
-1 -4
Final Result:
y(n)
1 1 1 1
0 1 2 3 4 n
-4
Task 1:
Write a function (in MATLAB) for decomposition of discrete time sequence to distinguish its
even and odd components.
Task 2:
Write a function convolution in MATLAB that performs 1D linear convolution by the steps
mentioned above using any method. You can process the sequence to distinguish the convolution
results of your function and the MATLAB built-in function “conv”.
You should have noticed that “conv” command calculates convolution assuming both input
sequences are starting from origin (i-e no values on –ve n-axis). This is not always the case; we do
have sequences which have values for n<0. Write a function conv_m to describe and analyze the
“conv” command that would remove this limitation in the built-in function “conv”.
Analyze the following sequences to convolve them using MATLAB Function “conv” and your
function “conv_m” and plot the input, impulse response, and output in one figure using “subplot”: