Digital Signal Processing-1703074

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 12

DIGITAL SIGNAL PROCESSING

( SCILAB PRACTICALS )

Name – Sourabh
Roll no – 1703074
Course – Bsc(H)Electronics

Bhaskaracharya College of Applied Sciences

SUBMITTED TO – SHANI SIR


INDEX
1. Generation of unit sample sequences , unit step , ramp function.

2. Generate and plot sequences over an interval.

3. Given x[n] ,write program to find X[z].

4. Inverse Z-transformation.

5. Plotting the zeros and ploes.

6. Find Circular Convolution.

7. Find FFT and inverse FFT.

8. Design the IIR filter using bilinear transformation.


1. Generation of unit sample sequences , unit step , ramp function.

CODES

clc;
clf;
subplot(2,1,1);
for i=-100:1:100
if i<0
then
n=0;
plot2d3(i,n,5)
else
n=1;
plot2d3(i,n,5) //plotting of unit step signal
end
end
xtitle("unit step sifgnal","x-axis","y-axis");
subplot(2,1,2)
for j=-100:1:100
if j<0
then
n=0;
plot2d3(j,n,5)
else
n=j;
plot2d3(j,n,5); //plotting of ranp signal
end
end
xtitle("ramp signal","x-axis","y-axis");
OUTPUT
2. Generate and plot sequences over an interval.

CODES

clc;
clf;
n=20;
x=-5*%pi:0.1:5*%pi;
k=0;
for i=2:2:n
y=(4/(%pi*i))*sin(i*x);
k=k+y;
end
plot(x,k);
xtitle("triangular wave","x-axis","k");

OUTPUT
3. Given x[n] ,write program to find X[z].

CODES

clc;
if n<0 then
un=0;
else
un=1;
end
k=0;
for i=0:10
n=i;
xn=((0.5)^n)*un;
X=xn*(%z)^(-i);
k=k+X;
end
disp(k)

OUTPUT

--> if n<0 then


--> un=0;
--> else
--> un=1;
--> end
--> k=0;
--> for i=0:10
--> n=i;
--> xn=((0.5)^n)*un;
--> X=xn*(%z)^(-i);
--> k=k+X;
--> end
--> disp(k)

2 3 4 5
0.0009766 + 0.0019531z + 0.0039062z + 0.0078125z +
0.015625z + 0.03125z
6 7 8 9 10
+ 0.0625z + 0.125z + 0.25z + 0.5z + z
------------------------------------------------------------------------
10
z
4. Inverse Z-transformation.

CODES

clc;
z=%z;
n=z;
d=z-0.5;
k=ldiv(n,d,5)
disp(k)

OUTPUT

-> z=%z;
--> n=z;
--> d=z-0.5;
--> k=ldiv(n,d,5)
k =
1.
0.5
0.25
0.125
0.0625
--> disp(k)
1.
0.5
0.25
0.125
0.0625
5. Plotting the zeros and ploes.

CODES

clc;
z=poly(0,'z');
n=1-0.5*(z^(-1));
d=1-0.25*(z^(-2));
h=syslin('c',n./d);
plzr(h);
xtitle("polezero","real axis","imaginary ")

OUTPUT
6. Find Circular Convolution.

CODES

clc;
l=4;
n=4;
x1=[2,1,2,1];
x2=[1,2,3,4];
x1=fft(x1,-1);
x2=fft(x2,-1);
x3=x1.*x2;
x3=abs(fft(x3,1));
disp(x3,'x3=');

OUTPUT

--> l=4;
--> n=4;
--> x1=[2,1,2,1];
--> x2=[1,2,3,4];
--> x1=fft(x1,-1);
--> x2=fft(x2,-1);
--> x3=x1.*x2;
--> x3=abs(fft(x3,1));
--> disp(x3,'x3=');
x3=
14. 16. 14. 16.
7. Find FFT and inverse FFT.

CODES

clc;
x=[1,2,3,4];
k=fft(x,-1);
h=abs(fft(k,1));
disp(k);
disp(h);

OUTPUT

--> x=[1,2,3,4];
--> k=fft(x,-1);
--> h=abs(fft(k,1));
--> disp(k);
10. -2. + 2.i -2. -2. - 2.i
--> disp(h);
1. 2. 3. 4.
8. Design the IIR filter using bilinear transformation.

//H(s)=2/(s+1)(s+2)

CODES

clc;
s=%s;
z=%z;
T=0.1;
H=2/((s+1)*(s+2));
Hz=horner(H,(2/T)*(z-1)/(z+1));
disp(Hz);

OUTPUT

--> s=%s;
--> z=%z;
--> T=0.1;
--> H=2/((s+1)*(s+2));
--> Hz=horner(H,(2/T)*(z-1)/(z+1));
--> disp(Hz);
2
2 + 4z + 2z
------------------
2
342 - 796z + 462z

You might also like