Beruflich Dokumente
Kultur Dokumente
LAB. MODULE
EXPERIMENT 2
CONVOLUTION
LECTURER
PLV
TECHNICIAN
Students Particular:
Name
Matric. No
Date
Signature
14
ENT 281
EXPERIMENT 2
CONVOLUTION
1.0
OBJECTIVES:
After completing this section you will be able to :
2.0
1.1
1.2
TOOLS
The MATLAB Signal Processing Toolbox.
3.0
INTRODUCTION
3.1
Convolution
The convolution sum describes the relationship between the input and output of
discrete-time system, and is easily evaluated to a compute as a sum of products of
numbers.
Conv evaluates the convolution of finite duration discrete time signals,
commands covered:
conv
deconv
To perform discrete time convolution, x[n]*h[n], define the vectors x and h with
elements in the sequences x[n] and h[n]. Then use the command
y = conv(x,h)
This command assumes that the first element in x and the first element in h
correspond to n = 0, so that the first element in the resulting output vector
corresponds to n = 0 . If this is not the case, then the output vector will be computed
correctly, but the index will have to be adjusted.
Example 3.1.1
>> x = [1 1 1 1 1];
>> h = [0 1 2 3];
>> y = conv(x,h)
15
ENT 281
y[1] =
1, .... In general, total up the index of the first element in h and the index of the first
element in x, this is the index of the first element in y.
For example, if the first element in h corresponds to n = -2 and the first element in x
corresponds to n = -3, then the first element in y corresponds to n = -5.
Care must be taken when computing the convolution of infinite duration signals. If the
vector x has length q and the vector h has length r, then you must truncate the vector
y to have length min(q,r).
Command conv can also be used to multiply polynomials: suppose that the
coefficients of a(s) are given in the vector a and the coefficients of b(s) are given in
the vector b, then the coefficients of the polynomial a(s) b(s) can be found as the
elements of the vector defined by ab = conv(a,b).Command deconv is the inverse
procedure to the convolution. In this text, it is used as a means of dividing
polynomials. Given a(s) and b(s) with coefficients stored in a and b, then the
coefficients of c(s) = b(s)/a(s) are found by using the command c = deconv(b,a).
3.2
For a discrete-time transfer function, the coefficients are stored in descending powers
1
of z or ascending powers of z . For example,
3.3
Time Simulations
Commands Covered:
conv
dstep
dimpulse
filter
There are two methods to compute the response of a system described by the
following recursive relationship
16
ENT 281
Recursive relationship
The first method to compute the response uses convolution and is useful when the
initial conditions on y are zero. This method involves first finding the impulse
response of the system, h[n], and then convolving h[n] with x[n] as discussed in
Section 3.1. For example, consider the system described above with zero initial
conditions, that is, y[-1]=y[-2]=0. The impulse response for this system is
% times starts at n = 0 to n = 10
>> x = ones(1,11);
% impulse response
>> y = conv(x,h)
>> y = y(1:length(n))
>> stem(n,h)
The vector y contains the values of y[n] for n = 0,1,...,10. Note that the vector was
truncated to length(n) because both x[n] and h[n] are infinite duration signals.
The second method of solving for the response requires that the transfer function of
the system be known. The commands dstep and dimpulse compute the unit step
response and the unit impulse response, respectively while the command filter
computes the response to initial conditions and to arbitrary inputs. The denominator
coefficients are stored as den = [a0 a1 a2 aN] and the numerator coefficients are
stored as num = [b0 b1 bM 0] where there are N-M zeros padded on the end of
the coefficients.
y[n] 0.6y[n-1] + 0.08y[n-2] = x[n-1]
where x[n] = u[n] and initial conditions y[-1] = y[-2] = 0
For example, consider the system given above with initial conditions
y[-1] = y[-2]= 0. To compute the step response for n=0 to n=10
ENT 281
The response can then be plotted using the stem plot. To compute the impulse
response, simply replace dstep with dimpulse in the above commands.To compute
the response to an arbitrary input, store the input sequence in the vector x. The
command
y = filter(num,den,x);
is used to compute the system response. If the system has nonzero initial conditions,
the initial conditions can be stored in a vector v0. For a first order system where N =
M = 1, define
1
2
1
2
1
2
define i
To compute the response with nonzero initial conditions, type
y = filter(num,den,x,zi);
Zi=filtic(num,den,[initial condition]);
For example, consider the previous system with the initial conditions y[-1] = 2 and y[2] = 1 and input x[n] = u[n]. Type the following commands to compute y[n].
>> num = [0 1 0];
>> den = [1 -0.6 0.08];
>> n = 0:10;
>> x = ones(1,11);
>> Zi=filtic(num,den,[2,1])
>> y = filter(num,den,x,Zi)
Example 3.3.1
Consider the discrete-time LTI System model representing a two-path propagation
channel, the strength of the indirect path is a = , then,
y [n] = x [n] + ax [n - 1]
y [n] = x [n] + ()x [n - 1]
letting x [n] = [n], the impulse response is
1, n = 0
h [n] =
, n = 1
0, otherwise
4, n = 1
-2, n = 1
0, otherwise
18
ENT 281
Solution 3.3.1
The first Nonzero value in the impulse response and input occur at time
n = kh = kx = 0. The last element of the impulse response and input occur at times n
= lh = 1 and n = lx = 2. Thus the convolution y starts at time n = k y = kx + kh = 0, end
at time n = ly = lx + lh = 3 and has length Ly = ly - ky + 1 = 4
(i) Convert the equation into differential equation form
h [n] = [n] + 1/2 [n-1]
x [n] = 2 [n] + 4 [n-1] - 2 [n-2]
(ii) We evaluate the convolution in MATLAB as follow
>> h = [ 1 , 0.5 ];
>> x = [ 2 , 4 , -2 ];
>> y = conv (x,h)
>> n = [0:length (y)-1];
>> stem (n,y)
>> xlabel(Time)
>> ylabel(Impulse Response)
y=
2
-1
Interpretation,
0,n<0
2,n=0
5 , n =1
y[n] =
0,n=2
-1 , n = 3
0,n4
Example 3.3.2
Determine the output of a system for impulse response given by
1
h [n] = ( 4 ) (u [n] - u [n - 4] )
_________________
(i)
19
ENT 281
and input
x [n] = u [n] - u [n-10]
_________________
(ii)
signal (i) & (ii) may be defined in MATLAB following this command:
>> h = 0.25*ones(1,4);
>> x = ones (1,10);
>> n = 0:12; y starts at time n = Ky = 0, ends at time n = Ly = 12
>> y = conv ( x, h);
>> n = [0:length(y)-1];
>> stem(n,y); xlabel(n); ylabel(y[n])
Problem 3.3.1
Evaluate the following discrete-time convolution sums using MATLAB.
y [n] = {u [n - 2] - u [n - 13] } * 2{u [n + 2] - u [n - 12] }
for = 0.9,
i.e, find the output of the system of input
x [n] = 2 {u [n + 2] - u [n -12] } and impulse response
h [n] = 0.9 {u [n - 2] - u [n -13] }.
3.4
STEP RESPONSE
The step response is the output of a system in response to a step input and is infinite
in duration, in general.
Example 3.4.1
Find the first 50 values of the step response of the first order recursive system with
impulse response.
h [n] = pn u [n],
assuming that | p | < 1
Solution 3.4.1
Try this command;
We may determine the 1st 50 values of the step response of the system
with p = - 0.9,
20
ENT 281
>> h = (-0.9).^[0:49];
>> u = ones (1,50);
>> y = conv (u,h);
>> stem ( [ 0:49] , y (1:50)); @
Exercise 3.4.2
Evaluate the first 20 values of the step response for the LTI system represented by
the following impulse response.
h [n] =
3/4,
0n5
0,
otherwise
>> h = [ 1 1 1 1 1] *0.75
% 1st. element at n = 0.
>> y = conv(h,stepfn);
>> y = y (1:20);
>> n = [0:length(y)-1];
>> stem (n,y)
>> xlabel(Time), ylabel(Step response of h)
3.5
The Impulse Response of the system is the output signal of the system when the
input signal is an impulse function applied at time t = 0.
x(t ) (t t 0 )
Suppose the system is modeled by a convolution integral. Then the output to the
y i (t )
system is ;
h(t ) ( t
) d
h(t t 0 )
21
ENT 281
h[ K ]e
j ( n 1)
K kh
Lh n < Kh + Lv
= h [n] * ejn ,
Lh n < Kh + Lv
= H (ej ) ejn ,
Lh n < Kh + Lv
Hence, the system output in response to a finite-duration sinusoidal input
corresponds to the output in response to an infinite-duration sinusoidal input on the
interval Lh n < Kh + Lv. The magnitude and phase response of the system maybe
determined from y[n], Lh n < Kh + Lv , by no trigger that ,
y[n] = |H (ej )| ej(n + arg {H ( e
)})
Lh n < Kh + Lv
Lh n < Kh + Lv
and
arg { y[n] } = - n = arg { H(ej) },
Lh n < Kh + Lv
Example 3.5.1
Consider the system with impulse response,
h2 [n] =
1
2
[n]
1
2
[n-1]
Find the frequency response of the system and plot 50 values of the steady-state
3
4 .
Solution 3.5.1
Here, Kh = 0
response, we require Lv 51, the output signal are obtained by MATLAB commands :
22
ENT 281
23
ENT 281
h [n] = n u [-n]
0 < < 1, N = 5
Use MATLAB command conv to plot the first 20 values of the responses.
Q 2.4 Evaluate the frequency response at the frequency = /3 and 50 values of
the steady-state output in response to a complex sinusoidal input of frequency =
/3 for the moving-average system with impulse response
1
4
0n1
h [n] =
0 otherwise
translate to h[n] = [n] + [n-1]
24