0% found this document useful (0 votes)
31 views9 pages

NMK31003 DSP Lab 2 Module For Sem 2 2023 - 24

Uploaded by

kajojim206
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views9 pages

NMK31003 DSP Lab 2 Module For Sem 2 2023 - 24

Uploaded by

kajojim206
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Universiti Malaysia Perlis

NMK 31003: DIGITAL SIGNAL PROCESSING


LABORATORY MODULES
SEMESTER 2 SESSION 2023/2024

LAB 2:
TIME-DOMAIN REPRESENTATION OF
SIGNALS AND SYSTEMS
(Convolution & Correlation)

1
OBJECTIVES:

(a) To get acquainted with SCILAB in digital signal processing (DSP) simulations.
(b) To use SCILAB in time-domain representation of signals and systems.
(c) To gain the ability in deploying SCILAB in doing operations on sequence e.g.
convolution, correlation, etc.

Convolution

Convolution is used when analyzing response of a system on arbitrary signals x[n], if we


know its impulse response h[n]. In discrete-time signal, the convolution sum is defined by:

𝑦
𝑘=−∞

The convolution sum describes the relationship between the input and output of discrete-time
system, and is easily evaluated to a compute as a sum of products of numbers. Briefly, we
define new auxiliary variable k, over which we will sum. The signal x[n] is redrawn as it is.
The impulse response h[n] is flipped in time, thus we get h[−k]. To compute nth output
sample, we need to create h[n−k]. It can be done in such a way that we shift zeroth time
sample of sequence h[−k] to the time n. Then, everything lying over is multiplied and
added, hence, we get y[n]. Then, we continue for next n sequences.

In SCILAB, the built-in function or command conv evaluates the convolution of finite
duration discrete-time signals. The syntax is:
y = conv(x,h) where x and h are input sequence vectors whereas y is the output
convolved sequence vector.

Example 1:
1. Find the convolution of the following discrete-time signals and show it graphically: The
SCILAB code:

2
The output:
x
=

-3 5 1 -2 5 0 0
h
=

3 2 1 0 0 0 0
y
=

-9 9 10 1 12 8 5 0 0 0
0 0 0

3
Correlation

Correlation is a mathematical tool used frequently in signal processing for analyzing


functions or series of values. Correlation is the mutual relationship between two or more
signals. Auto correlation is the correlation of a signal with itself. However, this is unlike
cross correlation, which is the correlation of two different signals. The cross correlation
equation:

𝑟𝑥,𝑦
𝑛=−∞
where the index l is called the shift or lag
parameter. The auto correlation equation:

𝑟𝑥,𝑥
𝑛=−∞
where the special case where 𝑦[𝑛] = 𝑥[𝑛].

The typical syntax for computing the cross correlation of two signals is:
[c, lagindex] =corr(x);
where:
C is the cross correlation sequence.

4
lagindex is a row vector, containing the lags index corresponding to the c values.at which
C was estimated. x and y are the two signals to be correlated.
This SCILAB built-in function returns the cross correlation sequence in a length 2N - 1
vector, where x and y are length N vectors (N > 1). If x and y are not the same length, the
shorter vector is zero-padded to the length of the longer vector.

Example:
2. Define two time-domain signals as follows:
The .m code:

5
The cross correlation between the previously defined two signals can be obtained using the
following code:

The typical syntax for computing the auto correlation of a signal is stated as:
[C Lags] = xcorr(x);
where:
C is the cross correlation sequence.
Lags is a vector of the lag indices at which C was estimated.
x is the signal to be correlated.
This SCILAB built-in function returns the auto correlation sequence in a length 2N - 1
vector, where x is a length N vector (N > 1).

3. Define three time-domain signals as follows:


The .m code:

6
The three auto correlation functions of the previously defined signals can be obtained using
the following code:

7
auto correlation functions

Exercise:

1. Write a SCILAB script to find the convolution on the following linear-time invariant
(LTI) discrete-time signals:
x[𝑛] = 0.5𝑛𝑢[𝑛];
ℎ[𝑛] = 𝑢[𝑛 + 3] − 𝑢[𝑛 − 6];
𝑦[𝑛] = 𝑥[𝑛] ∗ ℎ[𝑛];
Use subplot command to plot the input x[n], impulse response h[n]and output y[n]
sequences for −4 ≤ 𝑛 ≤ 7.

2. Repeat Exercise 1 but with the following LTI signals:


1; 0≤𝑛≤4
[𝑛] = {−1; 4 ≤ 𝑛 ≤ 10 ;
0; elsewhere
𝑛; 1≤𝑛≤6
ℎ[𝑛] = { ;
0; elsewhere
Use subplot command to plot the input x[n], impulse response h[n] and output
y[n] sequences.

3. (a) Given 𝑥1[𝑛] = cos(𝜋𝑛) and 𝑥2[𝑛] = sin(0.5𝜋𝑛) for −5 ≤ 𝑛 ≤ 5.

Compute the cross correlation and auto correlation. Show the plots for both signal
inputs and their corresponding cross correlation and auto correlation output using the
subplot command. Determine the maximum cross correlation value.

8
(b) Repeat Exercise 3(a) for 1[𝑛] = sin(𝜋𝑛) and 𝑥2[𝑛] = cos(0.5𝜋𝑛).
Briefly, explain the difference between the output in both Exercises 3(a) and 3(b).

You might also like