DSP Lab Report # 3: Submitted by
DSP Lab Report # 3: Submitted by
LAB REPORT # 3
Submitted By:
Marryam Nawaz
SP-12-BET-043
Hifza Sajid
SP-12-BET-029
Submitted To:
Sir Mubeen Sabir
Class Instructor:
Sumayya Haroon
Class:
BET-5A
Dated:
07/03/2014
In-Lab Tasks
Task1:
If arbitrary sequences are of infinite duration, then MATLAB cannot be used directly to compute
the convolution.
No overlap
Partially overlap
Complete overlap
A built in function to compute convolution of 2 finite duration is called “conv”.It assumes that
the two sequences begin at n = 0:
y = conv(x,h)
MFile code:
clear all;
close all;
clc
nx=-3:3;
nh=-1:4;
x=[3 11 7 0 -1 4 2];
h=[2 3 0 -5 2 1];
subplot(3,1,1)
stem(nx,x,'r')
xlabel('n');
ylabel('x[n]');
legend('x[n]');
subplot(3,1,2)
stem(nh,h,'g')
xlabel('n');
ylabel('h[n]');
legend('h[n]');
subplot(3,1,3)
y=conv(x,h);
ny=-4:7;
stem(ny,y)
xlabel('n');
ylabel('y[n]');
legend('y[n]');
Task-2:
Convolve following sequences using MATLAB Function “conv” and plot the input, impulse
response and output in one figure using “subplot”:
MFile code:
nx=0:2;
nh=0:2;
x=[1 2 1];
h=[1 1 1];
subplot(3,1,1)
stem(nx,x)
xlabel('n');
ylabel('x[n]');
legend('x[n]');
subplot(3,1,2)
stem(nh,h)
xlabel('n');
ylabel('h[n]');
legend('h[n]');
subplot(3,1,3)
y=conv(x,h);
ny=0:4;
stem(ny,y)
xlabel('n');
ylabel('y[n]');
legend('y[n]');
MFile code:
nx=-2:4;
x=[-1 4 -3 -2 1 0 2];
nh=-1:1;
h=[1 1 1];
subplot(3,1,1)
stem(nx,x)
xlabel('n');
ylabel('x[n]');
legend('x[n]');
subplot(3,1,2)
stem(nh,h)
xlabel('n');
ylabel('h[n]');
legend('h[n]');
subplot(3,1,3)
y=conv(x,h);
ny=-3:5;
stem(ny,y)
xlabel('n');
ylabel('y[n]');
legend('y[n]');