Sunteți pe pagina 1din 7

EE392 Digital Signal Processing

Lab 1 Convolution

Aim
The aim of this laboratory is to understand the concept of Convolution in
digital signal processing. The Convolution of two signals will be implemented
using a Matlab code which should be able to carry out the process for any
sequence entered by the user.

Introduction
Convolution is a mathematical operation of two functions; the first function is
the input signal and the second signal is the impulse response. The output
signal is a linear time invariant system. In the field of engineering
convolution is commonly used in digital signal processing, statistics,
computer vision, differential equations etc. The convolution of the two
functions can be computed in either continuous or discrete form. The
convolution formula for the continuous form of the signal is as follow:
+

y (t )= s ( ) h ( t ) d=s ( t )h( t)

On the other hand, the convolution of the two signals in discrete form is
given by:

The extension of the sequences to support finite functions is gives the


convolution of finite sequences. This experiment implements the convolution
of a general discrete time signal and a general discrete time system.

Matlab Code
close all
clear all
x=input('Enter_x: ') % Sequence 1
h=input('Enter_h: ') % Sequence 2
a=length(x); % Number of characters in sequence 1
b=length(h); % Number of characters in sequence 2
X=[x,zeros(1,a)]; % Zero padding of x[n] when size of x[n] is not equal to
h[n]
H=[h,zeros(1,b)]; % Zero padding of h[n] when size of x[n] is not equal to
h[n]
for i=1:a+b-1 % For loop executes the convolution calculation
Y(i)=0;
for j=1:a
if(i-j+1>0)
Y(i)=Y(i)+X(j)*H(i-j+1);
else
end
end
end
subplot(2,2,1)
grid on
stem(x); % Sequence 1 is plotted
ylabel('x[n]');
xlabel('n');
title('Sequence_1');

subplot(2,2,2)
grid on
stem(h); % Sequence 2 is plotted
ylabel('h[n]');
xlabel('n');
title('Sequence_2');
Y
subplot(2,2,[3 4])
grid on
stem(Y); % Output Y (Convoluted Signal) is plotted
ylabel('Y[n]');
xlabel('n');
title('Convolution_of_Two_Signals ');

Results
Question 1
Sequence 1: [1 2 3]
Sequence 2: [1 2 3]

Matlab Outputs

Figure 1: Graph showing the two input sequence signal and convolution of
both the signals
Question 2
Sequence 1: [2 4 6 8 10]
Sequence 2: [1 2 3 4 5]

Calculation For Convolution


x[n]

10

h[n]

______________________________________________________________________
2

10

12

16

12
8

18

20
24

30

16

24

32

40

10

20

30

40

50

_______________________________________________________________________
2

20

40

70

88

92

80

50

_______________________________________________________________________

Matlab Outputs

Figure 2: Graph showing the two input sequence signal and convolution of
both the signals

Discussion
Linear systems are known to satisfy the principle of superposition, having the
response equivalent to the input of the sum of weighted input signals.

ie. x[n] as the input signal and y[n] as the response.


LTI systems also have a
time
(time
invariant)
conditions:

For linear convolution, two


a third output signal is
represented as:

characteristic of not changing with


provided
the
following

signals are taken as inputs and


produced. LTI convolution is

The code provided takes in two inputs in terms of x, h and determines its
length with new assigned variables a and b respectively. Functions X and H
provides zero paddings to ensure that the lengths are maintained to a
common value. With the use of for loops, the output sequence Y(i) depending
on the length of inputs is determined. The for loop ensures that all the
separate sequences j are added to provided the final sequence Y(i). Finally,
the output is subplot to give a fair idea on the input values and consequently
the result of linear convolution.

Conclusion
It can be concluded that the concept of convolution was successfully
implemented using MATLAB and the desired results were obtained. The code
ensured that all inputs for the LTI system provided the correct result.
Convolution is defined by the behavior of two different discrete time
invariant signals. Convolution is equivalent to multiplication in Fourier
domain for the time domain.

References
[1] "Wikipedia, 'Convolution'," 12 November 2011. [Online]. Available:

https://en.wikipedia.org/wiki/Convolution.
[2] "Wolfram ,'Convolution'," 15 June 2009. [Online]. Available:
http://mathworld.wolfram.com/Convolution.html.
[3] "dspguide, 'Convolution'," 22 Janauary 2011. [Online]. Available:
http://www.dspguide.com/ch6.htm.
[4] "Matlab, 'Convolution and polynomial multiplication'," 26 May 2006.
[Online]. Available: http://au.mathworks.com/help/matlab/ref/conv.html.

S-ar putea să vă placă și