You are on page 1of 22

DIGITAL SIGNAL PROCESSING PRACTICAL 2

PROBLEM 1:- Write a program for the generation of unit impulse signal.

PROGRAM:

t= -2:1:2;
y=[zeros(1,2), ones(1,1),zeros(1,2)];
stem(t,y);
xlabel('(a)-->');
ylabel('Amplitude -->');
title('Unit Impulse signal);

OUTPUT:

Unit Impulse signal


1

0.9

0.8

0.7

0.6
Amplitude -->

0.5

0.4

0.3

0.2

0.1

0
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
(a)-->

LALITHA.V ROLL NO:15 VIII SEM BIOMEDICAL & INSTRUMENTATION


DIGITAL SIGNAL PROCESSING PRACTICAL 2

PROBLEM 2: Write a program for the generation of unit step signal.

PROGRAM:-

n= input(' enter the value of N=');


t= 0:1:n-1;
y1= ones(1,n);
stem(t,y1);
xlabel('tine -->');
ylabel('Amplitude -->');
title('Unit Step Signal');

OUTPUT:

Enter the value of N=5

Unit Step Signal


1

0.9

0.8

0.7

0.6
Amplitude -->

0.5

0.4

0.3

0.2

0.1

0
0 0.5 1 1.5 2 2.5 3 3.5 4
tine -->

LALITHA.V ROLL NO:15 VIII SEM BIOMEDICAL & INSTRUMENTATION


DIGITAL SIGNAL PROCESSING PRACTICAL 2

PROBLEM 3:- Write a program for the generation of unit ramp signal:

PROGRAM:

n= input('enter the length of ramp sequence:');


t= 0:n;
stem(t,t);
xlabel('time -->');
ylabel('Amplitude -->');
title('Unit ramp Signal');

OUTPUT:

Enter the length of ramp sequence: 7

Unit ramp Signal


7

5
Amplitude -->

0
0 1 2 3 4 5 6 7
time -->

LALITHA.V ROLL NO:15 VIII SEM BIOMEDICAL & INSTRUMENTATION


DIGITAL SIGNAL PROCESSING PRACTICAL 2

PROBLEM 4: Write a program for the generation of exponential sequence.

PROGRAM:

n= input(' Enter the length of exponential sequence:');


t= 0:n;
a=input('Enter the value of a=');
y= exp(a*t);
stem(t,y);
xlabel('Time -->');
ylabel('Amplitude -->');
title('Exponential sequence');

OUTPUT:

Enter the length of exponential sequence:7

Enter the value of a=1

Exponential sequence
1200

1000

800
Amplitude -->

600

400

200

0
0 1 2 3 4 5 6 7
Time -->

LALITHA.V ROLL NO:15 VIII SEM BIOMEDICAL & INSTRUMENTATION


DIGITAL SIGNAL PROCESSING PRACTICAL 2

PROBLEM 5: Write a program for the generation of sine sequence.

PROGRAM:

t= 0:0.01:pi;
y= sin(2*pi*t);
plot(t,y);
ylabel('Amplitude -->');
xlabel('Time -->');
title(' Sine Sequence');

OUTPUT:

Sine Sequence
1

0.8

0.6

0.4

0.2
Amplitude -->

-0.2

-0.4

-0.6

-0.8

-1
0 0.5 1 1.5 2 2.5 3 3.5
Time -->

LALITHA.V ROLL NO:15 VIII SEM BIOMEDICAL & INSTRUMENTATION


DIGITAL SIGNAL PROCESSING PRACTICAL 2

PROBLEM 6: Write a program for the generation of cosine sequence.

PROGRAM:

t= 0:0.01:pi;
y= cos(2*pi*t);
plot(t,y);
xlabel('Time -->');
ylabel('Amplitude -->');
title('Cosine Sequence');

OUTPUT:

Cosine Sequence
1

0.8

0.6

0.4

0.2
Amplitude -->

-0.2

-0.4

-0.6

-0.8

-1
0 0.5 1 1.5 2 2.5 3 3.5
Time -->

LALITHA.V ROLL NO:15 VIII SEM BIOMEDICAL & INSTRUMENTATION


DIGITAL SIGNAL PROCESSING PRACTICAL 2

Problem:1:- Write a program for the generation of unit step function.

Program:

disp('PROGRAM FOR UNIT STEP FUNCTION');


n0=input('enter the value of n0=');
n1=input('enter the value of n1=');
n2=input('enter the value of n2=');
n=[n1:n2];
x=[(n-n0)>=0];
n=[n1:n2];
stem(n,x);
grid on;
title('Unit Step Function');

OUTPUT:

Enter the value of n0=1


Enter the value of n1=1
Enter the value of n2=10

Unit Step Function


1

0.9

0.8

0.7

0.6
Amplitude-->

0.5

0.4

0.3

0.2

0.1

0
1 2 3 4 5 6 7 8 9 10
(a)-->

LALITHA.V ROLL NO 15 VIII SEM BIO-MEDICAL & INSTRUMENTATION


DIGITAL SIGNAL PROCESSING PRACTICAL 2

PROBLEM:2:- Write a program for the generation of shifted impulse sequence


Y=-5*x*(n-4)+ 6*x*(n-6)

PROGRAM:

disp('PROGRAM FOR UNIT IMPULSE FUNCTION');


n1=input('give the value of n1=');
n2=input('give the value of n2=');
n0=input('give the value of n0=');
n=[n1:n2];
x=[(n-n0)==0];
x1=5*x;
subplot(2,2,1);
n=[n1:n2];
stem(n,x1);
title('impulse shifted by 4 units');
n0=input('give the value of n0=');
n=[n1:n2];
x=[(n-n0)==0];
x2=6*x;
subplot(2,2,2);
n=n1:n2;
stem(n,x2);
title('impulse shifted by 6 units');
grid on;
y=x1+x2;
subplot(2,2,3);
stem(n,y);
grid on;
title('summation of the above shifted sequence');

LALITHA.V ROLL NO 15 VIII SEM BIO-MEDICAL & INSTRUMENTATION


DIGITAL SIGNAL PROCESSING PRACTICAL 2

OUTPUT:

Give the value of n1=1


Give the value of n2=10
Give the value of n0=4
Give the value of n0=6

impulse shifted by 4 units impulse shifted by 6 units


6 6

4 4

2 2

0 0
0 5 10 0 5 10

summation of the above shifted sequence


6

0
0 5 10

LALITHA.V ROLL NO 15 VIII SEM BIO-MEDICAL & INSTRUMENTATION


DIGITAL SIGNAL PROCESSING PRACTICAL 2

PROBLEM:3 Write a program for the generation of following output.


Y= 3*cos(x)+ 4*sin(x)

PROGRAM:

disp('program for adding two sequence');


x=0:0.4:10;
subplot(2,2,1);
y1= 3*sin(x);
stem(x,y1,’-r’);
title('plot the sin function');
subplot(2,2,2);
y2=4*cos(x);
stem(x,y2,’-g’);
title('plot as cos function');
y=y1+y2;
subplot(2,2,3);
stem(x,y,’-b’);
title('summation of the above two plot');

OUTPUT:

Program for adding two sequence.


plot the sin function plot as cos function
4 4

2 2

0 0

-2 -2

-4 -4
0 5 10 0 5 10

summation of the above two plot


5

-5
0 5 10

LALITHA.V ROLL NO 15 VIII SEM BIO-MEDICAL & INSTRUMENTATION


DIGITAL SIGNAL PROCESSING PRACTICAL 4

PROBLEM:1:- Write a program to check the stability of the following transfer function:

H(z)= z^4+ 16*z^3+ 44*z^2+ 56*z+32


----------------------------------------
3* z^4+ 3*z^3- 15*z^2+ 18*z-12

PROGRAM:

b= input('give the numerator coefficients:');


a= input('give the denominator coefficients:');
ts=1;
g= tf(b,a,ts);
y= zpk(g);
[z,p,k]= tf2zp(b,a);
zplane(z,p);

OUTPUT:

Enter the numerator coefficients: [1, 16, 44, 56, 32]


Enter the denominator coefficients: [3, 3, -15, 18, -12]

2
Imaginary Part

-2

-4

-6

-16 -14 -12 -10 -8 -6 -4 -2 0 2


Real Part

LALITHA.V ROLL NO:15 VIII SEM BIOMEDICAL & INSTRUMENTATION


DIGITAL SIGNAL PROCESSING PRACTICAL 4

PROBLEM:2:- Find the transfer function of the following:

Z= { 21, 3.14, (-3+0.5i), (-3-0.5i)}


P={-0.45, -0.67, (0.81+0.72i),( 0.81-0.72i)}
K= 2.2
PROGRAM:

z= [0.21, 3.14,-0.3,0.5i,-0.3-0.5i];
p= [-0.45,0.67,0.81+0.72i,0.81-1.72i];
k=[2.2];
ts=1;
[num,den]=zp2tf(z',p',k);
g=tf(num,den,ts);
y=zpk(g);

OUTPUT:
g

Transfer function:
2.2 z^5 - 6.05 z^4 - 2.223 z^3 - 1.47 z^2 - 0.05952 z + 0.1088
--------------------------------------------------------------
z^4 - 1.84 z^3 + 1.949 z^2 + 0.07164 z - 0.5712

Sampling time: 1
y

Zero/pole/gain:
2.2 (z-3.14) (z+0.3) (z-0.21) (z^2 + 0.3z + 0.25)
--------------------------------------------------
(z-0.67) (z+0.45) (z^2 - 1.62z + 1.894)

Sampling time: 1

LALITHA.V ROLL NO:15 VIII SEM BIOMEDICAL & INSTRUMENTATION


DIGITAL SIGNAL PROCESSING PRACTICAL 4

PROBLEM:3:- Write a program for finding the residues of the following transfer
Functions:

(i) Numerator= {18,0,0,0}


Denominator= {18,3,-4,-1}
(ii) Numerator= {1,0.2, 0}
Denominator= {1, 0.4,-0.12}
(iii) Numerator= {1,0,0}
Denominator={1,-1,0.5}

PROGRAM:

b= input ('the coefficients of numerator are:');


a= input ('the coefficients of denominator are:');
ts=1;
g= tf(b,a,ts);
y= zpk(g);
[z,p,k]=tf2zp(b,a);
[r,p,k1]=residuez(b,a);
[b1,a1]=residuez(r,p,k1);
g1= tf(b1,a1,ts);

OUTPUT:

(i) the coefficients of numerator are:[18, 0, 0, 0,]


the coefficients of denominator are:[18, 3, -4, -1]
g

Transfer function:
18 z^3
------------------------
18 z^3 + 3 z^2 - 4 z - 1

Sampling time: 1
y

Zero/pole/gain:
z^3
--------------------
(z-0.5) (z+0.3333)^2

Sampling time: 1
g1

Transfer function:

LALITHA.V ROLL NO:15 VIII SEM BIOMEDICAL & INSTRUMENTATION


DIGITAL SIGNAL PROCESSING PRACTICAL 4

z^3 - 2.776e-017 z^2 - 8.327e-017 z


-------------------------------------
z^3 + 0.1667 z^2 - 0.2222 z - 0.05556

Sampling time: 1

(ii) the coefficients of numerator are:[1, 0.2, 0]


the coefficients of denominator are:[1, 0.4, -0.12]

>> g

Transfer function:
z^2 + 0.2 z
------------------
z^2 + 0.4 z - 0.12

Sampling time: 1
>> y

Zero/pole/gain:
z (z+0.2)
---------------
(z+0.6) (z-0.2)

Sampling time: 1
>> g1

Transfer function:
z^2 + 0.2 z
------------------
z^2 + 0.4 z - 0.12

Sampling time: 1

(iii) the coefficients of numerator are:[1, 0, 0]


the coefficients of denominator are:[1, -1, 0.5]

>> g

Transfer function:
z^2
-------------
z^2 - z + 0.5

Sampling time: 1
>> y

LALITHA.V ROLL NO:15 VIII SEM BIOMEDICAL & INSTRUMENTATION


DIGITAL SIGNAL PROCESSING PRACTICAL 4

Zero/pole/gain:
z^2
----------------
(z^2 - z + 0.5)

Sampling time: 1

>> g1

Transfer function:
z^2 + 5.551e-017 z
------------------
z^2 - z + 0.5

Sampling time: 1

LALITHA.V ROLL NO:15 VIII SEM BIOMEDICAL & INSTRUMENTATION


DIGITAL SIGNAL PROCESSING PRACTICAL 5

PROBLEM:1:-

PROGRAM:

w=10:200;
t=0.02;
z=cos(w*t)+i*sin(w*t);
T=(((-4.*z)+4)./(z-0.6));
p=abs(T);
q= 20.*log(p);
semilogx(w,q);
grid on;
title('HENCE THE GIVEN TRANSFER FUNCTION IS OF A HIGH PASS FILTER');

OUTPUT:

HENCE THE GIVEN TRANSFER FUNCTION IS OF A HIGH PASS FILTER


35

30

25

20

15

10
1 2 3
10 10 10

LALITHA.V ROLL NO:15 VIII SEM BIOMEDICAL & INSTRUMENTATION


DIGITAL SIGNAL PROCESSING PRACTICAL 5

PROBLEM:2:- Plot the frequency response of following equation:

(i) y(n)= 0.7 *y(n-1)+ x(n)


t= 0.0126 seconds

PROGRAM:

w= 10:200;
t=0.0075;
z= cos(w*t)+i*sin(w*t);
T=((z)./(z-0.7));
p= abs(T);
q= 20.*log(p);
semilogx(w,q);
grid on;
title('hence the given filter is a low pass filter');

OUTPUT:

hence the given filter is a low pass filter


25

20

15

10

-5
1 2 3
10 10 10

LALITHA.V ROLL NO:15 VIII SEM BIOMEDICAL & INSTRUMENTATION


DIGITAL SIGNAL PROCESSING PRACTICAL 5

(ii) y(n+1)= 0.915 *y(n)+0.5*(x+1)


T= 0.0075 seconds.

PROGRAM:

w= 10:200;
t=0.0075;
z= cos(w*t)+i*sin(w*t);
T=((0.5.*z)./(z-0.915));
p= abs(T);
q= 20.*log(p);
semilogx(w,q);
grid on;
title('hence the given filter is a low pass filter');

OUTPUT:

hence the given filter is a low pass filter


40

30

20

10

-10

-20
1 2 3
10 10 10

LALITHA.V ROLL NO:15 VIII SEM BIOMEDICAL & INSTRUMENTATION


DIGITAL SIGNAL PROCESSING PRACTICAL 5

(iii) y(n+2)= 0.85*y(n+1)+ 5*x(n+1)+ x(n)


t=0.02 seconds

PROGRAM:

w= 10:200;
t= 0.02;
z= cos(w*t)+i*sin(w*t);
T=(((5.*z)+1))./((z.^2)-(0.85.*z));
p= abs(T);
q= 20.*log(p);
semilogx(w,q);
grid on;
title('HENCE THE GIVEN FILTER IS A LOW PASS FILTER');

OUTPUT:

HENCE THE GIVEN FILTER IS A LOW PASS FILTER


65

60

55

50

45

40

35

30

25

20

15
1 2 3
10 10 10

LALITHA.V ROLL NO:15 VIII SEM BIOMEDICAL & INSTRUMENTATION


DIGITAL SIGNAL PROCESSING PRACTICAL 5

PROBLEM:3:- Plot the frequency curve for the following transfer function and find

if it is a high pass or a low pass filter. Given that t= 0.01 seconds

1) 0.4414*(z+1)*(z+1)
------------------------
z^2-1.324*z+0.5006

PROGRAM:

w= 10:200;
t= 0.01;
z= cos(w*t)+i*sin(w*t);
T=(((0.04414.*z.^2)+(0.08828.*z)+0.04414)./((z.^2)+(1.324.*z)+0.5006));
p= abs(T);
q=20.*log(p);
semilogx(w,q);
grid on;
title('HENCE THE ABOVE FILTER IS A LOW PASS FILTER');

OUTPUT:

HENCE THE ABOVE FILTER IS A LOW PASS FILTER


-55.4

-55.45

-55.5

-55.55

-55.6

-55.65

-55.7
1 2 3
10 10 10

LALITHA.V ROLL NO:15 VIII SEM BIOMEDICAL & INSTRUMENTATION


DIGITAL SIGNAL PROCESSING PRACTICAL 5

2) 0.9191*z-0.9091
--------------------
z- 0.8182

PROGRAM:

w= 10:200;
t=0.01;
z= cos(w*t)+i*sin(w*t);
T= (((0.9191.*z)-(0.9091)./(z-0.8182)));
p= abs(T);
q= 20.*log(p);
semilogx(w,q);
grid on;
title('HENCE THE GIVEN FILTER IS A LOW PASS FILTER');

OUTPUT:

HENCE THE GIVEN FILTER IS A LOW PASS FILTER


30

25

20

15

10

0
1 2 3
10 10 10

LALITHA.V ROLL NO:15 VIII SEM BIOMEDICAL & INSTRUMENTATION


DIGITAL SIGNAL PROCESSING PRACTICAL 5

3) 0.6777*(z-1)
--------------
z-0.333

PROGRAM:

w= 10:200;
t=0.01;
z= cos(w*t)+i*sin(w*t);
T=(0.6777.*(z-1)./(z-0.333));
p= abs(T);
q= 20.*log(p);
semilogx(w,q);
grid on;
title('HENCE THE GIVEN FILTER IS A HIGH PASS FILTER');

OUTPUT:

HENCE THE GIVEN FILTER IS A HIGH PASS FILTER


0

-5

-10

-15

-20

-25

-30

-35

-40

-45

-50
1 2 3
10 10 10

LALITHA.V ROLL NO:15 VIII SEM BIOMEDICAL & INSTRUMENTATION

You might also like