0% found this document useful (0 votes)
48 views31 pages

LEC 3 Convolution - Continue

This document discusses convolution and its importance in digital signal processing (DSP). Convolution provides a mathematical framework for DSP by allowing each output sample to be calculated as the sum of weighted input samples. Convolution allows processing of signals through the use of an impulse response, which acts as a set of weighting coefficients. Common applications of convolution in DSP include filtering operations like removing DC components from signals. The document covers the detailed mathematics and algorithms for calculating convolution from both the input and output side perspectives. It also discusses problems that can arise, such as end effects, and how they can be addressed.

Uploaded by

Sherif Said
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)
48 views31 pages

LEC 3 Convolution - Continue

This document discusses convolution and its importance in digital signal processing (DSP). Convolution provides a mathematical framework for DSP by allowing each output sample to be calculated as the sum of weighted input samples. Convolution allows processing of signals through the use of an impulse response, which acts as a set of weighting coefficients. Common applications of convolution in DSP include filtering operations like removing DC components from signals. The document covers the detailed mathematics and algorithms for calculating convolution from both the input and output side perspectives. It also discusses problems that can arise, such as end effects, and how they can be addressed.

Uploaded by

Sherif Said
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/ 31

Lecture 3

DSP course

Convolution
continue
Convolution provides the mathematical framework for DSP.
Convolution

Detailed Mathematics of Convolution

The input side algorithm The output side algorithm

From the viewpoint of the input signal From the viewpoint of the output signal
Convolution
Detailed Mathematics of Convolution
From the viewpoint of the input signal

Convolution example

by
Matlab Code
Convolution
Detailed Mathematics of Convolution
From the viewpoint of the input signal

%input signal x (( 9 samples ))

x = [0 -1 -1.4 2 1.4 1.5 0.8 0 -0.5 ];

% unit impulse response ((4 samples))

h = [1 -0.5 -0.2 0 ];
Convolution
Detailed Mathematics of Convolution
From the viewpoint of the input signal
Matlab Code for Convolution
% input signal x (( 9 samples ))
x= [0 -1 -1.4 2 1.4 1.5 0.8 0 -0.5 ];

% unit impulse response ((4 samples))


h= [1 -0.5 -0.2 0 ];

% output ((9+4-1 = 12 samples))


y(1:12) =0;
figure
for n = 1 : 9 subplot(1,3,1);plot(x,'o','markeredgecolor'
for m = 1 : 4 ,'k','linewidth',3);grid
y(n+m-1)= y(n+m-1) + x(n)*h(m); subplot(1,3,2);plot(h,'*','markeredgecolor'
,'k','linewidth',3);grid
end subplot(1,3,3);plot(y,'gs','markeredgecolor
end ','k','linewidth',3);grid
Convolution
Detailed Mathematics of Convolution
From the viewpoint of the input signal
Matlab Code for Convolution
% input signal x (( 9 samples ))
x= [0 -1 -1.4 2 1.4 1.5 0.8 0 -0.5 ];

% unit impulse response ((4 samples))


h= [1 -0.5 -0.2 0 ];

% output ((9+4-1 = 12 samples))


y(1:12) =0;
figure
for i = 1 : 9 subplot(1,3,1);plot(x,'o','markeredgecolor'
for j = 1 : 4 ,'k','linewidth',3);grid
y(i+j-1)= y(i+j-1) + x(i)*h(j); subplot(1,3,2);plot(h,'*','markeredgecolor'
,'k','linewidth',3);grid
end subplot(1,3,3);plot(y,'gs','markeredgecolor
end ','k','linewidth',3);grid
Convolution
Detailed Mathematics of Convolution
From the viewpoint of the input signal
Matlab Result for Convolution
Convolution

Detailed Mathematics of Convolution

The input side algorithm The output side algorithm

From the viewpoint of the input signal From the viewpoint of the output signal
Convolution

Detailed Mathematics of Convolution


The output side algorithm
Convolution
Detailed Mathematics of Convolution
From the viewpoint of the input signal
𝒙𝟎 =𝟎 𝒙 𝟏 = −𝟏 𝒙 𝟐 = −𝟏.4
The nine signals

𝒙𝟑 =𝟐 𝒙 𝟒 = 𝟏. 𝟒 𝒙 𝟓 = 𝟏.5

𝒙 𝟔 = 𝟎. 𝟖 𝒙𝟕 =𝟎 𝒙 𝟖 = −𝟎.5
X[0] X[0] X[0] X[0]
h[0] h[1] h[2] h[3]
X[1] X[1] X[1] X[1]
h[0] h[1] h[2] h[3]
X[2] X[2] X[2] X[2]
h[0] h[1] h[2] h[3]
X[3] X[3] X[3] X[3]
h[0] h[1] h[2] h[3]
X[4] X[4] X[4] X[4]
h[0] h[1] h[2] h[3]
X[5] X[5] X[5] X[5]
h[0] h[1] h[2] h[3]
X[6] X[6] X[6] X[6]
h[0] h[1] h[2] h[3]
X[7] X[7] X[7] X[7]
h[0] h[1] h[2] h[3]
X[8] X[8] X[8] X[8]
h[0] h[1] h[2] h[3]
Convolution

Detailed Mathematics of Convolution


The output side algorithm
convolution
machine

The example point we will use is y[6]


y[6] = x[6] h[0] + x[5] h[1 ] +x[4] h[2] + x[3] h[3] .
Convolution

Detailed Mathematics of Convolution


The output side algorithm

To calculate y[7] , the convolution machine moves one sample to


the right. This results in another four samples entering the machine,
x[4] through x[7] , and the value for y[7] dropping into the proper
place. This process is repeated >>>
Convolution

The
output
side
algorith
m
Calculate
Calculate
y[3]
y[8]
Convolution
The output side algorithm
Problem
When calculating y[0], it is trying
to receive input from samples:
x[-3], x[-2], x[-1 ], and x[0] . The
problem is, three of these
samples: x[-3], x[-2], and x[-1] ,
do not exist! Calculate
y[0]
This same dilemma arises when
calculating y[11], where the Calculate
convolution machine tries to y[11]
accept samples to the right of
the defined input signal, points
x[9], x[10], and x[11] .
Convolution
The output side algorithm
Problem

One way to handle this problem is by inventing the nonexistent samples. This
involves adding samples to the ends of the input signal, with each of the added
samples having a value of zero.

This is called padding the signal with zeros. Instead of trying to access a
nonexistent value, the convolution machine receives a sample that has a value
of zero. Since this zero is eliminated during the multiplication, the result is
mathematically the same as ignoring the nonexistent inputs.
Convolution
The output side algorithm
End Effect Problem
Convolution
The output side algorithm End Effect Problem

The far left and far right samples in the output signal are based on incomplete
information. In DSP jargon, the impulse response is not fully immersed in the
input signal.

If the impulse response is M points in length, the first and last M-1 samples in
the output signal are based on less information than the samples between.
Convolution
The output side algorithm
End Effect Problem

The input signal is a sine wave plus a DC component. The desire is to remove the
DC part of the signal, while leaving the sine wave intact. This calls for a highpass
filter.
Convolution
The output side algorithm
End Effect Problem

The problem is, the first and last 30 points are a mess!

These “End Effect” problems are widespread in DSP. As a general rule, expect the
beginning and ending samples in processed signals will be quite useless.
Convolution
Convolution Sum

If x[n] is an N point signal running from 0 to N-1, and h[n] is an M point signal
running from 0 to M-1,

the convolution of the two:


y[n] = x[n] * h[n] ,
is an N+M-1 point signal running from 0 to N+M-2, given by:

It allows each point in the output signal to be calculated independently of all other points.
Convolution
Convolution Sum
From the viewpoint of the output signal
Matlab Code for Convolution
% input signal x (( 9 samples ))
x= [0 -1 -1.4 2 1.4 1.5 0.8 0 -0.5 ];

% unit impulse response ((4 samples))


h= [1 -0.5 -0.2 0 ];

Error
% output ((9+4-1 = 12 samples))
y(1:12) =0;

%for i = 1 : 9 % input side algorithm


for i = 1 : 12 % output side algortihm
for j = 1 : 4
%y(j+i-1)= y(j+i-1) + x(i)*h(j); % input side algorithm
y( i )= y( i ) + h(j) * x(i-j+1); % output side algortihm
end
end
Convolution
Convolution Sum
From the viewpoint of the output signal
Matlab Code for Convolution
% input signal x (( 9 samples ))
x= [0 -1 -1.4 2 1.4 1.5 0.8 0 -0.5 ];

% unit impulse response ((4 samples))


h= [1 -0.5 -0.2 0 ];

% output ((9+4-1 = 12 samples))


y(1:12) =0;

%for i = 1 : 9 % input side algorithm


for i = 1 : 12 % output side algortihm
for j = 1 : 4
%y(j+i-1)= y(j+i-1) + x(i)*h(j); % input side algorithm
if (i-j+1)> 9 ||(i-j+1)<0
continue
end
y( i )= y( i ) + x(i-j+1)*h(j); % output side algortihm
end
end
Convolution
Convolution Sum

Same
result
Convolution
Convolution Sum

Same
result
Convolution
The sum of weighted inputs

Why convolution is important in signal processing ??


Convolution
The sum of weighted inputs

convolution
Why convolution is important in machine
signal processing ??
Convolution
The sum of weighted inputs

convolution
machine
Look back at the convolution machine, and ignore that
the signal inside the dotted box is an impulse response.

Think of it as a set of weighing coefficients that happen


to be embedded in the flow diagram. In this view, each
sample in the output signal is equal to a sum of
weighted inputs.

Each sample in the output is influenced by a region of


samples in the input signal, as determined by what the
weighing coefficients are chosen to be.
Convolution
The sum of weighted inputs
Why convolution is important in
signal processing ?? convolution
machine

For example, imagine there are ten weighing


coefficients, each with a value of one-tenth.

This makes each sample in the output signal the


average of ten samples from the input.
Convolution
The sum of weighted inputs

convolution
machine
Taking this further, the weighing coefficients do not need to
be restricted to the left side of the output sample being
calculated.

For instance, y[6] being calculated from: x[3], x[4], x[5],


and x[6] . Viewing the convolution machine as a sum of
weighted inputs,
the weighing coefficients could be chosen symmetrically
around the output sample. For example, y[6] might receive
contributions from: x[4], x[5], x[6], x[7], and x[8].
Convolution

Mathematically, there is only one concept here: convolution as defined by the above
equation.

However, science and engineering problems approach this single concept from two distinct
directions..

Sometimes you will want to think of Other times you will understand
a system in terms of what its the system as a set of weighing
impulse response looks like coefficients.

You might also like