Вы находитесь на странице: 1из 53

List of Scilab based DSP Laboratory Experiments

Ex.pt.No:1 Ex.pt.No:2 Ex.pt.No:# Ex.pt.No:& Ex.pt.No:' Ex.pt.No:) Ex.pt.No:" Ex.pt.No:0 Ex.pt.No:4 Generation of Discrete Signals Basic Sequences Linear and Circular Con olution of t!o sequences Circular con olution using $$% Linear Con olution using Circular Con olution Calculation of $$% and ($$% of a sequence %i*e and $requenc+ ,esponse of L%( s+ste*s Sa*pling- .erification of Sa*pling and Effect of aliasing

Page No.
2 " 11 12 1& 1) 2/ 2& #' &) &0

Design of $(, $ilters 12indo! Design and $requenc+ Sa*pling3 Design of ((, $ilters 1Butter!ort5 6 C5e7+c5e 3

Ex.pt.No:1/ Deci*ation 7+ pol+p5ase deco*position Ex.pt.No:11 8eriodogra* 7ased Spectral Esti*ation

Ex.pt.No.1

Generation of Discrete Signals- Basic Sequences


1

Aim: To generate and to plot the basic seq ences s ch as !nit "mp lse# !nit Step# $amp and exponentially increasing and decreasing seq ences. Program (1) Unit Sample Sequence clear% clc% close% L & '% ((!pperlimit n & )L:L% x & *+eros,-#L.#-#+eros,-#L./% b & gca,.% b.y0location & 1middle1% plot2d3,4gnn4#n#x. a&gce,.% a.children,-..thic5ness &'% xtitle,46raphical $epresentation of !nit Sample Seq ence4#4n4#4x*n/4.% esult

Program (!) Unit Step Sequence


2

clear% clc% close% L & '% ((!pperlimit n & )L:L% x & *+eros,-#L.#ones,-#L7-./% a&gca,.% a.y0location & 1middle1% plot2d3,4gnn4#n#x. title,46raphical $epresentation of !nit Step Signal4. xlabel,4 n4.% ylabel,4 x*n/4.% esult

Program (") amp Sequence clear% clc%


3

close% L & '% ((!pperlimit n & )L:L% x & *+eros,-#L.#8:L/% b & gca,.% b.y0location & 4middle4% plot2d3,4gnn4#n#x. a&gce,.% a.children,-..thic5ness &2% xtitle,46raphical $epresentation of Discrete !nit $amp Seq ence4#4n4#4x*n/4.%

esult

Program (#) Exponentiall$ Decreasing Signal (( a 9 clear% clc%


4

close% a &8.:% n & 8:-8% x & ,a.;n% a&gca,.% a.x0location & 1origin1% a.y0location & 1origin1% plot2d3,4gnn4#n#x. a.thic5ness & 2% xtitle,46raphical $epresentation of Exponentially Decreasing Signal4#4n4#4x*n/4.% esult

Program (%) Exponentiall$ &ncreasing Signal clear% clc% close% a &-.:%


5

n &-:-8% x & ,a.;n% a&gca,.% a.thic5ness & 2% plot2d3,4gnn4#n#x. xtitle,46raphical $epresentation of Exponentially "ncreasing Signal4#4n4#4x*n/4.%

esult

Ex.pt.No'!

(inear an) *ircular *on+olution of t,o sequences

Aim: To perform Linear <on=ol tion and <irc lar <on=ol tion of t>o discrete seq ences. Program (1) (inear *on+olution Sum ((Program for Linear <on=ol tion
6

clc% clear all% close % x & inp t,4enter x seq4.% h & inp t,4enter h seq4.% m & length,x.% n & length,h.% ((?ethod - !sing Direct <on=ol tion S m @orm la for i & -:n7m)con=0s m & 8% for A & -:i if ,,,i)A7-. 9& n.B,A 9& m.. con=0s m & con=0s m 7 x,A.Ch,i)A7-.% end% y,i. & con=0s m% end% end% disp,y4#4<on=ol tion S m sing Direct @orm la ?ethod &4. ((?ethod 2 !sing "nb ilt @ nction f & con=ol,x#h. disp,f#4<on=ol tion S m $es lt sing "nb ilt @ ntion &4. ((?ethod 3 !sing freq ency Domain m ltiplication N & n7m)-% x & *x +eros,-#N)m./% h & *h +eros,-#N)n./% f- & fft,x. f2 & fft,h. f3 & f-.Cf2% (( freq domain m ltiplication f' & ifft,f3. disp,f'#4<on=ol tion S m $es lt D@T ) "D@T method &4. ((f' & real,f'. s bplot,3#-#-.% plot2d3,4gnn4#x. xtitle,46raphical $epresentation of "np t signal x4.% s bplot,3#-#2.% plot2d3,4gnn4#h. xtitle,46raphical $epresentation of "mp lse signal h4.% s bplot,3#-#3.% plot2d3,4gnn4#y. xtitle,46raphical $epresentation of D tp t signal y4.%
7

(($es lt ((enter x seq *- - - -/ ((enter h seq *- 2 3/ (( <on=ol tion S m sing Direct @orm la ?ethod & (( -. 3. E. E. :. 3. (( <on=ol tion S m $es lt sing "nb ilt @ ntion & (( -. 3. E. E. :. 3. (( <on=ol tion S m $es lt D@T ) "D@T method & (( -. 3. E. E. :. 3. $es lt graph

Program (!) *ircular *on+olution of t,o Discrete Sequences //Caption: Program to find the Circular Convolution of given //discrete sequences using Matrix method clear% clc% x- & *2#-#2#-/% //First sequence
8

x2 & *-#2#3#'/% //Second sequence m & length,x-.% //length of first sequence n & length,x2.% //length of second sequence //To make length of x1 and x are !qual if ,m Fn. for i & n7-:m x2,i. & 8% end elseif ,nFm. for i & m7-:n x-,i. & 8% end end N & length,x-.% x3 & +eros,-#N.% //x" # Circular convolution result initiali$ed to $eros a,-. & x2,-.% for A & 2:N a,A. & x2,N)A72.% end for i &-:N x3,-. & x3,-.7x-,i.Ca,i.% end G,-#:.&a% //Calculation of circular convolution for 5 & 2:N for A &2:N x2,A. & a,A)-.% end x2,-. & a,N.% G,5#:.& x2% for i & -:N a,i. & x2,i.% x3,5. & x3,5.7x-,i.Ca,i.% end end disp,G#4<irc lar <on=ol tion ?atrix x2*n/&4. disp,x3#4<irc lar <on=ol tion $es lt x3*n/ & 4. //%esult //Circular Convolution Matrix x &n'# //
9

// 1( )( "( ( // ( 1( )( "( // "( ( 1( )( // )( "( ( 1( // // Circular Convolution %esult x"&n' # // // 1)( 1*( 1)( 1*(

Ex.pt.No'"

*ircular con+olution using --.

Aim: To perform circ lar con=ol tion of t>o seq ences sing @@T)"@@T method. //Caption: Performing Circular Convolution +sing FFT,-FFT method clear% clc% close% L & '% //.ength of the Sequence N & '% // / ,point 0FT
10

x- & *2#-#2#-/% x2 & *-#2#3#'/% //Computing 0FT G- & fft,x-#)-.% G2 & fft,x2#)-.% disp,G-#4D@T of x-*n/ is G-,5.&4. disp,G2#4D@T of x-*n/ is G2,5.&4. //Multiplication of 0FTs G3 & G-.CG2% disp,G3#4D@T of x3*n/ is G3,5.&4. //Circular Convolution %esult x3 &abs,fft,G3#-.. disp,x3#4<irc lar <on=ol tion $es lt x3*n/&4. //Result // 0FT of x1&n' is 112k3# // // *( 4 ( 4 // // 0FT of x1&n' is 1 2k3# // // 14( , ( 5 (i , ( , ( , (i // // 0FT of x"&n' is 1"2k3# // // *4( 4 , )( 4 // // Circular Convolution %esult x"&n'# // 1)( 1*( 1)( 1*(

Ex.pt.No'#

(inear *on+olution using *ircular *on+olution

Aim: To perform Linear <on=ol tion sing <irc lar <on=ol tion Program //Caption: Performing .inear Convolution using Circular Convolution clear% clc% close%
11

h & *-#2#3/% //-mpulse %esponse of .T- S6stem x & *-#2#2#-/% //-nput %esponse of .T- S6stem N- & length,x.% N2 & length,h.% N & N-7N2)disp,N#4Length of D tp t $esponse y,n.4. //Padding $eros to Make .ength of 7h7 and 7x7 //!qual to length of output response 767 h- & *h#+eros,-#N)N2./% x- & *x#+eros,-#N)N-./% //Computing FFT H & fft,h-#)-.% G & fft,x-#)-.% //Multiplication of 0FTs I & G.CH //.inear Convolution %esult y &abs,fft,I#-.. disp,G#4D@T of i(p G,5.&4. disp,H#4D@T of imp lse seq ence H,5.&4. disp,I#4D@T of Linear @ilter o(p I,5.&4. disp,y#4Linear <on=ol tion res lt y*n/&4. //Result // .ength of 8utput %esponse 62n3 // // *( // // 0FT of i/p 12k3# // *( , "()*)141*i 4 4 4 "()*)141*i // // 0FT of impulse sequence 92k3# // // *( 4(: , )(""41 ;i , 1(: 5 4(<**4 :)i ( , 1(: , 4(<**4 :)i )(""41 ;i // // 0FT of .inear Filter o/p =2k3# // // "*( , 1:( , 1(;" 4:4<i 4 4 4 , 1:( 5 1(;" 4:4<i //
12

4(: 5

// .inear Convolution result 6&n'# // // 1( )( >( 11( <( "(

Ex.pt.No'%

*alculation of --. an) &--. of a Sequence

Aim: To find o t the @@T and "@@T of a gi=en discrete seq ence. Program //Caption :Performing FFT and -FFT of a discrete sequence clear% clc% close% L & '% //.ength of the Sequence N & '% // / ,point 0FT
13

x & *-#2#3#'/% //Computing 0FT G & fft,x#)-.% disp,G#4@@T of x*n/ is G,5.&4. x &abs,fft,G#-.. disp,x#4"@@T of G,5. is x*n/&4. //Plotting the spectrum of 0iscrete Sequence s bplot,2#-#-. a&gca,.% a.data0bo nds&*8#8%:#-8/% plot2d3,4gnn4#8:length,x.)-#x. b & gce,.% b.children,-..thic5ness &3% xtitle,46raphical $epresentation of Discrete Seq ence4#4n4#4x*n/4.% s bplot,2#-#2. a&gce,.% a.data0bo nds&*8#8%:#-8/% plot2d3,4gnn4#8:length,G.)-#abs,G.. b & gce,.% b.children,-..thic5ness &3% xtitle,46raphical $epresentation of Discrete Spectr m4#454#4G,5.4.% //%esult //FFT of x&n' is 12k3# // 14( , ( 5 (i , ( , ( , (i // //-FFT of 12k3 is x&n'# // 1( ( "( )( esult

14

Ex.pt.No'/

.ime an) -requenc$ esponse of (.& s$stems


15

Aim: To >rite a scilab program in order to generate and plot the imp lse response and freq ency response of a first order Linear <onstant <oefficient Differential Eq ation Program' .ime response an) -requenc$ response of an (.& s$stem )escri0e) 0$ (inear *onstant *oefficient Differential Equation //Caption: Program to generate and plot the impulse response and frequenc6 //response of a .inear constant coefficient first order 0ifferential !quation //&1'(-mpulse response h2t3# exp2,a?t3u2t3@ AB4 //& '(Frequenc6 response 92CD3 # 1/2CD5a3 clear% clc% close% //&1'( To generate and plot the impulse response a &-% //Constant coefficient a #1 Dt & 8.88:% t & 8:Dt:-8% ht & exp,)aCt.% fig re,-. a & gca,.% a.y0location & 1origin1% plot,t#ht.% xlabel,4time t ))))))F4.% ylabel,4h,t.4. title,4"mp lse $epsonse of "st Drder Linear <onstant <oeff. Differential Eq ..4. // //& '( Finding Frequenc6 response using Continuous Time Fourier Transform Jmax & 2CKpiC-% //Analog Frequenc6 # 19$ L & '% 5 & 8:,L(-888.:L% J & 5CJmax(L% HJ & htC exp,)sqrt,)-.Ct4CJ. C Dt% HJ0?ag & abs,HJ.% J & *)mtlb0fliplr,J.# J,2:-88-./% // 8mega from ,Emax to Emax HJ0?ag & *mtlb0fliplr,HJ0?ag.#HJ0?ag,2:-88-./% *HJ0Phase#db/ & phasemag,HJ.% HJ0Phase & *)mtlb0fliplr,HJ0Phase.#HJ0Phase,2:-88-./% fig re,2. //Plotting Magnitude %esponse
16

s bplot,2#-#-.% a & gca,.% a.y0location & 1origin1% plot,J#HJ0?ag.% xlabel,4@req ency in $adians(Seconds)))F J4.% ylabel,4abs,H,AJ..4. title,4?agnit de $esponse4. //Plotting Phase %eponse s bplot,2#-#2.% a & gca,.% a.y0location & 1origin1% a.x0location & 1origin1% plot,J#HJ0PhaseCKpi(-M8.% xlabel,4 @req ency in $adians(Seconds)))F J4.% ylabel,4 9H,AJ.4. title,4Phase $esponse in $adians4. esult

17

18

Ex.pt.No'1

Sampling2 3erification of Sampling an) Effect of aliasing

Aim: To >rite a scilab program in order to con=ert a contin o s time signal ,<TS. into discrete time sampled signal ,DTSS. and to =erify the sampling theorem. Aliasing effect can be analy+ed for different sampling freq encies. Program' Generation of a *. Signal x(t) 4 exp(-567t7) an) to generate t8e correspon)ing Discrete .ime Sample) Signal x(n.)4exp(-567n.7). &n or)er to sample *ontinuous .ime Signal t8e -ollo,ing Sampling -requencies are use)'91:.-s 4 1 ;< 9!:.-s 4 ! ;< 9":.-s 4 #;< 9#:.-s 4!= ;< 9%:.-s 41==;<. 5liasing Effect' 5s t8e Sampling frequenc$ increases aliasing effect )ecreases. >ain Program //Caption: Sampling and %econstruction of a Signal x2t3 # exp2,A?FtF3 //0iscrete Time Sampled Signal x2nT3# exp2,A?FnTF3 //FolloDing Sampling Frequencies are used: //&1'(Fs # 1 9$ & '(Fs # 9$ &"'(Fs # )9$ &)'(Fs # 4 9$ &:'(Fs #1449$ //Aliasing !ffect: As the Sampling frequenc6 increases aliasing effect decreases clc% // Analog Signal A &-% //Amplitude Dt & 8.88:% t & )2:Dt:2% //Continuous Time Signal xa & exp,)ACabs,t..% //0iscrete Time Signal @s &inp t,4Enter the Sampling @req ency in Hert+4.%//Fs # 19$@ 9$@)9$@ 49$@1449$ Ts & -(@s% nTs & )2:Ts:2% x & exp,)ACabs,nTs..% // Analog Signal reconstruction Dt & 8.88:% t & )2:Dt:2% Ga & x Csinc0ne>,@sC,ones,length,nTs.#-.Ct)nTs4Cones,-#length,t....% //Plotting the original signal and reconstructed signal
19

s bplot,2#-#-.% a &gca,.% a.x0location & 1origin1% a.y0location & 1origin1% plot,t#xa.% xlabel,4t in sec.4.% ylabel,4xa,t.4. title,4Driginal Analog Signal4. s bplot,2#-#2.% a &gca,.% a.x0location & 1origin1% a.y0location & 1origin1% xlabel,4t in sec.4.% ylabel,4xa,t.4. title,4$econstr cted Signal sing sinc f nction# @s & -88H+4.% plot,t#Ga.% Sinc -unction f nction *$/&sinc0ne>,x. i&find,x&&8.% x,i.& -% // don7t need this is /4 Darning is off $ & sin,KpiCx..(,KpiCx.% $,i. & -% endf nction

esult
20

21

22

Ex.pt.No'?

Design of -& -ilters (@in)o, Design an) -requenc$ Sampling)

(?).a -& -ilter -@in)o, Base) Design


Aim: To design Jindo>)based @"$ Lo> Pass @ilter# High Pass @ilter# Nand Pass @ilter and Nand Stop @ilter sing gi=en desired freq ency response. Program 1' -& (o, Pass -ilter //Caption: Program to 0esign F-% .oD Pass Filter clc% close% ? & inp t,4Enter the Ddd @ilter Length &4.% //Filter length Jc & inp t,4Enter the Digital < toff freq ency &4.% //0igital Cutoff frequenc6 T o & ,?)-.(2 //Center Galue for n & -:? if ,n && T o7-. hd,n. & Jc(Kpi% else hd,n. & sin,JcC,,n)-.)T o..(,,,n)-.)T o.CKpi.% end end //%ectangular EindoD for n & -:? J,n. & -% end //EindoDing Filter Coefficients h & hd.CJ% disp,h#4@ilter <oefficients are4. *h+m#fr/&frmag,h#2:E.% h+m0dN & 28Clog-8,h+m..(max,h+m.% s bplot,2#-#-. plot,2Cfr#h+m. xlabel,4Normali+ed Digital @req ency J4.% ylabel,4?agnit de4.% title,4@req ency $esponse 8f @"$ LP@ sing $ectang lar >indo>4. xgrid,-. s bplot,2#-#2.
23

plot,2Cfr#h+m0dN. xlabel,4Normali+ed Digital @req ency J4.% ylabel,4?agnit de in dN4.% title,4@req ency $esponse 8f @"$ LP@ sing $ectang lar >indo>4. xgrid,-. //%esult //!nter the 8dd Filter .ength # ; //!nter the 0igital Cutoff frequenc6 # Hpi/ // // Filter Coefficients are // // , 4(14*14"" // 1(>)>0,1; # 4(4 // 4("1<"4>> // 4(: // 4("1<"4>> // 1(>)>0,1; # 4(4 // , 4(14*14"" esult

24

Program !' -& ;ig8 Pass -ilter //Caption: Program to 0esign F-% 9igh Pass Filter clear% clc% close% ? & inp t,4Enter the Ddd @ilter Length &4.% //Filter length Jc & inp t,4Enter the Digital < toff freq ency &4.% //0igital Cutoff frequenc6 T o & ,?)-.(2 //Center Galue for n & -:? if ,n && T o7-. hd,n. & -)Jc(Kpi% else hd,n. & ,sin,KpiC,,n)-.)T o.. )sin,JcC,,n)-.)T o...(,,,n)-.)T o.CKpi.% end end //%ectangular EindoD for n & -:? J,n. & -% end //EindoDing Fitler Coefficients h & hd.CJ% disp,h#4@ilter <oefficients are4. *h+m#fr/&frmag,h#2:E.%
25

h+m0dN & 28Clog-8,h+m..(max,h+m.% s bplot,2#-#-. plot,2Cfr#h+m. xlabel,4Normali+ed Digital @req ency J4.% ylabel,4?agnit de4.% title,4@req ency $esponse 8f @"$ HP@ sing $ectang lar >indo>4. xgrid,-. s bplot,2#-#2. plot,2Cfr#h+m0dN. xlabel,4Normali+ed Digital @req ency J4.% ylabel,4?agnit de in dN4.% title,4@req ency $esponse 8f @"$ HP@ sing $ectang lar >indo>4. xgrid,-. //%esult //!nter the 8dd Filter .ength # : //!nter the 0igital Cutoff frequenc6 # Hpi/) //Filter Coefficients are // // , 4(1:>1:)> // , 4( :4;>1 // 4(;: // , 4( :4;>1 // , 4(1:>1:)> esult

26

Program "' -& Ban) Pass -ilter //Caption: Program to 0esign F-% Iand Pass Filter clear% clc% close% ? & inp t,4Enter the Ddd @ilter Length &4.% //Filter length //0igital Cutoff frequenc6 &.oDer Cutoff@ +pper Cutoff' Jc & inp t,4Enter the Digital < toff freq ency &4.% Jc2 & Jc,2.
27

Jc- & Jc,-. T o & ,?)-.(2 //Center Galue hd & +eros,-#?.% J & +eros,-#?.% for n & -:-if ,n && T o7-. hd,n. & ,Jc2)Jc-.(Kpi% else n hd,n. & ,sin,Jc2C,,n)-.)T o.. )sin,Jc-C,,n)-.)T o...(,,,n)-.)T o.CKpi.% end if,abs,hd,n..9,8.8888-.. hd,n.&8% end end hd% //%ectangular EindoD for n & -:? J,n. & -% end //EindoDing Fitler Coefficients h & hd.CJ% disp,h#4@ilter <oefficients are4. *h+m#fr/&frmag,h#2:E.% h+m0dN & 28Clog-8,h+m..(max,h+m.% s bplot,2#-#-. plot,2Cfr#h+m. xlabel,4Normali+ed Digital @req ency J4.% ylabel,4?agnit de4.% title,4@req ency $esponse 8f @"$ NP@ sing $ectang lar >indo>4. xgrid,-. s bplot,2#-#2. plot,2Cfr#h+m0dN. xlabel,4Normali+ed Digital @req ency J4.% ylabel,4?agnit de in dN4.% title,4@req ency $esponse 8f @"$ NP@ sing $ectang lar >indo>4. xgrid,-. //%esult //!nter the 8dd Filter .ength # 11 //!nter the 0igital Cutoff frequenc6 # &Hpi/)@ "?Hpi/)'
28

//Filter Coefficients are // 4( 4( 4( , 4("1<"4>> esult

4(

4(:

4( , 4("1<"4>>

4( 4( 4(

Program #' -& Ban) Stop -ilter //Caption: Program to 0esign F-% Iand %eCect Filter clear % clc% close% ? & inp t,4Enter the Ddd @ilter Length &4.% //Filter length //0igital Cutoff frequenc6 &.oDer Cutoff@ +pper Cutoff' Jc & inp t,4Enter the Digital < toff freq ency &4.% Jc2 & Jc,2. Jc- & Jc,-.
29

T o & ,?)-.(2 //Center Galue hd & +eros,-#?.% J & +eros,-#?.% for n & -:? if ,n && T o7-. hd,n. & -),,Jc2)Jc-.(Kpi.% else hd,n.&,sin,KpiC,,n)-.)T o..)sin,Jc2C,,n)-.)T o..7sin,Jc-C,,n)-.)T o...(,,,n) -.)T o.CKpi.% end if,abs,hd,n..9,8.8888-.. hd,n.&8% end end //%ectangular EindoD for n & -:? J,n. & -% end //EindoDing Fitler Coefficients h & hd.CJ% disp,h#4@ilter <oefficients are4. *h+m#fr/&frmag,h#2:E.% h+m0dN & 28Clog-8,h+m..(max,h+m.% s bplot,2#-#-. plot,2Cfr#h+m. xlabel,4Normali+ed Digital @req ency J4.% ylabel,4?agnit de4.% title,4@req ency $esponse 8f @"$ NS@ sing $ectang lar >indo>4. xgrid,-. s bplot,2#-#2. plot,2Cfr#h+m0dN. xlabel,4Normali+ed Digital @req ency J4.% ylabel,4?agnit de in dN4.% title,4@req ency $esponse 8f @"$ NS@ sing $ectang lar >indo>4. xgrid,-. //%esult //!nter the 8dd Filter .ength # 11 //!nter the 0igital Cutoff frequenc6 #&Hpi/"@ ?Hpi/"' //Filter Coefficients are //column 1 to >
30

// 4( , 4(1";<" //column 14 to 11 // , 4(1";<" 4( esult

4(

4( ;:**))

4(

4(******;

4(

4( ;:**))

4(

(?).0 -& -ilter A-requenc$ Sampling .ec8nique


Aim: To design @req ency Sampling techniq e based @"$ Lo> Pass @ilter sing gi=en desired freq ency response. Program' -& (o, Pass -ilter //Caption: 0esign of F-% .PF Filter using Frequenc6 Sampling Technique clear% clc% close% ? &-:%
31

Hr & *-#-#-#-#8.'#8#8#8/% for 5 &-:length,Hr. 6,5.&,,)-.;,5)-..CHr,5.% end h & +eros,-#?.% ! & ,?)-.(2 for n & -:? h- & 8% for 5 & 2:!7h- &6,5.Ccos,,2CKpi(?.C,5)-.C,,n)-.7,-(2...7h-% end h,n. & ,-(?.C ,6,-.72Ch-.% end disp,h#4@ilter <oefficients are h,n.&4. *h+m#fr/&frmag,h#2:E.% h+m0dN & 28Clog-8,h+m..(max,h+m.% s bplot,2#-#-. plot,2Cfr#h+m. a&gca,.% xlabel,4Normali+ed Digital @req ency J4.% ylabel,4?agnit de4.% title,4@req ency $esponse 8f @"$ LP@ sing @req ency Sampling Techniq e >ith ? & -: >ith < toff @req ency & 8.'EE4. xgrid,2. s bplot,2#-#2. plot,2Cfr#h+m0dN. a&gca,.% xlabel,4Normali+ed Digital @req ency J4.% ylabel,4?agnit de in dN4.% title,4@req ency $esponse 8f @"$ LP@ sing @req ency Sampling Techniq e >ith ? & -: >ith < toff @req ency & 8.'EE4. xgrid,2. //%esult //Filter Coefficients are h2n3# //column 1 to ; // // ,4(41)1 <> ,4(441>):" 4(4) 4(41 "): ,4(4>1"<<4 ,4(41<4<>> 4("1""1;* // //column < to 1) // //4(: 4("1""1;* , 4(41<4<>> , 4(4>1"<<4 4(41 "): 4(4) , 4(441>):" // //column 1: // // , 4(41)1 <>
32

esult

Ex.pt.No'B

Design of && -ilters (Butter,ort8 C *8e0$c8e+)

(B).a. Design of Digital && Butter,ort8 -ilters


Aim: To design Nilinear Transform method based Digital ""$ N tter>orth Lo> Pass @ilter and con=erting into High Pass @ilter# Nand Pass @ilter and Nand Stop @ilter sing Digital @req ency Transformation techniq e. Program 1' && Butter,ort8 (P//Caption: To design a digital --% First 8rder IutterDorth .PF Filter //+sing Iilinear Transformation clear all% clc%
33

close% s & poly,8#4s4.% Dmegac & 8.2CKpi% // Cutoff frequenc6 H & Dmegac(,s7Dmegac.% //Analog first order IutterDorth filter tranfer function T &-%//Sampling period T # 1 Second + & poly,8#4+4.% H+ & horner,H#,2(T.C,,+)-.(,+7-... //Iilinear Transformation HJ &frmag,H+,2.#H+,3.#:-2.% //Frequenc6 response for :1 points J & 8:Kpi(:--:Kpi% a&gca,.% a.thic5ness & -% plot,J(Kpi#HJ#4r4. a.foregro nd & -% a.font0style & O% xgrid,-. xtitle,4?agnit de $esponse of Single pole LP@ @ilter < toff freq ency & 8.2Cpi4#4Normali+ed Digital @req ency)))F4#4?agnit de4.%

esult

34

Program !' && Butter,ort8 ;P//Caption: To design First 8rder IutterDorth .oD Pass Filter and convert it into
35

// 9PF +sing 0igital Filter Transformation clear all% clc% close% s & poly,8#4s4.% Dmegac & 8.2CKpi% //Filter cutoff frequenc6 H & Dmegac(,s7Dmegac.% //First order IutterDorth --% filter T &-%//Sampling period T # 1 Second + & poly,8#4+4.% H+0LP@ & horner,H#,2(T.C,,+)-.(,+7-...% //Iilinear Transformation alpha & ),cos,,Dmegac7Dmegac.(2..(,cos,,Dmegac)Dmegac.(2..% HP0HP@&horner,H+0LP@#),+7alpha.(,-7alphaC+..//.PF to 9PF digital transformation HJ &frmag,HP0HP@,2.#HP0HP@,3.#:-2.% //Frequenc6 response for :1 points J & 8:Kpi(:--:Kpi% a&gca,.% a.thic5ness & -% plot,J(Kpi#HJ#4r4. a.foregro nd & -% a.font0style & O% xgrid,-. xtitle,4?agnit de $esponse of Single pole HP@ @ilter < toff freq ency & 8.2Cpi4#4Normali+ed Digital @req ency J(pi)))F4#4?agnit de4.%

esult

36

Program "' && Butter,ort8 BP37

///Caption:To 0esign a 0igital --% IutterDorth .PF Filter from Analog --% //IutterDorth Filter and .PF to IPF using 0igital Transformation clear all% clc% close% omegaP & 8.2CKpi% //Filter cutoff frequenc6 omegaL & ,-(:.CKpi% //.oDer Cutoff frequenc6 for ISF omega! & ,3(:.CKpi% //+pper Cutoff frequenc6 for ISF +&poly,8#4+4.% H0LP@ & ,8.2':.C,-7,+;)-..(,-)8.:8OC,+;)-..% //Iilinear transformation alpha & ,cos,,omega!7omegaL.(2.(cos,,omega!)omegaL.(2..%//parameter 7alpha7 //parameter 7k7 5 & ,cos,,omega! ) omegaL.(2.(sin,,omega! ) omegaL.(2..Ctan,omegaP(2.% N!? &),,+;2.),,2CalphaC5(,57-..C+.7,,5)-.(,57-...% DEN & ,-),,2CalphaC5(,57-..C+.7,,,5)-.(,57-..C,+;2...% HP0NP@&horner,H0LP@#N!?(DEN.%//.PF to IPF conversion using digital transformation disp,HP0NP@#4Digital NP@ ""$ @ilter H,P.& 4.% HJ &frmag,HP0NP@,2.#HP0NP@,3.#:-2.%//frequenc6 response J & 8:Kpi(:--:Kpi% a&gca,.% a.thic5ness & -% plot,J(Kpi#HJ#4r4. a.foregro nd & -% a.font0style & O% xgrid,-. xtitle,4?agnit de $esponse of NP@ @ilter c toff freq ency *8.2#8.E/4#4Normali+ed Digital @req ency)))F4#4?agnit de4.%

esult
38

Program #' && Butter,ort8 BS//Caption:To 0esign a 0igital --% IutterDorth .PF Filter from Analog --%
39

//IutterDorth Filter and .PF to ISF using 0igital Transformation clear all% clc% close% omegaP & 8.2CKpi% //Filter cutoff frequenc6 omegaL & ,-(:.CKpi% //.oDer Cutoff frequenc6 for ISF omega! & ,3(:.CKpi% //+pper Cutoff frequenc6 for ISF +&poly,8#4+4.% H0LP@ & ,8.2':.C,-7,+;)-..(,-)8.:8OC,+;)-..//Iilinear transformation alpha & ,cos,,omega!7omegaL.(2.(cos,,omega!)omegaL.(2..% //parameter 7alpha7 5 & tan,,omega! ) omegaL.(2.Ctan,omegaP(2.% //parameter 7k7 N!? &,,+;2.),,2Calpha(,-75..C+.7,,-)5.(,-75...% ///umerator DEN & ,-),,2Calpha(,-75..C+.7,,,-)5.(,-75..C,+;2...% //0enominator HP0NS@&horner,H0LP@#N!?(DEN.% //.PF to ISF conversion using digital transformation HJ &frmag,HP0NS@,2.#HP0NS@,3.#:-2.% //frequenc6 response for :1 points J & 8:Kpi(:--:Kpi% a&gca,.% a.thic5ness & -% plot,J(Kpi#HJ#4r4. a.foregro nd & -% a.font0style & O% xgrid,-. xtitle,4?agnit de $esponse of NS@ @ilter c toff freq *8.2#8.E/ 4#4Normali+ed Digital @req ency)))F4#4?agnit de4.%

esult

40

(B).0. Design of Digital && *8e0$s8e+ -ilter


41

Aim: To design Nilinear Transform method based Digital ""$ <hebyshe= Lo> Pass @ilter. Program' && *8e0$s8e+ (P//Program To 0esign the 0igital CheJ6shev --% Filter clear% clc% close% Jp & inp t,4Enter the Digital Pass Nand Edge @req ency4.% Js & inp t,4Enter the Digital Stop Nand Edge @req ency4.% T & inp t,4Sampling "nter=al4. DmegaP & ,2(T.Ctan,Jp(2. DmegaS & ,2(T.Ctan,Js(2. Delta- & inp t,4Enter the Pass Nand $ipple4.% Delta2 & inp t,4Enter the Stop Nand $ipple4.% Delta & sqrt,,,-(Delta2.;2.)-. Epsilon & sqrt,,,-(Delta-.;2.)-. N & ,acosh,Delta(Epsilon..(,acosh,DmegaS(DmegaP.. N & ceil,N. Dmega< & DmegaP(,,,,-(Delta-.;2.)-.;,-(,2CN... *pols#gn/ & +pch-,N#Epsilon#DmegaP. Hs & poly,gn#4s4#4coeff4.(real,poly,pols#4s4.. + & poly,8#4+4.% H+ & horner,Hs#,,2(T.C,,+)-.(,+7-.... HJ &frmag,H+,2.#H+,3.#:-2.% //Frequenc6 response for :1 points J & 8:Kpi(:--:Kpi% a&gca,.% a.thic5ness & -% plot,J(Kpi#abs,HJ.#4r4. a.foregro nd & -% a.font0style & O% xgrid,-. xtitle,4?agnit de $esponse of <hebyshe= LP@ @ilter4#4Normali+ed Digital @req ency)))F4#4?agnit de in dN4.% //%!S+.T //!nter the 0igital Pass Iand !dge Frequenc6 4( ?Hpi //!nter the 0igital Stop Iand !dge Frequenc6 4(*?Hpi
42

//Sampling -nterval 1 // T # // 1( // 8megaP # // 4(*)><">) // 8megaS # // (;: ;*"< //!nter the Pass Iand %ipple 4(< //!nter the Stop Iand %ipple 4( // 0elta # // )(<><>;>: // !psilon # // 4(;: // / # // 1( 4;>:)< // / # // ( // 8megaC # // 4(;:4"*>> // gn # // 4( <1: ;: // pols # // , 4( *: >:< 5 4(:"4:>1*i , 4( *: >:< , 4(:"4:>1*i // 9s # // // 4( <1: ;: // ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, // // 4(":1>4>) 5 4(:"4:>1*s 5 s // //9$ # // // 4( <1: ;: 5 4(:*"4::4$ 5 4( <1: ;:$ // ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, // // "( >4; *1 , ;( >*1<1"$ 5 :()1"4> *$ //,,B4(:?4(:* > // ans # // 4( <1): // 9$2 3# 9$2 3/:()1"4> *
43

// 9$ # // // // 4(4: 44<* 5 4(14)41; $ 5 4(4: 44<*$ // ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, // // "( >4; *1 , ;( >*1<1"$ 5 :()1"4> *$ // //,,B9$2"3 # 9$2"3/:()1"4> * // 9$ # // // 4(4: 44<* 5 4(14)41; $ 5 4(4: 44<*$ // ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, // // 4(*4;>1>< , 1(");<;*;$ 5 $ esult

Ex.pt.No'1=

Decimation 0$ Pol$p8ase Decomposition

Aim: To design a Decimator ,@"$ LP@. of factor D & 2 by poly)phase decomposition


44

Program' Decimation 0$ Pol$p8ase Decomposition //Caption:0ecimation J6 @ Filter .ength # "4 //Cutoff Frequenc6 Ec # Hpi/ //Pass Jand !dge frequenc6 fp # 4( : and a Stop Jand edge frequenc6 fs # 4("1 // Choose the numJer of cosine functions and create a dense grid // in &4@4( :' and &4("1@4(:' //magnitude for pass Jand # 1 K stop Jand # 4 2i(e3 &1 4' //Eeighting function #& 1' clear% clc% close% ? & 38% //Filter .ength D & 2% //0ecimation Factor # Jc & Kpi(2% //Cutoff Frequenc6 Jp & Jc(,2CKpi.% //PassJand !dge Frequenc6 Js & 8.3-% //StopJand !dge Frequenc6 hn&eqfir,?#*8 Jp%Js .:/#*- 8/#*2 -/.% disp,hn#4The LP@ @ilter <oefficients are:4. //8Jtaining Pol6phase Filter Coefficients from hn p & +eros,D#?(D.% for 5 & -:D for n & -:,length,hn.(D. p,5#n. & hn,DC,n)-.75.% end end disp,p#4The Polyphase Decimator for D &2 are:4. //Result //The LPF Filter Coefficients are: //column 1 to ; //4(44*4 4" , 4(41 <4"; , 4(44 <:") 4(41"**<; , 4(44)*;*1 , 4(41>;44 4(41:>>1: //column < to 1) //4(4 1"<11 , 4(4")><4< , 4(41:* :1 4(4><4: //column 1: to 1 4(4*)4 "4 , 4(44;"*44 , 4(11<;" :

45

//4()> );* 4()> );* 4(4><4: , 4(11<;" : , 4(44;"*44 4(4*)4 "4 , 4(41:* :1 //column to < //, 4(4")><4< 4(4 1"<11 4(41:>>1: , 4(41>;44 , 4(44)*;*1 4(41"**<; , 4(44 <:") //column > to "4 //, 4(41 <4"; 4(44*4 4" //The Polyphase Decimator for D =2 are: //column 1 to ; //4(44*4 4" , 4(44 <:") , 4(44)*;*1 4(41:>>1: , 4(4")><4< 4(4*)4 "4 , 4(11<;" : //, 4(41 <4"; 4(41"**<; , 4(41>;44 4(4 1"<11 , 4(41:* :1 , 4(44;"*44 4(4><4: //column < to 1) //4()> );* 4(4><4: , 4(44;"*44 , 4(41:* :1 4(41"**<; //4()> );* , 4(11<;" : 4(4*)4 "4 , 4(4")><4< 4(44 <:") //column 1: //, 4(41 <4"; // 4(44*4 4" 4(4 1"<11 , 4(41>;44 4(41:>>1: , 4(44)*;*1 ,

Ex.pt.No'11

Perio)ogram 0ase) Spectral Estimation

Aim: To >rite a Scilab program in order to estimate the Po>er Spectr m of a discrete seq ence based on Periodogram method and to plot the same.
46

Program' Scila0 program for Perio)ogram 0ase) Spectrum Estimation //Caption: Periodogram !stimate of Liven 0iscrete Sequence //x2n3 #M1@4@ @4@"@1@4@ N //using 0FT clear% clc% close% N &M% //<,point 0FT x & *-#8#2#8#3#-#8#2/% //given discrete sequence G & dft,x#)-.% //<,point 0FT of given discrete sequence Pxx & ,-(N.C,abs,G..;2.% //Peridogram !stimate disp,G#4D@T of x,n.is G,5.&4. disp,Pxx#4Peridogram of x,n. is Pxx,5(N.&4. fig re,-. a & gca,.% a.data0bo nds &*8#8%M#--/% plot2d3,4gnn4#*-:N/#Pxx. a.foregro nd & :% a.font0color & :% a.font0style & :% title,4Peridogram Estimate4. xlabel,4Discrete @req ency Qariable L )))))F4. ylabel,4Periodogram Pxx ,5 (N. ))))F4. //Result //0FT of x2n3is 12k3# // // >( // , 1( > <>" 5 4(1 1" 4"i // (5i // , (;4;14*< 5 )(1 1" 4"i // "( , "(*;)0,1*i // , (;4;14*< , )(1 1" 4"i // (,i // , 1( > <>" , 4(1 1" 4"i // // Peridogram of x2n3 is Pxx2k//3# //
47

// // // // // // // //

14(1 : 4( 14;<*) 4(* : "(4"> 1"* 1(1 : "(4"> 1"* 4(* : 4( 14;<*) esult

48

5rc8itecture of t8e Digital Signal Processor Dne of the biggest bottlenec5s in exec ting DSP algorithms is transferring information to and from memory. This incl des data# s ch as samples from the inp t signal and the filter coefficients# as >ell as program instr ctions# the binary codes that go into the program seq encer. @or example# s ppose >e need to
49

m ltiply t>o n mbers that reside some>here in memory. To do this# >e m st fetch three binary =al es from memory# the n mbers to be m ltiplied# pl s the program instr ction describing >hat to do. @ig re ,a. sho>s ho> this seemingly simple tas5 is done in a traditional microprocessor. This is often called a Qon Ne mann architect re# after the brilliant American mathematician Rohn Qon Ne mann ,-O83)-O:S.. Qon Ne mann g ided the mathematics of many important disco=eries of the early t>entieth cent ry. His many achie=ements incl de: de=eloping the concept of a stored program comp ter# formali+ing the mathematics of q ant m mechanics# and >or5 on the atomic bomb. As sho>n in ,a.# a Qon Ne mann architect re contains a single memory and a single b s for transferring data into and o t of the central processing nit ,<P!.. ? ltiplying t>o n mbers req ires at least three cloc5 cycles# one to transfer each of the three n mbers o=er the b s from the memory to the <P!. Je don4t co nt the time to transfer the res lt bac5 to memory# beca se >e ass me that it remains in the <P! for additional manip lation ,s ch as the s m of prod cts in an @"$ filter.. The Qon Ne mann design is q ite satisfactory >hen yo are content to exec te all of the req ired tas5s in serial. "n fact# most comp ters today are of the Qon Ne mann design. Je only need other architect res >hen =ery fast processing is req ired# and >e are >illing to pay the price of increased complexity. This leads s to the Har=ard architect re# sho>n in ,b.. This is named for the >or5 done at Har=ard !ni=ersity in the -O'8s nder the leadership of Ho>ard Ai5en ,-O88)-OS3.. As sho>n in this ill stration# Ai5en insisted on separate memories for data and program instr ctions# >ith separate b ses for each. Since the b ses operate independently# program instr ctions and data can be fetched at the same time# impro=ing the speed o=er the single b s design. ?ost present day DSPs se this d al b s architect re. @ig re ,c. ill strates the next le=el of sophistication# the S per Har=ard Architect re. This term >as coined by Analog De=ices to describe the internal operation of their ADSP)2-8Ex and ne> ADSP)2--xx families of Digital Signal Processors. These are called SHA$<T DSPs# a contraction of the longer term# S per Har=ard A$<hitect re. The idea is to b ild pon the Har=ard architect re by adding feat res to impro=e the thro ghp t. Jhile the SHA$< DSPs are optimi+ed in do+ens of >ays# t>o areas are important eno gh to be incl ded in @ig. c: an instr ction cache# and an "(D controller.
50

@irst# let4s loo5 at ho> the instr ction cache impro=es the performance of the Har=ard architect re. A handicap of the basic Har=ard design is that the data memory b s is b sier than the program memory b s. Jhen t>o n mbers are m ltiplied# t>o binary =al es ,the n mbers. m st be passed o=er the data memory b s# >hile only one binary =al e ,the program instr ction. is passed o=er the program memory b s. To impro=e pon this sit ation# >e start by relocating part of the 1data1 to program memory. @or instance# >e might place the filter coefficients in program memory# >hile 5eeping the inp t signal in data memory. ,This relocated data is called 1secondary data1 in the ill stration.. At first glance# this doesn4t seem to help the sit ation% no> >e m st transfer one =al e o=er the data memory b s ,the inp t signal sample.# b t t>o =al es o=er the program memory b s ,the program instr ction and the coefficient.. "n fact# if >e >ere exec ting random instr ctions# this sit ation >o ld be no better at all. Ho>e=er# DSP algorithms generally spend most of their exec tion time in loops. This means that the same set of program instr ctions >ill contin ally pass from program memory to the <P!. The S per Har=ard architect re ta5es ad=antage of this sit ation by incl ding an instr ction cache in the <P!. This is a small memory that contains abo t 32 of the most recent program instr ctions. The first time thro gh a loop# the program instr ctions m st be passed o=er the program memory b s. This res lts in slo>er operation beca se of the conflict >ith the coefficients that m st also be fetched along this path. Ho>e=er# on additional exec tions of the loop# the program instr ctions can be p lled from the instr ction cache. This means that all of the memory to <P! information transfers can be accomplished in a single cycle: the sample from the inp t signal comes o=er the data memory b s# the coefficient comes o=er the program memory b s# and the program instr ction comes from the instr ction cache. "n the Aargon of the field# this efficient transfer of data is called a high memory)access band>idth.

51

52

53

Вам также может понравиться