Professional Documents
Culture Documents
EEE324 - Digital Signal Processing
EEE324 - Digital Signal Processing
EEE324 - Digital Signal Processing
Lab # 03
Class FA17-BEE-E
LAB TASKS
PRE-LAB TASKS:
TASK 1:
Let the following rectangular pulse (𝒏) be an input to an LTI system with impulse response ℎ(), determine the output(𝒏). Plot the
input signal and output signal. .
CODE:
clc
clear all
close all
n=-10:10
x=heaviside(n)-heaviside(n-10)
h=(0.9.^n).*heaviside(n)
y=conv(x,h)
subplot(3,1,1)
stem(n,x)
xlabel('n')
ylabel('amplitude')
title('input signal')
subplot(3,1,2)
stem(n,h)
xlabel('n')
ylabel('amplitude')
title('impulse response')
subplot(3,1,3)
stem(y)
Figure 1 pre-TASK 01 OUTPUT
xlabel('n')
ylabel('amplitude')
title('output signal')
IN-LAB TASKS
LAB TASK 1
Given the following two sequences, determine the convolution y(n). Plot each step in the subplot.
CODE:
clc
clear all
close all
n1=-3:3
x=[3,11,7,0,-1,4,2]
n2=-1:4
h=[2,3,0,-5,2,1]
y=conv(x,h)
subplot(3,1,1)
stem(n1,x)
xlabel('n')
ylabel('amplitude')
title('input signal')
subplot(3,1,2)
stem(n2,h)
xlabel('n')
ylabel('amplitude')
title('impulse response')
subplot(3,1,3)
stem(y)
xlabel('n')
Figure 2 output for task 1
ylabel('amplitude')
title('output signal')
TASK 2:
Write a MATLAB function to systematically develop the sequence [𝒏] generated by the convolution of the two-finite length
sequence [𝒏] and [𝒏]. Program should be able to handle causal and non- casual sequences. You should verify this functionality of
the program. Program should call for the input sequences and their indices vectors..
CODE:
nyb=nx(1)+nh(1)
nye=nx(length(x)) + nh(length(h))
y=conv(x,h)
end
clc
clear all
close all
nx= -3:3
nh= -1:4
x=[3 11 7 0 -1 4 2]
h=[9 5 3 4 5 6]
[y,ny] = convo(nx,nh,x,h)
y1=conv(x,h)
TASK 3
Show that the convolution of a length-M sequence with a length-N sequence leads to a sequence of length (M+N1).
CODE:
clc
clear all
close all
n1=-3:3
n2=-1:4
x=[3 11 7 0 -1 4 2]
h=[2 3 0 -5 2 1]
y=conv(x,h)
M=length(x)
N=length(h)
Z=length(y)
LAB TASK 3
Verify Properties of LTI Systems 1. Commutative Law 2. Associative Law 3. Distributive Law 4. Linearity 5. Time Invariance
CODE:
clc
clear all
close all
n=-5:5
x=[3 11 7 0 -1 4 2]
h=[2 3 0 -5 2 1]
y2=conv(h,x)
subplot(2,1,1)
stem(y1)
xlabel('n')
ylabel('amplitude')
Figure 3output for commutative law
title('x(n)*h(n)')
subplot(2,1,2)
stem(y2)
xlabel('n')
ylabel('amplitude')
title('h(n)*x(n)')
n=-5:5
x=[3 11 7 0 -1 4 2]
h1=[2 3 0 -5 2 1]
h2=[3 4 0 -6 3 2]
y2=conv(y1,h2)
y3=conv(h1,h2)
y4=conv(x,y3)
subplot(2,1,1)
stem(y2)
xlabel('n')
ylabel('amplitude')
title('[x(n)*h1(n)]*h2(n)')
subplot(2,1,2)
Figure 4output for associative law
stem(y4)
xlabel('n')
ylabel('amplitude')
title('x(n)*[h1(n)*h2(n)]')
n=-5:5
x=[3 11 7 0 -1 4 2]
h1=[2 3 0 -5 2 1]
h2=[3 4 0 -6 3 2]
h=h1+h2
y2=conv(x,h1)
y3=conv(x,h2)
y4=y2+y3
subplot(2,1,1)
stem(y1)
xlabel('n')
ylabel('amplitude')
title('x(n)*[h1(n)+h2(n)]')
subplot(2,1,2)
stem(y4)
xlabel('n')
title('x(n)*h1(n)+x(n)*h2(n)')