Signals and Systems EEE223 Analysis of Continuous Time LTI Systems Using Convolution Integral

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

Signals and Systems

EEE223

Lab 07
Analysis of Continuous Time LTI Systems using
Convolution Integral

Name Tayyab Ahmad Khan

Registration Number FA18-BEE-154

Class 4-C

Instructor’s Name Mam Nida Zamir


t
Task 01: Suppose that a LTI system is described by impulse response h(t )  e u (t ) .
Compute the response of the system (by both methods) to the input signal

0.6 1  t  0.5

x(t )  0.3 0.5  t  3
0 t  1 and t  3

Code Method 1
clear all
close all x[t]
0.6

%initializing t & x[t]


tx1 = -1:0.01:0.5; 0.5

tx2 = 0.5:0.01:3;
t = [tx1 tx2]; 0.4

x1 = ones(size(tx1)).*0.6; 0.3
-1 -0.5 0 0.5 1 1.5 2 2.5 3
x2 = ones(size(tx2)).*0.3;
h[t]
x = [x1 x2]; 1

% Plotting h[t] and x[t]


h = exp(-t).*heaviside(t); 0.5

subplot(2,1,1)
plot(t,x)
title('x[t]') 0
-1 -0.5 0 0.5 1 1.5 2 2.5 3

subplot(2,1,2)
plot(t,h) 2.5
FINAL Response

title('h[t]')
figure;
% For convolution 2

y=conv(x,h).*0.05;
xL=length(x);
hL=length(h); 1.5

nL=(xL+hL-1).*0.05;
tnew=0:0.05:nL-0.05;
plot(tnew,y); 1

title('FINAL Response')
0.5

0
0 5 10 15 20 25 30 35 40 45

Code Method 2
clear all
close all
x[t]
0.6
% Initializing t and x[t]
tx1 = -1:0.01:0.5; 0.5

tx2 = 0.5:0.01:3; 0.4


t = [tx1 tx2];
0.3
-1 -0.5 0 0.5 1 1.5 2 2.5 3
x1 = ones(size(tx1)).*0.6; h[t]
x2 = ones(size(tx2)).*0.3; 1

x = [x1 x2];
0.5

% Plotting h[t] and x[t]


h = exp(-t).*heaviside(t); 0
-1 -0.5 0 0.5 1 1.5 2 2.5 3
subplot(3,1,1)
plot(t,x) 1
h[-t]

title('x[t]')
subplot(3,1,2)
0.5
plot(t,h)
title('h[t]')
subplot(3,1,3) 0
-3 -2.5 -2 -1.5 -1 -0.5 0 0.5 1
plot(-t,h)
title('h[-t]')

figure At delay of 0
1
0.5
n=0; %delay 0
-3 -2.5 -2 -1.5 -1 -0.5 0 0.5 1
subplot(6,1,1) At delay of 1
plot(n-t,h,'linewidth',2) 1

title('At delay of 0') 0.5


0
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2

n=1; %delay 1
At delay of 2

subplot(6,1,2) 0.5
plot(n-t,h,'linewidth',2) 0
-1 -0.5 0 0.5 1 1.5 2 2.5 3
title('At delay of 1') At delay of 3
1
0.5
n=2; %delay 0
subplot(6,1,3) 0 0.5 1 1.5 2 2.5 3 3.5 4

plot(n-t,h,'linewidth',2) At delay of 4
1
title('At delay of 2') 0.5
0
1 1.5 2 2.5 3 3.5 4 4.5 5
n=3; %delay At delay of 5
1
subplot(6,1,4) 0.5
plot(n-t,h,'linewidth',2) 0
2 2.5 3 3.5 4 4.5 5 5.5 6
title('At delay of 3')

n=4; %delay
subplot(6,1,5)
plot(n-t,h,'linewidth',2)
title('At delay of 4')

n=5; %delay
subplot(6,1,6)
plot(n-t,h,'linewidth',2)
title('At delay of 5')

Task 02: Compute (by both methods) and plot the response of the system
0 0  t 1

x(t )  h(t )  1 1 t  2
0 2  t  10

Code Method 1
clear all
close all
x(t)
% Initializing t 1
t1 = 0:0.001:1;
t2 = 1.001:0.001:2;
t3 = 2.001:0.001:10; 0.5
t = [t1 t2 t3];

% Initializing x[t] 0
0 1 2 3 4 5 6 7 8 9 10
x1 = zeros(size(t1));
x2 = ones(size(t2)); h(t)
1
x3 = zeros(size(t3));
x = [x1 x2 x3];
0.5
% Initializing h[t]
h = x;
subplot(3,1,1) 0
plot(t,x,'linewidth',2) 0 1 2 3 4 5 6 7 8 9 10
title('x(t)') Final Response
subplot(3,1,2) 1
plot(t,h,'linewidth',2);
title('h(t)')
0.5

% For convolution
subplot(3,1,3)
0
y = conv(x,h).*0.001; 0 2 4 6 8 10 12 14 16 18 20
n = 0:0.001:20;
plot(n,y,'linewidth',2)
title('Final Response')

Code Method 2
clear all
close all 1
x(t)

% Initializing t
t1 = 0:0.001:1; 0.5

t2 = 1.001:0.001:2;
t3 = 2.001:0.001:10; 0
0 1 2 3 4 5 6 7 8 9 10
t = [t1 t2 t3];
h(t)
1

% Initializing x[t]
x1 = zeros(size(t1)); 0.5

x2 = ones(size(t2));
x3 = zeros(size(t3)); 0
0 1 2 3 4 5 6 7 8 9 10
x = [x1 x2 x3];

h = x;
subplot(3,1,1)
plot(t,x,'linewidth',2)
title('x(t)')
subplot(3,1,2)
plot(t,h,'linewidth',2);
title('h(t)')
At delay of 0
1
figure; 0.5
0
n=0; %delay -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0
subplot(6,1,1) At delay of 1
1
plot(n-t,h,'linewidth',2) 0.5
title('At delay of 0') 0
-9 -8 -7 -6 -5 -4 -3 -2 -1 0 1
At delay of 2
n=1; %delay 1

subplot(6,1,2) 0.5
0
plot(n-t,h,'linewidth',2) -8 -7 -6 -5 -4 -3 -2 -1 0 1 2
title('At delay of 1') At delay of 3
1
0.5
n=2; %delay 0
-7 -6 -5 -4 -3 -2 -1 0 1 2 3
subplot(6,1,3) At delay of 4
plot(n-t,h,'linewidth',2) 1
title('At delay of 2') 0.5
0
-6 -5 -4 -3 -2 -1 0 1 2 3 4

n=3; %delay 1
At delay of 5

subplot(6,1,4) 0.5
plot(n-t,h,'linewidth',2) 0
-5 -4 -3 -2 -1 0 1 2 3 4 5
title('At delay of 3')

n=4; %delay
subplot(6,1,5)
plot(n-t,h,'linewidth',2)
title('At delay of 4')

n=5; %delay
subplot(6,1,6)
plot(n-t,h,'linewidth',2)
title('At delay of 5')

figure;
n=6; %delay
subplot(6,1,1)
plot(n-t,h,'linewidth',2)
title('At delay of 6')
n=7; %delay
subplot(6,1,2)
At delay of 6
plot(n-t,h,'linewidth',2) 1
title('At delay of 7') 0.5
0
-4 -3 -2 -1 0 1 2 3 4 5 6
n=8; %delay At delay of 7
subplot(6,1,3) 1

plot(n-t,h,'linewidth',2) 0.5
0
title('At delay of 8') -3 -2 -1 0 1 2 3 4 5 6 7
At delay of 8
1
n=9; %delay 0.5
subplot(6,1,4) 0
plot(n-t,h,'linewidth',2) -2 -1 0 1 2 3 4 5 6 7 8

title('At delay of 9') At delay of 9


1
0.5
n=10; %delay 0
-1 0 1 2 3 4 5 6 7 8 9
subplot(6,1,5) At delay of 10
plot(n-t,h,'linewidth',2) 1
title('At delay of 10') 0.5
0
0 1 2 3 4 5 6 7 8 9 10
n=11; %delay At delay of 11
1
subplot(6,1,6)
0.5
plot(n-t,h,'linewidth',2) 0
title('At delay of 11') 1 2 3 4 5 6 7 8 9 10 11
Task 03: Suppose that a system is described by the impulse response
h(t )  cos(2 t )(u (t )  u (t  4)) . Compute (by both methods) and plot the response of the
system to the input

Code Method 1

clear all
close all
% Initializing t x(t)
2
t1 = 0:0.001:1;
t2 = 1.001:0.001:2;
t = [t1 t2];
1

% Initializing x[t]
x1 = 2.*t1; 0
x2 = -2.*t2 + 4; 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
x = [x1 x2];
subplot(3,1,1) h(t)
1
plot(t,x)
title('x(t)')
0
n=heaviside(t)-
heaviside(t-4);
h=cos(2.*pi.*t).*n;
-1
subplot(3,1,2) 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
plot(t,h)
title('h(t)') FINAL Response
0.1

%For response of the


system
y=conv(x,h)*0.001; 0
xL=length(x);
hL=length(h);
nL=(xL+hL-1).*0.001; -0.1
0 0.5 1 1.5 2 2.5 3 3.5 4
t3=0:0.001:nL-0.001;
subplot(3,1,3)
plot(t3,y)
title('FINAL Response')

Code Method 2

clear all
close all
% Initializing t
t1 = 0:0.001:1;
t2 = 1.001:0.001:2;
t = [t1 t2];
% Initializing x[t]
x1 = 2.*t1; x[t]
x2 = -2.*t2 + 4; 2

x = [x1 x2];
1
subplot(3,1,1)
plot(t,x,'linewidth',2)
0
title('x[t]') 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2

h[t]
% Expressing h[t] 1

u=heaviside(t)-heaviside(t-
4); 0
h=cos(2.*pi.*t).*u;
subplot(3,1,2)
plot(t,h,'linewidth',2) -1
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
title('h[t]')

figure;
n=0; %delay
subplot(5,1,1)
plot(n-t,h,'linewidth',2)
title('At delay of 0')

n=1; %delay
subplot(5,1,2)
plot(n-t,h,'linewidth',2)
title('At delay of 1') At delay of 0
1

0
n=2; %delay
subplot(5,1,3) -1
-2 -1.8 -1.6 -1.4 -1.2 -1 -0.8 -0.6 -0.4 -0.2 0
plot(n-t,h,'linewidth',2) At delay of 1
title('At delay of 2') 1

0
n=3; %delay -1
subplot(5,1,4) -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
plot(n-t,h,'linewidth',2) At delay of 2
1
title('At delay of 3')
0

n=4; %delay -1
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
subplot(5,1,5)
At delay of 3
plot(n-t,h,'linewidth',2) 1
title('At delay of 4')
0

-1
1 1.2 1.4 1.6 1.8 2 2.2 2.4 2.6 2.8 3
At delay of 4
1

-1
2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6 3.8 4
Critical Analysis:
Basically this lab is all about the convolution or overlapping of two continuous
signals. Almost in all the tasks we are asked to represent the response of the
system to a specific input. The impulse response of a linear time-invariant system
completely specifies the system. More, specifically, if the impulse response of a
system is known one can compute the system output for any input signal. There
are two methods to perform the tasks like some of the last lab experiments. The
first method is use of convolution command i.e. conv. Secondly, apart from this
command, the signals can also be overlapped. There are three types of
overlapping which is used in this lab experiment: Zero Overlapping, no
overlapping and Overlapping etc. Another command used frequently was syms ( )
which is used to integrate any variable initialized to a function. Another command
we learnt was deconv ( ) .The deconvolution process is also useful for determining
the impulse response of a system if the input and output signals are known.

You might also like