0% found this document useful (0 votes)
12 views

lab_06.docx

This lab report focuses on the analysis of discrete Linear Time-Invariant (LTI) systems using convolution sum methods. It includes detailed tasks for computing and plotting the convolution of specified signals using two different methods, demonstrating the process through various MATLAB code snippets. The report is structured into three main tasks, each illustrating the convolution process with different input signals and impulse responses.

Uploaded by

zimalabdi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

lab_06.docx

This lab report focuses on the analysis of discrete Linear Time-Invariant (LTI) systems using convolution sum methods. It includes detailed tasks for computing and plotting the convolution of specified signals using two different methods, demonstrating the process through various MATLAB code snippets. The report is structured into three main tasks, each illustrating the convolution process with different input signals and impulse responses.

Uploaded by

zimalabdi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 54

Signals & Systems

EEE-223

Lab Report#06

Name
SHALIZA AAMIR

Registration Number FA19-BEE-196

Class 4-D

Instructor’s Name
SIR. KHURRAM SHEHZAD

1|Page 58
Lab 06- Analysis of Discrete LTI Systems using
Convolution Sum
In-Lab Tasks:
Task 01

Compute and plot the convolution y[ n]  x[n]* h[ n] by any of the two procedures, where
n
 1
x[n]   u[ n  1]
 3 and h[n] u[n  1]

Method 01:

n = -5:5
u = (n<=1)
x = 0.3.^-n.*u
subplot(3,1,1)
stem(n,x,'LineWidth',3)
title('x[n]')

h=zeros(1,11)
h(7:11)=1
subplot(3,1,2)
stem(n,h,'LineWidth',3)
title('h[n]')

y =conv(h,x)
subplot(3,1,3)
stem(-5:15,y,'LineWidth',3)
title('y[n]')

2|Page 58
Method #02:

n=-2:2
u=(n<=1)
x=((0.3).^-n).*u
subplot(2,1,1)
stem(n,x,'linewidth',3)
title('x(n)')

h=(n>=1)
subplot(2,1,2)
stem(n,h,'linewidth',3)
title('h(n)')

3|Page 58
%taking the signal from n =>k axis

k=-2:2
u=(n<=1)
x=((0.3).^-k).*u
subplot(4,1,1)
stem(k,x,'linewidth',3)
title('x(k)')

h=(k>=1)
subplot(4,1,2)
stem(k,h,'linewidth',3)
title('h(k)')

%first of all flip the h(k)

a=-1
subplot(4,1,3)
stem((1/a)*k,h,'linewidth',3)
title('h(-k)')

n=0
subplot(4,1,4)
stem(((1/a)*k)+n,h,'linewidth',3)

4|Page 58
title('h(-k+0)')

%original signal

k=-2:2
u=(k<=1)
x=((0.3).^-k).*u
subplot(4,1,1)
stem(k,x,'linewidth',3)
title('x(k)')

%flip the h(k) directly

a=-1
subplot(4,1,2)
stem((1/a)*k,h,'linewidth',3)
title('h(-k)')

% shifting the h(-k)by n=1


n=1
subplot(4,1,3)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+1)')

% shifting the h(-k)by n=2


n=2
subplot(4,1,4)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+2)')

5|Page 58
%original signal

k=-2:2
u=(k<=1)
x=((0.3).^-k).*u
subplot(4,1,1)
stem(k,x,'linewidth',3)
title('x(k)')

%flip the h(k) directly

a=-1
subplot(4,1,2)
stem((1/a)*k,h,'linewidth',3)
title('h(-k)')

% shifting the h(-k)by n=3


n=3
subplot(4,1,3)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+3)')

% shifting the h(-k)by n=4


n=4
subplot(4,1,4)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+4)')

6|Page 58
%original signal

k=-2:2
u=(k<=1)
x=((0.3).^-k).*u
subplot(4,1,1)
stem(k,x,'linewidth',3)
title('x(k)')

%flip the h(k) directly

a=-1
subplot(4,1,2)
stem((1/a)*k,h,'linewidth',3)
title('h(-k)')

% shifting the h(-k)by n=5


n=5
subplot(4,1,3)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+5)')

7|Page 58
Task 02
Compute and plot the convolution of following signals (by both procedures)
1 0 n 4
x[n] 
0 elsewhere

and

1.5n 0 n 6
h[ n] 
 0 elsewhere

Method 01
%signal x(n)
n = -5:10;
x = [0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0];

subplot(3,1,1)
stem(n,x,'LineWidth',3)
title('x[n]')

%signal h(n)

subplot(3,1,2)
a1 = (n>=0)&(n<=6);
a2 = 1.5.^n;

8|Page 58
h = a1.*a2;
stem(n,h,'LineWidth',3)
title('h[n]')

%convolution

y = conv(x,h);
subplot(3,1,3)
stem(-1:29,y,'LineWidth',3)
title('y[n]')

Method #02

n=-1:7
x=(n>=0)&(n<=4)
subplot(3,1,1)
stem(n,x)
title('signal of x(n)')

a1=(1.5).^n
a2=(n>=0)&(n<=6)
h=a1.*a2
subplot(3,1,2)
stem(n,h)
title('signal of h(n)')

9|Page 58
%first of all take the reflection of h(n)

b=-1
subplot(3,1,3)
stem((1/b)*n,h)
title('signal of h(-n)')

Express the signal from n --> k

k=-1:7
x=(k>=0)&(k<=4)
subplot(4,1,1)
stem(k,x)
title('x(k)')

% direct we flip the h(k)


a1=(1.5).^k
a2=(k>=0)&(k<=6)
h=a1.*a2
c=-1
subplot(4,1,2)

10 | P a g e 5 8
stem((1/c)*k,h)
title('h(-k)')

% strat shifting the x(-k)

n=0
subplot(4,1,3)
stem(((1/c)*k)+n,h)
title('h(-k+0)')

n=1
subplot(4,1,4)
stem(((1/c)*k)+n,h)
title('h(-k+1)')

%original signal
k=-1:7
x=(k>=0)&(k<=4)
subplot(4,1,1)
stem(k,x)
title('x(k)')
%fliping of orignal signal
a1=(1.5).^k
a2=(k>=0)&(k<=6)
h=a1.*a2

11 | P a g e 5 8
c=-1
subplot(4,1,2)
stem((1/c)*k,h)
title('h(-k)')
% shifting the x(-k) at n=2
n=2
subplot(4,1,3)
stem(((1/c)*k)+n,h)
title('h(-k+2)')

% shifting the x(-k) at n=2

n=3
subplot(4,1,4)
stem(((1/c)*k)+n,h)
title('h(-k+3)')

%original signal
k=-1:7
x=(k>=0)&(k<=4)
subplot(4,1,1)
stem(k,x)
title('x(k)')

12 | P a g e 5 8
%fliping the h(k) direct
a1=(1.5).^k
a2=(k>=0)&(k<=6)
h=a1.*a2
c=-1
subplot(4,1,2)
stem((1/c)*k,h)
title('h(-k)')

% shifting the x(-k) at n=4


n=4
subplot(4,1,3)
stem(((1/c)*k)+n,h)
title('h(-k+4)')

% shifting the x(-k) at n=5


n=5
subplot(4,1,4)
stem(((1/c)*k)+n,h)
title('h(-k+5)')

%original signal
k=-1:7
x=(k>=0)&(k<=4)
subplot(4,1,1)

13 | P a g e 5 8
stem(k,x)
title('x(k)')

%fliping the h(k) directly


a1=(1.5).^k
a2=(k>=0)&(k<=6)
h=a1.*a2
c=-1
subplot(4,1,2)
stem((1/c)*k,h)
title('h(-k)')

% shifting the x(-k) at n=6


n=6
subplot(4,1,3)
stem(((1/c)*k)+n,h)
title('h(-k+6)')

% shifting the x(-k) at n=7


n=7
subplot(4,1,4)
stem(((1/c)*k)+n,h)
title('h(-k+7)')

14 | P a g e 5 8
%original signal x(k)

k=-1:7
x=(k>=0)&(k<=4)
subplot(4,1,1)
stem(k,x)
title('x(k)')

%fliping h(k) directly

a1=(1.5).^k
a2=(k>=0)&(k<=6)
h=a1.*a2
c=-1
subplot(4,1,2)
stem((1/c)*k,h)
title('h(-k)')

% shifting the x(-k) at n=8

n=8
subplot(4,1,3)
stem(((1/c)*k)+n,h)
title('h(-k+8)')

% shifting the x(-k) at n=9

n=9
subplot(4,1,4)
stem(((1/c)*k)+n,h)
title('h(-k+9)')

15 | P a g e 5 8
% original signal x(k)

k=-1:7
x=(k>=0)&(k<=4)
subplot(3,1,1)
stem(k,x)
title('x(k)')

% fliping the signal h(k) directly

a1=(1.5).^k
a2=(k>=0)&(k<=6)
h=a1.*a2
c=-1
subplot(3,1,2)
stem((1/c)*k,h)
title('h(-k)')

% shifting the x(-k) at n=10

n=10
subplot(3,1,3)
stem(((1/c)*k)+n,h)
title('h(-k+10)')

16 | P a g e 5 8
Task 03

Consider and LTI system with input x[n] and unit impulse response h[n] specified as
x[n] 2n u[ n]
h[ n] u[ n]
Compute the response of the system (by both methods) where we have  6 n 6 .

Method 01

%signal x(n)

n = -6:6
h = [0 0 0 0 0 0 1 1 1 1 1 1 1]
x = 2.^n.*(n<=0)
subplot(3,1,1)
stem(n,x,'LineWidth',3)
title('x(n)')

%signal h(n)

17 | P a g e 5 8
subplot(3,1,2)
stem(n,h,'LineWidth',3)
title('h(n)')

%signal y(n)

y = conv(h,x);
yn = -12:12;
subplot(3,1,3)
stem(yn,y,'LineWidth',3)
title('y[n]')

Method #02

%original signal x(n)

n=-6:6
u=(n<=0)
x=(2.^n).*u
subplot(2,1,1)
stem(n,x,'linewidth',3)
title('x(n)')

%signal h(n)

18 | P a g e 5 8
v=(n>=0)
h=v
subplot(2,1,2)
stem(n,h,'linewidth',3)
title('h(n)')

%changing the axis from n=>k axis


k=-6:6
u=(k<=0)
x=(2.^k).*u
subplot(3,1,1)
stem(k,x,'linewidth',3)
title('x(k)')

%signal h(k)
v=(k>=0)
h=v
subplot(3,1,2)
stem(k,h,'linewidth',3)
title('h(k)')

%fliping the h(k)


a=-1

19 | P a g e 5 8
subplot(3,1,3)
stem((1/a)*k,h,'linewidth',3)
title('h(-k)')

%the original signal x(k)


k=-6:6
u=(k<=0)
x=(2.^k).*u
subplot(5,1,1)
stem(k,x,'linewidth',3)
title('x(k)')

%the signal h(k)


v=(k>=0)
h=v
subplot(5,1,2)
stem(k,h,'linewidth',3)
title('h(k)')

%flip version of the h(k)


a=-1
subplot(5,1,3)
stem((1/a)*k,h,'linewidth',3)
title('h(-k)')

%now shift the signal for n=1

20 | P a g e 5 8
n=1
subplot(5,1,4)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+1)')

% shift the signal for n=2

n=2
subplot(5,1,5)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+2)')

%the original signal x(k)


k=-6:6
u=(k<=0)
x=(2.^k).*u
subplot(5,1,1)
stem(k,x,'linewidth',3)
title('x(k)')

%the signal h(k)

21 | P a g e 5 8
v=(k>=0)
h=v
subplot(5,1,2)
stem(k,h,'linewidth',3)
title('h(k)')

%flip version of the h(k)


a=-1
subplot(5,1,3)
stem((1/a)*k,h,'linewidth',3)
title('h(-k)')

%now shift the signal for n=3

n=3
subplot(5,1,4)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+3)')

% shift the signal for n=4

n=4
subplot(5,1,5)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+4)')

22 | P a g e 5 8
%the original signal x(k)
k=-6:6
u=(k<=0)
x=(2.^k).*u
subplot(5,1,1)
stem(k,x,'linewidth',3)
title('x(k)')

%the signal h(k)


v=(k>=0)
h=v
subplot(5,1,2)
stem(k,h,'linewidth',3)
title('h(k)')

%flip version of the h(k)


a=-1
subplot(5,1,3)
stem((1/a)*k,h,'linewidth',3)
title('h(-k)')

%now shift the signal for n=5

n=5

23 | P a g e 5 8
subplot(5,1,4)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+5)')

% shift the signal for n=6

n=6
subplot(5,1,5)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+6)')

%now shift the signal h(-k) for negative value of n

%the original signal x(k)


k=-6:6
u=(k<=0)
x=(2.^k).*u
subplot(5,1,1)
stem(k,x,'linewidth',3)
title('x(k)')

%the signal h(k)


v=(k>=0)
h=v
subplot(5,1,2)

24 | P a g e 5 8
stem(k,h,'linewidth',3)
title('h(k)')

%flip version of the h(k)


a=-1
subplot(5,1,3)
stem((1/a)*k,h,'linewidth',3)
title('h(-k)')

%now shift the signal for n=-1

n=-1
subplot(5,1,4)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k-1)')

% shift the signal for n=-2

n=-2
subplot(5,1,5)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k-2)')

25 | P a g e 5 8
%the original signal x(k)
k=-6:6
u=(k<=0)
x=(2.^k).*u
subplot(5,1,1)
stem(k,x,'linewidth',3)
title('x(k)')

%the signal h(k)


v=(k>=0)
h=v
subplot(5,1,2)
stem(k,h,'linewidth',3)
title('h(k)')

%flip version of the h(k)


a=-1
subplot(5,1,3)
stem((1/a)*k,h,'linewidth',3)
title('h(-k)')

%now shift the signal for n=-3

n=-3
subplot(5,1,4)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k-3)')

% shift the signal for n=-4

n=-4
subplot(5,1,5)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k-4)')

26 | P a g e 5 8
Task 04

Compute (by both procedures) and graph the convolution y[ n]  x[n]* h[n] , where
x[n] u[n]  u[n  4] and h[n]  [n]   [ n  2] .

Method #01:

%signal x(n)

n = 0:6;
h = [1 0 -1 0 0 0 0];
x = [1 1 1 1 0 0 0];
subplot(3,1,1)
stem(n,x,'LineWidth',3)
title('x[n]')

%signal h(n)

subplot(3,1,2)
stem(n,h,'LineWidth',3)
title('h[n]')

27 | P a g e 5 8
%convolution

y = conv(x,h);
subplot(3,1,3)
stem(0:12,y,'LineWidth',3)
title('y[n]')

Method #02

%signal x(n)

n=-5:5
u=(n>=0)
v=(n>4)
x=u-v
subplot(2,1,1)
stem(n,x,'linewidth',3)
title('x(n)')

%signal h(n)

w=[0 0 0 0 0 1 0 0 0 0 0]
y=[0 0 0 0 0 0 0 1 0 0 0]
h=w-y
subplot(2,1,2)
stem(n,h,'linewidth',3)
title('h(n)')

28 | P a g e 5 8
% changing the signal axis from n => k axis
% signal x(k)

k=-5:5
u=(k>=0)
v=(k>4)
x=u-v
subplot(3,1,1)
stem(k,x,'linewidth',3)
title('x(k)')

% signal h(k)

w=[0 0 0 0 0 1 0 0 0 0 0]
y=[0 0 0 0 0 0 0 1 0 0 0]
h=w-y
subplot(3,1,2)
stem(k,h,'linewidth',3)
title('h(k)')

% now we flip the h(k)

a=-1
subplot(3,1,3)
stem((1/a)*k,h,'linewidth',3)
title('h(-k)')

29 | P a g e 5 8
% signal x(k)

k=-5:5
u=(k>=0)
v=(k>4)
x=u-v
subplot(5,1,1)
stem(k,x,'linewidth',3)
title('x(k)')

% signal h(k)

w=[0 0 0 0 0 1 0 0 0 0 0]
y=[0 0 0 0 0 0 0 1 0 0 0]
h=w-y
subplot(5,1,2)
stem(k,h,'linewidth',3)
title('h(k)')

% now we flip the h(k)

a=-1
subplot(5,1,3)
stem((1/a)*k,h,'linewidth',3)
title('h(-k)')

%shifting the h(-k) for +ve value of n because from the fig.very clear that
%the output will b zero for negative n

30 | P a g e 5 8
%shifting the signal for n=0
n=0
subplot(5,1,4)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+0)')

%shifting the signal for n=1


n=1
subplot(5,1,5)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+1)')

% signal x(k)

k=-5:5
u=(k>=0)
v=(k>4)
x=u-v
subplot(5,1,1)
stem(k,x,'linewidth',3)
title('x(k)')

% signal h(k)

w=[0 0 0 0 0 1 0 0 0 0 0]

31 | P a g e 5 8
y=[0 0 0 0 0 0 0 1 0 0 0]
h=w-y
subplot(5,1,2)
stem(k,h,'linewidth',3)
title('h(k)')

% now we flip the h(k)

a=-1
subplot(5,1,3)
stem((1/a)*k,h,'linewidth',3)
title('h(-k)')

%shifting the h(-k) for +ve value of n because from the fig.very clear that
%the output will b zero for negative n

%shifting the signal for n=2


n=2
subplot(5,1,4)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+2)')

%shifting the signal for n=3


n=3
subplot(5,1,5)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+3)')

32 | P a g e 5 8
% signal x(k)

k=-5:5
u=(k>=0)
v=(k>4)
x=u-v
subplot(5,1,1)
stem(k,x,'linewidth',3)
title('x(k)')

% signal h(k)

w=[0 0 0 0 0 1 0 0 0 0 0]
y=[0 0 0 0 0 0 0 1 0 0 0]
h=w-y
subplot(5,1,2)
stem(k,h,'linewidth',3)
title('h(k)')

% now we flip the h(k)

a=-1
subplot(5,1,3)
stem((1/a)*k,h,'linewidth',3)
title('h(-k)')

33 | P a g e 5 8
%shifting the h(-k) for +ve value of n because from the fig.very clear that
%the output will b zero for negative n

%shifting the signal for n=4


n=4
subplot(5,1,4)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+4)')

%shifting the signal for n=5


n=5
subplot(5,1,5)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+5)')

% signal x(k)

k=-5:5
u=(k>=0)
v=(k>4)
x=u-v
subplot(4,1,1)
stem(k,x,'linewidth',3)
title('x(k)')

34 | P a g e 5 8
% signal h(k)

w=[0 0 0 0 0 1 0 0 0 0 0]
y=[0 0 0 0 0 0 0 1 0 0 0]
h=w-y
subplot(4,1,2)
stem(k,h,'linewidth',3)
title('h(k)')

% now we flip the h(k)

a=-1
subplot(4,1,3)
stem((1/a)*k,h,'linewidth',3)
title('h(-k)')

%shifting the h(-k) for +ve value of n because from the fig.very clear that
%the output will b zero for negative n

%shifting the signal for n=6


n=6
subplot(4,1,4)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+6)')

35 | P a g e 5 8
Task 05
Compute (by both procedures) and graph the convolution y[n] , where
(a) y[n] u[ n]* u[n], 0 n 6

Method #01
n = 0:6;
u = ones(size(n));

subplot(2,1,1)
stem(n,u,'linewidth',2)
title('u[n]')

y = conv(u,u);
subplot(2,1,2)
stem(0:12,y,'lineWidth',3)
title('y[n]')

Method 02

36 | P a g e 5 8
%signal x(n)
n=0:6
u=(n>=0)
x=u
subplot(2,1,1)
stem(n,x,'linewidth',3)
title('x(n)')

%signal h(n)
h=u
subplot(2,1,2)
stem(n,h,'linewidth',3)
title('h(n)')

%changing the the axis from n => k axis


k=0:6
u=(k>=0)
x=u
subplot(3,1,1)
stem(k,x,'linewidth',3)
title('x(k)')

%signal h(k)

h=u

37 | P a g e 5 8
subplot(3,1,2)
stem(k,h,'linewidth',3)
title('h(k)')

% now flip the signal h(k)

a=-1
subplot(3,1,3)
stem((1/a)*k,h,'linewidth',3)
title('h(-k)')

% shifting the signal

%original signal x(k)


k=0:6
u=(k>=0)
x=u
subplot(5,1,1)
stem(k,x,'linewidth',3)
title('x(k)')

%signal h(k)
h=u
subplot(5,1,2)
stem(k,h,'linewidth',3)
title('h(k)')

38 | P a g e 5 8
% now flip the signal h(k)

a=-1
subplot(5,1,3)
stem((1/a)*k,h,'linewidth',3)
title('h(-k)')

%shift the signal n=0


n=0
subplot(5,1,4)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+0)')

%shift the signal n=1


n=1
subplot(5,1,5)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+1)')

% shifting the signal

39 | P a g e 5 8
%original signal x(k)
k=0:6
u=(k>=0)
x=u
subplot(5,1,1)
stem(k,x,'linewidth',3)
title('x(k)')

%signal h(k)
h=u
subplot(5,1,2)
stem(k,h,'linewidth',3)
title('h(k)')

% now flip the signal h(k)

a=-1
subplot(5,1,3)
stem((1/a)*k,h,'linewidth',3)
title('h(-k)')

%shift the signal n=2


n=2
subplot(5,1,4)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+2)')

%shift the signal n=3


n=3
subplot(5,1,5)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+3)')

40 | P a g e 5 8
% shifting the signal

%original signal x(k)


k=0:6
u=(k>=0)
x=u
subplot(5,1,1)
stem(k,x,'linewidth',3)
title('x(k)')

%signal h(k)
h=u
subplot(5,1,2)
stem(k,h,'linewidth',3)
title('h(k)')

% now flip the signal h(k)

a=-1
subplot(5,1,3)
stem((1/a)*k,h,'linewidth',3)
title('h(-k)')

%shift the signal n=4


n=4
subplot(5,1,4)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+4)')

%shift the signal n=5

41 | P a g e 5 8
n=5
subplot(5,1,5)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+5)')

% shifting the signal

%original signal x(k)


k=0:6
u=(k>=0)
x=u
subplot(5,1,1)
stem(k,x,'linewidth',3)
title('x(k)')

%signal h(k)
h=u
subplot(5,1,2)
stem(k,h,'linewidth',3)
title('h(k)')

% now flip the signal h(k)

a=-1
subplot(5,1,3)
stem((1/a)*k,h,'linewidth',3)

42 | P a g e 5 8
title('h(-k)')

%shift the signal n=6


n=6
subplot(5,1,4)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+6)')

%shift the signal n=7


n=7
subplot(5,1,5)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+7)')

% shifting the signal

%original signal x(k)


k=0:6
u=(k>=0)
x=u
subplot(5,1,1)
stem(k,x,'linewidth',3)
title('x(k)')

%signal h(k)

43 | P a g e 5 8
h=u
subplot(5,1,2)
stem(k,h,'linewidth',3)
title('h(k)')

% now flip the signal h(k)

a=-1
subplot(5,1,3)
stem((1/a)*k,h,'linewidth',3)
title('h(-k)')

%shift the signal n=8


n=8
subplot(5,1,4)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+8)')

%shift the signal n=9


n=9
subplot(5,1,5)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+9)')

% shifting the signal

44 | P a g e 5 8
%original signal x(k)
k=0:6
u=(k>=0)
x=u
subplot(5,1,1)
stem(k,x,'linewidth',3)
title('x(k)')

%signal h(k)
h=u
subplot(5,1,2)
stem(k,h,'linewidth',3)
title('h(k)')

% now flip the signal h(k)

a=-1
subplot(5,1,3)
stem((1/a)*k,h,'linewidth',3)
title('h(-k)')

%shift the signal n=10


n=10
subplot(5,1,4)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+10)')

%shift the signal n=11


n=11
subplot(5,1,5)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+11)')

45 | P a g e 5 8
% shifting the signal

%original signal x(k)


k=0:6
u=(k>=0)
x=u
subplot(4,1,1)
stem(k,x,'linewidth',3)
title('x(k)')

%signal h(k)
h=u
subplot(4,1,2)
stem(k,h,'linewidth',3)
title('h(k)')

% now flip the signal h(k)

a=-1
subplot(4,1,3)
stem((1/a)*k,h,'linewidth',3)
title('h(-k)')

%shift the signal n=12

46 | P a g e 5 8
n=12
subplot(4,1,4)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+12)')

Task 05

B. Compute (by both procedures) and graph the convolution y[n] , where
y[n] 3 [n  4]*(3 4) n u[ n],0 n 5

47 | P a g e 5 8
Method #01
%signal x(n)

n = 0:5;
h = (3./4).^n.*(n>=0);
x = [0 0 0 0 3 0];
subplot(3,1,1)
stem(n,x,'LineWidth',3)
title('x[n]')

%signal h(n)

subplot(3,1,2)
stem(n,h,'LineWidth',3)
title('h[n]')

% convolution

y = conv(x,h);
subplot(3,1,3)
stem(0:10,y,'LineWidth',3)
title('y(n)')

48 | P a g e 5 8
Method #02
% signal x(n)

n=0:5
x=[0 0 0 0 3 0]
subplot(2,1,1)
stem(n,x,'linewidth',3)
title('x(n)')

% signal h(n)

u=(n>=0)
h=((3./4).^n).*u
subplot(2,1,2)
stem(n,h,'linewidth',3)
title('h(n)')

49 | P a g e 5 8
% changing the axis from n => k axis

% signal x(k)

k=0:5
x=[0 0 0 0 3 0]
subplot(3,1,1)
stem(k,x,'linewidth',3)
title('x(k)')

% signal h(k)

u=(k>=0)
h=((3./4).^k).*u
subplot(3,1,2)
stem(k,h,'linewidth',3)
title('h(k)')

% flip the h(k)

a=-1
subplot(3,1,3)
stem((1/a)*k,h,'linewidth',3)
title('h(-k)')

% now shifting the h(-k) for different values of n in this case there is no

50 | P a g e 5 8
% overlap until the value of n reaches at n= 4 so we start or shifting from
% n =4

% signal x(k)

k=0:5
x=[0 0 0 0 3 0]
subplot(5,1,1)
stem(k,x,'linewidth',3)
title('x(k)')

% signal h(k)

u=(k>=0)
h=((3./4).^k).*u
subplot(5,1,2)
stem(k,h,'linewidth',3)
title('h(k)')

% flip the h(k)

a=-1
subplot(5,1,3)
stem((1/a)*k,h,'linewidth',3)
title('h(-k)')

% shifting the signal at n=4


n=4
subplot(5,1,4)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+4)')

% shifting the signal at n=5


n=5
subplot(5,1,5)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+5)')

51 | P a g e 5 8
% signal x(k)

k=0:5
x=[0 0 0 0 3 0]
subplot(5,1,1)
stem(k,x,'linewidth',3)
title('x(k)')

% signal h(k)

u=(k>=0)
h=((3./4).^k).*u
subplot(5,1,2)
stem(k,h,'linewidth',3)
title('h(k)')

% flip the h(k)

a=-1
subplot(5,1,3)
stem((1/a)*k,h,'linewidth',3)
title('h(-k)')

% shifting the signal at n=6


n=6
subplot(5,1,4)
stem(((1/a)*k)+n,h,'linewidth',3)

52 | P a g e 5 8
title('h(-k+6)')

% shifting the signal at n=7


n=7
subplot(5,1,5)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+7)')

% signal x(k)

k=0:5
x=[0 0 0 0 3 0]
subplot(5,1,1)
stem(k,x,'linewidth',3)
title('x(k)')

% signal h(k)

u=(k>=0)
h=((3./4).^k).*u
subplot(5,1,2)
stem(k,h,'linewidth',3)
title('h(k)')

% flip the h(k)

53 | P a g e 5 8
a=-1
subplot(5,1,3)
stem((1/a)*k,h,'linewidth',3)
title('h(-k)')

% shifting the signal at n=8


n=8
subplot(5,1,4)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+8)')

% shifting the signal at n=9


n=9
subplot(5,1,5)
stem(((1/a)*k)+n,h,'linewidth',3)
title('h(-k+9)')
% after n=9 there is no overlap

Conclusion:
In this lab we learnt about the convolution sum .we took analysis of discrete LTI systems using
convolution sum .in this lab we learnt two methods for finding the convolution sum of the discrete
signals. In one method we apply directly the CONV command in the MATLAB. In second method we use
the basic method in which we flip a signal then we shift the flipped signal with respect to the other signal
.Also we apply these methods on MATLAB and analyze the signal.

54 | P a g e 5 8

You might also like