Department of Electronics & Communication Engineering Lab Manual Digital Signal Processing Using Matlab B-Tech - 6th Semester

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 22

Department of Electronics & Communication Engineering LAB MANUAL Digital Signal Processing Using MATLAB

ECP - 3 !

B-Tec" # !t" Semester


$Branc"% ECE&

C"an'igar" Uni(ersit) *"aruan+ Mo"ali-,-.3./

C0AND1*A20 UN13E2S1T4 *0A2UAN+ M50AL1


DEPA2TMENT 56 ELECT25N1CS & C5MM7 EN** ECP-326: Digital Signal Processing Using MATLAB

ECP-3 !% Signal Processing Using MATLAB


7 List of E8periments Exp No !: To st"#$ i%portant co%%an#s o& MATLAB so&t'are Exp No 2: To #e(elop ele%entar$ signal &"nction %o#"les )%-&iles* &or "nit sa%ple+ "nit step+ exponential an# "nit ra%p se,"ences Exp No 3: To #e(elop progra% &or #iscrete con(ol"tion an# correlation Exp No -: To #e(elop progra% &or &in#ing response o& t.e LT/ s$ste% #escri0e# 0$ t.e #i&&erence e,"ation Exp No 1: To #e(elop progra% &or co%p"ting in(erse 2-trans&or% Exp No 6: To #e(elop progra% &or &in#ing %agnit"#e an# p.ase response o& LT/ s$ste% #escri0e# 0$ s$ste% &"nction 3)4* Exp No 5: To #e(elop progra% &or co%p"ting D6T an# /D6T Exp No 7: To #e(elop progra% &or co%p"ting circ"lar con(ol"tion Exp No 8: To #e(elop progra% &or #esigning 6/9 &ilter Exp No !:: To #e(elop progra% &or #esigning //9 &ilter

C0AND1*A20 UN13E2S1T4 *0A2UAN+ M50AL1


DEPA2TMENT 56 ELECT25N1CS & C5MM7 EN** ECP-326: Digital Signal Processing Using MATLAB

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!

C0AND1*A20 UN13E2S1T4 *0A2UAN+ M50AL1


DEPA2TMENT 56 ELECT25N1CS & C5MM7 EN** ECP-326: Digital Signal Processing Using MATLAB

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

C0AND1*A20 UN13E2S1T4 *0A2UAN+ M50AL1


DEPA2TMENT 56 ELECT25N1CS & C5MM7 EN** ECP-326: Digital Signal Processing Using MATLAB Co%%an# 3istor$ : State%ents entere# in t.e Co%%an# ?in#o' are logge# in t.e Co%%an# 3istor$ 6ro% t.e Co%%an# 3istor$+ pre(io"sl$ r"n state%ents can 0e (ie'e#+ copie# an# exec"te# M-&ile can 0e create# &ro% selecte# state%ents )ii* C"rrent Director$ Bro'ser an# Searc. Pat. : MATLAB &ile operations "se t.e c"rrent #irector$ an# t.e searc. pat. as re&erence points An$ &ile re,"ire# to r"n %"st eit.er 0e in t.e c"rrent #irector$ or on t.e searc. pat. )iii* ?or>space Bro'ser an# Arra$ E#itor :T.e MATLAB 'or>space consists o& t.e set o& (aria0les )na%e# arra$s* 0"ilt "p #"ring a MATLAB session an# store# in %e%or$ T.e (aria0les can 0e a##e# to t.e 'or>space 0$ "sing &"nctions+ r"nning M&iles+ an# loa#ing sa(e# 'or>spaces To #elete (aria0les &ro% t.e 'or>space+ select t.e (aria0les an# select E#it A Delete Arra$ E#itor : Do"0le-clic> a (aria0le in t.e ?or>space 0ro'ser+ or "se open (ar (aria0le na%e+ to see it in t.e Arra$ E#itor Use t.e Arra$ E#itor to (ie' an# e#it a (is"al representation o& (aria0les in t.e 'or>space )i(* E#itorCDe0"gger : E'itor;De9ugger is use' to create an' 'e9ug M-files+ :"ic" are programs to run MATLAB functions7 T.e E#itorCDe0"gger pro(i#es a grap.ical "ser inter&ace &or text e#iting+ as 'ell as &or M-&ile #e0"gging To create or e#it an M&ile "se 6ile A Ne' or 6ile A Bpen+ or "se t.e e#it &"nction T.e i%portant co%%an#sC &"nctions are as 0elo' : ,7 clc $2emo(e items from :or<space+ freeing up s)stem memor)& clears all inp"t an# o"tp"t &ro% t.e Co%%an# ?in#o' #ispla$+ gi(ing Dclean screen D A&ter "sing clc+ t.e scroll 0ar cannot 0e "se# to see t.e .istor$ o& &"nctions+ 0"t still t.e "p arro' can 0e "se# to recall state%ents &ro% t.e co%%an# .istor$ 7 close $2emo(e specifie' figure&: close #eletes t.e c"rrent &ig"re or t.e speci&ie# &ig"re)s* /t optionall$ ret"rns t.e stat"s o& t.e close operation

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

C0AND1*A20 UN13E2S1T4 *0A2UAN+ M50AL1


DEPA2TMENT 56 ELECT25N1CS & C5MM7 EN** ECP-326: Digital Signal Processing Using MATLAB title)FstringF* o"tp"ts t.e string at t.e top an# in t.e center o& t.e c"rrent axes ?7 figure )create &ig"re grap.ics o0Eect* : &ig"re creates &ig"re grap.ics o0Eects 6ig"re o0Eects are t.e in#i(i#"al 'in#o's on t.e screen in '.ic. MATLAB #ispla$s grap.ical o"tp"t !7 su9plot $Create a8es in tile' positions&% s"0plot #i(i#es t.e c"rrent &ig"re into rectang"lar panes t.at are n"%0ere# ro' 'ise Eac. pane contains an axes o0Eect S"0se,"ent plots are o"tp"t to t.e c"rrent pane " @ su9plot$m+n+p& or su9plot$mnp& 0rea>s t.e &ig"re 'in#o' into an %-0$-n %atrix o& s%all axes+ selects t.e pt. axes o0Eect &or t.e c"rrent plot+ an# ret"rns t.e axes .an#le T.e axes are co"nte# along t.e top ro' o& t.e &ig"re 'in#o'+ t.en t.e secon# ro'+ etc 6or exa%ple+ s"0plot)2+!+!*+ plot)inco%e* su9plot$ +,+ &+ plot$outgo& plots inco%e on t.e top .al& o& t.e 'in#o' an# o"tgo on t.e 0otto% .al& /7 stem $Plot 'iscrete seAuence 'ata& : A t'o-#i%ensional ste% plot #ispla$s #ata as lines exten#ing &ro% a 0aseline along t.e x-axis A circle )t.e #e&a"lt* or ot.er %ar>er '.ose $-position represents t.e #ata (al"e ter%inates eac. ste% stem$4& Plots t.e #ata se,"ence = as ste%s t.at exten# &ro% e,"all$ space# an# a"to%aticall$ generate# (al"es along t.e x-axis ?.en = is a %atrix+ ste% plots all ele%ents in a ro' against t.e sa%e x (al"e stem$B+4& plots G (ers"s t.e col"%ns o& = G an# = %"st 0e (ectors or %atrices o& t.e sa%e si4e A##itionall$+ G can 0e a ro' or a col"%n (ector an# = a %atrix 'it. lengt.)G* ro's C7 9ar$Plot 9ar grap" $(ertical an' "ori=ontal&& : A 0ar grap. #ispla$s t.e (al"es in a (ector or %atrix as .ori4ontal or (ertical 0ars 9ar$4& #ra's one 0ar &or eac. ele%ent in = /& = is a %atrix+ 0ar gro"ps t.e 0ars pro#"ce# 0$ t.e ele%ents in eac. ro' T.e x-axis scale ranges &ro% ! "p to lengt.)=* '.en = is a (ector+ an# ! to si4e)=+!*+ '.ic. is t.e n"%0er o& ro's+ '.en = is a %atrix 9ar") * an# . H 0ar.) * create .ori4ontal 0ars = #eter%ines t.e 0ar lengt. T.e (ector x is a (ector #e&ining t.e $-axis inter(als &or .ori4ontal 0ars D7 plot $ -D line plot& : plot$4& Plots t.e col"%ns o& = (ers"s t.eir in#ex i& = is a real n"%0er /& = is co%plex+ plot)=* is e,"i(alent to plot)real)=*+i%ag)=** /n all ot.er "ses o& plot+ t.e i%aginar$ co%ponent is ignore#

C0AND1*A20 UN13E2S1T4 *0A2UAN+ M50AL1


DEPA2TMENT 56 ELECT25N1CS & C5MM7 EN** ECP-326: Digital Signal Processing Using MATLAB plot$B,+4,+777& Plots all lines #e&ine# 0$ Gn (ers"s =n pairs /& onl$ Gn or =n is a %atrix+ t.e (ector is plotte# (ers"s t.e ro's or col"%ns o& t.e %atrix+ #epen#ing on '.et.er t.e (ectorFs ro' or col"%n #i%ension %atc.es t.e %atrix /& Gn is a scalar an# =n is a (ector+ #isconnecte# line o0Eects are create# an# plotte# as #iscrete points (erticall$ at Gn ,.7 input $2eAuest user input& : T.e response to t.e inp"t pro%pt can 0e an$ MATLAB expression+ '.ic. is e(al"ate# "sing t.e (aria0les in t.e c"rrent 'or>space userEentr) @ input$>prompt>& Displa$s pro%pt as a pro%pt on t.e screen+ 'aits &or inp"t &ro% t.e >e$0oar#+ an# ret"rns t.e (al"e entere# in "serIentr$ "serIentr$ H inp"t)Fpro%ptF+ FsF* ret"rns t.e entere# string as a text (aria0le rat.er t.an as a (aria0le na%e or n"%erical (al"e ,,7 =eros $Create arra) of all =eros& : B @ =eros$n& 9et"rns an n-0$-n %atrix o& 4eros An error %essage appears i& n is not a scalar , 7 ones $Create arra) of all ones& : 4 @ ones$n& 9ret"rns an n-0$-n %atrix o& !s An error %essage appears i& n is not a scalar ,37 e8p $E8ponential& % 4 @ e8p$B& T.e exp &"nction is an ele%entar$ &"nction t.at operates ele%ent'ise on arra$s /ts #o%ain incl"#es co%plex n"%0ers = H exp)G* ret"rns t.e exponential &or eac. ele%ent o& G ,-7 'isp $Displa) te8t or arra)& % 'isp$B& Displa$s an arra$+ 'it.o"t printing t.e arra$ na%e /& G contains a text string+ t.e string is #ispla$e# Anot.er 'a$ to #ispla$ an arra$ on t.e screen is to t$pe its na%e+ 0"t t.is prints a lea#ing DGH+D '.ic. is not al'a$s #esira0le Note t.at #isp #oes not #ispla$ e%pt$ arra$s ,?7 con( $Con(olution an' pol)nomial multiplication& % : @ con($u+(& con(ol(es (ectors " an# ( Alge0raicall$+ con(ol"tion is t.e sa%e operation as %"ltipl$ing t.e pol$no%ials '.ose coe&&icients are t.e ele%ents o& " an# (

C0AND1*A20 UN13E2S1T4 *0A2UAN+ M50AL1


DEPA2TMENT 56 ELECT25N1CS & C5MM7 EN** ECP-326: Digital Signal Processing Using MATLAB ,!7 8corr $Cross-correlation& % c H xcorr)x+$* ret"rns t.e cross-correlation se,"ence in a lengt. 2JN-! (ector+ '.ere x an# $ are lengt. N (ectors )NA!* /& x an# $ are not t.e sa%e lengt.+ t.e s.orter (ector is 4ero-pa##e# to t.e lengt. o& t.e longer (ector ,/7 filter $,-D 'igital filter& % ) @ filter$9+a+B& &ilters t.e #ata in (ector G 'it. t.e &ilter #escri0e# 0$ n"%erator coe&&icient (ector 0 an# #eno%inator coe&&icient (ector a /& a)!* is not e,"al to !+ &ilter nor%ali4es t.e &ilter coe&&icients 0$ a)!* /& a)!* e,"als :+ &ilter ret"rns an error ,C7 pol) $Pol)nomial :it" specifie' roots& % r @ roots$p& '.ic. ret"rns a col"%n (ector '.ose ele%ents are t.e roots o& t.e pol$no%ial speci&ie# 0$ t.e coe&&icients ro' (ector p 6or (ectors+ roots an# pol$ are in(erse &"nctions o& eac. ot.er+ "p to or#ering+ scaling+ an# ro"n# o&& error ,D7 tf$Con(ert unconstraine' MPC controller to linear transfer function& % s)s@tf$MPCo9F& T.e t& &"nction co%p"tes t.e trans&er &"nction o& t.e linear controller ss)MPCo0E* as an LT/ s$ste% in t& &or% correspon#ing to t.e MPC controller '.en t.e constraints are not acti(e T.e p"rpose is to "se t.e linear e,"i(alent control in Control S$ste% Tool0ox &or sensiti(it$ an# ot.er linear anal$sis .7 freA= $6reAuenc) response of filter & % G"+:H @ freA=$"a& ret"rns t.e &re,"enc$ response (ector . an# t.e correspon#ing &re,"enc$ (ector ' &or t.e a#apti(e &ilter .a ?.en .a is a (ector o& a#apti(e &ilters+ &re,4 ret"rns t.e %atrix . Eac. col"%n o& . correspon#s to one &ilter in t.e (ector ,7 a9s $A9solute (alue an' comple8 magnitu'e& % a9s$B& ret"rns an arra$ = s"c. t.at eac. ele%ent o& = is t.e a0sol"te (al"e o& t.e correspon#ing ele%ent o& G 7 fft $Discrete 6ourier transform& % 4 @ fft$B& = H &&t)G* ret"rns t.e #iscrete 6o"rier trans&or% )D6T* o& (ector G+ co%p"te# 'it. a &ast 6o"rier trans&or% )66T* algorit.%

C0AND1*A20 UN13E2S1T4 *0A2UAN+ M50AL1


DEPA2TMENT 56 ELECT25N1CS & C5MM7 EN** ECP-326: Digital Signal Processing Using MATLAB

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!);%

C0AND1*A20 UN13E2S1T4 *0A2UAN+ M50AL1


DEPA2TMENT 56 ELECT25N1CS & C5MM7 EN** ECP-326: Digital Signal Processing Using MATLAB

#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 2 (a)n ------> Ramp sequence

0 -4

0 2 (b)n ------> Exponential sequence

-2

6 Amplitude------> Amplitude------> 0 2 4 (c)n ------> 6

60

40

20

2 (d)n ------>

!:

C0AND1*A20 UN13E2S1T4 *0A2UAN+ M50AL1


DEPA2TMENT 56 ELECT25N1CS & C5MM7 EN** ECP-326: Digital Signal Processing Using MATLAB

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

!!

C0AND1*A20 UN13E2S1T4 *0A2UAN+ M50AL1


DEPA2TMENT 56 ELECT25N1CS & C5MM7 EN** ECP-326: Digital Signal Processing Using MATLAB 5utput % Con(ol"tion : Enter t.e !st se,"ence : K! 2L Enter t.e 2n# se,"ence : K! 2 -L T.e res"ltant Signal is : $ H ! - 7 7 Correlation : Enter t.e !st se,"ence : K! 2 3 -L Enter t.e 2n# se,"ence : K- 3 2 !L T.e res"ltant Signal is : $! H ! :::: - :::: !: :::: 2: :::: 21 :::: 2- :::: !6 :::: *rap"%
Discrete Convolution 4 3 (h) ------> 2 1 0 (y) ------> 1

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

8 6 4 2 0

1.5 (a)n ------>

4 (x1) ------> (h1) ------> 3 2 1 0

2 3 (b)n ------> Discrete Correlation 4 (y1) ------> 3 2 1 0

2 (c)n ------>

30

20

10

2 (d)n ------>

2 (e)n ------>

5 (f)n ------>

10

E8periment No7 -

!2

C0AND1*A20 UN13E2S1T4 *0A2UAN+ M50AL1


DEPA2TMENT 56 ELECT25N1CS & C5MM7 EN** ECP-326: Digital Signal Processing Using MATLAB Aim% To #e(elop progra% &or &in#ing t.e response o& t.e LT/ s$ste% 0$ #i&&erence e,"ation Soft:are Use'% MATLAB Program%
% prog for fin#ing t.e response of :7' system by #ifference e)uation % let y(n) -y(n-1) ;2<,y(n- )=%(n) plot impulse response .(n) at % n = 2,<<<122 b = [1]; a = [1,-1,2<,]; % coefficient arrays from t.e =n % = impse)(2,- 2,1 2); n = [- 2:1 2]; . = filter(b,a,%) subplot( ,1,1);stem(n,.); ylabel(!.(n) ------$!); %label(!n ------$!); title(!'mplse 3esponse of :7' system!);

function [%,n] = impse)(n2,n1,n ) n = [n1:n ]; % = [(n-n2)==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

C0AND1*A20 UN13E2S1T4 *0A2UAN+ M50AL1


DEPA2TMENT 56 ELECT25N1CS & C5MM7 EN** ECP-326: Digital Signal Processing Using MATLAB Aim% To 'e(elop program for computing in(erse I-transform Soft:are Use'% MATLAB Program%
%prog for computing t.e in/erse =-transform by using resi#uez function %let %(z) = 1>((1-2<,z-1)? (1;2<,z-1)) @z@$2<, b =1; a = poly([2<,,2<,,-2<,]) % #enominator of t.e polynomial calculate# by % poly function [3,p,6] =resi#uez(b,a) [#elta,n]= impse)(2,2,1) %call impse) % = filter(b,a,#elta)

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

!-

C0AND1*A20 UN13E2S1T4 *0A2UAN+ M50AL1


DEPA2TMENT 56 ELECT25N1CS & C5MM7 EN** ECP-326: Digital Signal Processing Using MATLAB Program%
%prog for fin#ing t.e magnitu#e an# p.ase response of :7' system by %.(n) =(2<,)?n4u(n) A =[2:1:822]4pi>822; %[2,pi] a%is #i/i#e# into 821 points . =e%p(B4A)<>(e%p(B4A)-2<,4ones(1,821)); mag. =abs(.); ang. =angle(.); subplot( ,1,1);plot(A>pi,mag.);gri#; ylabel(!@.@------$!); %label(!(Cre)uency in pi units!); title(!Dagnitu#e 3esponse!); subplot( ,1, );plot(A>pi,ang.>pi);gri#; ylabel(!E.ase in pi 3a#ians!); %label(!(Cre)uency in pi units!); title(!E.ase 3esponse!)

*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

C0AND1*A20 UN13E2S1T4 *0A2UAN+ M50AL1


DEPA2TMENT 56 ELECT25N1CS & C5MM7 EN** ECP-326: Digital Signal Processing Using MATLAB
3 + 8 9 1] !) %n =F .as to be

%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 :

-- :::: M 8 6168i -- :::: - ! 6168i

-- :::: M - ::::i -- :::: - - ::::i

-- :::: M ! 6168i -- :::: - 8 6168i

Enter lengt. o& D6T - H : :!7: : :!66 : :!3: : ::83

!6

C0AND1*A20 UN13E2S1T4 *0A2UAN+ M50AL1


DEPA2TMENT 56 ELECT25N1CS & C5MM7 EN** ECP-326: Digital Signal Processing Using MATLAB *rap"% D6T :
D iscrete Fo u rier T ran sfo rm 10 8 6 Im a g in a ry a xis------> 4 2 0 -2 -4 -6 -8 -10 1

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

C0AND1*A20 UN13E2S1T4 *0A2UAN+ M50AL1


DEPA2TMENT 56 ELECT25N1CS & C5MM7 EN** ECP-326: Digital Signal Processing Using MATLAB

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

5utput % T.e res"ltant Signal is $ H 6 *rap"%


2 0

-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

C0AND1*A20 UN13E2S1T4 *0A2UAN+ M50AL1


DEPA2TMENT 56 ELECT25N1CS & C5MM7 EN** ECP-326: Digital Signal Processing Using MATLAB

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

C0AND1*A20 UN13E2S1T4 *0A2UAN+ M50AL1


DEPA2TMENT 56 ELECT25N1CS & C5MM7 EN** ECP-326: Digital Signal Processing Using MATLAB
G ain in dB ------> 100

-100

-200 0

0.5 (a) N ormalised freq ---->

2:

C0AND1*A20 UN13E2S1T4 *0A2UAN+ M50AL1


DEPA2TMENT 56 ELECT25N1CS & C5MM7 EN** ECP-326: Digital Signal Processing Using MATLAB

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!

C0AND1*A20 UN13E2S1T4 *0A2UAN+ M50AL1


DEPA2TMENT 56 ELECT25N1CS & C5MM7 EN** ECP-326: Digital Signal Processing Using MATLAB Enter t.e sa%pling &re, !:::: *rap"%
Low Pass Filter 500 Gain in dB ------>

-500

-1000

0.5 (a) Normalised freq ---->

Phase in Radians ------>

4 2 0 -2 -4

0.1

0.2

0.3

0.4 0.5 0.6 0.7 (b) Normalised freq ---->

0.8

0.9

22

You might also like