Lab Manual
Lab Manual
(15EC2206L)
LABORATORY MANUAL
Prepared by
Signal processing course team
K L UNIVERSITY
Vaddeswaram
Dec, 2016
LIST OF LAB EXPERIMENTS
banks
7. Subband coding of audio signals
8. Time frequency analysis of non stationary signals - STFT and Wavelets.
9. Wavelet based image compression.
10. Image Edge detection using wavelet transform
11.Total Harmonic distortion estimation with 2 Harmonics.
EXPERIMENT I
INTRODUCTION
In order to facilitate digital system based computation and processing, a continuous signal collected
from the physical process is sampled at regular intervals and preserved as a discrete time signal. Discrete
time signals can be used for various processing modalities. Hence it is necessary to have a basic
understanding of their properties and manipulations, which are practiced in this experiment.
AIM
To generate and display basic discrete-time sequences.
To compute and display basic operations on discrete-time sequences.
Requirements: Digital Computer with MATLAB software.
OBJECTIVES
1. Generate a sinusoidal signal of frequency equal to the last three digits of your register number
and display it and its spectrum.
2. Develop the MATLAB scripts and exhibits the result for the following for the DT sequences,
x1[n]={-1, 2, -2.3, 0, 1, 3, 3.5, -2.1, 6, 0, 7} x 2 [n]={-1, 2, -2.3, 0, 15, 13, 8.5, -2.1, 5, 0, 7}
and
a. X1+X2
b.X1-X2
c. X1*X2
3. Develop the MATLAB scripts and exhibits the result for Time reversal operation of DT
FOR OBJECTIVE 1:
1. MATLAB Script for Generate a sinusoidal signal of frequency equal to the last three digits of
students register number and to display it and its spectrum.
2. Results and analysis:
a. Plot of results
b. Observations
FOR OBJECTIVE 2:
1. MATLAB Script for Generate a sinusoidal signal of frequency equal to the last three digits of
students register number and to display it and its spectrum.
2. Results and analysis:
a. Plot of results
b. Observations
FOR OBJECTIVE 3:
1. MATLAB Script for Generate a sinusoidal signal of frequency equal to the last three digits of
students register number and to display it and its spectrum.
2. Results and analysis:
a. Plot of results
b. Observations
.. to be developed similarly for each objective ..
CONCLUSION:
To be practiced at home:
Pre lab work:
a Study and understand the basic theory required for this lab.
b Run the Matlab scripts given for examples and study the results.
c Perform the analytical solutions for the given laboratory exercises.
d Prepare the Matlab codes for the given laboratory exercises well before the
commencement of lab scheduled time.
Post Lab:
(a) Complete the lab work in all aspects in the given specified lab time.
(b) Practice the exercises at home and show the results to your lab incharge before
commencement of the next lab.
(c) Submit the lab report to the lab in-structure and get the signature before commencement
of the next lab.
(d) Bring the completed lab report to the next lab.
10 n 20
Exercise 1: Develop Matlab scripts for the sequence given below, in the range and
plot them.
(f)
Exercise 2: Determine analytically the following operations. Then develop Matlab scripts and plot for
the following operations.
x[n] x[ n 2] x[n 3] x[ n / 2] x[2 n] x[2n 1] x[n] x[n]
(a) (b) (c) (d) (e) (f) (g)
x[n] [n 1] x[ n]u[n 2] x[n] x[ n]
(h) (i) (j) .
Note: Refer the text book Vinay K Ingle and John G. Proakis, Digital Signal Processing
using Matlab, third edition, Cambridge University Press, New York, 2011.
EXPERIMENT 2
Introduction: Linear and time invariant LTI systems are particularly important class of systems
has significant signal processing applications. These systems satisfy both the linearity and time-
invariant properties. The processing of signals / sequences in time domain through discrete time
systems are usually referred to as convolution or filtering operation. A mathematical operation that
closely resembles convolution and used to compare the similarity between two sequences is
correlation.
AIM
To find the convolution sum of two sequences
To find the correlation between two sequences
Requirements: Digital Computer with MATLAB software.
OBJECTIVES
x[n] {2 4 5 3 1 2 6}; h[n] {1 1 1 1 1}
(a) Find the convolution sum of and
display it.
(b). Find the auto correlation of the following sequences and display it.
(c). Find the cross correlation between the following sequences and display it.
(a). CONVOLUTION:
x[n]
Let is an input sequence applied to an DT, LTI system characterized by an impulse response
h[ n ]
. Then the output of the system is described mathematically by,
y[n] x[k]h[n-k] h[k]x[n-k] x[k]*h[k]
k k
is known as convolution summation.
Convolution Algorithm: The convolution operation or algorithm is illustrated in the following
steps.
h[k ] k 0 h[k ]
Step1: Folding: Fold about to obtain .
h[k ] n0 n0
Step2: Shifting: Shift by to the right (left) if is positive (negative), to obtain
h[n0 k ]
.
x[k ] h[n0 k ]
Step3: Multiplication: Multiply by to obtain the product sequence
vn0 [k ] x[k ]h[ n0 k ]
.
vn0 [k ]
Step4: Summation: Sum all the values of the product sequence to obtain the value of the
n n0
output at time .
MATLAB Script for Generate a sinusoidal signal of frequency equal to the last three digits of
students register number and to display it and its spectrum.
Observations
Correlation of DT Sequences: A mathematical operation that closely resembles convolution is
correlation. Just as in the case of convolution, two sequences are involved in correlation. In contrast
to convolution, however, our objective in computing the correlation between the two sequences is
to measure the degree to which the two sequences are similar and thus to extract some information
that depends to a large extent on the application.
x[ n] y[ n]
(b). Cross-Correlation: Suppose that we have two real sequences and each of which
x[n] y[ n] rxy (l )
has finite energy. The cross-correlation of and is a sequence , which is defined
as
rxy (l )
n
x[n] y[n l ], l 0, 1, 2,...
n
x[n l ] y[n], l 0, 1, 2,...
l xy
The index is is the (time) shift (or lag) parameter and the subscripts on the cross
rxy (l )
correlation sequence indicate the sequences being correlated.
y[ n] x[ n] xy
If the roles of and , therefore reverse order of the indices , then the cross
correlation sequence is defined as
ryx (l )
n
y[n] x[n l ]
n
y[n l ]x[n]
rxy (l ) ryx (l )
Then we conclude that .
Consequently, if we have computer program that performs convolution, we can use it to perform
x[n]
cross-correlation by providing as inputs to the program the sequence the folded sequence
y[ n] x[ n] y[n] rxy (l )
. Then the convolution of with yields the cross-correlation , that is
rxy (l ) x[l ] y[l ]
MATLAB Script for Generate a sinusoidal signal of frequency equal to the last three digits of
students register number and to display it and its spectrum.
Observations
y[ n] x[ n] x[ n]
(c). Auto-Correlation: In the special case where , we have the autocorrelation of ,
which is defined as the sequence
rxx (l )
n
x[n]x[n l ]
n
x[n l ]x[n] l 0, 1, 2,...
MATLAB Script for Generate a sinusoidal signal of frequency equal to the last three digits of
students register number and to display it and its spectrum.
Observations
Home assignment:
y[n] x[n] h[n]
Determine analytically the convolution of the following sequences, and verify your
answers using the Matlab.
x[n ] {2 4 5 3 1 2 6}; h[n] {1 1 1 1 1}
(b)
1, 2 n 4 2, 1 n 2
x[n] h[n]
0, Elsewhere 0, Elsewhere
(c)
4
1
x[n] u[n 1] u[n 4]
4 h[n] u[ n] u[ n 5]
(d) ;
rxx [l ] ryy [l ]
Exercise2: Using Matlab, determine the auto-correlation sequences , and cross
rxy [l ]
correlation of the following sequences.
x[ n] {1 2 4 }; h[n] {1 1 1 1} x[ n] {1 2 3 4 }; h[n] {1 2 3 4 }
(a) (b)
Objectives:
To study of the design of analog filter design.
Design and implement digital IIR filters.
Basic theory: The input output relation of a IIR digital filter is described by a difference
equation:
N M
y[n] ak y[ n k ] bk x[ n k ]
k 1 k 0
ak bk
where and are filter coefficients, N is the order of the filter, N > M. The transfer function
of the digital filter is represented by
M k
bk z
H [ z] k 0
N
1 ak z k
k 10
ak bk
The design of an IIR filter for the given specifications is determining filter coefficients and
of the filter.
Ex1: Determine the order of the LPF filter with the following specifications using Matlab.
Pass band frequency: 1500 Hz, Stop band frequency: 3000 Hz
Pass band ripple: 0.15 dB, Stop band ripple: 60 dB, Sampling frequency : 7000 Hz.
Use the following approximations: (i) Butterworth
Result:
Order of the filter is :
Theoretically:
From calculations:
Ex2: Design a Butterworth LPF with the specifications given in Ex1 using Matlab. Plot the
magnitude and phase response both in normalized frequency and logarithmic scale.
Results:
Images for frequency response:
Magnitude response:
Phase response: