DSP Lab Manual 2022 batch
DSP Lab Manual 2022 batch
INDEX
S.N DATE EXPERIMENT NAME SUBMISSIO MARK SIGN
O N S
DATE
1. GENERATION OF ELEMENTARY
DISCRETE-TIME SEQUENCES
7.
8.
9.
10.
1
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY
AIM:
SOFTWARE REQUIRED:
● Scilab 6.1.1
PROCEDURE:
COSINE WAVES:
f=0.2;
t=0:0.1:10;
x=cos(2*%pi*t*f);
plot2d3(t,x)
title(' cosine wave ');
xlabel(' t ');
ylabel(' x ');
2
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY
SINE WAVES:
f=0.2;
t=0:0.1:10;
x=sin(2*%pi*t*f);
plot2d3(t,x)
title(' sine wave ');
xlabel(' t ');
ylabel(' x ');
UNIT STEP:
3
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY
t=0:4;
y=ones(1,5);
subplot(2,1,1);
plot2d3(t,y);
xlabel('time');
ylabel('amplitude');
title('Unit Step Discrete Signal');
SINC SIGNAL:
t=-10:0.2:10
x=sinc(t);
plot2d3(t,x)
title(' sinc wave ');
xlabel(' t ');
ylabel('x ');
4
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY
RECTANGULAR WAVE:
clf;
t=linspace(0,10,50);
vm=5*squarewave(t);
plot2d3(t,vm)
EXPONENTIAL WAVE:
t=-2:0.1:2;
x=exp(t);
plot2d3(t,x)
5
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY
RESULT:
6
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY
AIM:
SOFTWARE USED:
● Scilab 6.1.1
PROCEDURE:
CODE:
7
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY
title('first sequence');
xlabel('n−−−−−−>');
ylabel('amp−−−−>');
subplot(2,2,2);
plot2d3(y);
title ('second sequence') ;
xlabel ( ' n−−−−−−> ' ) ;
ylabel ( 'amp−−−−> ' ) ;
subplot (2,2,3) ;
plot2d3(n);
title ( 'convolved sequence') ;
xlabel( ' n−−−−−−> ' ) ;
ylabel ( 'amp−−−−> ' ) ;
disp( 'The Convolved Sequences' ) ;
disp(n);
OUTPUT:
Enter the first sequence : [ 4 2 6 2 ]
Enter the second Sequence : [ 6 5 2 3 ]
The convolved sequences
24 32 54 58 28 22 6
8
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY
9
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY
for n =1: N
y ( n ) =0;
for i =1: N
j =n - i +1;
if(j <=0)
j=N+j;
end
y ( n ) = y( n ) + g ( i ) * h( j ) ;
end
end
disp ( ’ The resultant signal is : ’ ) ;
disp ( y );
subplot (3 ,1 ,1) ;
plot2d3 ( g );
title ( ’ f i r s t i n p u t s e q u e n c e ’ ) ;
subplot (3 ,1 ,2) ;
plot2d3 ( h );
title ( ’ s e c o n d i n p u t s e q u e n c e ’ ) ;
subplot (3 ,1 ,3) ;
plot2d3 ( y );
title ( ’ convolved sequence ’ ) ;
10
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY
OUTPUT:
// Enter the first sequence : [ 5 3 6 4 ]
// Enter the second sequence : [ 2 6 5 3 ]
// The resultant signal is :
// 7 3 7 4 6 7 7 4
RESULT:
11
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY
AIM:
SOFTWARE REQUIRED:
● Scilab 6.1.1
PROCEDURE:
AUTOCORRELATION CODE:
12
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY
OUTPUT:
OUTPUT:
RESULT:
The autocorrelation and cross correlation of signals was performed.
13
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY
AIM:
SOFTWARE REQUIRED:
● Scilab 6.1.1
PROCEDURE:
CODE:
BasebandFrequency = 10e3;
SamplingFrequency = 1e6;
BufferLength = 200;
n = 0:(BufferLength - 1);
BasebandSignal = sin(2*%pi*n / (SamplingFrequency/BasebandFrequency));
plot(n, BasebandSignal)
BasebandDFT = fft(BasebandSignal);
BasebandDFT_magnitude = abs(BasebandDFT);
plot(BasebandDFT_magnitude);
14
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY
OUTPUT:
RESULT:
AIM:
SOFTWARE REQUIRED:
● Scilab 6.1.1
PROCEDURE:
LPF CODE:
16
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY
17
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY
HPF CODE:
18
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY
OUTPUT:
19
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY
BPF CODE:
ylabel('Magnitude |H(w)|=');
title('Magnitude R e s po n s e of FIR BPF');
xgrid(1)
OUTPUT:
22
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY
BSF CODE:
23
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY
wc2=w2/%pi;
disp(wc1,'Normalized digital lower cutoff frequency in cycles/samples');
disp(wc2,'Normalized digital higher cutoff frequency in cycles/samples');
[wft,wfm,fr]=wfir('sb',M+1,[wc1/2,wc2/2],'re',[0,0]);
disp(wft,'Impulse response of BSF FIR Filter:h[n]:');
subplot(2,1,1)
plot(2*fr,wfm)
xlabel("Normalized digital frequency w---->");
ylabel("Magnitude |H(w)|:");
title("Magnitude response of FIR BSF");
xgrid(1)
subplot(2,1,2)
plot(fr*fs,wfm)
xlabel("Analog Frequency in Hz f---->");
ylabel("Magnitude |H(w)|:");
title("Magnitude response of FIR BSF");
xgrid(1)
OUTPUT:
24
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY
25
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY
RESULT:
The FIR filters like LPF, HPF, BPF, BSF were designed and output waveforms
were obtained.
AIM:
● To design butterworth and chebyshev IIR filters for LPF, HPF, BPF, BSF.
SOFTWARE REQUIRED:
● Scilab 6.1.1
PROCEDURE:
26
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY
27
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY
OUTPUT :
clear all;
clc;
close ;
s = poly(0,'s');
Omegac = 0.2*%pi;
H = Omegac/(s+Omegac);
T=1;
z=poly(0,'z');
Hz_LPF = horner(H,(2/T)*((z-1)/(z+1)));
alpha = -(cos((Omegac+Omegac)/2))/(cos((Omegac-Omegac)/2));
28
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY
OUTPUT :
29
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY
clear all;
clc;
close;
omegaP = 0.2*%pi;
omegaL = (1/5)*%pi;
omegaU = (3/5)*%pi;
z=poly(0,'z');
H_LPF=(0.245)*(1+(z^-1))/(1-0.509*(z^-1));
alpha = (cos((omegaU+omegaL)/2)/cos((omegaU-omegaL)/2));
k=(cos((omegaU-omegaL)/2)/sin((omegaU-omegaL)/2))*tan(omegaP/2);
NUM = -((z^2)-((2*alpha*k/(k+1))*z)+((k-1)/(k+1)));
DEN = (1-((2*alpha*k/(k+1))*z)+(((k-1)/(k+1))*(z^2)));
30
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY
HZ_BPF=horner(H_LPF,NUM/DEN);
disp(HZ_BPF,'Digital BPF IIR Filter H(Z)= ');
HW = frmag(HZ_BPF(2),HZ_BPF(3),512);
W=0:%pi/511:%pi;
a=gca();
a.thickness=1;
plot(W/%pi,HW,'r')
a.foreground=1;
a.font_style=9;
xgrid(1)
xtitle('Magnitude Response of BPF Filter cutoff frequency [0.2,0.6]','Normalized
digital frequency --->','MAgnitude');
OUTPUT :
31
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY
clear all;
clc;
close;
omegaP = 0.2*%pi;
omegaL = (1/5)*%pi;
omegaU = (3/5)*%pi;
z=poly(0,'z');
H_LPF=(0.245)*(1+(z^-1))/(1-0.509*(z^-1));
alpha = (cos((omegaU+omegaL)/2)/cos((omegaU-omegaL)/2));
k=tan((omegaU-omegaL)/2)*tan(omegaP/2);
NUM = -((z^2)-((2*alpha/(1+k))*z)+((1-k)/(1+k)));
DEN = (1-((2*alpha/(1+k))*z)+(((1-k)/(1+k))*(z^2)));
HZ_BPF=horner(H_LPF,NUM/DEN);
HW = frmag(HZ_BPF(2),HZ_BPF(3),512);
W=0:%pi/511:%pi;
a=gca();
a.thickness=1;
plot(W/%pi,HW,'r')
a.foreground=1;
a.font_style=9;
xgrid(1)
xtitle('Magnitude Response of BSF Filter cutoff frequency [0.2,0.6]','Normalized
digital frequency --->','MAgnitude');
OUTPUT :
32
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY
clear all;
clc;
close;
Wp= input('Enter the digital pass band edge frequency');
Ws= input('Enter the digital stop band edge frequency');
T=input('sampling interval')
OmegaP = (2/T)*tan(Wp/2)
OmegaS = (2/T)*tan(Ws/2)
Delta1 = input('Enter the pass band ripple');
Delta2 = input('Enter the stop band ripple');
Delta = sqrt(((1/Delta2)^2)-1)
Epsilon = sqrt(((1/Delta1)^2)-1)
N = (acosh(Delta/Epsilon))/(acosh(OmegaS/OmegaP))
33
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY
N=ceil(N)
OmegaC = OmegaP/((((1/Delta1)^2)-1)^(1/(2*N)))
[pols,gn]=zpch1(N,Epsilon,OmegaP)
Hs=poly(gn,'s','coeff')/real(poly(pols,'s'))
z=poly(0,'z');
Hz=horner(Hs,((2/T)*((z-1)/(z+1))))
HW = frmag(Hz(2),Hz(3),512);
W=0:%pi/511:%pi;
a=gca();
a.thickness=1;
plot(W/%pi,abs(HW),'r')
a.foreground=1;
a.font_style=9;
xgrid(1)
xtitle('Magnitude Response of Chebyshev LPF Filter','Normalized digital
frequency --->','MAgnitude in dB');
OUTPUT :
34
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY
35