7/28/2019 LTI systems3studs
1/23
LTI systems: Convolution and
difference equations
7/28/2019 LTI systems3studs
2/23
7/28/2019 LTI systems3studs
3/23
7/28/2019 LTI systems3studs
4/23
7/28/2019 LTI systems3studs
5/23
7/28/2019 LTI systems3studs
6/23
7/28/2019 LTI systems3studs
7/23
7/28/2019 LTI systems3studs
8/23
In Matlab
>> x = [ 3 2 1]x =
3 2 1
>> h = [ 2 1 3]
h =
2 1 3
>> conv(x,h)ans =
6 7 13 7 3
length = length(x) + length(h) - 1
7/28/2019 LTI systems3studs
9/23
Compute by (1) hand
(2) with the use of Matlab
7/28/2019 LTI systems3studs
10/23
>> x = [ 0 0 1 2 1 0];
>> h = [ 0 0 1 -1 0 0];>> y = conv(x,h)
y =
Columns 1 through 7
0 0 0 0 1 1 -1
Columns 8 through 11
-1 0 0 0
A
>> x = [ 0 1 1 1 1 0];
>> h = [0 0 1 -1 1 0];>> y = conv(x,h)
y =
Columns 1 through 7
0 0 0 1 0 1 1
Columns 8 through 11
0 1 0 0
B
7/28/2019 LTI systems3studs
11/23
)(*)()()()( nhnxknhkxnyk
)()()()()( nxnhknxkhnyk
)(*)()(*)( nxnhnhnx Commutative Law
Convolution
Equation
Therefore
impulsenh
inputnx
outputny
)(
)(
)(
7/28/2019 LTI systems3studs
12/23
)(*)](*)([)(*)()(
)](*)([*)()(*)](*)([)(
2121
2121
nhnhnxnhnyny
nhnhnxnhnhnxny
Associative Law
)()(*)( 21 nhnhnh Cascade Form
impulsenh
inputnx
outputny
)(
)(
)(
7/28/2019 LTI systems3studs
13/23
)(*)()(*)()]()([*)()( 2121 nhnxnhnxnhnhnxny
Distributive Law
)()()( 21 nhnhnh Parallel Form
impulsenh
inputnx
outputny
)(
)(
)(
7/28/2019 LTI systems3studs
14/23
Plot from 0 n 9,
Convolution is commutative!!!
7/28/2019 LTI systems3studs
15/23
>> x = [ 1 1 1 1 1 0 0 0 0 0];
>> h1 = [ 1 -1 3 0 1 0 0 0 0 0];>> h2 = [ 0 2 5 4 -1 0 0 0 0 0];
>> y = conv(x,h1)
y =
Columns 1 through 6
1 0 3 3 4 3Columns 7 through 12
4 1 1 0 0 0
Columns 13 through 18
0 0 0 0 0 0
Column 19
0
>> y = conv(h1,x)
y =
Columns 1 through 71 0 3 3 4 3 4
Columns 8 through 14
1 1 0 0 0 0 0
Columns 15 through 19
0 0 0 0 0
Therefore convolution is commutative!!!
length = length(x) + length(h) - 1
7/28/2019 LTI systems3studs
16/23
Convolution is distributive!!!!
Plot from 0 n 9,
7/28/2019 LTI systems3studs
17/23
>> y= conv(x,h1+h2)
y =
Columns 1 through 7
1 2 10 14 14 13 12
Columns 8 through 144 0 0 0 0 0 0
Columns 15 through 19
0 0 0 0 0
>> x = [ 1 1 1 1 1 0 0 0 0 0];
>> h1 = [ 1 -1 3 0 1 0 0 0 0 0];
>> h2 = [ 0 2 5 4 -1 0 0 0 0 0];
>> y2 = conv(x,h1) + conv (x,h2)
y2 =
Columns 1 through 11
1 2 10 14 14 13 12 4 0 0 0Columns 12 through 19
0 0 0 0 0 0 0 0
Therefore convolution is distributive!!!!
length = length(x) + length(h) - 1
7/28/2019 LTI systems3studs
18/23
Convolution is associative!!!
>> x = [ 1 1 1 1 1 0 0 0 0 0];
>> h1 = [ 1 -1 3 0 1 0 0 0 0 0];
>> h2 = [ 0 2 5 4 -1 0 0 0 0 0];
>> y = conv(conv(x,h1),h2)
y =
Columns 1 through 7
0 2 5 10 20 35 35
Columns 8 through 14
36 30 20 5 3 -1 0
Columns 15 through 21
0 0 0 0 0 0 0
Columns 22 through 28
0 0 0 0 0 0 0
>> y2 = conv(x,conv(h1,h2))
y2 =
Columns 1 through 7
0 2 5 10 20 35 35
Columns 8 through 14
36 30 20 5 3 -1 0
Columns 15 through 21
0 0 0 0 0 0 0
Columns 22 through 28
0 0 0 0 0 0 0
length = length(x) + length(h) - 1
7/28/2019 LTI systems3studs
19/23
Ex2: Convolution
Determine the unit step response of the system
described by the impulse response. Plot using
stem command evaluate from n = 0 to 9.
h(n) = 0.75nsin(2*pi*n) [u(n) u(n-10)]
ones(1,10)
7/28/2019 LTI systems3studs
20/23
n=0:9;
hna = 0.75.^n.*sin(2*pi*n).*ones(1,10);
x = ones(1,10);
y = conv(x,hna);
ma = length(y)-1;
stem(0:ma,y);
7/28/2019 LTI systems3studs
21/23
Difference Equations
Filteringfilter(b,a,x) filters the vectorx using a difference equation where vectors a and b
represent the equation coefficients. This command implements the equation
Ifa = 1, then the command
performs the convolution of vectors x and b with the length of the output equal to the
length of the input data.
If a = [ 1 2 3 4], b = [5 6], x = [ 1 2 3] then:conv(a,b) = 5 16 27 38 24,
conv(b,a) = 5 16 27 38 24,
filter (b,a,x) = 5 6 0,
filter(b,1,x) = 5 16 27,
filter(x,1,b) = 5 16.
7/28/2019 LTI systems3studs
22/23
Able to properly represent the input/output relationship to a given LTI
system
A linear constant-coefficient difference equation (LCCDE) serves as a
way to express just this relationship
y[n]+7y[n1]+2y[n2]=x[n]4x[n1]
7/28/2019 LTI systems3studs
23/23
Write a MATLAB program to simulate thefollowing difference equation 8y[n] - 2y[n-
1] - y[n-2] = x[n] + x[n-1] initial conditions:
x(n) = 5u(n)
Example
>> b = [1 1 0];
>> a = [ 8 -2 -1];
>> x = 5*ones(1,5);
>> y = filter(b,a,x)
y =
0.6250 1.4063 1.6797 1.8457 1.9214