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

Elce203l Lab05

Uploaded by

Azamat Shmitov
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)
11 views

Elce203l Lab05

Uploaded by

Azamat Shmitov
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/ 21

ELCE 203L: Signals & Systems Laboratory – Lab 05: Convolution (Discrete and Continuous)

School of Engineering & Digital Sciences


(FALL 2023)

ELCE 203L Signals and Systems


Laboratory

Lab 05. Convolution (Discrete and Continuous)


(Week # 9-10)

Lab Manual

1
ELCE 203L: Signals & Systems Laboratory – Lab 05: Convolution (Discrete and Continuous)

Objective:

The purpose of this lab is to learn Convolution Analysis in MATLAB

Important Notes:
1. You MUST Study this manual before joining the LAB session.
2. The completed lab Tasks & Report MUST be submitted by midnight after the Lab
Session. (Link will be provided on Moodle)
3. Please write your own interpretation in your own words.

Good Luck!!
_______________________________________________________________________________

Lab 05 – Convolution (Discrete and Continuous)

5.1 Discrete Time Convolution:


An LTI discrete-time system is (equivalently to the continuous-time case) completely describes
by impulse response, which is usually denoted by h[ n] . The impulse response of an LTI discrete-
time system is the output of the system when the unit impulse sequence (or Kronecker delta
function) is applied as input. Even though the unit impulse input consists of one no-zero term,
the impulse response signal h[ n] usually consists of more than one non-zero elements. The
explanation is that the system is dynamic (with memory); that is, the system responds over
various time instances to the output applied at n  0 . The knowledge of the impulse response
h[ n] of a system allows the computation of the response y[n] of the system to any input signal
x[ n] . The output signal is computed by discrete time convolution. The mathematical expression
(5.1) of discrete time convolution is
 
y[n]  x[n]* h[n]   x[k ]h[n  k ]   h[k ]x[n  k ]
k  k 
(5.1)

The convolution between two discrete time signals is computed by using the MATLAB
command conv.

5.1.1 The Command conv:

In MATLAB, the command conv allows the direct computation of the convolution between two
signals. In order to illustrate the conv command. There are three rules that have to be applied for
successful computation of the convolution between two continuous-time signals.

2
ELCE 203L: Signals & Systems Laboratory – Lab 05: Convolution (Discrete and Continuous)

 First rule: Two signals (input and impulse response) should be defined in the same time
interval. Hence, both signals are defined in the time interval a  n  b .
 Second rule: When a signal consists of multiple parts, the time intervals in which each
part is defined must not overlap. For example,

1  n 0  n  1
h[ n]   (5.2)
 0 1 n  2

Note that the equality at n  1 is placed only in the upper part.

Having defined the input and impulse response signals, the response of the system can be
computed by convoluting the two signals. The convolution is implemented by the command
y=conv(x,h). The response of the system is now computed and the only thing left to do is to plot
it. However, the number of elements of the output vector y is not equal to the number of elements
of vectors x or h .

The precise relationship is length( y )=length( x )+length( h )-1. To overcome this, the third rule
must be applied.

 Third rule: The output of the system is plotted in the double time interval of the one in
which the output and impulse response signals are defined.

5.1.2 The Unit Impulse Sequence as Input to a System:

In this section, the impulse response of a discrete time system is discussed in detail. More
specifically, it is established that if the unit impulse sequence  [n] is the input to a system, the
output of the system is the impulse response h[ n] of the system.

Example:

Suppose that adiscrete time system is described by the impulse response


h[n]  [2 4 1 3], 0  n  3 . Compute the response of the system to the input signal

1 n  0
x[n]   [n]   (5.3)
0 n  0
The response of the system is computed by convoluting the impulse response h[ n] with the input
signal  [n] . Recall that  [n] must be defined in the same time interval to h[ n] ; that is, 0  n  3 .
For illustration purposes both signals are plotted.

3
ELCE 203L: Signals & Systems Laboratory – Lab 05: Convolution (Discrete and Continuous)

Commands Results Comments


x=[1 0 0 0];
n=0:3;
Input signal x[n]   [n]
stem(n,x,'fill','linewidth',2),grid on plotted in 0  n  3 .
axis([-0.2 3.2 -0.1 1.1])
legend('x[n]=\delta[n]')

h=[2 4 3 1]; Impulse response


n=0:3;
stem(n,h,'fill','linewidth',2),grid on h[n]  [2 4 1 3] plotted in
0 n 3.
axis([-0.2 3.2 -0.1 4.1])
legend('h[n]')

The number of elements of the output vector y[n] compared to the number of elements of the
input and impulse response vectors. The exact relationship is length( y )=length( x )+length( h )-1.
Therefore the output of the system is plotted in the double time interval from input and impulse
response signals.

Commands Results Comments


y=conv(x,h); The output y[n] is computed
stem(0:6,y,'fill','linewidth',2),grid on
axis([-0.2 6.2 -0.1 4.1]) and plotted for 0  n  6 . As
legend('y[n]=h[n]')
expected the output and
impulse response signals are
the same.

The output and impulse response signals are the same; thus the identity property
 h[n]*  [n]  h[n] clearly stands. The system under consideration is a linear shift invariant
system. If at a linear and shift invariant system, with impulse response h[ n] , the input signal
 [n  k ] , i.e., a shifted unit impulse sequence is applied, then the response of the system is also
shifted by k units.

4
ELCE 203L: Signals & Systems Laboratory – Lab 05: Convolution (Discrete and Continuous)

Commands Results Comments


x=[0 1 0 0]; The shifted unit impulse
n=0:3;
stem(n,x,'fill','linewidth',2),grid on sequence x[n]   [n  1] is
axis([-0.2 3.2 -0.1 1.1])
legend('x[n]=\delta[n-1]')
the input to the system.

h=[2 4 3 1]; Impulse response


n=0:3;
stem(n,h,'fill','linewidth',2),grid on h[n]  [2 4 1 3] , 0  n  3 .
axis([-0.2 3.2 -0.1 4.1])
legend('h[n]')

y=conv(x,h); The output of the system is


stem(0:6,y,'fill','linewidth',2),grid on
axis([-0.2 6.2 -0.1 4.1]) its impulse response shifted
legend('y[n]=h[n-1]') by 1 unit to the right.

As expected, the response y[n] of the system to the input signal  [n  1] is h[n  1] . More
generally, the response of a linear shift invariant system to a shifted unit impulse sequence
 [n  k ] shifted by k units version of impulse response, i.e., the output of the system is h[n  k ] .

5.1.3 Computation of Discrete Time Convolution:

The process that has to be followed to analytically derive the convolution sum (equation 5.1) is
as follows. First, the input and impulse response signals are plotted in the k -axis. One of the two
signals is reversed about the amplitude axis and its reflection is shifted from  to  by
changing appropriately the value of n . The output of the system is computed from the
overlapping values of x[ n] and h[n  k ] according to the convolution sum


y[n]  x[n]* h[n]   x[k ]h[n  k ]
k 
(5.4)

The convolution procedure for two discrete time signals is demonstrated by using the signals
x[n]  [1 2], 0  n  1 and h[n]  [2 1 1 1], 0  n  3 .

5
ELCE 203L: Signals & Systems Laboratory – Lab 05: Convolution (Discrete and Continuous)

Step 1: The two signals are plotted at the k -axis.

Commands Results Comments


kx=[0 1]; Input signal x[ k ] .
x=[1 2];
stem(kx,x,'fill','linewidth',2),grid on
axis([-0.1 3.1 -0.1 2.1])

kh=0:3; Impulse response signal h[ k ]


h=[2 1 1 1];
stem(kh,h,'fill','linewidth',2),grid on .
axis([-0.1 3.1 -0.1 2.1])
legend('h[k]')

Step 2: The reflected version of h[ k ] , namely, h[k ] is plotted.

Commands Results Comments


stem(-kh,h,'fill','linewidth',2) ,grid on
axis([-3.1 0.1 -0.1 2.1])
The reflected signal h[k ] .
legend('h[-k]')

Step 3: The signal h[n  k ] is shifted from  to  by changing appropriately the value of n .
The output if the system is computed at each shift through equation 5.1, in which only the values
of overlapping parts of x[ n] and h[n  k ] are considered. In discrete time case we will compute
the sum of x[ n] and h[n  k ] . There are three stages, first there is zero overlap, next there is
overlap and finally there is no overlap.

6
ELCE 203L: Signals & Systems Laboratory – Lab 05: Convolution (Discrete and Continuous)

 First Stage: Zero Overlap. The stage occurs for n  1 .

Commands Results Comments


stem(kx,x,'fill','linewidth',2),grid on Input signal x[ k ] .
axis([-5.1 3.1 -0.1 2.1])
legend('x[k]')

n=-2; Impulse response signal


stem(-kh+n,h,'fill','linewidth',2), grid
on h[n  k ] for n  2 .
axis([-5.2 3.1 -0.1 2.1])
legend('h[-2-k]')

Obviously the two signals do not overlap. Thus the output is y[n]  0, n  1 .

 Second Stage: Overlap. The signals x[ n] and h[n  k ] overlap for 0  n  4 .

In order to compute the output, the two signals are plotted for n  0,1,..., 4. The output is
computed through the convolution sum by taking into account only the overlapping samples.

For n  0,

Commands Results
stem(kx,x,'fill','linewidth',2),grid on
axis([-5.1 3.1 -0.1 2.1])
legend('x[k]')

n=0;
stem(-kh+n,h,'fill','linewidth',2),grid on
axis([-5.2 3.1 -0.1 2.1])
legend('h[n-k]=h[0-k]')

7
ELCE 203L: Signals & Systems Laboratory – Lab 05: Convolution (Discrete and Continuous)

For n  0, the signals x[ k ] and h[n  k ]  h[0  k ] have one overlapping sample at k  0. The
output of the system for n  0 ; that is, y[0]  (1)(2) , where 1 is the value of x[ k ] and 2 is the value
of h[n  k ] at the overlapping sample. In order to understand better the output calculation,

notice that according to the definition of the convolution sum y[n]  x[n]* h[n]   x[k ]h[n  k ] ,
k 

the overlapping samples of x[ k ] and h[n  k ] are multiplied. The sum is applied when more than
one samples overlap. This is the case for n  1 .

Commands Results
stem(kx,x,'fill','linewidth',2),grid on
axis([-5.1 3.1 -0.1 2.1])
legend('x[k]')

n=1;
stem(-kh+n,h,'fill','linewidth',2),grid on
axis([-5.2 3.1 -0.1 2.1])
legend('h[n-k]=h[0-k]')

For n  1 , the signals x[ k ] and h[n  k ]  h[1  k ] overlap with two samples, namely, at k  0 and
at k  1 . The output for n  1 , that is, y[n]  y[1] is computed as y[1]  (2)(2)  (1)(1) , where 2 is
the value of x[ k ] and h[n  k ] at k  1 , while 1 is the value of x[ k ] and h[n  k ] at k  0 . Hence
y[1]  5 .

For n  2 , we have
Commands Results
stem(kx,x,'fill','linewidth',2),grid on
axis([-5.1 3.1 -0.1 2.1])
legend('x[k]')

8
ELCE 203L: Signals & Systems Laboratory – Lab 05: Convolution (Discrete and Continuous)

n=2;
stem(-kh+n,h,'fill','linewidth',2),grid on
axis([-5.2 3.1 -0.1 2.1])
legend('h[n-k]=h[2-k]')

For n  2 , the signals x[ k ] and h[n  k ]  h[2  k ] overlap at two points, at k  0 and at k  1 . The
output for n  2 , that is, y[n]  y[2] is computed as y[2]  (2)(1)  (1)(1) , where 2 is the value of
x[ k ] and 1 is the value of h[n  k ] at k  1 , while 1 is the value of x[ k ] and h[n  k ] at k  0 .
Hence y[2]  3.

For n  3 , we have

Commands Results
stem(kx,x,'fill','linewidth',2),grid on
axis([-5.1 3.1 -0.1 2.1])
legend('x[k]')

n=3;
stem(-kh+n,h,'fill','linewidth',2),grid on
axis([-5.2 3.1 -0.1 2.1])
legend('h[n-k]=h[3-k]')

The output for n  3 , i.e., y[n]  y[3] is computed as y[3]  (2)(1)  (1)(1)  3.
For n  4 ,

Commands Results
stem(kx,x,'fill','linewidth',2),grid on
axis([-2.1 6.1 -0.1 2.1])
legend('x[k]')

9
ELCE 203L: Signals & Systems Laboratory – Lab 05: Convolution (Discrete and Continuous)

n=4;
stem(-kh+n,h,'fill','linewidth',2),grid on
axis([-2.1 6.1 -0.1 2.1])
legend('h[n-k]=h[4-k]')

For n  4 , there is only one overlap at k  1 . Thus the output for n  4 is y[4]  (2)(1)  2.

 Third Stage: Zero Overlap. For n  5 , the input and impulse response signals do not
overlap, hence y[n]  0, n  5 .

For n  5 , we have

Commands Results
stem(kx,x,'fill','linewidth',2),grid on
axis([-2.1 6.1 -0.1 2.1])
legend('x[k]')

n=5;
stem(-kh+n,h,'fill','linewidth',2),grid on
axis([-2.1 6.1 -0.1 2.1])
legend('h[n-k]=h[5-k]')

10
ELCE 203L: Signals & Systems Laboratory – Lab 05: Convolution (Discrete and Continuous)

Combining the derived results we conclude that the response of the system with impulse
response h[n]  [2 1 1 1], 0  n  3 to the input signal x[n]  [1 2], 0  n  1 is
y[n]  [2 5 3 3 2], 0  n  4 . The output signal is plotted in figure below.

Commands Results
n=0:4;
y=[2 5 3 3 2];
stem(n,y,'fill','linewidth',2),grid on
axis([-0.1 4.1 -0.1 5.1])
legend('y[n]')

There are two basic principles that should be considered while computing the convolution
between two discrete time signals x[ n] and h[ n] using conv command.

1. Suppose that the length of vector x is N and the length of vector of h is M . The outcome of
command y=conv(x,h) is a vector y of length M  N  1 . In other words,
length( y )=length( x )+length( h )-1.
2. If non zeros values of x[ n] are in the interval [ax , bx ] and non-zero values of h[ n] are in the
interval [ah , bh ] , then the non-zero values of the output y[n] are in the interval
[ax  ah , bx  bh ] .

11
ELCE 203L: Signals & Systems Laboratory – Lab 05: Convolution (Discrete and Continuous)

5.2 Impulse Response:


The meaning of impulse response of the system is easily derived if one considers the terms that it
is named from. The terms, ‘response’, denotes the output of a system, while the term, ‘impulse’
denotes that the input signal applied to the system is the unit impulse or Dirac Delta function.
Hence, the impulse response of a causal linear and time invariant continuous time system is the
output when the Dirac Delta function is the input applied to the system. Mathematically,
impulse response of the system is denoted by

h(t )  S{ (t )} (5.5)


5.2.1 Continuous-Time Convolution:
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.

The response (or output) of a system to any input signal is computed by the convolution of the
input signal with the impulse response of the system.

Suppose that y (t ) denotes the output of the system, x(t ) is the input signal, and h(t ) is the impulse
response of the system. The mathematical expression of the convolution relationship is

y (t )  x(t )  h(t ) (5.6)


5.2.2 Computation of Convolution:

In order to calculate the convolution between two signals, a specific (and not exactly trivial)
computational procedure has to be followed. The convolution computational procedure is
introduced through an example.

Example

A linear time-invariant signal is described by the impulse response


1  t 0  t  1
h(t )   (5.7)
 0 elsewhere
Calculate the response of the system to the input signal
1 0  t  2
x(t )   (5.8)
0 elsewhere

In order to compute the convolution between x(t ) and h(t ) , the computational procedure is
implemented in the following steps.

12
ELCE 203L: Signals & Systems Laboratory – Lab 05: Convolution (Discrete and Continuous)

Step 1: Time impulse response signals are plotted in the  -axis; that is, t is replaced with  , or
in other words the signals
1   0    1 1 0    2
h( )   and x( )  
 0 elsewhere 0 elsewhere (5.9)

are defined and plotted.

Commands Results Comments


tx1=-2:0.1:0; The signals x( )
tx2=0:0.1:2;
tx3=2:0.1:4; and h( ) are defined
tx=[tx1 tx2 tx3]; in the usual way of
x1=zeros(size(tx1));
x2=ones(size(tx2));
constructing two part
x3=zeros(size(tx3)); functions. The input
x=[x1 x2 x3]; signal x( ) is plotted
with solid line, while
the impulse response
signal h( ) is plotted
with dotted line and
asterisks. Both the
signals are defined in
the time interval
2    4. Notice
that the signals are
plotted in the  -axis
and how Greek
letters are inserted
into the legend.
th1=-2:0.1:0;
th2=0:0.1:1;
th3=1:0.1:4;
th=[th1 th2 th3];
h1=zeros(size(th1));
h2=1-th2;
h3=zeros(size(th3));
h=[h1 h2 h3];
plot(tx,x,th,h,':*')
ylim([-0.1 1.1])
legend('x(\tau)','h(\tau)')
grid

Step 2: The second step is known as reflection. One of the two signals is selected (in this
example h( ) is chosen, but x( ) could have been also selected) and its symmetric with respect
to the vertical axis, i.e., h( ) is plotted.

13
ELCE 203L: Signals & Systems Laboratory – Lab 05: Convolution (Discrete and Continuous)

Commands Results
plot(tx,x,-th,h,':*')
ylim([-0.1 1.1])
legend('x(\tau)','h(-\tau)')
grid

Step 3: The third step is shifting. The signal h( ) is shifted by t ; that is, the signal h(t   ) is
plotted. Note that t is constant, as the variable of the defined signals is variable  .

Commands Results Comments


t=-2; The signal
plot(tx,x,-th+t,h,':*')
ylim([-0.1 1.1])
h(t   ) is plotted
legend('x(\tau)','h(t- for t  2 .
\tau)') Notice that
grid
h(t   ) is shifted
by 2 units to the
left compared to
h( ) .

A very useful (for future computations) observation is the point in the  -axis where the right end
of h(t   ) is. The right end h(t   ) for t  2 ; that is, the right end of h(2   ) is at the point
  2 . In the previous graph, it has been observed that the right end of h( ) , that is, the right
end of h(0   ) is at   0 . Hence, we conclude that in general case the right end of h(t   ) is the
point   t . On the other hand, the left end of h(t   ) is at   t  T , where T is the duration of
h(t   ) . In this example we have T  1 .

Step 4: The fourth step is sliding step. The value of the output signal y (t ) at time t , that is, the
value of convolution between the input signal and impulse response signal at time t depends on
overlap between x( ) and h(t   ) at time t . In order to compute the convolution for all t , we have

14
ELCE 203L: Signals & Systems Laboratory – Lab 05: Convolution (Discrete and Continuous)

to slide the signal h(t   ) from  to  and to derive the kind (or stage) of overlap in
reference to the value of t . Note that x(t ) remains still.

 First Stage: Zero Overlap

Commands Results Comments


t=-2; For t  0 (in this
plot(tx,x,-th+t,h,':*')
ylim([-0.1 1.1]) figure t  2 ),
legend('x(\tau)','h(t- the signal
\tau)') h(t   ) and x( )
grid
do not overlap.
Thus the output is
y (t )  0 .

 Second Stage: Partial Overlap

Commands Results Comments


t=0.5; For 0  t  1 , the
plot(tx,x,-
th+t,h,':*'),grid on signal h(t   ) is
ylim([-0.1 1.1]) entering at x( ) .
legend('x(\tau)','h(t-
\tau)')
The two signals
% the following code are partially
% produce the shadowed overlapped. The
% area plot overlapped part is
T=1;
r=0:0.1:t;
shadowed.
a=1/T*r+1-t/T;
hold on; area(r,a);
hold off;

15
ELCE 203L: Signals & Systems Laboratory – Lab 05: Convolution (Discrete and Continuous)

 Third Stage: Complete Overlap


Commands Results Comments
t=1.6; For 1  t  2 , the
plot(tx,x,-
th+t,h,':*'),grid on
signals h(t   ) and
ylim([-0.1 1.1]) x( ) are completely
legend('x(\tau)','h(t-
\tau)')
overlapped.
% the following code
% produce the shadowed
% area plot
T=1;
r=t-T:0.1:t;
a=1/T*r+1-t/T;
hold on; area(r,a);
hold off;

 Fourth Stage: Exit-partial overlap


Commands Results Comments
t=2.4; For 2  t  3 , the
plot(tx,x,-
th+t,h,':*'),grid on signal h(t   )
ylim([-0.1 1.1]) exits x( ) . The
legend('x(\tau)','h(t-
\tau)')
two signals are
% the following code partially
% produce the shadowed overlapped.
% area plot
T=1;
r=t-T:0.1:2;
a=1/T*r+1-t/T;
hold on; area(r,a);
hold off;

 Fifth Stage: Zero Overlap


Commands Results Comments
t=3.6; For t  3 , he signal
plot(tx,x,-
th+t,h,':*'),grid on h(t   ) does not
ylim([-0.1 1.1]) overlap with x( ) do
legend('x(\tau)','h(t-
\tau)')
not overlap. Thus the
output is y (t )  0 .

16
ELCE 203L: Signals & Systems Laboratory – Lab 05: Convolution (Discrete and Continuous)

Step 5: Specification of limits and calculation of the convolution integral. Having derived the
time intervals for various stages of overlap, the convolution integral is computed separately for
each stage. Before computing the integrals the integration limits have to be specified. Recall that
the right end of h(t   ) is at point   t , while the left end of h(t   ) is at point   t  T  t  1 .

1. For t  0 , the two signals do not overlap (zero-overlap stage). Thus the response of the
system is y (t )  0 .
2. For 0  t  1 , the two signals start to overlap (entry stage-partial overlap). The limits of
the integral are the limits that specified the shadowed area.
The input signal x( ) is given by x( )  1 , while the impulse response signal h(t   ) is
given by h(t   )  1  (t   )  1  t   . The expression of h(t   ) is derived by substituting
t with t   in h(t ) . Thus the integral that has to be calculated is

t t
y (t )  0 1(1t  )d  0 (1t  )d (5.10)

Commands Results Comments


syms t r y-t-1/2*t^2 The integral is computed and the
f=1-t+r; response of the system at the entry
y=int(f,r,0,t)
stage is y (t )  t  t 2,0  t  1.
2

3. For 1  t  2 , the two signals overlap completely (complete overlap stage). The only
difference to the previous calculation is the integral limits. In this case, the output is
given by

t
y (t )  t 1 (1t  )d (5.11)

Commands Results Comments


y=int(f,r,t-1,t) Y=1-t+1/2*t^2-1/2*(t-1)^2 The integral is computed and the
simplify(y) ans=1/2 result is simplified. The response
of the system at complete overlap
is y (t )  0.5,1  t  2.

4. For 2  t  3 , the two signals overlap partially (exit stage). Thus, the output is given by

2
y (t )  t 1 (1t  )d (5.12)

Commands Results Comments


y=int(f,r,t-1,2) Y=5-t-t*(3-t)-1/2*(t-1)^2 The response of the system at exit
stage is

17
ELCE 203L: Signals & Systems Laboratory – Lab 05: Convolution (Discrete and Continuous)

y (t )  (3  t ) 2 2, 2  t  3.

5. For t  3 , there is no overlap; thus the output is y (t )  0, t  3 .

Combining all the derived results, we conclude that the response of the system with impulse
response h(t )  1  t , 0  t  1to the input signal x(t )  1, 0  t  2 is

 t  t2 2 0  t 1

 12 1 t  2
y (t )   (5.13)
(3  t ) 2
2
2t 3

 0 t  0 and t  3
Finally, the output y (t ) is plotted in MATLAB according to the technique of plotting multipart
function.

Commands Results
t1=0:0.1:1;
t2=1:0.1:2;
t3=2:0.1:3;
y1=t1-(t1.^2)/2;
y2=0.5*ones(size(t2));
y3=0.5*((3-t3).^2);
plot(t1,y1,t2,y2,'.',t3,y3,':'),grid on
ylim([0 0.6])
title('Output Signal y(t)')

5.2.3 The Command conv:

The computational process followed in the previous subsection is the analytical way of deriving
the convolution between two signals. In MATLAB, the command conv allows the direct
computation of the convolution between two signals. In order to illustrate the conv command we
consider the previously used example, namely the impulse response signal is given by
h(t )  1  t , 0  t  1 and an input signal given by x(t )  1, 0  t  2 . There are four rules that have
to be applied for successful computation of the convolution between two continuous-time
signals.

 First rule: Two signals (input and impulse response) should be defined in the same time
interval. Hence both the signals are defined in the time interval a  t  b , where t  a is
the first time instance that at least one of the signals x(t ) or h(t ) is not zero and t  b is the
last time instance that at least one of the two signals is not zero. In our example, the time

18
ELCE 203L: Signals & Systems Laboratory – Lab 05: Convolution (Discrete and Continuous)

interval is 0  t  2 . Thus the input signal x(t )  1, 0  t  2 and the impulse response
signal is expressed as

1  t 0  t  1
h(t )   (5.14)
 0 0t 2

 Second rule: When a signal consists of multiple parts, the time intervals in which each
part is defined must not overlap. Therefore, the impulse response signal is defined as

1  t 0  t  1
h(t )   (5.15)
 0 1 t  2
Note that the equality at t  1 is placed only in the upper part.

Commands Comments
step=0.01; The time step has to be quite small in order to
approximate accurately the continuous time signal.
t=0:step:2; The input signal x(t )  1, 0  t  2 is defined.
x=ones(size(t));
t1=0:step:1; The intervals of two parts of h(t ) are defined in
t2=1+step:step:2;
such a way that they do not overlap. More
specifically, vector t 2 is defined from the instance
1+step, i.e., is defined from the time instance 1.01
(second rule). Also notice that the time step is used
at the definition of the two signals must be same.
h1=1-t1; The impulse response h(t ) is defined in the wider
h2=zeros(size(t2));
time interval, namely, in the same interval where
h=[h1 h2];
the input x(t ) is defined (first rule).

Having defined the input and impulse response signals the response of the system can be
computed by convoluting the two signals. The convolution is implemented by the command
y=conv(x,h). However, there is still one detail that needs to be addressed and is described at the
next rule.

 Third rule: The output of the conv command has to be multiplied with time step used in
the definition of the input and impulse response signals, in order to correctly compute the
output of the system. The rule emerges from the fact that the convolution integral is
approximated by sum in MATLAB.

Commands Comments
y=conv(x,h)*step; The response y (t ) of the system is computed by
convoluting the input signal x(t ) with the impulse
response signal h(t ) and multiplying the result
with the time step (third rule).

19
ELCE 203L: Signals & Systems Laboratory – Lab 05: Convolution (Discrete and Continuous)

The response of the system is now computed and the only thing left to do is to plot it. However,
the number of elements of the output vector y is not equal to the number of elements of vectors x
or h .

The precise relationship is length( y )=length( x )+length( h )-1

Commands Results Comments


length(y) ans=401 Indeed the relationship length(
length(x) ans=201 y )=length( x )+length( h )-1 is
length(h) and=201 true.

To overcome this, the fourth rule must be applied.

 Fourth rule: The output of the system is plotted in the double time interval of the one in
which the output and impulse response signals are defined.

Commands Results Comments


ty=0:step:4; The time interval in
which the output
signal y will be
plotted is 0  t  4 ,
namely, it is double
from time interval
where the vectors x
and h are defined.
plot(ty,y),grid on The response if the
system y (t ) computed
from the convolution
between the input
x(t ) and the impulse
response h(t ) is
plotted.

The output signal that was obtained through the MATLAB implementation (by using the
command conv) is the same as the one derived with the analytical approach in Section 5.2.2. In
this point the necessity for applying the fourth rule must be already clear. In case if first and
second rule was not followed it would not be possible to apply the fourth rule hardening the
proper plotting of the output of the system.

5.2.4 Deconvolution:

20
ELCE 203L: Signals & Systems Laboratory – Lab 05: Convolution (Discrete and Continuous)

Suppose that the impulse response of the system h(t ) and output of the system is y (t ) are
available and we want to compute the input signal x(t ) that was applied to the system in order to
generate the output y (t ) . The process called deconvolution and is implemented in MATLAB by
using the command deconv. The syntax is x=deconv(y,h), where x is the input vector, h is the
impulse response vector, and y is the system response vector.

The deconvolution process is also useful for determining the impulse response of a system if the
input and output signals are known. In this case the command is h=deconv(y,x).

Remark

The commutativity property is not valid for deconv command; hence, the output signal must be
the first input argument of the command deconv.

Example:

We will use the same signals used in the previous example. Therefore, the problem is to compute
the impulse response h(t ) of a system when the response of the system to the input
x(t )  1, 0  t  2 is the signal y (t ) , which is depicted in the previous figure.

The signals x(t ) and y (t ) and the time t are already defined in the previous example, so we can
directly use them to compute the impulse response h(t ) .

Commands Results Comments


hh=deconv(y,x)*(1/step); The impulse
plot(t,hh),grid on response h(t ) is
ylim([-0.1 1.1])
legend('Impulse Response computed by
h(t)') multiplying the
outcome of the
command
deconv by the
quantity (1/step)
as
deconvolution is
the inverse
operation of
convolution.

__________________________

21

You might also like