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

Assignment 3

This document contains an assignment on digital signal processing. It involves calculating the linear convolution of signals using different methods like the conv function, graphical method, and matrix method. It also involves plotting the magnitude and phase response of signals from their discrete time Fourier transforms. The key tasks are to find the linear convolution and discrete time Fourier transform of various signals using code and to discuss the outputs.

Uploaded by

sayanvk290
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Assignment 3

This document contains an assignment on digital signal processing. It involves calculating the linear convolution of signals using different methods like the conv function, graphical method, and matrix method. It also involves plotting the magnitude and phase response of signals from their discrete time Fourier transforms. The key tasks are to find the linear convolution and discrete time Fourier transform of various signals using code and to discuss the outputs.

Uploaded by

sayanvk290
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

Digital Signal Processing Lab

(PCCEC592)
ASSIGNMENT: 3

NAME:..................................................................................................................
YEAR : ........................ SEC : ............. ROLL NO.: ......................................
DATE of EXPERIMENT: ………………………….........................................
INSTITUTE OF ENGINEERING & MANAGEMENT
Dept. of Electronics and Comm. Engg, Salt lake, Kolkata
ASSIGNMENT: 3

[1] Find linear convolution between 𝒙(𝒏) and 𝒉(𝒏) using ‘conv’ inbuilt function where
a) 𝒙[𝒏] = [ 𝟏 𝟐 𝟑 𝟒 ] and 𝒉[𝒏] = [ 𝟏 𝟏 𝟏 𝟏 ]

b) 𝒙[𝒏] = [𝟑 𝟏 𝟐 𝟏] and 𝒉[𝒏] = [𝟏 𝟏 𝟏]

Compare the results.

THEORY:

Linear convolution is the basic operation to calculate the output for any linear time invariant system given
its input sequence 𝑥(𝑛) and its impulse response ℎ(𝑛). One dimensional linear discrete convolution is defined
as:

𝑦(𝑛) = ℎ(𝑛) ∗ 𝑥(𝑛) = ∑ ℎ(𝑘) 𝑥(𝑛 − 𝑘)


𝑘=−∞

Notice that when ℎ(𝑛) is of length N, and 𝑥(𝑛) is of length L, the linear convolution is of length (N + L – 1).

-: SOURCE CODE:-

Digital Signal Processing Lab (PCCEC592) Page 2 of 29


INSTITUTE OF ENGINEERING & MANAGEMENT
Dept. of Electronics and Comm. Engg, Salt lake, Kolkata
ASSIGNMENT: 3

-: OUTPUT and DISCUSSION:-

Digital Signal Processing Lab (PCCEC592) Page 3 of 29


INSTITUTE OF ENGINEERING & MANAGEMENT
Dept. of Electronics and Comm. Engg, Salt lake, Kolkata
ASSIGNMENT: 3

[2] Using GRAPHICAL Method, find the linear convolution between 𝒙(𝒏) and 𝒉(𝒏) (use ‘For
Loop’) where
i) 𝒙[𝒏] = [ 𝟏 𝟐 𝟑 𝟒 ] and 𝒉[𝒏] = [ 𝟏 𝟏 𝟏 𝟏 ]

ii) x[n]=[ 𝟑 𝟐 𝟏 𝟏] and 𝒉[𝒏] = [𝟏 𝟏 𝟏]

THEORY:

Linear convolution is the basic operation to calculate the output for any linear time invariant system given
its input sequence 𝑥(𝑛) and its impulse response ℎ(𝑛). One dimensional linear discrete convolution is
defined as:

𝑦(𝑛) = ∑ 𝑥(𝑘) ℎ(𝑛 − 𝑘) = ℎ(𝑛) ∗ 𝑥(𝑛)


𝑘=−∞

Notice that when 𝑥(𝑛) is of length N, and ℎ(𝑛) is of length L, the linear convolution is of length (N + L –
1).

Steps to follow:
1. List the index ‘k’ covering a sufficient range
2. List the input 𝑥[𝑘]
3. Obtain the reversed sequence ℎ[−𝑘], and align the rightmost element of ℎ[𝑛 − 𝑘] to the leftmost
element of 𝑥[𝑘]

4. Multiply the two sequences 𝑥[𝑘] and ℎ[−𝑘], element by element and sum the products to produce
y[n].
5. Slide h[n-k] to the right by one position
6. Repeat step 4;
7. stop if all the output values are zero or if required.
8. For example if 𝑥(n) ={1, 2,1, 3}, h(n)={1, 2,1,2 }

The sequence 𝑥(𝑛) starts at 𝑛1 =0 and ℎ(𝑛) starts at 𝑛2 =-1. Then the starting time for evaluation
the o/p sequence 𝑦(𝑛) is (𝑛1 + 𝑛2 ) = 0 + (−1) = −1

-: SOURCE CODE:-

Digital Signal Processing Lab (PCCEC592) Page 4 of 29


INSTITUTE OF ENGINEERING & MANAGEMENT
Dept. of Electronics and Comm. Engg, Salt lake, Kolkata
ASSIGNMENT: 3

Digital Signal Processing Lab (PCCEC592) Page 5 of 29


INSTITUTE OF ENGINEERING & MANAGEMENT
Dept. of Electronics and Comm. Engg, Salt lake, Kolkata
ASSIGNMENT: 3

-: OUTPUT and DISCUSSION:-

Digital Signal Processing Lab (PCCEC592) Page 6 of 29


INSTITUTE OF ENGINEERING & MANAGEMENT
Dept. of Electronics and Comm. Engg, Salt lake, Kolkata
ASSIGNMENT: 3

[3] Using MATRIX Method, find the linear convolution between 𝒙(𝒏) and 𝒉(𝒏) (use ‘For Loop’)
where 𝒙[𝒏] = [𝟑 𝟐 𝟏 𝟏 ] and 𝒉[𝒏] = [ 𝟏 𝟏 𝟏 ]

THEORY:

MATRIX Method (TABULATION METHOD)

𝑋(𝑛) = {𝑥1, 𝑥2, 𝑥3} & ℎ(𝑛) = { ℎ1, ℎ2, ℎ3}

y(-1) = h1 x1

y(0) = h2 x1 + h1 x2

y(1) = h1 x3 + h2x2 + h3 x1 ………

-: SOURCE CODE:-

Digital Signal Processing Lab (PCCEC592) Page 7 of 29


INSTITUTE OF ENGINEERING & MANAGEMENT
Dept. of Electronics and Comm. Engg, Salt lake, Kolkata
ASSIGNMENT: 3

Digital Signal Processing Lab (PCCEC592) Page 8 of 29


INSTITUTE OF ENGINEERING & MANAGEMENT
Dept. of Electronics and Comm. Engg, Salt lake, Kolkata
ASSIGNMENT: 3

-: OUTPUT and DISCUSSION:-

Digital Signal Processing Lab (PCCEC592) Page 9 of 29


INSTITUTE OF ENGINEERING & MANAGEMENT
Dept. of Electronics and Comm. Engg, Salt lake, Kolkata
ASSIGNMENT: 3

[4] If the Discrete Time Fourier Transform (DTFT) of 𝒙[𝒏] is 𝑿(𝒆𝒋𝝎𝒏) such that:

𝟏, 𝟎≤𝒏≤𝟑 𝒋𝝎𝒏
𝟏 − 𝒆−𝟒𝒋𝝎
𝒙[𝒏] = { 𝐚𝐧𝐝 𝑿(𝒆 )=
𝟎, 𝐨𝐭𝐡𝐞𝐫𝐰𝐢𝐬𝐞 𝟏 − 𝒆−𝒋𝝎

Plot the magnitude and phase response of 𝑿(𝒆𝒋𝝎𝒏 ).

THEORY:

The magnitude spectrum of the signal is


|𝑿(𝒆𝒋𝝎 )| = √𝑿𝟐𝒓𝒆 (𝒆𝒋𝝎 ) + 𝑿𝟐𝒊𝒎 (𝒆𝒋𝝎 )
The phase spectrum is (in radians)

𝑿(𝒆𝒋𝝎𝒏 ) = 𝐭𝐚𝐧−𝟏 [𝑿𝒊𝒎 (𝒆𝒋𝝎 )/𝑿𝒓𝒆 (𝒆𝒋𝝎 )]

-: SOURCE CODE:-

Digital Signal Processing Lab (PCCEC592) Page 10 of 29


INSTITUTE OF ENGINEERING & MANAGEMENT
Dept. of Electronics and Comm. Engg, Salt lake, Kolkata
ASSIGNMENT: 3

-: OUTPUT and DISCUSSION:-

Digital Signal Processing Lab (PCCEC592) Page 11 of 29


INSTITUTE OF ENGINEERING & MANAGEMENT
Dept. of Electronics and Comm. Engg, Salt lake, Kolkata
ASSIGNMENT: 3

[5] If the Discrete Time Fourier Transform (DTFT) of 𝒙[𝒏] is 𝑿(𝒆𝒋𝛚 ) such that:

𝟏
𝒙[𝒏] = 𝒂𝒏 𝒖[𝒏] 𝐰𝐡𝐞𝐫𝐞 |𝒂| < 1 𝐚𝐧𝐝 𝑿(𝒆𝒋𝜴 ) =
𝟏 − 𝒂𝒆−𝒋𝝎

Plot the magnitude and phase response of 𝑿(𝒆𝒋𝝎 ). Compare the results.

THEORY:

The Discrete-Time Fourier Transform (DTFT) is a form of Fourier analysis that is applicable to
the uniformly-spaced samples of a continuous function. The term discrete-time refers to the fact
that the transform operates on discrete data (samples) whose interval often has units of time. The
Discrete-Time Fourier transform (DTFT) of 𝑥[𝑛] can be expressed as

𝑿(𝝎) = ∑ 𝒙[𝒏] 𝒆−𝒋𝝎𝒏


𝒏=−∞

where we have used the uppercase omega (𝜔) as the frequency variable to distinguish the
continuous-time and discrete-time cases. 𝑋(𝜔) is referred as the Fourier spectrum of 𝑥[𝑛]

-: SOURCE CODE:-

Digital Signal Processing Lab (PCCEC592) Page 12 of 29


INSTITUTE OF ENGINEERING & MANAGEMENT
Dept. of Electronics and Comm. Engg, Salt lake, Kolkata
ASSIGNMENT: 3

-: OUTPUT and DISCUSSION:-

Digital Signal Processing Lab (PCCEC592) Page 13 of 29


INSTITUTE OF ENGINEERING & MANAGEMENT
Dept. of Electronics and Comm. Engg, Salt lake, Kolkata
ASSIGNMENT: 3

[6] Find the FOUR point DFT coefficient of 𝒙[𝒏] = [𝟎, 𝟏, 𝟐, 𝟑].

THEORY:

Discrete Fourier Transform (DFT) can be used to represent a discrete sequence into its equivalent
frequency domain representation. The Discrete Fourier Transform is a numerical variant of the Fourier
Transform. It is used to convert a finite discrete-time sequence x(n) to an N –point frequency domain
sequence 𝑋(𝑘), The DFT is defined as such:

𝑁−1

𝑋(𝑘) = ∑ 𝑥(𝑛) 𝑒 −𝑗2𝜋𝑛𝑘/𝑁, where 0 ≤ 𝑘 ≤ 𝑁 − 1


𝑛=0

here, 𝑘 is used to denote the frequency domain ordinal, and n is used to represent the time-domain
ordinal. The big "𝑁" is the length of the sequence to be transformed.

-: SOURCE CODE:-

Digital Signal Processing Lab (PCCEC592) Page 14 of 29


INSTITUTE OF ENGINEERING & MANAGEMENT
Dept. of Electronics and Comm. Engg, Salt lake, Kolkata
ASSIGNMENT: 3

-: OUTPUT and DISCUSSION:-

Digital Signal Processing Lab (PCCEC592) Page 15 of 29


INSTITUTE OF ENGINEERING & MANAGEMENT
Dept. of Electronics and Comm. Engg, Salt lake, Kolkata
ASSIGNMENT: 3

Digital Signal Processing Lab (PCCEC592) Page 16 of 29


INSTITUTE OF ENGINEERING & MANAGEMENT
Dept. of Electronics and Comm. Engg, Salt lake, Kolkata
ASSIGNMENT: 3

[7] Plot 𝑲-point DFT of question for question no [3] for 𝑲 = 𝟒, 𝟖, 𝟏𝟔 and 𝟑𝟐. Compare the results.

THEORY:

Same as given in question no 6.

-: SOURCE CODE:-

Digital Signal Processing Lab (PCCEC592) Page 17 of 29


INSTITUTE OF ENGINEERING & MANAGEMENT
Dept. of Electronics and Comm. Engg, Salt lake, Kolkata
ASSIGNMENT: 3

-: OUTPUT and DISCUSSION:-

Digital Signal Processing Lab (PCCEC592) Page 18 of 29


INSTITUTE OF ENGINEERING & MANAGEMENT
Dept. of Electronics and Comm. Engg, Salt lake, Kolkata
ASSIGNMENT: 3

[8] Find the IDFT of following sequences using inbuilt command and ‘for loop’.
a) 𝑿[𝒌] = [𝟏, 𝟏 − 𝟐𝒋, −𝟏, 𝟏 + 𝟐𝒋]
b) 𝑿[𝒌] = [𝟏, 𝟎, 𝟏, 𝟎]

THEORY:
Discrete Fourier transform (DFT) of x[n] can be expressed as

𝑁−1

𝑋(𝑘) = ∑ 𝑥(𝑛) 𝑒 −𝑗2𝜋𝑛𝑘/𝑁, where 0 ≤ 𝑘 ≤ 𝑁 − 1


𝑛=0

An operation that recovers the discrete data sequence from the DFT function is called an inverse
DFT. Inverse DFT is defined by:

𝑁−1
,
𝑥(𝑛) = 1/𝑁 ∑ 𝑋(𝑘) 𝑒 −𝑗2𝜋𝑛𝑘/𝑁, where 0 ≤ 𝑛 ≤ 𝑁 − 1
𝑘=0

-: SOURCE CODE:-

Digital Signal Processing Lab (PCCEC592) Page 19 of 29


INSTITUTE OF ENGINEERING & MANAGEMENT
Dept. of Electronics and Comm. Engg, Salt lake, Kolkata
ASSIGNMENT: 3

-: OUTPUT and DISCUSSION:-

Digital Signal Processing Lab (PCCEC592) Page 20 of 29


INSTITUTE OF ENGINEERING & MANAGEMENT
Dept. of Electronics and Comm. Engg, Salt lake, Kolkata
ASSIGNMENT: 3

Digital Signal Processing Lab (PCCEC592) Page 21 of 29


INSTITUTE OF ENGINEERING & MANAGEMENT
Dept. of Electronics and Comm. Engg, Salt lake, Kolkata
ASSIGNMENT: 3

[9] Write a program to find the circular convolution between two sequences 𝒙(𝒏) and 𝒉(𝒏) using
MATLAB in build command.
(a) 𝒙(𝒏) = {𝟏, −𝟏, −𝟐, 𝟑, −𝟏} and 𝒉(𝒏) = {𝟏, 𝟐, 𝟑}
(b) 𝒙(𝒏) = {𝟏, −𝟐, 𝟐, 𝟏} and 𝒉(𝒏) = {𝟏, 𝟐, 𝟑}

THEORY: The circular convolution is very similar to normal convolution apart from that the
signal is shifted using circular shift. If 𝑥1 (𝑛) and 𝑥2 (𝑛) are finite discrete time sequence with
length N then the result of the circular convolution 𝑦(𝑛) can be realized by
𝑁−1

𝑦(𝑛) = ∑ 𝑥1 (𝑛) 𝑥2 (𝑛 − 𝑚)𝑁 where 𝑚 = 0,1,2,3 … . (𝑁 − 1)


𝑚=0

This operation to obtain 𝑦[𝑛] is known as the resultant of circular convolution. This is also termed
as cyclic convolution. The circular convolution is represented by, 𝑦(𝑛) = 𝑥1 (𝑛) 𝑥2 (𝑛)

The shifting in this operation is a circular shifting. Generally, there are two methods, which are
adopted to perform the circular convolution. These are,
(a) Concentric circular convolution method and
(b) Matrix circular convolution method.

-: SOURCE CODE:-

Digital Signal Processing Lab (PCCEC592) Page 22 of 29


INSTITUTE OF ENGINEERING & MANAGEMENT
Dept. of Electronics and Comm. Engg, Salt lake, Kolkata
ASSIGNMENT: 3

-: OUTPUT and DISCUSSION:-

Digital Signal Processing Lab (PCCEC592) Page 23 of 29


INSTITUTE OF ENGINEERING & MANAGEMENT
Dept. of Electronics and Comm. Engg, Salt lake, Kolkata
ASSIGNMENT: 3

[10] Find the circular convolution using DFT, IDFT methods (using fft, ifft command) between
𝒙(𝒏) = {𝟑, 𝟒, −𝟐, 𝟎, 𝟏, 𝟒} and 𝒉(𝒏) = {𝟏, −𝟑, 𝟎, 𝟒}.

Compare the results.

THEORY:

Let us take two finite duration sequences 𝑥1(𝑛) and 𝑥2(𝑛), having integer length as N. Their DFTs are
𝑋1(𝑘) and 𝑋2(𝑘) respectively, which is shown below −

𝑁−1
𝑗2𝜋𝑘𝑛
𝑋1(𝑘) = ∑ 𝑥1(𝑛)𝑒 𝑁 𝑘 = 0,1,2. . . 𝑁 − 1
𝑛=0

𝑁−1
𝑗2𝜋𝑘𝑛
𝑋(𝑘) = ∑ 𝑥2(𝑛)𝑒 𝑁 𝑘 = 0,1,2. . . 𝑁 − 1
𝑛=0
Now, we will try to find the DFT of another sequence 𝑥3(𝑛), which is given as 𝑋3(𝑘)
Where 𝑋3(𝑘) = 𝑋1(𝑘) × 𝑋2(𝑘)
By taking the IDFT of the above we get,
𝑁−1
𝑗2𝜋𝑘𝑛
𝑥3(𝑛) = 1/𝑁 ∑ 𝑋3(𝑘)𝑒 𝑁
𝑛=0
We know, 𝑥3(𝑛) = 𝐼𝐷𝐹𝑇[𝑋3(𝑘)]
𝑥3(𝑛) = IDFT [𝑋1(𝑘) 𝑋2(𝑘)]
= 𝑥1(𝑛) 𝑥2(𝑛)

-: SOURCE CODE:-

Digital Signal Processing Lab (PCCEC592) Page 24 of 29


INSTITUTE OF ENGINEERING & MANAGEMENT
Dept. of Electronics and Comm. Engg, Salt lake, Kolkata
ASSIGNMENT: 3

Digital Signal Processing Lab (PCCEC592) Page 25 of 29


INSTITUTE OF ENGINEERING & MANAGEMENT
Dept. of Electronics and Comm. Engg, Salt lake, Kolkata
ASSIGNMENT: 3

-: OUTPUT and DISCUSSION:-

Digital Signal Processing Lab (PCCEC592) Page 26 of 29


INSTITUTE OF ENGINEERING & MANAGEMENT
Dept. of Electronics and Comm. Engg, Salt lake, Kolkata
ASSIGNMENT: 3

[11] Make a comparison between circular and linear convolution for two sequences: 𝒙(𝒏) =
{𝟑, 𝟒, −𝟐, 𝟎, 𝟏, 𝟒} and 𝒉(𝒏) = {𝟏, −𝟑, 𝟎, 𝟒}

THEORY:

Comparison points Linear Convolution Circular Convolution


1.Shifting Linear shifting Circular shifting
2.Samples in the convolution
(N1+N2−1) Max(N1,N2)
result

3.Finding response
Possible Cannot possible without zero
of a filter
padding

-: SOURCE CODE:-

Digital Signal Processing Lab (PCCEC592) Page 27 of 29


INSTITUTE OF ENGINEERING & MANAGEMENT
Dept. of Electronics and Comm. Engg, Salt lake, Kolkata
ASSIGNMENT: 3

Digital Signal Processing Lab (PCCEC592) Page 28 of 29


INSTITUTE OF ENGINEERING & MANAGEMENT
Dept. of Electronics and Comm. Engg, Salt lake, Kolkata
ASSIGNMENT: 3

-: OUTPUT and DISCUSSION:-

…….….................................................... …………………………………………………..

(SIGNATURE OF THE
TEACHER-IN-CHARGE) (SIGNATURE OF THE LAB-IN-CHARGE)
WITH DATE)

STUDENT'S NAME:..................................................................................................................

YEAR:..........................................SEC:........................................ ROLL NO.:.........................

DATE of EXPERIMENT: ....................................................................................................

Digital Signal Processing Lab (PCCEC592) Page 29 of 29

You might also like