0% found this document useful (0 votes)
9 views38 pages

Lab Manual-Dsp

The document is a laboratory manual for the BE Electronics and Communication Engineering program at the University Institute of Technology, RGPV, Bhopal. It includes a certificate of completion, an index of experiments, and detailed MATLAB scripts for various signal processing tasks such as generating discrete-time signals, performing operations on sequences, and computing transforms. The manual serves as a guide for students to complete their laboratory work satisfactorily.

Uploaded by

bhargavaudyan
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)
9 views38 pages

Lab Manual-Dsp

The document is a laboratory manual for the BE Electronics and Communication Engineering program at the University Institute of Technology, RGPV, Bhopal. It includes a certificate of completion, an index of experiments, and detailed MATLAB scripts for various signal processing tasks such as generating discrete-time signals, performing operations on sequences, and computing transforms. The manual serves as a guide for students to complete their laboratory work satisfactorily.

Uploaded by

bhargavaudyan
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/ 38

Department

of
Electronics & Communication Engineering

Laboratory Manual

BE (Electronics and Communications)

UNIVERSITY INSTITUTE OF TECHNOLOGY, RGPV, BHOPAL

Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
UNIVERSITY INSTITUTE OF TECHNOLOGY, RGPV, BHOPAL

Certificate

This is to certify that Mr. /Ms..............................................................................

Of electronics and Communication department, semester....................Enrolment

No............................... has satisfactory completed his/her laboratory work in the

Course.............................................. course code...................................for them

ending in 2014.

Date of Submission: ...............................

(Ajay Urmaliya) (Dr R K Singhai)

Sign of In-charge Head of Department

Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
INDEX

S.No Title of the Experiment Date Page Sign Marks

1 Generation, analysis and plot of


discrete-time signals.

2 Implementation of operations on
sequences(addition, multiplication,
folding etc)
3 Implementation of linear-time-
invariant (LTI) systems and testing
them for stability and causality.
4 Computation and plot of DTFT
of sequences.
5 Computation and plots of
Z-transform.
6 Computation and plot of DFT of
sequences.
7 Computation and plots of
linear/circular convolution of two
sequences.
8 Implementation of various window
design techniques (Rectangular,
Bartlett, Hann, Hamming etc)

Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
Experiment-1
Objective: Generation, analysis and plots of discrete-time signals.
(A) Unit Impulse Signal:
MATLAB SCRIPT:

t=-2:1:2;
y=[zeros(1,2), ones(1,1), zeros(1,2)]; % Expression
stem(t,y);
xlabel('time');
ylabel('Amplitude');
title('unit impulse signal');

Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
(B) Unit Step Signal:
MATLAB SCRIPT:

n=-5:5;
y=[zeros(1,5),ones(1,6)];
stem(n,y)
xlabel('Sequence');
ylabel('Amplitude');
title('unit step signal');

Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
(C) Ramp Signal:
MATLAB SCRIPT:

n=input('Enter the No of sequence = ');


t=0:n;
stem(t,t);
xlabel('sequences');
ylabel('Amplitude');
title('Ramp Signal');

Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
(D) Sine Signal:

MATLAB SCRIPT:

A = input('Enter the Value of Amplitude A = ');


S = input('Enter the Value of Sample S = ');
x=linspace(0,(2*pi),S);
y=A*sin(x);
stem(x,y,'r');
xlabel('Sequences');
ylabel('Amplitude');
title('Sine Wave')

Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
(D) Cosine Signal:

MATLAB SCRIPT:

a=input('Enter the value of amplitude a= ');


S = input('Enter the Value of Sample S = ');
x=linspace(0,(2*pi),S);
y=a*cos(x);
stem(x,y, 'r');
xlabel('x=0:2/pi');
Ylabel('cos of x');
title('Cosine Wave');

Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
(E) Real Exponential Signal:
MATLAB SCRIPT:

a = input ('Type in argument =' ) ;


K = input ('Type in gain constant =') ;
N = input ('Type in length of sequence =') ;
n = 0: N ;
x =K*a.^n ;
stem (n ,x,'r' ) ;
xlabel ('Sequence n') ;
ylabel ('Amplitude') ;
title (['\alpha =',num2str(a)]) ;

a= 1.2, K=20, N=20 (Growing)

Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
a= 0.8, K=20, N=20 (Decaying)

Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
a= -1.2, K=20, N=20

a= - 0.8, K=20, N=20

Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
(F) Complex Exponential Signal:
MATLAB SCRIPT:

a = input ('Type in real exponent =') ;


b = input ('Type in imaginary exponent =') ;
c = a + b*i ;
K = input ('Type in the gain constant =') ;
N = input ('Type in length of sequence =') ;
n = 1: N ;
x =K*exp (c*n) ;
stem (n,real (x) ) ;
xlabel ('Sequences n') ;
ylabel ('Amplitude') ;
title ('Real part') ;
disp ( 'PRESS RETURN for imaginary part' ) ;
pause
stem (n,imag(x) ) ;
xlabel ( 'Sequences n') ;
ylabel ('Amplitude') ;
title ('Imaginary part' ) ;

Euler's formula: [ ei𝜃 = cos 𝜃 + i sin 𝜃 ]


Real part value: -(1/12)

Imaginary part value: pi/6

Gain constant: 1

Length of sequence: 40

Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
Experiment-2
Objective: Implementation of operations on sequences (addition,
multiplication, folding etc.)
(A) Addition of two sequences:

MATLAB SCRIPT:

n=-3:3;
a=[1,3,5,6,7,9,2];
b=[2,4,7,2,9,5,6];
c=a+b;
stem(n,c,'r');
xlabel ( 'Sequences n') ;
ylabel ('Amplitude') ;
title ('addition of two sequences')

Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
(B) Multiplication of two sequences:

MATLAB SCRIPT:

n=-3:3;
a=[1,3,5,6,7,9,2];
b=[2,4,7,2,9,5,6];
c=a.*b;
stem(n,c,'r');
xlabel ( 'Sequences n') ;
ylabel ('Amplitude') ;
title ('Multiplication of two sequences')

Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
(C) Folding operation on sequence:

MATLAB SCRIPT:

n=-3:3;
a=[1,3,5,6,7,9,2];
b=fliplr(a);
stem(n,b,'r');
xlabel ( ' n') ;
ylabel ('x(-n)') ;
title ('folding of sequence')

Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
Experiment-3

Objective: Implementation of linear-time-invariant (LTI) systems and


testing them for stability and causality.
(A) Linearity Property of two sequences:

MATLAB SCRIPT:

n=0:40; a=2; b=-3;


x1=cos(2*pi*0.1*n);
x2=cos(2*pi*0.4*n);
x=a*x1+b*x2;
ic=[0 0];
num=[2.2403 2.4908 2.2403];
den=[1 -0.4 0.75];
y1=filter(num,den,x1,ic);
y2=filter(num,den,x2,ic);
y=filter(num,den,x,ic);
yt=a*y1+b*y2;
subplot(2,1,1);
stem(n,y)
ylabel ('y(n)') ;
subplot(2,1,2);
stem(n,yt)
ylabel ('yt(n)') ;

Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
(B) Time shift Invariance property:

MATLAB SCRIPT:

n=0:40;D=10;
x=3*cos(2*pi*0.1*n)-2*cos(2*pi*0.4*n);
xd=[zeros(1,D) x];
num=[2.2403 2.4908 2.2403];
den=[1 -0.4 0.75];
ic=[0 0];
y=filter(num,den,x,ic);
yd=filter(num,den,xd,ic);
d=y-yd(1+D:41+D);
subplot(3,1,1),stem(y),grid;ylabel ('y') ;
subplot(3,1,2),stem(yd),grid;ylabel ('yd') ;
subplot(3,1,3),stem(d),grid;grid;ylabel ('d') ;

Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
(C) To check stability of a system:

MATLAB SCRIPT:

num=[1 0.8];
den=[1 1.5 .9];
N=200;
h=impz(num,den,N+1);
sum=0;
n=0:N;
for k=1:N+1
if abs(h(k))<10^(-6);
break
end
sum=sum+h(k);
end
stem(n,h); grid;
disp('Value='),
disp(sum)

Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
Experiment-4

Objective: Computation and plot of DTFT of sequences..


MATLAB SCRIPT:

% Discrete-Time Fourier Transform Computation

% Read in the desired number of frequency samples


k = input('Number of frequency points = ');
% Read in the numerator and denominator
coefficients
num = input('Numerator coefficients = ');
den = input('Denominator coefficients = ');
% Compute the frequency response
w = 0:pi/(k-1):pi;
h = freqz(num, den, w);
% Plot the frequency response
subplot(2,2,1)
plot(w/pi,real(h));grid
title('Real part')
xlabel('\omega/\pi'); ylabel('Amplitude')
subplot(2,2,2)
plot(w/pi,imag(h));grid
title('Imaginary part')
xlabel('\omega/\pi'); ylabel('Amplitude')
subplot(2,2,3)
plot(w/pi,abs(h));grid
title('Magnitude Spectrum')

Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
xlabel('\omega/\pi'); ylabel('Magnitude')
subplot(2,2,4)
plot(w/pi,angle(h));grid
title('Phase Spectrum')
xlabel('\omega/\pi'); ylabel('Phase, radians')

Input data:
k = 256
num = [0.008 -0.033 0.05 -0.033 0.008]
den = [1 2.37 2.7 1.6 0.41]

Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
Experiment-5

Objective: Computation and plots of Z-transform.


(A) Express the following z-transform in factored form, plot its poles and zeros,and
then determine its ROCs:
2z4 + 16z3 + 44z4 + 56z +32
G(z) = --------------------------------------
3z4 + 3z3 – 15z2 + 18z -12
Determination of the Factored Form of a rational z-transform:
MATLAB SCRIPT:

num =input('Type in the numerator coefficients = '); %[2 16 44 56 32]


den =input('Type in the denominator coefficients = '); %[3 3 -15 18 -12]
[z , p , k] = tf2zp(num, den) ;
m = abs (p) ;
disp ('zeros are at ') ; disp(z) ;
disp('Poles are at ') ; disp(p) ;
disp('Gain constant') ; disp(k) ;
disp( 'Radius of poles ') ; disp(m) ;
sos = zp2sos( z ,p , k) ;
disp( 'Second –order sections ') ; disp (real ( sos ) ) ;
zplane (num ,den )

Input data:
Type in the numerator coefficients = [2 16 44 56 32]

Type in the denominator coefficients = [3 3 -15 18 -12]

Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
Output Data:

zeros are at
-4.0000
-2.0000
-1.0000 + 1.0000i
-1.0000 - 1.0000i

Poles are at
-3.2361
1.2361
0.5000 + 0.8660i
0.5000 - 0.8660i

Gain constant
0.6667

Radius of poles
3.2361
1.2361
1.0000
1.0000

Second –order sections


0.6667 4.0000 5.3333 1.0000 2.0000 -4.0000
1.0000 2.0000 2.0000 1.0000 -1.0000 1.0000

Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
Therefore the factored form of the z-transform is given by:
(0.6667 + 0.4z-1 + 0.5333z-2) (1.0 + 2.0z-1 + 2.0z-2)
G(z) = ----------------------------------------------------------------
(1.0 + 2.0z-1- 4z-2) (1 – z-1 + z-2)

(1 + 6z-1 + 8z-2) (1 +2z-1 + 2z-2)


= 0.6667 -------------------------------------------
(1+ 2z-1 +- 4z-2)(1 – z-1 + z-2)
The pole – zero plot developed by the program is shown in Figure.The four ROCs
are thus seen to be
R1 :   |z|  3.2361,
R2 : 3.2361  |z|  1.2361,
R3 : 1.2361  |z|  1,
R4 : 1  |z|  0.

Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
(B) Determine the partial-fraction expansion of the z-transform G(z) given by:

18z 3
G(z) 
18z 3  3z 2  4z  1

MATLAB SCRIPT:

%Partial-Fraction Expansion of Rational z-Transform


num=input('Type in numerator coefficients =');
den=input('Type in denominator coefficients =');
[r,p,k] =residuez(num, den);
disp ('Residues'); disp(r)
disp ('poles'); disp(p)
disp ('constants'); disp(k)

Input data:

Num=[18]

Den = [18 3 -4 -1]

Output data:

For our above example, these are as given below.

Residues

0.3600 0.2400 0.4000

Poles

0.5000 -0.3333 -0.3333

Constants

Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
Note also that z-transform has double poles at z = -0.3333. The first entry in
both the residues and poles given above corresponds to the simple pole factor
(1  0.5z 1 ) ,the second entry corresponds to the simple pole factor
(1  0.3333z 1 ) ,and the third entry corresponds to the factor (1  0.3333z 1 ) 2 , in

the partial fraction expansion is given by:

0.36 0.24 0.4


G ( z)  -1
 -1

1 - 0.5z 1 - 0.3333z (1 - 0.3333z - 1 ) 2

Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
Experiment-6

Objective: Computation and plot of DFT of sequences.


MATLAB SCRIPT:

% Illustration of DFT Computation


% Read in the length N of sequence and the desired length M of the DFT
N = input('Type in the length of the sequence = ');
M = input('Type in the length of the DFT = ');
% Generate the length-N time-domain sequence
u = [ones(1,N)];
% Compute its M-point DFT
U = fft(u,M);
% Plot the time-domain sequence and its DFT
t = 0:1:N-1;
stem(t,u)
title('Original time-domain sequence')
xlabel('Time index n'); ylabel('Amplitude')
pause
subplot(2,1,1)
k = 0:1:M-1;
stem(k,abs(U))
title('Magnitude of the DFT samples')
xlabel('Frequency index k'); ylabel('Magnitude')
subplot(2,1,2)
stem(k,angle(U))
title('Phase of the DFT samples')
xlabel('Frequency index k'); ylabel('Phase')

Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
Input data:

Type in the length of the sequence = 8


Type in the length of the DFT = 16

Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
Experiment-7

Objective: Computation and plots of linear/circular convolution of two


sequences.
(A) Linear convolution of two sequences.
MATLAB SCRIPT:

clear all;
close all;
clc;
x1 = input ('enter the first sequence = ');
subplot (2,2,1);
stem (x1,'r');
ylabel ('amplitude');
title ('plot of the first sequence');
grid on;
x2 = input ('enter 2nd sequence = ');
subplot (2,2,2);
stem (x2, 'r');
ylabel ('amplitude');
title ('plot of 2nd sequence');
grid on;
f = conv (x1,x2);
disp ('output of linear conv is');
disp (f);
subplot (2,2,3);
stem (f,'m');
xlabel ('sequences n');
ylabel ('amplitude f');
title('linear conv of sequence');
grid on;
Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
(B) Circular convolution of two sequences.
MATLAB SCRIPT:

% computing circular convolution of two sequences


clc;
clear all;
close all;
g =[1 -3 4 2 0 -2];
h =[3 0 1 -1 2 1];
for i = 1:6,
y(i) =0;
for k = 1:6,
z =mod(6-k+i,6)+1;
y(i)=y(i)+g(z)*h(k);
end
end
disp('The resultant Signal is ');y
stem(y);
ylabel('Amplitude------>');
xlabel('n------>');
title('Circular Convolution');

Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
Experiment-8

Objective: Implementation of various window design techniques


(Rectangular, Bartlett, Hann, Hamming etc)

(A) Plot magnitude response and phase response of digital FIR Filter using
Rectangular window :
a. Low pass Filter
b. High pass Filter
c. Bandpass Filter
d. Bandstop Filter
a. Low Pass FIR Filter Designing:
clc;
clear all;
close all;
N=input('Enter the value of N:');
wc=input('Enter cutoff frequency:');
h=fir1(N, wc/pi, rectwin(N+1));
freqz(h);

Enter the value of N: 5


Enter cutoff frequency: 0.5*pi

Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
b. High Pass FIR Filter Designing:
clc;
clear all;
close all;
N=input('Enter the value of N:');
wc=input('Enter cutoff frequency:');
h=fir1(N,wc/pi, 'high',rectwin(N+1));
freqz(h);

Enter the value of N: 28


Enter cut off frequency: 0.5*pi

Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
c. Band Pass FIR Filter Designing:
clc;
clear all;
close all;
N=input('Enter the value of N:');
wc=input('Enter cutoff frequency:');
h=fir1(N,wc/pi,rectwin(N+1));
freqz(h);

Enter the value of N:28


Enter cutoff frequency:[0.3*pi 0.7*pi]

Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
d. Band Stop FIR Filter Designing:
clc;
clear all;
close all;
N=input('Enter the value of N:');
wc=input('Enter cutoff frequency:');
h=fir1(N,wc/pi, 'stop',rectwin(N+1));
freqz(h);

Enter the value of N:28


Enter cutoff frequency:[0.2*pi 0.7*pi]

Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)
Hanning Window:
1. h=fir1(N,wc/pi,hanning(N+1)); - Low Pass FIR Filter
2. h=fir1(N,wc/pi, 'high',hanning(N+1)); - High Pass FIR Filter
3. h=fir1(N,wc/pi,hanning(N+1)); - Band Pass FIR Filter
4. h=fir1(N,wc/pi, 'stop', hanning(N+1)); - Band Stop FIR Filter

Hamming Window:
1. h=fir1(N,wc/pi,hamming(N+1)); - Low Pass FIR Filter
2. h=fir1(N,wc/pi, 'high',hamming(N+1)); - High Pass FIR Filter
3. h=fir1(N,wc/pi,hamming(N+1)); - Band Pass FIR Filter
4. h=fir1(N,wc/pi, 'stop', hamming(N+1)); - Band Stop FIR Filter

Dept. Of Electronics and Comm. UIT, RGPV BE (Electronics & Communication Engineering - Lab Manual)

You might also like