Professional Documents
Culture Documents
Department of Electronics & Communication Engineering Lab Manual Digital Signal Processing Using Matlab B-Tech - 6th Semester
Department of Electronics & Communication Engineering Lab Manual Digital Signal Processing Using Matlab B-Tech - 6th Semester
Department of Electronics & Communication Engineering Lab Manual Digital Signal Processing Using Matlab B-Tech - 6th Semester
ECP - 3 !
Ta9le of Contents
C3AND/;A93 UN/<E9S/T= Experi%ent No ! Experi%ent No 2 Experi%ent No 3 Experi%ent No Experi%ent No 1 Experi%ent No 6 Experi%ent No 5 Experi%ent No 7 Experi%ent No 8 Experi%ent No !: 2 2 8 !! !2 !3 !!1 !5 !7 2!
E8periment No7 ,
Aim% To st"#$ i%portant co%%an#s o& MATLAB so&t'are Soft:are Use'% MATLAB ! /ntro#"ction : MATLAB is a .ig.-per&or%ance lang"age &or tec.nical co%p"ting /t integrates co%p"tation+ (is"ali4ation+ an# progra%%ing in an eas$-to-"se en(iron%ent '.ere pro0le%s an# sol"tions are expresse# in &a%iliar %at.e%atical notation T$pical "ses incl"#e Mat. an# co%p"tation+ Algorit.% #e(elop%ent+ Data ac,"isition+ Mo#eling+ si%"lation+ an# protot$ping+ Data anal$sis+ exploration+ an# (is"ali4ation+ Scienti&ic an# engineering grap.ics+ Application #e(elop%ent+ incl"#ing grap.ical "ser inter&ace 0"il#ing MATLAB is an interacti(e s$ste% '.ose 0asic #ata ele%ent is an arra) t.at #oes not re,"ire #i%ensioning T.is allo's $o" to sol(e %an$ tec.nical co%p"ting pro0le%s+ especiall$ t.ose 'it. %atrix an# (ector &or%"lations+ in a &raction o& t.e ti%e it 'o"l# ta>e to 'rite a progra% in a scalar non interacti(e lang"age s"c. as C or 6ortran T.e na%e MATLAB stan#s &or matri8 la9orator) Starting MATLAB on ?in#o's plat&or%s+ start MATLAB 0$ #o"0le-clic>ing t.e MATLAB s.ortc"t icon on $o"r ?in#o's #es>top @"itting MATLAB: To en# $o"r MATLAB session+ select 6ile A Exit MATLAB in t.e #es>top+ or t$pe ,"it in t.e Co%%an# ?in#o' =o" can r"n a script &ile na%e# &inis. % eac. ti%e MATLAB ,"its t.at+ &or exa%ple+ exec"tes &"nctions to sa(e t.e 'or>space 2 MATLAB #es>top: Bn starting MATLAB t.e MATLAB #es>top appears+ containing tools )grap.ical "ser inter&aces * &or %anaging &iles + (aria0les an# applications associate# 'it. MATLAB /t contains : )i* Co%%an# ?in#o' an# Co%%an# 3istor$ Co%%an# ?in#o' : Use t.e Co%%an# ?in#o' to enter (aria0les an# to r"n &"nctions an# M-&ile scripts Press t.e "p arro' >e$ to recall a state%ent pre(io"sl$ t$pe# E#it t.e state%ent as nee#e# an# t.en press Enter to r"n it
37 8la9el+ )la9el+ =la9el $La9el 8-+ )-+ an' =-a8is& % Eac. axes grap.ics o0Eect can .a(e one la0el &or t.e x-+ $-+ an# 4-axis T.e la0el appears 0eneat. its respecti(e axis in a t'o-#i%ensional plot an# to t.e si#e or 0eneat. t.e axis in a t.ree#i%ensional plot 8la9el$>string>& la0els t.e x-axis o& t.e c"rrent axes )la9el$777& an' =la9el$777& la0el t.e $-axis an# 4-axis+ respecti(el$+ o& t.e c"rrent axes -7 title$ A## title to c"rrent axes* : Eac. axes grap.ics o0Eect can .a(e one title T.e title is locate# at t.e top an# in t.e center o& t.e axes
E8periment No7
Aim% To #e(elop ele%entar$ signal &"nction %o#"les )%-&iles* &or "nit sa%ple+ "nit step+ exponential an# "nit ra%p se,"ences Soft:are Use'% MATLAB Program%
% program for generation of unit sample clc;clear all;close all; t = -3:1:3; y = [zeros(1,3),ones(1,1),zeros(1,3)]; subplot( , ,1);stem(t,y); ylabel(!"mplitu#e------$!); %label(!(a)n ------$!); title(!&nit 'mpulse (ignal!); % program for genration of unit step of se)uence [u(n)- u(n)-*] t = -+:1:+; y1 = ones(1,,); subplot( , , );stem(t,y1); ylabel(!"mplitu#e------$!); %label(!(b)n ------$!); title(!&nit step!); % program for generation of ramp signal n1 = input(!-nter t.e /alue for en# of t.e se)euence !); %n1 = 0any /alue$1 % % = 2:n1; subplot( , ,3);stem(%,%); ylabel(!"mplitu#e------$!); %label(!(c)n ------$!); title(!3amp se)uence!); % program for generation of e%ponential signal n = input(!-nter t.e lengt. of e%ponential se)euence !); %n = 0any /alue$1 % t = 2:n ; a = input(!-nter t.e "mplitu#e!); %a=1% y = e%p(a4t); subplot( , ,+);stem(t,y ); ylabel(!"mplitu#e------$!); %label(!(#)n ------$!); title(!-%ponential se)uence!); #isp(!&nit impulse signal!);y #isp(!&nit step signal!);y1 #isp(!&nit 3amp signal!);%
#isp(!-%ponential signal!);%
5utput % Enter t.e (al"e &or en# o& t.e se,e"ence 6 Enter t.e lengt. o& exponential se,e"ence Enter t.e A%plit"#e! Unit i%p"lse signal $ H : : : ! : : : Unit step signal $! H ! ! ! ! ! ! ! ! ! Unit 9a%p signal x H : ! 2 3 - 1 6 Exponential signal x H : ! 2 3 - 1 6 *rap"%
Unit Impulse Signal 1 Amplitude------> Amplitude------> 1 Unit step
0.5
0.5
0 -4
-2
0 -4
-2
60
40
20
2 (d)n ------>
!:
E8periment No7 3
Aim% To #e(elop progra% &or #iscrete con(ol"tion an# correlation Soft:are Use'% MATLAB Program%
% program for #iscrete con/olution % of %= [1 ] an# . = [1 +] clc;clear all;close all; % = input(!-nter t.e 1st se)uence : !); %[1 ] . = input(!-nter t.e n# se)uence : !); %[1 +] y =con/(%,.); subplot( ,3,1);stem(%); ylabel(!(%) ------$!); %label(!(a)n ------$!); subplot( ,3, );stem(.); ylabel(!(.) ------$!); %label(!(b)n ------$!); title(!5iscrete 6on/olution!); subplot( ,3,3);stem(y); ylabel(!(y) ------$!); %label(!(c)n ------$!); #isp(! 7.e resultant (ignal is :!);y % program for #iscrete correlation % of . =[+ 3 1] %1 = input(!-nter t.e 1st se)uence : !); %[1 3 +] .1 = input(!-nter t.e n# se)uence : !); %[+ 3 1] y1 =%corr(%1,.1); subplot( ,3,+);stem(%1); ylabel(!(%1) ------$!); %label(!(#)n ------$!); subplot( ,3,8);stem(.1); ylabel(!(.1) ------$!); %label(!(e)n ------$!); title(!5iscrete 6orrelation!); subplot( ,3,9);stem(y1); ylabel(!(y1) ------$!); %label(!(f)n ------$!); #isp(! 7.e resultant (ignal is :!);y1
!!
8 6 4 2 0
2 (c)n ------>
30
20
10
2 (d)n ------>
2 (e)n ------>
5 (f)n ------>
10
E8periment No7 -
!2
*rap"%
I m p l s e R e s p o n s eo fL T Is y s t e m h ( n )> 1 0 . 5 0 0 . 5 1 2 0
2 0
4 0 6 0 n >
8 0
1 0 0
1 2 0
E8periment No7 ?
!3
5utput % a H ! :::: -: 8::: -: 7!:: 9 H : 21:: : 1::: : 21:: p H : 8::: : 8::: -: 8::: C H KL #elta H ! nH xH : : ! : 2 : 3 : : 1 : 6 : 5 ! 8673 ! 55!1 2 !217 ! 8!32 : 528:
! ::::
: 8:::
! 62::
! -17:
E8periment No7 !
Aim% To 'e(elop program for fin'ing t"e magnitu'e an' p"ase response of LT1 s)stem 'escri9e' 9) t"e s)stem function "$=&7 Soft:are Use'% MATLAB
!-
*rap"%
M a g n itu d eR e sp o n se 1 5 |h |------>
1 0
0 0 P h a se in p iR a d ia n s
0 .1
0 .2
0 .3
0 .4 0 .5 0 .6 F re q u e n cy in p iu n its P h a se R e sp o n se
0 .7
0 .8
0 .9
0 -0 .1 -0 .2 -0 .3 -0 .4 0
0 .1
0 .2
0 .3
0 .4 0 .5 0 .6 F re q u e n cy in p iu n its
0 .7
0 .8
0 .9
E8periment No7 /
Aim% To 'e(elop program for computing 'iscrete 6ourier Transform $D6T& an' in(erse 'iscrete 6ourier Transform $1D6T&7 Soft:are Use'% MATLAB Program% D6T :
!1
%prog for computing #iscrete Courier 7ransform clc;clear all;close all; % =input(!-nter t.e se)uence !); %% =[2 1 n = input(!-nter t.e lengt. of Courier 7ransform same as %t.e lengt. of se)uence % =fft(%,n); stem(%); ylabel(!imaginary a%is------$!); %label(!(real a%is------$!); title(!-%ponential se)uence!); #isp(!5C7 is!);% '5C7 :
% prog for in/erse #iscrete Courier 7ransform ('5C7) clc;clear all;close all; % =input(!-nter lengt. of 5C7 !); % for best results in poAer of t = 2:pi>%:pi; num =[2<28 2<233 2<22F]; #en =[2<29 + 1]; trans = tf(num,#en); [fre),A] =fre)z(num,#en,%); gri# on; subplot( ,1,1);plot(abs(fre)),!G!); #isp(abs(fre))); ylabel(!Dagnitu#e!); %label(!Cre)uency in#e%!); title(!Dagnitu#e 3esponse!);
5utput % D6T : Enter t.e se,"ence K: ! 2 3 - 1 6 5L Enter t.e lengt. o& 6o"rier Trans&or% 7 nH 7 D6T is x H 27 :::: -- ::::
'5C7 :
!6
4 5 R ea la xis------>
/D6T
M a g n i t u d e M a g n i t u d e R e s p o n s e 0 . 0 2 0 . 0 1 5
0 . 0 1
0 . 0 0 5 1
1 . 5
2 . 5 F r e q u e n c yi n d e x
3 . 5
E8periment No7 C
Aim% To 'e(elop program for computing circular con(olution7 Soft:are Use'% MATLAB Program%
%prog for computing circular con/olution of se)uence % g =[1 -3 + 2 - ] an# . =[3 2 1 -1 1]
!5
clc;clear all;close all; g =[1 -3 + 2 - ]; . =[3 2 1 -1 1]; for i = 1:9, y(i) =2; for G = 1:9, z =mo#(9-G;i,9);1; y(i)=y(i);g(z)4.(G); en# en# #isp(!7.e resultant (ignal is stem(y); ylabel(!"mplitu#e------$!); %label(!n------$!); title(!6ircular 6on/olution!);
!);y
-3
!5
-2
5 -!3
C i r c u la rC o n v o lu t io n
1 5 A m p l it u d e >
1 0
1 0
1 5 1
1 .5
2 . 5
3 .5 n >
4 .5
5 . 5
E8periment No7 D
Aim% To 'e(elop program for 'esigning 612 filter7 Soft:are Use'% MATLAB Program%
%prog for #esigning of C'3 loA pass % filters using rectangular Ain#oA clc;clear all;close all;
!7
rp =input(!-nter t.e pass ban# ripple !); rs =input(!-nter t.e stop ban# ripple !); fp =input(!-nter t.e pass ban# fre) !); fs =input(!-nter t.e stop ban# fre) !); f =input(!-nter t.e sampling fre) !); Ap = 4fp>f; As = 4fs>f; num = - 24log12(s)rt(rp4rs))-13; #em = 1+<94(fs-fp)>f; n = ceil(num>#em); n1 = n;1; if (rem(n, )H=2) n1 =n; n = n-1; en# y = bo%car(n1); % loA pass filter b = fir1(n,Ap,y); [.,o] = fre)z(b,1, 89); m = 24log(abs(.)); subplot( , ,1);plot(o>pi,m); ylabel(!Iain in #J ------$!); %label(!(a) *ormalise# fre) ----$!);
5utput % Enter t.e pass 0an# ripple : :1 Enter t.e stop 0an# ripple : :Enter t.e pass 0an# &re, !1:: Enter t.e stop 0an# &re, 2::: Enter t.e sa%pling &re, 8::: *rap"%
!8
-100
-200 0
2:
E8periment No7 ,.
Aim% To 'e(elop program for for 'esigning 112 filter7 Soft:are Use'% MATLAB Program%
%prog for #esigning of ''3 loA pass % filters using rectangular Ain#oA clc;clear all;close all; rp =input(!-nter t.e pass ban# ripple !); rs =input(!-nter t.e stop ban# ripple !); Ap =input(!-nter t.e pass ban# fre) !); As =input(!-nter t.e stop ban# fre) !); fs =input(!-nter t.e sampling fre) !); A1 = 4Ap>fs; A = 4As>fs; [n,An] = buttor#(A1,A ,rp,rs); [b,a] = butter(n,An); A =2:2<21:pi; [.,om] = fre)z(b,a,A); m = 24log(abs(.)); an = angle(.); subplot( , ,1);plot(om>pi,m); ylabel(!Iain in #J ------$!); %label(!(a) *ormalise# fre) ----$!); title(!:oA Eass Cilter!); subplot( ,1, );plot(om>pi,an); ylabel(!E.ase in 3a#ians ------$!); %label(!(b) *ormalise# fre) ----$!);
5utput % Enter t.e pass 0an# ripple : 1 Enter t.e stop 0an# ripple 1: Enter t.e pass 0an# &re, !2:: Enter t.e stop 0an# &re, 2-::
2!
-500
-1000
4 2 0 -2 -4
0.1
0.2
0.3
0.8
0.9
22