0% found this document useful (0 votes)
4 views4 pages

DSP Lab2

The document provides an overview of discrete time convolution, explaining its relationship between input and output signals in linear time invariant systems, and detailing the algorithm for performing convolution in MATLAB. It also discusses the characteristics of discrete time filters, including finite impulse response (FIR) and infinite impulse response (IIR) systems, along with their mathematical representations. Additionally, it covers MATLAB functions for convolution and the approximation of continuous convolution into discrete form.

Uploaded by

zbadizbadi04
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)
4 views4 pages

DSP Lab2

The document provides an overview of discrete time convolution, explaining its relationship between input and output signals in linear time invariant systems, and detailing the algorithm for performing convolution in MATLAB. It also discusses the characteristics of discrete time filters, including finite impulse response (FIR) and infinite impulse response (IIR) systems, along with their mathematical representations. Additionally, it covers MATLAB functions for convolution and the approximation of continuous convolution into discrete form.

Uploaded by

zbadizbadi04
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

Experiment 1) Discrete time convolution

Tutorial:
The convolution sum expresses the relation between the input signal of a linear
time invariant system and its output. The expression of the discrete time
convolution is:

We can think about the convolution sum as a weighted sum of shifted versions of
input vector. The weights of the different versions are determined by the
impulse response of the system y[n]= ……………+h[-1] x[n+1] +h[0] x[n]+h[1] x[n-1]
+…………………

So, to get the result of convolution, you have to add different versions of the signal
multiplied by a number that depends on the system.

Assume x[n] starts from ax, and ends at bx

Assume h[n] starts from ah, and ends at bh

Then y[n] starts at ax+ah and ends at bx+bh

In MATLAB, we treat the signal and its time axis independently.

The complete algorithm to do the convolution is:

1- Define nx, x , nh, h

2- ny ”the time index of the result” as a vector:

starting from nx(1)+nh(1) and ends at nx(end)+nh(end)

3- Initialize the output vector y to all zeros, its length should equal to
length(x)+length(h)-1

4- Loop over all elements of the vector h, at each iteration add a shifted version of
the signal to the old y
5- End

Experiment 2) The (conv) command:

The MATLAB conv command implements the discrete time convolution, see the
MATLAB help and try to use it to verify your results in the previous part

Experiment 3) Filters:

Tutorial:
A discrete time filter is just a discrete time system with certain impulse response.
The impulse response of the filter determines its characteristics; either low
pass, high pass … etc. The relationship between the input and the output of the
filter can be also expressed in another form called representation using finite
difference equations:

a(1)*y(n) = b(1)*x(n) + b(2)*x(n-1) + ... + b(nb+1)*x(n-nb)- a(2)*y(n-1) - ... -


a(na+1)*y(n-na)

Any system that can be expressed as a finite difference equation is an LTI systems ,
we can prove time invariance by entering new input for the system called
x2(n) equals to x1(n-N) "delayed version of the original input, we will find

(First input): (1)

a(1)*y1(n) = b(1)*x1(n) + b(2)*x1(n-1) + ... + b(nb+1)*x1(n-nb)- a(2)*y1(n-1)


- ... - a(na+1)*y1(n-na)

(Second input=delayed version of input) "x2(n)=x1(n-N)" (2)

a(1)*y2(n) = b(1)*x2(n) + b(2)*x2(n-1) + ... + b(nb+1)*x2(n-nb) - a(2)*y2(n-


1) - ... - a(na+1)*y2(n-na)

a(1)*y2(n) = b(1)*x1(n-N) + b(2)*x1(n-1-N) + ... + b(nb+1)*x1(n-nb-N)-


a(2)*y2(n-1) - ... - a(na+1)*y2(n-na)
By delaying the output of the first input by N "means replace every n by n-N in the
first equation, we will find that y2(n)=y1(n-N), this means that the system is time
invariant.

If we want to prove linearity, we will enter x1(n) on the system, get y1(n),
then enter x2(n) to get y2(n), then enter x3(n)=a*x1(n)+b*x2(n), if the output
y3=a*y1(n)+b*y2(n), then the system is Linear, this can be easily verified if
we multiplied eq (1) by a, eq(2) by b and add the two equations, we will find that
we got new input a*x1(n)+b*x2(n) with new output a*y1(n)+b*y2(n)

If all the a coefficients equals to zero except a(1), then we have a finite
impulse response system. An example of a famous FIR that acts as a low pass filter
is the moving average filter. Y[n]=(x[n]+x[n-1+x[n-2]])/3;

The output of the system at any time instant equals to the average of the previous
sample, the current sample and the future sample. Here we have
b(1)=b(2)=b(3)=1/3

“Moving average filter of order 3”

If any of the a’s other than a(1) doesn’t equal to zero, then we have infinite
impulse response system, the current output depends on all the previous inputs
till the output moment. An example of this system is

Y[n]=.5 y[n-1]+x[n].

The previous inputs affects the current output through the term y[n-1].

To know the output of a system described by a difference equation, MATLAB has


the (filter) command.
Session 3
System representation

3.1 Time domain (Impulse response):


x The system is represented by its impulse response, and the relation between the input and the output
of the system is as follows:

y(t) = x(t) * h(t)

X(t) h(t) y(t)

x Matlab performs only discrete convolution:

Z = x*y

Z[n] = x[n] * y[n]

= σ ‫ݔ‬ሾ݇ሿ‫ݕ‬ሾ݊ െ ݇ሿ

To implement continuous convolution, we must approximate it into discrete one:

Z(t) = x(t) * y(t)



= ‫ି׬‬ஶ ‫ݔ‬ሺ߬ሻ‫ݕ‬ሺ‫ ݐ‬െ ߬ሻ݀߬

؆ σ ‫ݔ‬ሺ߬ሻ‫ݕ‬ሺ݊ െ ߬ሻο߬

؆ ܶ‫ݏ‬Ǥ discrete convolution (x,y)

3.2 Matlab function of convolution:


For continuous signals,

Z = ௙௦ conv(x,y)

x Start time for the output of the convolution (z) = start time of (x) + start time of (y)
x End time for the output of the convolution (z) = End time of (x) + End time of (y)
x Length of the output (z) = length of (x) + length of (y) - 1

You might also like