LAB 6 OPEN ENDED Usman Jadoon

You might also like

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

Pak-Austria Fachhochschule Institute of Applied

Sciences and Technology, Haripur, Pakistan

DEPARTMENT OF ELECTRICAL ENGINEERING


COURSE: SIGNAL AND SYSTEMS
COURSE CODE: ECE-251
Lab Report
LAB 06
Submitted by:
Name: Muhammad Usman Jadoon
Reg# B20F0447EE031

Submitted to:
Name: Rafi Ullah
Designation: LAB Engineer

Date:
March 24, 2022
OPEN ENDED LAB
OBJECTIVE:
The objective of this lab is to apply concepts of previous lab in this lab.

Software:
MATLAB

Introduction:
Convolution is a mathematical operation used to relate input, output and impulse response of an
LTI system as: 𝑦(𝑛) = 𝑥(𝑛) ∗ ℎ(𝑛)
Where 𝒚 (𝒏) = output of LTI, 𝒙 (𝒏) = input of LTI and 𝒉 (𝒏) = impulse response of LTI.

Steps to Implement Convolution:

• Suppose x(t) is the input applied to the system and h(t) is the impulse response of the
system.
• Its output y(t) can be obtained using the mathematical expression given below.
y(t) = x(t)*h(t)

Block Diagram

• I have made a very simple block diagram representation of convolution.


• The input x(t) is applied to the system.
• The system has convolved the input x(t) and the impulse response of the
system h(t) to obtain its output y(t).

• The block diagram is shown in the figure below.


Lab 06 Tasks
TASK 1:
Convolve the given signals as a proof of convolution.

Associative property. Convolve the output and plot the graphs a


Finds out if both are equals or not.
i. x[n]=e^-nu[n-2]
ii. h[n]= (9-2) ^n.*u [n+2]
iii. h2[n]= (0.5) ^n.*u[n+5]

ANSWER:
CODE:
x = 1: 10
n=1:2:10
x = exp(-n).*heaviside(n-2);
h1 = (-2.^n).*heaviside(n+2);

z= conv(x,h1);
a=0:(length(z)-1);
stem(a,z)
x=(exp(-n)).*heaviside(n-2)
h=(2.^n).*heaviside(n+2)
h2=((0.5).^n).*heaviside(n+5) %Associative Property x(h*h2)=(x*h)*h2
a=conv(h,h2)
n=0:(length(a)-1);
subplot(321)
stem(n,a)
title('(h*h2)')

b=conv(x,h)
n=0:(length(b)-1);
subplot(322)
stem(n,b)
title('(x*h)')

c=conv(x,a)
n=0:(length(c)-1);
subplot(323)
stem(n,c)
title('x*(h*h2)')

d=conv(h2,b)
n=0:(length(d)-1);
subplot(324)
stem(n,d)
title('(x*h)*h2')
OUTPUT:

EXPLANATION:
In this task firstly, we make steps of n. Then with Heaviside function we made the functions. We
proved the associative property of convolution. First, we convolve the two impulses then
convolve them with x input. Then we convolve the input the input and the impulse then convolve
them with the second impulse. Results are same.

TASK 2:
Convolve the given signals as a proof of convolution.
Distributive property. Convolve the output and plot the graphs a

Finds out if both are equals or not.


i. x[n]=e^-nu[n-2]
ii. h[n]= (9-2) ^n.*u [n+2]
iii. h2[n]= (0.5) ^n.*u[n+5]

ANSWER:
CODE:
x = 1: 10
n=1:2:10
x=(exp(-n)).*heaviside(n-2)
h=(2.^n).*heaviside(n+2)
h2=((0.5).^n).*heaviside(n+5) %Distributive Property x(h+h2)=(x*h)+(x*h2)
a=h+h2
n=0:(length(a)-1);
subplot(321)
stem(n,a)
title('(h+h2)')
b=conv(x,h)
n=0:(length(b)-1);
subplot(322)
stem(n,b)
title('(x*h)')
c=conv(x,h2)
n=0:(length(c)-1);
subplot(323)
stem(n,c)
title('(x*h2)')
d=conv(x,a)
n=0:(length(d)-1);
subplot(324)
stem(n,d)
title('(x*(h+h2)')
e=b+c
n=0:(length(e)-1);
subplot(325)
stem(n,e)
title('(x*h)+(x*h2)')

OUTPUT:
EXPLANATION:
First, we make steps of n. Then with Heaviside function we made the functions. We added the
two impulses and then convolve them with input. Secondly, we convolve input with first impulse
and then with the second impulse and then added them. Both the results were same hence
proved the distributive property.

TASK 3:
Convolve the given signals as a proof of convolution.
Commutative property. Convolve the output and plot the graphs a

Finds out if both are equals or not.


i. x[n]=e^-n.*u[n-2]
ii. h[n]= (9-2) ^n.*u [n+2]

ANSWER:
CODE:
x = 1: 10
n=1:2:10
x = exp(-n).*heaviside(n-2);
h= (-2.^n).*heaviside(n+2);
a=conv(x,h)
n=0:(length(a)-1);
subplot(321)
stem(n,a)
title('x*h')
b=conv(h,x)
n=0:(length(b)-1);
subplot(322)
stem(n,b)
title('h*x')

OUTPUT:

EXPLANATION:
We make steps of n. Then with Heaviside function we made the functions. We proved the
commutative property by first convolving input with impulse and then impulse with input. Both
the outputs are same so proved the result.

TASK 3:
x = [0 0 1 2 3 4];
h = [1 1 1 1 ];
Generation of signal by using loops.

ANSWER:
CODE:
clear variables
close all
n = 1:10;
x = [0 0 1 2 3 4];
h = [1 1 1 1 ];
N = length(x);
M = length(h);
Ny = N + M -1;
y = zeros(1,Ny);
for i = 1:N
for k = 1:M
y(i+k-1) = y(i+k-1) + h(k)*x(i);
end
end
m = 0: Ny-1;
% Make plot
figure
stem(m,y,'linewidth',3,'color','B')
grid;

OUTPUT:

EXPLANATION:
We made loop for initialization and displayed the result.

CONCLUSION:
In this lab we reised previous concepts of signal and systems mainly used Heaviside
functions and proved the properties of LTI systems and then generate the signal by using
loop.

You might also like