DSP
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:
Convolution can be evaluated in many different ways.
If arbitrary sequences are of infinite duration, then MATLAB cannot be used directly to compute
the convolution.
As you already know, there are 3 conditions (cases) for evaluation:
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”:
x[n] = [1 2 1], n=[0 1 2] h[n] = [1 1 1], n= [0 1 2]
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]');
x[n] = [-1 4 -3 -2 1 0 2], n=[-2:4] h[n] = [1 1 1], n= [-1 0 1]
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]');