Files 3 2021 December NotesHubDocument 1638774645
Files 3 2021 December NotesHubDocument 1638774645
Files 3 2021 December NotesHubDocument 1638774645
DIGITAL SIGNAL
PROCESSING
LAB
(ETEC-356)
SUBMITTED TO : SUBMITTED BY :
MR. PAWAN BHUTANI UTKARSH
PROFESSOR ECE-6A
Dept. of ECE 20113302818
INDEX
S.NO. ACTIVITY DATE SIGN /
REMARK
1 Write a program to generate basic
signal:
1. Unit step.
2. Unit ramp.
3. Unit impulse.
4. Exponential.
5. Sine.
6. Random.
2 Write a program to find out the DFT
and magnitude response and phase
response of input sequence using
Scilab.
3 Write a program to perform circular
convolution of two given sequence.
4 Write a program to design an analog
Butterworth filter having cut-off
frequency equal to 500.
5 Write a program to design type 1
and type 2 chebyshev filter using
Scilab.
6 Write a program to design a FIR
LPF using window based technique.
7 Write a program to design a
upsampling and downsampling
based program.
8 Write a program to perform
autocorrelation and cross-correlation
of given sequences.
EXPERIMENT NO. = 01
AIM : Write a program to generate basic signal:
1. Unit step.
2. Unit ramp.
3. Unit impulse.
4. Exponential.
5. Sine .
6. Random.
CODE :
clc;
clear;
n=0:6;
x=ones(1,7);
subplot(3,2,1);
plot2d3(n,x);
xlabel("Time");
ylabel("Amplitude");
title("Unit step");
y=n;
subplot(3,2,2);
plot2d3(n,y);
xlabel("Time");
ylabel("Amplitude");
title("Unit ramp");
t=-2:2;
z=[zeros(1,2),ones(1,1),zeros(1,2)];
subplot(3,2,3);
plot2d3(t,z);
xlabel("Time");
ylabel("Amplitude");
title("Unit impulse");
m=0:0.1:6;
e=exp(-m);
subplot(3,2,4);
plot2d3(m,e);
xlabel("Time");
ylabel("Amplitude");
title("Exponential signal");
h=0:0.1:2*3.14;
s=sin(h);
subplot(3,2,5);
plot2d3(h,s);
xlabel("Time");
ylabel("Amplitude");
title("Sine signal");
r=rand(m);
subplot(3,2,6);
plot2d3(m,r);
xlabel("Time");
ylabel("Amplitude");
title("Random signal");
EXPERIMENT NO. = 01
OUTPUT :
EXPERIMENT NO. = 02
AIM : Write a program to find out the DFT and magnitude
response and phase response of input sequence using Scilab.
CODE :
clc;
clear all;
x=input(“Enter the input sequence: ”);
N=length(x)
for k=0:N-1
temp=0;
for n=0:N-1
temp=temp+x(n+1)*exp(-%i*2*3.14*k*n/N);
end
z(k+1)=temp;
end
subplot(3,1,1);
plot2d3(x);
title('input sequence plot');
xlabel('amplitude');
ylabel('time');
subplot(3,1,2);
plot2d3(abs(z));
title('magnitude plot');
xlabel('amplitude');
ylabel('time');
subplot(3,1,3);
plot2d3(atan(imag(z),real(z)));
title('input');
xlabel('amplitude');
ylabel('time');
EXPERIMENT NO. = 02
OUTPUT :
EXPERIMENT NO. = 03
AIM : Write a program to perform circular convolution of two
given sequence.
CODE :
clc;
clear all;
x1=[1 2 3 4 5];
x2=[1 2 3];
N1=length(x1);
N2=length(x2);
N=N1-N2;
If (N>O) then
x2=[x2,zeros(1,N)];
else
xl=[x1,zeros(1,-N)];
end
X=fft(x1,-1);
Y=fft(x2,-1);
Z=X.*Y;
z=fft(Z,1);
subplot(3,2,1);
plot2d3(x1);
title('first input sequence');
xlabel('time');
ylabel('amplitude');
subplot(3,2,2);
plot2d3(x2);
title('second input sequence');
xlabel('time');
ylabel('amplitude');
subplot(3,2,3);
plot2d3(z);
title('output sequence');
EXPERIMENT NO. = 03
xlabel('time');
ylabel('amplitude');
OUTPUT :
EXPERIMENT NO. = 04
AIM : Write a program to design an analog Butterworth filter
having cut-off frequency equal to 500.
CODE :
clc;
clear all;
omep=input('enter the value of pass band freq: ');
omes=input('enter the value of stop band freq: ');
rp=input('enter the value of pass band ripple: ');
rs=input('enter the value of stop band ripple: ');
x=(1/(rp*rp))-1;
y=(1/(rs*rs))-1;
N=0.5*(log(y/x))/log(omes/omep);
N=ceil(N);
omec=500;
h=buttmag(N,omec, 1:1000);
plot2d(abs(h));
title("butterworth filter");
xlabel("discrete time axis");
ylabel("amplitude ");
EXPERIMENT NO. = 04
OUTPUT :
EXPERIMENT NO. = 05
AIM : Write a program to design type 1 and type 2 chebyshev
filter using Scilab.
CODE :
clc;
clear all;
N=input("enter the order of filter: ");
omec=input("enter the value of cut off frequency: ");
rp=input("enter the value of passband ripple: ");
rs=input("enter the value of stop band ripple: ");
b=cheb2mag(N,omec,rs, 0.001:0.05:10);
a=cheb1mag(N,omec,rp,0:0.05:10);
subplot(2,1,1);
plot2d(abs(a));
title('Type 1 chebyshev filter');
xlabel('frequency');
ylabel(' magnitude');
subplot(2,1,2);
plot2d(abs(b));
title('Type 2 chebyshev filter'};
xlabel('frequency');
ylabel('magnitude');
OUTPUT :
EXPERIMENT NO. = 05
EXPERIMENT NO. = 06
AIM : Write a program to design a FIR LPF using window
based technique.
CODE :
m=input('enter the length of the filter: ');
wc=input('enter the cut off freq: ');
n=0:1:m-1
t=(m-1)/2
h=sin(wc*(n-t)/(3.14)*(n-t))
w1=window('re',m)
w2=window('hn',m)
w3=window('hm',m)
w4=window('tr',m)
h1=h*w1
ha=frmag(h1,256)
h2=h*w2
hb=frmag(h2,256)
h3=h*w3
hc=frmag(h3,256)
h4=h*w4
hd=frmag(h4,256)
subplot(2,2,1)
plot2d(abs(ha))
xlabel('frequency');
ylabel('magnitude');
subplot(2,2,2)
plot2d(abs(hb))
xlabel('frequency');
ylabel('magnitude');
subplot(2,2,3)
plot2d(abs(hc))
xlabel('frequency');
ylabel('magnitude');
EXPERIMENT NO. = 06
subplot(2,2,4)
plot2d(abs(hd))
xlabel('frequency');
ylabel('magnitude');
OUTPUT :
EXPERIMENT NO. = 07
AIM : Write a program to design a upsampling and
downsampling based program.
CODE :
clc;
clear all;
N=input('enter the length of sequence: ');
L=input('enter the upsampling factor: ');
M=input('enter the downsampling factor: ');
fi=input('signal frequency');
pi=3.14;
n=0:1:N-1;
x=sin(2*pi*fi*n);
y=zeros(1,L*length(x));
y([1:L:N*L])=x;
y1=x([1:M:N]);
subplot(2,2,1);
plot2d3(n,abs(x));
subplot(2,2,2);
n1=0:N*L-1;
plot2d3(n1,abs(y));
subplot(2,2,3);
n2=0:M:N-1;
plot2d3(n2,abs(y1));
OUTPUT :
EXPERIMENT NO. = 07
EXPERIMENT NO. = 08
AIM : Write a program to perform autocorrelation and
cross-correlation of given sequences.
CODE :
clc;
clear;
x=[5 3 6 4];
h=[2 6 5 3];
y=xcorr(x,x);
y1=xcorr(x,h);
subplot(2,2,1);
plot2d3(x);
title('First signal');
subplot(2,2,2);
plot2d3(h);
title('Second signal');
subplot(2,2,3);
plot2d3(y);
title('Autocorrelation');
subplot(2,2,4);
plot2d3(y1);
title('Cross-correlation');
OUTPUT :
EXPERIMENT NO. = 08