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

Convolution

This document covers the convolution of continuous-time and discrete-time signals using MATLAB. It details the convolution theorem, provides MATLAB code for performing convolutions, and discusses the results of the experiments conducted in the lab. The conclusion emphasizes the successful execution of convolutions for both signal types.

Uploaded by

rustturf
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)
5 views

Convolution

This document covers the convolution of continuous-time and discrete-time signals using MATLAB. It details the convolution theorem, provides MATLAB code for performing convolutions, and discusses the results of the experiments conducted in the lab. The conclusion emphasizes the successful execution of convolutions for both signal types.

Uploaded by

rustturf
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/ 4

LAB 2

Convolutions
Objectives
• To understand the convolution of signals in MATLAB.

Convolution Theorem for Continuous-Time Signals


The convolution of two continuous-time signals x(t) and h(t) is defined as:
Z ∞
y(t) = (x ∗ h)(t) = x(τ )h(t − τ )dτ
−∞

The Fourier transform of x(t) is X(ω) and for h(t) is H(ω).


Applying the Fourier transform to both sides:
Z ∞ 
Y (ω) = F{y(t)} = F x(τ )h(t − τ )dτ
−∞

Using the convolution property of the Fourier transform:

Y (ω) = X(ω)H(ω)

Thus, the convolution theorem for continuous-time signals is:

F{x(t) ∗ h(t)} = X(ω)H(ω)

Convolution Theorem for Discrete-Time Signals


The convolution of two discrete-time signals x[n] and h[n] is defined as:

X
y[n] = (x ∗ h)[n] = x[k]h[n − k]
k=−∞

The Discrete-Time Fourier Transform (DTFT) of x[n] is X(ejω ) and for h[n] is H(ejω ).
Applying the DTFT to both sides:
( ∞ )
X
Y (ejω ) = DTFT{y[n]} = DTFT x[k]h[n − k]
k=−∞

Using the convolution property of the DTFT:

Y (ejω ) = X(ejω )H(ejω )

Thus, the convolution theorem for discrete-time signals is:

DTFT{x[n] ∗ h[n]} = X(ejω )H(ejω )

1
MATLAB Code for Discrete-Time Convolution

1 clear all ;\\


2 close all ;\\
3 x1 = input ( ’ Enter ␣ First ␣ sequence ␣ x1 ( n ) ␣ []: ’) ;\\
4 t1 = input ( ’ Enter ␣ Origin ␣ location ␣ Of ␣ Sequence ␣ x1 : ␣ ’) ;\\
5 x2 = input ( ’ Enter ␣ Second ␣ sequence ␣ x2 ( n ) ␣ []: ’) ;\\
6 t2 = input ( ’ Enter ␣ Origin ␣ location ␣ Of ␣ Sequence ␣ x2 : ␣ ’) ;\\
7 11= length ( x1 ) ; \\ % length of sequence x1
8 12= length ( x2 ) ;\\ % length of sequence x2
9 y = conv ( x1 , x2 ) ;\\ % performing convolution using conv () function
10 ln = length ( y ) ;\\ % length of convoluted sequence
11 a = t1 +11 -1;\\
12 t = tl : a ;\\
13 subplot (3 ,1 ,1) ;\\
14 stem ( tx1 ) ;\\
15 grid on ;\\
16 xlabel ( ’ Time ’) ;\\
17 ylabel ( ’ Amplitude ’) ;\\
18 title ( ’ x1 ’) ;\\
19 at2 +12 -1;\\
20 t = t2 : a ;\\
21 subplot (3 ,1 ,2) ;\\
22 stem (t , x2 ) ;\\
23 grid on ;\\
24 xlabel ( ’ Time ’) ;\\
25 ylabel ( ’ Amplitude ’) ;\\
26 title ( ’ x2 ’) ;\\
27 tn = t1 + t2 ;\\
28 a = tn + ln -1;\\
29 t = tn : a ;\\
30 subplot (3 ,1 ,3) ;\
31 disp ( ’ Convoluted ␣ Sequence ␣ ’) ;\\
32 disp ( y ) ;\\ % For printing the convulated output in MATLAB command
window
33 stem (t , y ) ;\\ % For plotting the convulated output in MATLAB graph window
34 grid on ;\\
35 xlabel ( ’ Time ’) ;\\
36 ylabel ( ’ Amplitude ’) ;\\
37 title ( ’ Convoluted ␣ Sequence ’) ;\\

MATLAB Code for Continuous-Time Convolution

1 dt = 0.01;
2 t1 = -1: dt :1;
3 x = ones (1 , length ( t1 ) ) ;
4 subplot (3 , 1 , 1) ;
5 plot ( t1 , x ) ;
6 title ( ’x ( t ) ’) ;
7 xlabel ( ’t ’) ;
8 ylabel ( ’x ( t ) ’) ;
9

10 t2 = -1: dt :1;
11 h = ones (1 , length ( t2 ) ) ;
12 subplot (3 , 1 , 2) ;
13 plot ( t2 , h ) ;

2
14 title ( ’h ( t ) ’) ;
15 xlabel ( ’t ’) ;
16 ylabel ( ’h ( t ) ’) ;
17
18 % Perform the convolution
19 y = conv (x , h ) * dt ;
20 ys = t1 (1) + t2 (1) ;
21 yt = ys + (0: length ( y ) - 1) * dt ;
22 subplot (3 , 1 , 3) ;
23 plot ( yt , y ) ;
24 title ( ’ Convolution ␣ y ( t ) ’) ;
25 xlabel ( ’t ’) ;
26 ylabel ( ’y ( t ) ’) ;

Discussion
In this lab, we analaysed the convolution theorem for discrete time convolution and continuous
time convolution. We convoluted two discrete time signals. We entered the two sequence as
[1,-1,3,1,1] and convoluted the signal with another signal h(τ ) as [1,1,1,1]. We advanced the
signal by 1 sec and showed the convolution in MATLAB(Figure 1). Similarly, the convolution
for continuous time signal is shown. To get the unit step signal, we didn’t use any function but
rather we decreased the time value and at each point assigned it to 1. The convolution was
performed as shown in the Figure 2 in MATLAB and the output was shown to be t − 2 to 2 − t
which matched the theoretical convolution performed in class.

Figure 1: Discrete Time Convolution

Conclusion
Hence the convolution of discrete time signals and continuous time signals was performed.

3
Figure 2: Continuous Time Convolution

You might also like