Lab 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

LAB-1

Digital Signal Processing Lab


508518

Name

Registration Number

Batch & Section

Instructor’s Name
Lab # 01 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 familiarize 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.

PRE-LAB
Before performing convolution, you should be familiar with the basic operations on continuous
time signals.

1. Time Reversal y(t) = x(-t)


2. Time Shifting y(t) = x(t-td)
3. Amplitude Scaling y(t) = Bx(t)
4. Addition y(t) = x1(t) + x2(t)
5. Multiplication y(t) = x1(t)x2(t)
6. Time Scaling y(t) = x(at)
7. Decomposition of signals:

Lets have a look at how to decompose a signal into its even and odd components

Even and odd synthesis

 if xe (n)  xe (n)
  if xo (n)   xo (n)
then xe (n) is called even( symmetric) 
then xo (n) is called odd (antisymmetric)
Any arbitrary real-valued sequence x(n) can be decomposed into its even and odd component

x(n)  xe (n)  xo (n)


xe (n)  1 [ x(n)  x(n)], xo (n)  1 [ x(n)  x(n)]
2 2
 Try writing a function that decomposes a given signal into its even and odd components.
You can think like the steps given below.
 Input a signal
 Flip the signal
 Calculate its length
 Calculating even and odd parts.
 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?

IN-LAB:
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:

• For any given n, one point convolution is evaluated as

– Step 1: time reversal of either signal (e.g., x(k)x(-k) ) or h(k)h(-k)

– Step 2: shift h(-k) by n samples to obtain h(n-k)

– Step 3: multiply x(k) and h(n-k) for each k and then take the summation over k

Note

• You need to change variable n to get the whole sequence

Example:

x(n)=[1 2 3 4] and h(n)=[1 –1]

Step 1: Time reversal

h(k)=[1 -1] h(n-k)=[-1 1]


Step 2: Time shift

Step 3: Multiply and Add

Final Result:
x(n)
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)= ∑k (∑k ak δ(n-k)) h(n-k)

y(n)= ∑ (a0 δ(n)+ a1 δ(n-1)+ a2 δ(n-2)+ a3 δ(n-3)+ …….. ) h(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:

Consider the same example we solved in first method of convolution as above.

X(n) = [1 2 3 4], h(n)= [1 -1]

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:

Final result is the summation of y0, y1,y2, y3.

y(n)
1 1 1 1

0 1 2 3 4 n

-4

Lab Tasks: [Q Marks-10, CLO-1, PLO-4]

Task 1:

Write a Matlab code to decompose a sequence to describe its even and odd components. Take
help from Pre-Lab work.

Task 2:

Analyze the function convolution in MATLAB that performs 1D linear convolution by the steps
mentioned above. You can process the sequence using any method.

Task 3:

You should have noticed that ‘conv’ command calculates convolution assuming both input
sequences are starting from origin (i-e no values on –ve t-axis). This is not always the case, we do
have sequences which have values for t<0. Write a code conv_m to describe and analyze the
‘conv’ command that would remove this limitation in the code conv.
Task 4:

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”:

 x[n] = [1 2 1], n=[0 1 2] h[n] = [1 1 1], n= [0 1 2]


 x[n] = [-1 4 -3 -2 1 0 2], n=[-2:4] h[n] = [1 1 1], n= [-1 0 1]

You might also like