Professional Documents
Culture Documents
Users Guide
Version 4.2
PHONE
!
FAX MAIL
508-647-7000 508-647-7001
P h on e Fax Ma il
"
INTERNET
Web An on ym ou s F TP ser ver Newsgr ou p Tech n ica l su ppor t P r odu ct en h a n cem en t su ggest ion s Bu g r epor t s Docu m en t a t ion er r or r epor t s Su bscr ibin g u ser r egist r a t ion Or der st a t u s, licen se r en ewa ls, pa sscodes Sa les, pr icin g, a n d gen er a l in for m a t ion
S ign al Processin g T oolbox U sers Gu id e ! COP YRIGH T 1988 - 1999 by Th e Ma t h Wor ks, In c. All Righ t s Reser ved.
Th e soft wa r e descr ibed in t h is docu m en t is fu r n ish ed u n der a licen se a gr eem en t . Th e soft wa r e m a y be u sed or copied on ly u n der t h e t er m s of t h e licen se a gr eem en t . No pa r t of t h is m a n u a l m a y be ph ot ocopied or r epr odu ced in a n y for m wit h ou t pr ior wr it t en con sen t fr om Th e Ma t h Wor ks, In c. U .S. GOVE RN ME N T: If Licen see is a cqu ir in g t h e P r ogr a m s on beh a lf of a n y u n it or a gen cy of t h e U .S. Gover n m en t , t h e followin g sh a ll a pply: (a ) F or u n it s of t h e Depa r t m en t of Defen se: t h e Gover n m en t sh a ll h a ve on ly t h e r igh t s specified in t h e licen se u n der wh ich t h e com m er cia l com pu t er soft wa r e or com m er cia l soft wa r e docu m en t a t ion wa s obt a in ed, a s set for t h in su bpa r a gr a ph (a ) of t h e Righ t s in Com m er cia l Com pu t er Soft wa r e or Com m er cia l Soft wa r e Docu m en t a t ion Cla u se a t DF ARS 227.7202-3, t h er efor e t h e r igh t s set for t h h er ein sh a ll a pply; a n d (b) F or a n y ot h er u n it or a gen cy: N OTICE : N ot wit h st a n din g a n y ot h er lea se or licen se a gr eem en t t h a t m a y per t a in t o, or a ccom pa n y t h e deliver y of, t h e com pu t er soft wa r e a n d a ccom pa n yin g docu m en t a t ion , t h e r igh t s of t h e Gover n m en t r ega r din g it s u se, r epr odu ct ion , a n d disclosu r e a r e a s set for t h in Cla u se 52.227-19 (c)(2) of t h e F AR. MATLAB, Sim u lin k, St a t eflow, H a n dle Gr a ph ics, a n d Rea l-Tim e Wor ksh op a r e r egist er ed t r a dem a r k s, a n d Ta r get La n gu a ge Com piler is a t r a dem a r k of Th e Ma t h Wor ks, In c. Ot h er pr odu ct or br a n d n a m es a r e t r a dem a r k s or r egist er ed t r a dem a r k s of t h eir r espect ive h older s.
P r in t in g H ist or y: Decem ber 1996 F ir st pr in t in g J a n u a r y 1998 Secon d pr in t in g J a n u a r y 1999 (On lin e on ly)
New for MATLAB 5.0 Revised for MATLAB 5.2 Revised for Ver sion 4.2 (Relea se 11)
Contents
B e fo re Yo u B e g in
S ig n a l P ro c e s s in g B a s ic s
S ig n a l P ro c e s s in g To o lbo x Ce n tra l F e a tu re s . . . . . . . . . . . . . . F ilt er in g a n d F F Ts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Sign a ls a n d Syst em s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Key Ar ea s: F ilt er Design a n d Spect r a l An a lysis . . . . . . . . . . . . Gr a ph ica l User In t er fa ce (GUI) . . . . . . . . . . . . . . . . . . . . . . . . . E xt en sibilit y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Re p re s e n tin g S ig n a ls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4 Vect or Repr esen t a t ion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4 Wa v e fo rm Ge n e ra tio n : Tim e Ve c to rs a n d S in u s o id s . . . . . . . 1-6 Com m on Sequ en ces: Un it Im pu lse, Un it St ep, a n d Un it Ra m p 1-7 Mu lt ich a n n el Sign a ls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7 Com m on P er iodic Wa vefor m s . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7 Com m on Aper iodic Wa vefor m s . . . . . . . . . . . . . . . . . . . . . . . . . . 1-8 Th e pu lst r a n F u n ct ion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9 Th e Sin c F u n ct ion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-10 Th e Dir ich let F u n ct ion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-11
Wo rk in g w it h D a t a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13 F ilte r Im p le m e n ta tio n a n d An a ly s is . . . . . . . . . . . . . . . . . . . . . . Con volu t ion a n d F ilt er in g . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F ilt er s a n d Tr a n sfer F u n ct ion s . . . . . . . . . . . . . . . . . . . . . . . . . F ilt er Coefficien t s a n d F ilt er Na m es . . . . . . . . . . . . . . . . . . F ilt er in g wit h t h e filt er F u n ct ion . . . . . . . . . . . . . . . . . . . . . . .
1-14 1-14 1-15 1-15 1-16
filt e r F u n c tio n Im p le m e n t a t io n a n d In itia l Co n d it io n s . . . 1-17 Oth e r F u n c tio n s fo r F ilt e rin g . . . . . . . . . . . . . . . . . . . . . . . . . . . . Mu lt ir a t e F ilt er Ba n k Im plem en t a t ion . . . . . . . . . . . . . . . . . . An t i-Ca u sa l, Zer o-P h a se F ilt er Im plem en t a t ion . . . . . . . . . . . F r equ en cy Dom a in F ilt er Im plem en t a t ion . . . . . . . . . . . . . . . .
1-19 1-19 1-20 1-22
Ze ro -P o le An a ly s is . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-30 Lin e a r S y s t e m Mo d e ls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Discr et e-Tim e Syst em Models . . . . . . . . . . . . . . . . . . . . . . . . . . Tr a n sfer F u n ct ion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Zer o-P ole-Ga in . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . St a t e-Spa ce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . P a r t ia l F r a ct ion E xpa n sion (Residu e F or m ) . . . . . . . . . . . . Secon d-Or der Sect ion s (SOS) . . . . . . . . . . . . . . . . . . . . . . . . La t t ice St r u ct u r e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Con volu t ion Ma t r ix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Con t in u ou s-Tim e Syst em Models . . . . . . . . . . . . . . . . . . . . . . . Lin ea r Syst em Tr a n sfor m a t ion s . . . . . . . . . . . . . . . . . . . . . . . .
1-32 1-32 1-32 1-33 1-34 1-35 1-36 1-37 1-39 1-40 1-41
ii
Con ten ts
F ilte r D e s ig n
F ilte r Re qu ire m e n ts a n d S p e c ific a tio n . . . . . . . . . . . . . . . . . . . . 2-2 IIR F ilte r D e s ig n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4 Cla ssica l IIR F ilt er Design Usin g An a log P r ot ot ypin g . . . . . . . 2-6 Com plet e Cla ssica l IIR F ilt er Design . . . . . . . . . . . . . . . . . . . 2-6 Design in g IIR F ilt er s t o F r equ en cy Dom a in Specifica t ion s . 2-7 Com pa r ison of Cla ssica l IIR F ilt er Types . . . . . . . . . . . . . . . . . . 2-8 Bu t t er wor t h F ilt er . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8 Ch ebysh ev Type I F ilt er . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9 Ch ebysh ev Type II F ilt er . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10 E llipt ic F ilt er . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10 Bessel F ilt er . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-11 Dir ect IIR F ilt er Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-13 Gen er a lized Bu t t er wor t h F ilt er Design . . . . . . . . . . . . . . . . 2-14 F IR F ilte r D e s ig n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Lin ea r P h a se F ilt er s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Win dowin g Met h od . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . St a n da r d Ba n d F IR F ilt er Design : fir 1 . . . . . . . . . . . . . . . . Mu lt iba n d F IR F ilt er Design : fir 2 . . . . . . . . . . . . . . . . . . . . Mu lt iba n d F IR F ilt er Design wit h Tr a n sit ion Ba n ds . . . . . . . Ba sic Con figu r a t ion s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Th e Weigh t Vect or . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . An t i-Sym m et r ic F ilt er s / H ilber t Tr a n sfor m er s . . . . . . . . . . Differ en t ia t or s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Con st r a in ed Lea st Squ a r es F IR F ilt er Design . . . . . . . . . . . . . Ba sic Lowpa ss a n d H igh pa ss CLS F ilt er Design . . . . . . . . . Mu lt iba n d CLS F ilt er Design . . . . . . . . . . . . . . . . . . . . . . . . Weigh t ed CLS F ilt er Design . . . . . . . . . . . . . . . . . . . . . . . . .
2-16 2-17 2-18 2-20 2-21 2-22 2-22 2-24 2-25 2-26 2-27 2-28 2-29 2-30
i ii
Ar bit r a r y-Respon se F ilt er Design . . . . . . . . . . . . . . . . . . . . . . . 2-31 Mu lt iba n d F ilt er Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-32 F ilt er Design wit h Redu ced Dela y . . . . . . . . . . . . . . . . . . . . 2-34 S p e c ia l To p ic s in IIR F ilte r D e s ig n An a log P r ot ot ype Design . . . . . . . . . F r equ en cy Tr a n sfor m a t ion . . . . . . . F ilt er Discr et iza t ion . . . . . . . . . . . . . Im pu lse In va r ia n ce . . . . . . . . . . . Bilin ea r Tr a n sfor m a t ion . . . . . . . ....................... .................... .................... .................... .................... ....................
2-37 2-38 2-38 2-41 2-42 2-43
. . . . .
Re fe re n c e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-46
S ta tis t ic a l S ig n a l P ro c e s s in g
Co rre la tio n a n d Co v a ria n c e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2 Bia s a n d Nor m a liza t ion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3 Mu lt iple Ch a n n els . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4 S p e c tra l An a ly s is . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5 Welch s Met h od . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6 P ower Spect r a l Den sit y F u n ct ion . . . . . . . . . . . . . . . . . . . . . 3-10 Bia s a n d Nor m a liza t ion in Welch s Met h od . . . . . . . . . . . . . 3-12 Cr oss-Spect r a l Den sit y F u n ct ion . . . . . . . . . . . . . . . . . . . . . 3-14 Con fiden ce In t er va ls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-14 Tr a n sfer F u n ct ion E st im a t e . . . . . . . . . . . . . . . . . . . . . . . . . 3-14 Coh er en ce F u n ct ion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-15 Mu lt it a per Met h od . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-16 Yu le-Wa lker AR Met h od . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-19 Bu r g Met h od . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-20 Cova r ia n ce a n d Modified Cova r ia n ce Met h ods . . . . . . . . . . . . 3-22 MUSIC a n d E igen vect or An a lysis Met h ods . . . . . . . . . . . . . . . 3-23 E igen a n a lysis Over view . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-24 Con t r ollin g Su bspa ce Th r esh olds . . . . . . . . . . . . . . . . . . . . . 3-25
iv
Con ten ts
Re fe re n c e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-27
S p e c ia l To p ic s
Win d o w s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Ba sic Sh a pes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Gen er a lized Cosin e Win dows . . . . . . . . . . . . . . . . . . . . . . . . . . . Ka iser Win dow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Ka iser Win dows in F IR Design . . . . . . . . . . . . . . . . . . . . . . . . Ch ebysh ev Win dow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . P a ra m e tric Mo d e lin g . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Tim e-Dom a in Ba sed Modelin g . . . . . . . . . . . . . . . . . . . . . . . . . Lin ea r P r edict ion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . P r on ys Met h od (ARMA Modelin g) . . . . . . . . . . . . . . . . . . . . St eiglit z-McBr ide Met h od (ARMA Modelin g) . . . . . . . . . . . F r equ en cy-Dom a in Ba sed Modelin g . . . . . . . . . . . . . . . . . . . . .
Re s a m p lin g . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-20 Ce p s tru m An a ly s is . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-23 In ver se Com plex Cepst r u m . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-25 F F T-B a s e d Tim e -F re qu e n c y An a ly s is . . . . . . . . . . . . . . . . . . . . . 4-27 Me d ia n F ilte rin g . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-28 Co m m u n ic a tio n s Ap p lic a t io n s . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-29 D e c o n v o lu t io n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-33 S p e c ia lize d Tra n s fo rm s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Ch ir p z-Tr a n sfor m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Discr et e Cosin e Tr a n sfor m . . . . . . . . . . . . . . . . . . . . . . . . . . . . H ilber t Tr a n sfor m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4-34 4-34 4-36 4-38
Re fe re n c e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-40
In te ra c tiv e To o ls
S P To o l: An In te ra c tiv e S ig n a l P ro c e s s in g En v iro n m e n t . . . 5-2 Over view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2 U s in g S P To o l . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3 Open in g SP Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3 Qu ick St a r t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3 E xa m ple: Im por t in g Sign a l Da t a fr om a MAT-F ile . . . . . . . . 5-3 Ba sic SP Tool F u n ct ion s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-5 F ile Men u . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-6 H elp Men u . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-6 Im por t in g Sign a ls, F ilt er s, a n d Spect r a . . . . . . . . . . . . . . . . . . . 5-7 Loa din g Va r ia bles fr om t h e MATLAB Wor kspa ce . . . . . . . . 5-7 Loa din g Va r ia bles fr om Disk . . . . . . . . . . . . . . . . . . . . . . . . . 5-8 Im por t in g Wor kspa ce Con t en t s a n d F ile Con t en t s . . . . . . . . 5-8 Wor kin g wit h Sign a ls, F ilt er s, a n d Spect r a . . . . . . . . . . . . . . . 5-13 Com pon en t List s in SP Tool . . . . . . . . . . . . . . . . . . . . . . . . . . 5-14 Select in g Da t a Object s in SP Tool . . . . . . . . . . . . . . . . . . . . . 5-15 E dit in g Da t a Object s in SP Tool . . . . . . . . . . . . . . . . . . . . . . 5-15 Viewin g a Sign a l . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17 Viewin g a F ilt er . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17 Design in g a F ilt er . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17 Applyin g a F ilt er . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18 Cr ea t in g a Spect r u m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19 Viewin g a Spect r u m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19 Upda t in g a Spect r u m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19
vi
Con ten ts
Cu st om izin g P r efer en ces . . . . . . . . . . . . . . . . . . . . Ru ler Set t in gs . . . . . . . . . . . . . . . . . . . . . . . . . . Color Set t in gs . . . . . . . . . . . . . . . . . . . . . . . . . . . Sign a l Br owser Set t in gs . . . . . . . . . . . . . . . . . . Spect r u m Viewer Set t in gs . . . . . . . . . . . . . . . . . F ilt er Viewer Set t in gs . . . . . . . . . . . . . . . . . . . . F ilt er Viewer Tilin g Set t in gs . . . . . . . . . . . . . . F ilt er Design er Set t in gs . . . . . . . . . . . . . . . . . . Defa u lt Session Set t in g . . . . . . . . . . . . . . . . . . . E xpor t in g Com pon en t s Set t in g . . . . . . . . . . . . . P lu g-In s Set t in g . . . . . . . . . . . . . . . . . . . . . . . . . Sa vin g a n d Disca r din g Ch a n ges t o P r efer en ces Con t r ols for Viewin g a n d Mea su r in g . . . . . . . . . . Zoom Con t r ols . . . . . . . . . . . . . . . . . . . . . . . . . . Ru ler Con t r ols . . . . . . . . . . . . . . . . . . . . . . . . . . Ma k in g Sign a l Mea su r em en t s . . . . . . . . . . . . .
......... ......... ......... ......... ......... ......... ......... ......... ......... ......... ......... Set t in gs . ......... ......... ......... .........
. . . . . . . . . . . . . . . .
5-20 5-21 5-22 5-23 5-24 5-25 5-26 5-27 5-28 5-29 5-30 5-30 5-31 5-31 5-33 5-37 5-43 5-43 5-44 5-45 5-46 5-46 5-46 5-47 5-47 5-48 5-49 5-49 5-49 5-52 5-53 5-54 5-54 5-57
U s in g t h e S ig n a l B ro w s e r: In te ra c tiv e S ig n a l An a ly s is . . . Open in g t h e Sign a l Br owser . . . . . . . . . . . . . . . . . . . . . . . . . . . Ba sic Sign a l Br owser F u n ct ion s . . . . . . . . . . . . . . . . . . . . . . . . Men u s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Zoom Con t r ols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Ru ler a n d Lin e Displa y Con t r ols . . . . . . . . . . . . . . . . . . . . . H elp Bu t t on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Displa y Ma n a gem en t Con t r ols . . . . . . . . . . . . . . . . . . . . . . . Ma in Axes Displa y Ar ea . . . . . . . . . . . . . . . . . . . . . . . . . . . . P a n n er . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Ma k in g Sign a l Mea su r em en t s . . . . . . . . . . . . . . . . . . . . . . . Viewin g a n d E xplor in g Sign a ls . . . . . . . . . . . . . . . . . . . . . . . . . Select in g a n d Displa yin g a Sign a l . . . . . . . . . . . . . . . . . . . . P a n n er Displa y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Ma n ipu la t in g Displa ys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Wor kin g wit h Sign a ls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . P r in t in g Sign a l Da t a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Sa vin g Sign a l Da t a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
v ii
Ba sic F ilt er Design er F u n ct ion s . . . . . . . . . . . . . . . . . . . . . . . . Men u s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F ilt er P op-Up Men u . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Zoom Con t r ols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . H elp Bu t t on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Gen er a l Con t r ols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F ilt er Specifica t ion s P a n elDesign Met h ods . . . . . . . . . . . F ilt er Mea su r em en t s P a n elDesign Met h ods . . . . . . . . . . F ilt er Specifica t ion s P a n elP ole/Zer o E dit or . . . . . . . . . . . F ilt er Mea su r em en t s P a n elP ole/Zer o E dit or . . . . . . . . . . Ma gn it u de P lot (Displa y) Ar ea Design Met h ods . . . . . . . . Ma gn it u de P lot (Displa y) Ar ea P ole/Zer o E dit or . . . . . . . . Design in g F in it e Im pu lse Respon se (F IR) F ilt er s . . . . . . . . . . E xa m ple: F IR F ilt er Design , St a n da r d Ba n d Con figu r a t ion F ilt er Design Opt ion s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Or der Select ion for F IR F ilt er Design . . . . . . . . . . . . . . . . . Design in g In fin it e Im pu lse Respon se (IIR) F ilt er s . . . . . . . . . E xa m ple: Cla ssica l IIR F ilt er Design . . . . . . . . . . . . . . . . . . F ilt er Design Opt ion s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Or der Select ion for IIR F ilt er Design . . . . . . . . . . . . . . . . . . Redesign in g a F ilt er Usin g t h e Ma gn it u de P lot . . . . . . . . . . . . Sa vin g F ilt er Da t a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Viewin g F r equ en cy Respon se P lot s . . . . . . . . . . . . . . . . . . . . . . U s in g t h e F ilte r Vie w e r: In te ra c tiv e Open in g t h e F ilt er Viewer . . . . . . . . . Ba sic F ilt er Viewer F u n ct ion s . . . . . . Men u s . . . . . . . . . . . . . . . . . . . . . . . F ilt er Iden t ifica t ion P a n el . . . . . . . P lot s P a n el . . . . . . . . . . . . . . . . . . . F r equ en cy Axis Set t in gs . . . . . . . . Zoom Con t r ols . . . . . . . . . . . . . . . . H elp Bu t t on . . . . . . . . . . . . . . . . . . Ma in P lot s Ar ea . . . . . . . . . . . . . . . F ilt e r An a ly s is . . . . . . .................... .................... .................... .................... .................... .................... .................... .................... ....................
5-60 5-60 5-60 5-61 5-61 5-62 5-63 5-65 5-66 5-68 5-69 5-71 5-73 5-73 5-75 5-75 5-76 5-76 5-77 5-78 5-78 5-79 5-82 5-84 5-84 5-84 5-86 5-86 5-86 5-87 5-87 5-87 5-88
v ii i Con ten ts
Viewin g F ilt er P lot s . . . . . . . . . . . Viewin g Ma gn it u de Respon se . Viewin g P h a se Respon se . . . . . Viewin g Gr ou p Dela y . . . . . . . . Viewin g a Zer o-P ole P lot . . . . . Viewin g Im pu lse Respon se . . . Viewin g St ep Respon se . . . . . .
. . . . . . .
U s in g t h e S p e c tru m Vie w e r: In te ra c t iv e P S D An a ly s is . . . 5-97 Open in g t h e Spect r u m Viewer . . . . . . . . . . . . . . . . . . . . . . . . . 5-97 Ba sic Spect r u m Viewer F u n ct ion s . . . . . . . . . . . . . . . . . . . . . . 5-98 Men u s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-99 Sign a l ID P a n el . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-100 Spect r u m Ma n a gem en t Bu t t on s . . . . . . . . . . . . . . . . . . . . . 5-100 Zoom Con t r ols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-101 Ru ler a n d Lin e Displa y Con t r ols . . . . . . . . . . . . . . . . . . . . 5-101 H elp Bu t t on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-101 Ma in Axes Displa y Ar ea . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-101 Ma k in g Spect r u m Mea su r em en t s . . . . . . . . . . . . . . . . . . . . 5-102 Viewin g Spect r a l Den sit y P lot s . . . . . . . . . . . . . . . . . . . . . . . . 5-102 Con t r ollin g a n d Ma n ipu la t in g P lot s . . . . . . . . . . . . . . . . . . . . 5-102 Ch a n gin g P lot P r oper t ies . . . . . . . . . . . . . . . . . . . . . . . . . . 5-102 Ch oosin g Com pu t a t ion P a r a m et er s . . . . . . . . . . . . . . . . . . 5-103 Com pu t a t ion Met h ods a n d P a r a m et er s . . . . . . . . . . . . . . . 5-104 Set t in g Con fiden ce In t er va ls . . . . . . . . . . . . . . . . . . . . . . . . 5-107 P r in t in g Spect r u m Da t a . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-107 Sa vin g Spect r u m Da t a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-110 Ex a m p le : Ge n e ra tio n o f B a n d lim ite d N o is e . . . . . . . . . . . . . . Cr ea t e, Im por t , a n d Na m e a Sign a l . . . . . . . . . . . . . . . . . . . . Design a F ilt er . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Apply t h e F ilt er t o a Sign a l . . . . . . . . . . . . . . . . . . . . . . . . . . . View, P la y, a n d P r in t t h e Sign a ls . . . . . . . . . . . . . . . . . . . . . . Com pa r e Spect r a of Bot h Sign a ls . . . . . . . . . . . . . . . . . . . . . .
5-113 5-113 5-115 5-116 5-117 5-120
Re fe re n c e
ix
Con ten ts
or by open in g t h e M-file in t h e MATLAB E dit or /Debu gger . You ca n ch a n ge t h e wa y a n y t oolbox fu n ct ion wor ks by copyin g a n d r en a m in g t h e M-file, t h en m odifyin g you r copy. You ca n a lso ext en d t h e t oolbox by a ddin g you r own M-files. Secon d, t h e t oolbox pr ovides a n u m ber of in t er a ct ive t ools t h a t let you a ccess m a n y of t h e fu n ct ion s t h r ou gh a graph ical u ser in terface (GUI). Th e GUI-ba sed t ools pr ovide a n in t egr a t ed en vir on m en t for filt er design , a n a lysis, a n d im plem en t a t ion , a s well a s sign a l explor a t ion a n d edit in g. F or exa m ple, wit h t h e gr a ph ica l u ser in t er fa ce t ools you ca n : Use t h e m ou se t o gr a ph ica lly edit t h e m a gn it u de r espon se of a filt er or m ea su r e t h e slope of a sign a l wit h on scr een r u ler s. P la y a sign a l on you r syst em s a u dio h a r dwa r e by select in g a m en u it em or pr essin g a cor r espon din g keyst r oke com bin a t ion . Cu st om ize t h e pa r a m et er s a n d m et h od of com pu t in g t h e spect r u m of a sign a l.
x ii
Wh en you feel com for t a ble wit h t h e ba sic fu n ct ion s, m ove on t o Ch a pt er 2 a n d Ch a pt er 3 for a m or e in -dept h in t r odu ct ion t o u sin g t h e Sign a l P r ocessin g Toolbox: Ch a pt er 2, F ilt er Design , for a det a iled expla n a t ion of u sin g t h e Sign a l P r ocessin g Toolbox in in fin it e im pu lse r espon se (IIR) a n d fin it e im pu lse r espon se (F IR) filt er design a n d im plem en t a t ion , in clu din g specia l t opics in IIR filt er design . Ch a pt er 3, St a t ist ica l Sign a l P r ocessin g, for h ow t o u se t h e cor r ela t ion , cova r ia n ce, a n d spect r a l a n a lysis t ools t o est im a t e im por t a n t fu n ct ion s of discr et e r a n dom sign a ls. On ce you u n der st a n d t h e gen er a l pr in ciples a n d a pplica t ion s of t h e t oolbox, lea r n h ow t o u se t h e in t er a ct ive t ools. Ch a pt er 5, In t er a ct ive Tools, for a n over view of t h e in t er a ct ive GUI en vir on m en t a n d exa m ples of h ow t o u se it for sign a l explor a t ion , filt er design a n d im plem en t a t ion , a n d spect r a l a n a lysis. F in a lly, see t h e followin g ch a pt er for a discu ssion of specia lized t oolbox fu n ct ion s. Ch a pt er 4, Specia l Topics, for specia lized fu n ct ion s, in clu din g filt er win dows, pa r a m et r ic m odelin g, r esa m plin g, cepst r u m a n a lysis, t im e-depen den t F ou r ier t r a n sfor m s a n d spect r ogr a m s, m edia n filt er in g, com m u n ica t ion s a pplica t ion s, decon volu t ion , a n d specia lized t r a n sfor m s.
If you are an experienced toolbox user. See Ch a pt er 5, In t er a ct ive Tools, for a n over view of t h e in t er a ct ive GUI en vir on m en t a n d exa m ples of h ow t o u se it for sign a l viewin g, filt er design a n d im plem en t a t ion , a n d spect r a l a n a lysis.
x iii
All toolbox users. Use Ch a pt er 6, Refer en ce, for loca t in g in for m a t ion on specific fu n ct ion s. Refer en ce descr ipt ion s in clu de a syn opsis of t h e fu n ct ion s syn t a x, a s well a s a com plet e expla n a t ion of opt ion s a n d oper a t ion s. Ma n y r efer en ce descr ipt ion s a lso in clu de h elpfu l exa m ples, a descr ipt ion of t h e fu n ct ion s a lgor it h m , a n d r efer en ces t o a ddit ion a l r ea din g m a t er ia l.
Use t h is m a n u a l in con ju n ct ion wit h t h e soft wa r e t o lea r n a bou t t h e power fu l fea t u r es t h a t MATLAB pr ovides. E a ch ch a pt er pr ovides n u m er ou s exa m ples t h a t a pply t h e t oolbox t o r epr esen t a t ive sign a l pr ocessin g t a sk s. Som e exa m ples u se MATLABs r a n dom n u m ber gen er a t ion fu n ct ion randn. In t h ese ca ses, t o du plica t e t h e r esu lt s in t h e exa m ple, t ype
randn('seed',0)
x iv
Installation
Installation
To in st a ll t h is t oolbox on a wor kst a t ion , see t h e M AT L AB In stallation Gu id e for UN IX . To in st a ll t h e t oolbox on a P C, see t h e M AT L AB PC In stallation Gu id e. To det er m in e if t h e Sign a l P r ocessin g Toolbox is a lr ea dy in st a lled on you r syst em , ch eck for a su bdir ect or y n a m ed signal wit h in t h e m a in t oolbox dir ect or y or folder .
xv
Typographical Conventions
To Indicate This Manual Uses Monospace type. Example
E xa m ple code
To a ssign t h e va lu e 5 t o A, en t er
A = 5
MATLAB ou t pu t
Monospace type.
F u n ct ion n a m es
Monospace type.
Th e cos fu n ct ion fin ds t h e cosin e of ea ch a r r a y elem en t . An array is a n or der ed collect ion of in for m a t ion . P r ess t h e Re tu rn key. Ch oose t h e F ile m en u .
New t er m s
Italics.
xvi
Typographical Conventions
Technical Notations
Th is m a n u a l a n d t h e Sign a l P r ocessin g Toolbox fu n ct ion s u se t h e followin g t ech n ica l n ot a t ion s: Nyqu ist fr equ en cy
x(1)
On e-h a lf t h e sa m plin g fr equ en cy. Most t oolbox fu n ct ion s n or m a lize t h is va lu e t o 1. Th e fir st elem en t of a da t a sequ en ce or filt er, cor r espon din g t o zer o la g. An a log fr equ en cy in r a dia n s per secon d. Digit a l fr equ en cy in r a dia n s per secon d. Digit a l fr equ en cy in H er t z. Th e in t er va l fr om x t o y, in clu din g x bu t n ot in clu din g y
" # or w f
[x , y )
x v ii
x v iii
1
Sign a l P r ocessin g Ba sics
S ig n a l P ro c e s s in g To o lbo x Ce n tra l F e a tu re s . . . . . . . . . . . 1-2 Re p re s e n tin g S ig n a ls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4 Wa v e fo rm Ge n e ra tio n : Tim e Ve c to rs a n d S in u s o id s . . . . 1-6 Wo rk in g w ith D a ta . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13 F ilte r Im p le m e n ta tio n a n d An a ly s is . . . . . . . . . . . . . . . . . . 1-14 filt e r F u n c t io n Im p le m e n t a tio n a n d In it ia l Co n d itio n s . 1-17 Ot h e r F u n c t io n s fo r F ilte rin g . . . . . . . . . . . . . . . . . . . . . . . . 1-19 Im p u ls e Re s p o n s e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-23 F re qu e n c y Re s p o n s e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-24 Ze ro -P o le An a ly s is . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-30 Lin e a r S y s te m Mo d e ls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-32 D is c re te F o u rie r Tra n s fo rm . . . . . . . . . . . . . . . . . . . . . . . . . 1-43 Re fe re n c e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-46
1-2
Extensibility
P er h a ps t h e m ost im por t a n t fea t u r e of t h e MATLAB en vir on m en t is t h a t it is ext en sible: MATLAB let s you cr ea t e you r own M-files t o m eet n u m er ic com pu t a t ion n eeds for r esea r ch , design , or en gin eer in g of sign a l pr ocessin g syst em s. Sim ply copy t h e M-files pr ovided wit h t h e Sign a l P r ocessin g Toolbox a n d m odify t h em a s n eeded, or cr ea t e n ew fu n ct ion s t o expa n d t h e fu n ct ion a lit y of t h e t oolbox.
1-3
Representing Signals
Th e cen t r a l da t a con st r u ct in MATLAB is t h e n u m eric array , a n or der ed collect ion of r ea l or com plex n u m er ic da t a wit h t wo or m or e dim en sion s. Th e ba sic da t a object s of sign a l pr ocessin g (on e-dim en sion a l sign a ls or sequ en ces, m u lt ich a n n el sign a ls, a n d t wo-dim en sion a l sign a ls) a r e a ll n a t u r a lly su it ed t o a r r a y r epr esen t a t ion .
Vector Representation
MATLAB r epr esen t s or din a r y on e-dim en sion a l sa m pled da t a sign a ls, or sequ en ces, a s vectors . Vect or s a r e 1-by-n or n -by-1 a r r a ys, wh er e n is t h e n u m ber of sa m ples in t h e sequ en ce. On e wa y t o in t r odu ce a sequ en ce in t o MATLAB is t o en t er it a s a list of elem en t s a t t h e com m a n d pr om pt . Th e st a t em en t
x = [4 3 7 9 1]
cr ea t es a sim ple five-elem en t r ea l sequ en ce in a r ow vect or . Tr a n sposit ion t u r n s t h e sequ en ce in t o a colu m n vect or
x = x'
r esu lt in g in
x = 4 3 7 9 1
Colu m n or ien t a t ion is pr efer a ble for sin gle ch a n n el sign a ls beca u se it ext en ds n a t u r a lly t o t h e m u lt ich a n n el ca se. F or m u lt ich a n n el da t a , ea ch colu m n of a m a t r ix r epr esen t s on e ch a n n el. E a ch r ow of su ch a m a t r ix t h en cor r espon ds t o a sa m ple poin t . A t h r ee-ch a n n el sign a l t h a t con sist s of x, 2x, a n d x/$ is
y = [x 2*x x/pi]
1-4
Representing Signals
Th is r esu lt s in
y = 4.0000 3.0000 7.0000 9.0000 1.0000 8.0000 6.0000 14.0000 18.0000 2.0000 1.2732 0.9549 2.2282 2.8648 0.3183
1-5
wh er e MATLABs colon oper a t or cr ea t es a 1001-elem en t r ow vect or t h a t r epr esen t s t im e r u n n in g fr om zer o t o on e secon d in st eps of on e m illisecon d. Th e t r a n spose oper a t or (') ch a n ges t h e r ow vect or in t o a colu m n ; t h e sem icolon (;) t ells MATLAB t o com pu t e bu t n ot displa y t h e r esu lt . Given t you ca n cr ea t e a sa m ple sign a l y con sist in g of t wo sin u soids, on e a t 50 H z a n d on e a t 120 H z wit h t wice t h e a m plit u de:
y = sin(2*pi*50*t) + 2*sin(2*pi*120*t);
Th e n ew va r ia ble y, for m ed fr om vect or t, is a lso 1001 elem en t s lon g. You ca n a dd n or m a lly dist r ibu t ed wh it e n oise t o t h e sign a l a n d gr a ph t h e fir st fift y poin t s u sin g
yn = y + 0.5*randn(size(t)); plot(t(1:50),yn(1:50))
4 3 2 1 0 -1 -2 -3 -4
0.01
0.02
0.03
0.04
0.05
1-6
Multichannel Signals
Use st a n da r d MATLAB a r r a y syn t a x t o wor k wit h m u lt ich a n n el sign a ls. F or exa m ple, a m u lt ich a n n el sign a l con sist in g of t h e la st t h r ee sign a ls gen er a t ed a bove is
z = [t t.^2 square(4*t)];
You ca n gen er a t e a m u lt ich a n n el u n it sa m ple fu n ct ion u sin g t h e ou t er pr odu ct oper a t or . F or exa m ple, a six-elem en t colu m n vect or wh ose fir st elem en t is on e, a n d wh ose r em a in in g five elem en t s a r e zer os, is
a = [1 zeros(1,5)]';
To du plica t e colu m n vect or a in t o a m a t r ix wit h ou t per for m in g a n y m u lt iplica t ion , u se MATLABs colon oper a t or a n d t h e ones fu n ct ion .
c = a(:,ones(1,3));
1-7
sawtooth gen er a t es a sa wt oot h wa ve wit h pea k s a t 1 a n d a per iod of 2 $. An opt ion a l width pa r a m et er specifies a fr a ct ion a l m u lt iple of 2 $ a t wh ich t h e sign a ls m a xim u m occu r s. square gen er a t es a squ a r e wa ve wit h a per iod of 2 $. An opt ion a l pa r a m et er specifies d u ty cycle, t h e per cen t of t h e per iod for wh ich t h e sign a l is posit ive. To gen er a t e 1.5 secon ds of a 50 H z sa wt oot h wa ve wit h a sa m ple r a t e of 10 k H z a n d plot 0.2 secon ds of t h e gen er a t ed wa vefor m , u se
Fs = 10000; t = 0:1/Fs:1.5; x = sawtooth(2*pi*50*t); plot(t,x), axis([0 0.2 1 1])
1
0.5
-0.5
-1 0
0.02
0.04
0.06
0.08
0.1
0.12
0.14
0.16
0.18
0.2
1-8
r et u r n in -ph a se a n d qu a dr a t u r e pu lses, t h e RF sign a l en velope, a n d t h e cu t off t im e for t h e t r a ilin g pu lse en velope. chirp gen er a t es a lin ea r swept -fr equ en cy cosin e sign a l. An opt ion a l pa r a m et er specifies a lt er n a t ive sweep m et h ods. An opt ion a l pa r a m et er phi a llows in it ia l ph a se t o be specified in degr ees. To com pu t e 2 secon ds of a lin ea r ch ir p sign a l wit h a sa m ple r a t e of 1 kH z, t h a t st a r t s a t DC a n d cr osses 150 H z a t 1 secon d, u se
t = 0:1/1000:2; y = chirp(t,0,1,150);
Frequency
0.2
0.4
0.6
0.8 Time
1.2
1.4
1.6
1-9
of 10 m s, a n d a pu lse r epet it ion r a t e of 1 kH z; D specifies t h e dela y t o ea ch pu lse r epet it ion in colu m n 1 a n d a n opt ion a l a t t en u a t ion for ea ch r epet it ion in colu m n 2. Th e pu lse t r a in is con st r u ct ed by pa ssin g t h e n a m e of t h e gauspuls fu n ct ion t o pulstran, a lon g wit h a ddit ion a l pa r a m et er s t h a t specify a 10 k H z Ga u ssia n pu lse wit h 50% ba n dwidt h :
T = 0:1/50E3:10E-3; D = [0:1/1E3:10E-3;0.8.^(0:10)]'; Y = pulstran(T,D,'gauspuls',10E3,0.5); plot(T,Y)
1 0.8 0.6 0.4 0.2 0 -0.2 -0.4 -0.6 -0.8
0.001
0.002
0.003
0.004
0.005
0.006
0.007
0.008
0.009
0.01
1-10
To plot t h e sin c fu n ct ion for a lin ea r ly spa ced vect or wit h va lu es r a n gin g fr om 5 t o 5,
x = linspace(5,5); y = sinc(x); plot(x,y)
1
0.8
0.6
0.4
0.2
-0.2
-0.4 -5
-4
-3
-2
-1
wh er e n is a u ser -specified posit ive in t eger . F or n odd, t h e Dir ich let fu n ct ion h a s a per iod of 2 $; for n even , it s per iod is 4 $. Th e m a gn it u de of t h is fu n ct ion is (1/n ) t im es t h e m a gn it u de of t h e discr et e-t im e F ou r ier t r a n sfor m of t h e n -poin t r ect a n gu la r win dow.
1-11
1-12
1-13
NOTE Con volve r ect a n gu la r m a t r ices for t wo-dim en sion a l sign a l pr ocessin g u sin g t h e conv2 fu n ct ion .
y (n ) = h (n ) ) x (n ) =
h (n m ) x (m )
m = *
If a digit a l filt er s im pu lse r espon se h (n ) is fin it e len gt h , a n d t h e in pu t x (n ) is a lso fin it e len gt h , you ca n im plem en t t h e filt er u sin g conv. St or e x (n ) in a vect or x, h (n ) in a vect or h, a n d con volve t h e t wo.
x = randn(5,1); h = [1 1 1 1]/4; y = conv(h,x); % a random vector of length 5 % length 4 averaging filter
1-14
MATLAB st or es t h e coefficien t s in t wo vect or s, on e for t h e n u m er a t or a n d on e for t h e den om in a t or . By con ven t ion , MATLAB u ses r ow vect or s for filt er coefficien t s.
1-15
wh er e t h e vect or s b a n d a r epr esen t t h e coefficien t s of a filt er in t r a n sfer fu n ct ion for m . To a pply t h is filt er t o you r da t a
y = filter(b,a,x); filter gives you a s m a n y ou t pu t sa m ples a s t h er e a r e in pu t sa m ples, t h a t is, t h e len gt h of y is t h e sa m e a s t h e len gt h of x. If t h e fir st elem en t of a is n ot 1, filter divides t h e coefficien t s by a(1) befor e im plem en t in g t h e differ en ce equ a t ion .
1-16
wh er e n -1 is t h e filt er or der . Th is is a ca n on ica l for m t h a t h a s t h e m in im u m n u m ber of dela y elem en t s. At sa m ple m , filter com pu t es t h e differ en ce equ a t ion s y (m ) = b (1 ) x (m ) + z 1 (m 1 ) z 1 (m ) = b (2 ) x (m ) + z 2 (m 1 ) a (2 ) y (m ) M zn zn
2 (m ) 1 (m )
M
1 (m
= b (n 1 ) x (m ) + z n
1 ) a (n 1 ) y (m )
= b (n ) x (m ) a (n ) y (m )
In it s m ost ba sic for m , filter in it ia lizes t h e dela y ou t pu t s z i (1), i = 1, ..., n -1 t o 0. Th is is equ iva len t t o a ssu m in g bot h pa st in pu t s a n d ou t pu t s a r e zer o. Set t h e in it ia l dela y ou t pu t s u sin g a fou r t h in pu t pa r a m et er t o filter, or a ccess t h e fin a l dela y ou t pu t s u sin g a secon d ou t pu t pa r a m et er .
[y,zf] = filter(b,a,x,zi)
Access t o in it ia l a n d fin a l con dit ion s is u sefu l for filt er in g da t a in sect ion s, especia lly if m em or y lim it a t ion s a r e a con sider a t ion . Su ppose you h a ve collect ed da t a in t wo segm en t s of 5000 poin t s ea ch .
x1 = randn(5000,1); x2 = randn(5000,1); % two random sequences to % serve as simulated data
P er h a ps t h e fir st sequ en ce, x1, cor r espon ds t o t h e fir st 10 m in u t es of da t a a n d t h e secon d, x2, t o a n a ddit ion a l 10 m in u t es. Th e wh ole sequ en ce is x = [x1; x2]. If t h er e is n ot su fficien t m em or y t o h old t h e com bin ed sequ en ce,
1-17
filt er t h e su bsequ en ces x1 a n d x2 on e a t a t im e. To en su r e con t in u it y of t h e filt er ed sequ en ces, u se t h e fin a l con dit ion s fr om x1 a s in it ia l con dit ion s t o filt er x2.
[y1,zf] = filter(b,a,x1); y2 = filter(b,a,x2,zf);
Th e filtic fu n ct ion gen er a t es in it ia l con dit ion s for filter. filtic com pu t es t h e dela y vect or t o m a ke t h e beh a vior of t h e filt er r eflect pa st in pu t s a n d ou t pu t s t h a t you specify. To obt a in t h e sa m e ou t pu t dela y va lu es zf a s a bove u sin g filtic
zf = filtic(b,a,flipud(y1),flipud(x1));
Th is ca n be u sefu l wh en filt er in g sh or t da t a sequ en ces, a s a ppr opr ia t e in it ia l con dit ion s h elp r edu ce t r a n sien t st a r t u p effect s.
1-18
x(n)
FIR H
y(n)
F or exa m ple, t o ch a n ge t h e sa m ple r a t e of a sign a l fr om 44.1 k H z t o 48 k H z, we fir st fin d t h e sm a llest in t eger con ver sion r a t io p/q.
d = gcd(48000,44100); p = 48000/d; q = 44100/d;
wh er e we fin d t h a t p = 160 a n d q = 147. Sa m ple r a t e con ver sion is t h en a ccom plish ed by y = upfirdn(x,h,p,q). Th is ca sca de of oper a t ion s is im plem en t ed in a n efficien t m a n n er u sin g polyph a se filt er in g t ech n iqu es, a n d it is a cen t r a l con cept of m u lt ir a t e filt er in g (see r efer en ce [1] for det a ils on m u lt ir a t e filt er t h eor y). Not e t h a t t h e qu a lit y of t h e r esa m plin g r esu lt r elies on t h e qu a lit y of t h e F IR filt er h. F ilt er ba n ks m a y be im plem en t ed u sin g upfirdn by a llowin g t h e filt er h t o be a m a t r ix, wit h on e F IR filt er per colu m n . A sign a l vect or is pa ssed in depen den t ly t h r ou gh ea ch F IR filt er , r esu lt in g in a m a t r ix of ou t pu t sign a ls. Ot h er fu n ct ion s t h a t per for m m u lt ir a t e filt er in g (wit h fixed filt er ) in clu de resample, interp, a n d decimate.
1-19
X(1/z)H(1/z)
Wh en | z | = 1, t h a t is z = ej#, t h e ou t pu t r edu ces t o X (ej#)| H (ej#)| 2 . Given a ll t h e sa m ples of t h e sequ en ce x (n ), a dou bly filt er ed ver sion of x t h a t h a s zer o-ph a se dist or t ion is possible. F or exa m ple, a on e-secon d du r a t ion sign a l sa m pled a t 100 H z, com posed of t wo sin u soida l com pon en t s a t 3 H z a n d 40 H z, is
Fs = 100; t = 0:1/Fs:1; x = sin(2*pi*t*3)+.25*sin(2*pi*t*40);
1-20
Now cr ea t e a 10-poin t a ver a gin g F IR filt er , a n d filt er x u sin g bot h filter a n d filtfilt for com pa r ison :
b = ones(1,10)/10; y = filtfilt(b,1,x); yy = filter(b,1,x); plot(t,x,t,y,'--',t,yy,':')
1.5
0.5
-0.5
-1
-1.5 0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
Bot h filt er ed ver sion s elim in a t e t h e 40 H z sin u soid eviden t in t h e or igin a l, solid lin e. Th e plot a lso sh ows h ow filter a n d filtfilt differ ; t h e da sh ed (filtfilt) lin e is in ph a se wit h t h e or igin a l 3 H z sin u soid, wh ile t h e dot t ed (filter) lin e is dela yed by a bou t five sa m ples. Also, t h e a m plit u de of t h e da sh ed lin e is sm a ller du e t o t h e m a gn it u de squ a r ed effect s of filtfilt.
filtfilt r edu ces filt er st a r t u p t r a n sien t s by ca r efu lly ch oosin g in it ia l con dit ion s, a n d by pr epen din g on t o t h e in pu t sequ en ce a sh or t , r eflect ed piece of t h e in pu t sequ en ce. F or best r esu lt s, m a ke su r e t h e sequ en ce you a r e filt er in g h a s len gt h a t lea st t h r ee t im es t h e filt er or der a n d t a per s t o zer o on bot h edges.
1-21
Th is com pu t es r esu lt s t h a t a r e iden t ica l t o filter, bu t wit h differ en t st a r t u p t r a n sien t s (edge effect s). F or lon g sequ en ces, t h is com pu t a t ion is ver y in efficien t beca u se of t h e la r ge zer o-pa dded F F T oper a t ion s on t h e filt er coefficien t s, a n d beca u se t h e F F T a lgor it h m becom es less efficien t a s t h e n u m ber of poin t s n in cr ea ses. F or F IR filt er s, h owever , it is possible t o br ea k lon ger sequ en ces in t o sh or t er , com pu t a t ion a lly efficien t F F T len gt h s. Th e fu n ct ion
y = fftfilt(b,x)
u ses t h e over la p a dd m et h od (see r efer en ce [1] a t t h e en d of t h is ch a pt er ) t o filt er a lon g sequ en ce wit h m u lt iple m ediu m -len gt h F F Ts. It s ou t pu t is equ iva len t t o filter(b,1,x).
1-22
Impulse Response
Impulse Response
Th e im pu lse r espon se of a digit a l filt er is t h e ou t pu t a r isin g fr om t h e in pu t sequ en ce ( 1, x (n ) = ' % 0, n =1 n -1
Th e impz fu n ct ion in t h e t oolbox sim plifies t h is oper a t ion , ch oosin g t h e n u m ber of poin t s t o gen er a t e a n d t h en m a k in g a st em plot (u sin g t h e stem fu n ct ion ).
impz(b,a)
1 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0 0
10
20
30
40
50
60
70
80
90
Th e plot sh ows t h e expon en t ia l deca y h(n) = 0.9n of t h e sin gle pole syst em .
1-23
Frequency Response
Th e Sign a l P r ocessin g Toolbox en a bles you t o per for m fr equ en cy dom a in a n a lysis of bot h a n a log a n d digit a l filt er s.
Digital Domain
freqz u ses a n F F T-ba sed a lgor it h m t o ca lcu la t e t h e z -t r a n sfor m fr equ en cy r espon se of a digit a l filt er . Specifica lly, t h e st a t em en t [h,w] = freqz(b,a,n)
r et u r n s t h e n -poin t com plex fr equ en cy r espon se, H (ej#), of t h e digit a l filt er . b (1 ) + b (2 ) e j # + L + b (n b + 1 ) e j # ( n b ) H (e j #) = ---------------------------------------------------------------------------------------------------+ a (n a + 1 ) e j # ( n a ) a (1 ) + a (2 ) e j # + L In it s sim plest for m , freqz a ccept s t h e filt er coefficien t vect or s b a n d a, a n d a n in t eger n specifyin g t h e n u m ber of poin t s a t wh ich t o ca lcu la t e t h e fr equ en cy r espon se. freqz r et u r n s t h e com plex fr equ en cy r espon se in vect or h, a n d t h e a ct u a l fr equ en cy poin t s in vect or w in r a dia n s/secon d.
freqz ca n a ccept ot h er pa r a m et er s, su ch a s a sa m plin g fr equ en cy or a vect or of a r bit r a r y fr equ en cy poin t s. Th e exa m ple below fin ds t h e 256-poin t fr equ en cy r espon se for a 12t h -or der Ch ebysh ev t ype I filt er . Th e ca ll t o freqz specifies a sa m plin g fr equ en cy Fs of 1000 H z . [b,a] = cheby1(12,0.5,200/500); [h,f] = freqz(b,a,256,1000);
Beca u se t h e pa r a m et er list in clu des a sa m plin g fr equ en cy, freqz r et u r n s a vect or f t h a t con t a in s t h e 256 fr equ en cy poin t s bet ween 0 a n d Fs/2 u sed in t h e fr equ en cy r espon se ca lcu la t ion .
1-24
Frequency Response
Frequency Normalization Th is t oolbox u ses t h e con ven t ion t h a t u n it fr equ en cy is t h e Nyqu ist fr equ en cy, defin ed a s h a lf t h e sa m plin g fr equ en cy. Th e cu t off fr equ en cy pa r a m et er for a ll ba sic filt er design fu n ct ion s is n or m a lized by t h e Nyqu ist fr equ en cy. For a syst em wit h a 1000 H z sa m plin g fr equ en cy, for exa m ple, 300 H z is 300/500 = 0.6. To con ver t n or m a lized fr equ en cy t o a n gu la r fr equ en cy a r ou n d t h e u n it cir cle, m u lt iply by $. To con ver t n or m a lized fr equ en cy ba ck t o H er t z, m u lt iply by h a lf t h e sa m ple fr equ en cy. If you ca ll freqz wit h n o ou t pu t a r gu m en t s, it a u t om a t ica lly plot s bot h m a gn it u de ver su s fr equ en cy a n d ph a se versu s fr equ en cy. F or exa m ple, a n in t h -or der Bu t t er wor t h lowpa ss filt er wit h a cu t off fr equ en cy of 400 H z, ba sed on a 2000 H z sa m plin g fr equ en cy, is
[b,a] = butter(9,400/1000);
Now ca lcu la t e t h e 256-poin t com plex fr equ en cy r espon se for t h is filt er , a n d plot t h e m a gn it u de a n d ph a se wit h a ca ll t o freqz.
freqz(b,a,256,2000)
Magnitude Response (dB)
100 0 -100 -200 -300 -400 0 100 200 300 400 500 600 Frequency (Hertz) 700 800 900 1000
Phase (degrees)
-200 -400 -600 -800 -1000 0 100 200 300 400 500 600 Frequency (Hertz) 700 800 900 1000
1-25
freqz ca n a lso a ccept a vect or of a r bit r a r y fr equ en cy poin t s for u se in t h e fr equ en cy r espon se ca lcu la t ion . F or exa m ple, w = linspace(0,pi); h = freqz(b,a,w);
ca lcu la t es t h e com plex fr equ en cy r espon se a t t h e fr equ en cy poin t s in w for t h e filt er defin ed by vect or s b a n d a. Th e fr equ en cy poin t s ca n r a n ge fr om 0 t o 2$. To specify a fr equ en cy vect or t h a t r a n ges fr om zer o t o you r sa m plin g fr equ en cy, in clu de bot h t h e fr equ en cy vect or a n d t h e sa m plin g fr equ en cy va lu e in t h e pa r a m et er list .
Analog Domain
freqs eva lu a t es fr equ en cy r espon se for a n a n a log filt er defin ed by t wo in pu t coefficien t vect or s b a n d a. It s oper a t ion is sim ila r t o t h a t of freqz; you ca n specify a n u m ber of fr equ en cy poin t s t o u se (by defa u lt , t h e fu n ct ion u ses 200), su pply a vect or of a r bit r a r y fr equ en cy poin t s, a n d plot t h e m a gn it u de a n d ph a se r espon se of t h e filt er .
200 100
10
-5
0 10
-10
-100 -200 0
10
-15
100
200
300
400
100
200
300
400
1-26
Frequency Response
Th e unwrap fu n ct ion is a lso u sefu l in fr equ en cy a n a lysis. unwrap u n wr a ps t h e ph a se t o m a ke it con t in u ou s a cr oss 360 ph a se discon t in u it ies by a ddin g m u lt iples of 360, a s n eeded. To see h ow unwrap is u sefu l, design a 25t h -or der lowpa ss F IR filt er .
h = fir1(25,0.4);
150
100
50
-50
-100
-150
-200 0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
It is difficu lt t o dist in gu ish t h e 360 ju m ps (a n a r t ifa ct of t h e a r ct a n gen t fu n ct ion in side angle) fr om t h e 180 ju m ps t h a t sign ify zer os in t h e fr equ en cy r espon se.
1-27
-200
-400
-600
-800
-1000
-1200
-1400 0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
Delay
Th e grou p d elay of a filt er is a m ea su r e of t h e a ver a ge dela y of t h e filt er a s a fu n ct ion of fr equ en cy. It is defin ed a s t h e n ega t ive fir st der iva t ive of a filt er s ph a se r espon se. If t h e com plex fr equ en cy r espon se of a filt er is H (ej#), t h en t h e gr ou p dela y is d .(#) / g (#) = -------------d# wh er e . is t h e ph a se a n gle of H (ej#). Com pu t e gr ou p dela y wit h
[gd,w] = grpdelay(b,a,n)
wh ich r et u r n s t h e n-poin t gr ou p dela y, / g ( # ) , of t h e digit a l filt er specified by b a n d a, eva lu a t ed a t t h e fr equ en cies in vect or w. Th e ph ase d elay of a filt er is t h e n ega t ive of ph a se divided by fr equ en cy .(#) / p (#) = ---------#
1-28
Frequency Response
20
10
!10
!20
!30 0
200
400
600
800
1000
1-29
Zero-Pole Analysis
Th e zplane fu n ct ion plot s poles a n d zer os of a lin ea r syst em . F or exa m ple, a sim ple filt er wit h a 0 a t -1/2 a n d a com plex pole pa ir a t 0.9 e j 2 $ ( 0.3 ) a n d 0.9 e j 2 $ ( 0.3 ) is
zer = 0.5; pol = .9*exp(j*2*pi*[0.3 .3]');
In t h is ca se zplane fin ds t h e r oot s of b a n d a u sin g t h e roots fu n ct ion a n d plot s t h e r esu lt in g zer os a n d poles.
1-30
Imaginary part
Zero-Pole Analysis
See Lin ea r Syst em Models on pa ge 1-32 for det a ils on zer o-pole a n d t r a n sfer fu n ct ion r epr esen t a t ion of syst em s.
1-31
Transfer Function
Th e tran sfer fu n ction is a ba sic z -dom a in r epr esen t a t ion of a digit a l filt er , expr essin g t h e filt er a s a r a t io of t wo polyn om ia ls. It is t h e pr in cipa l discr et e-t im e m odel for t h is t oolbox. Th e t r a n sfer fu n ct ion m odel descr ipt ion for t h e z -t r a n sfor m of a digit a l filt er s differ en ce equ a t ion is + b (n b + 1 ) z n b b (1 ) + b (2 ) z 1 + L - X (z ) Y (z ) = --------------------------------------------------------------------------------------- 1 + a (n a + 1 ) z n a a (1 ) + a (2 ) z + L H er e, t h e con st a n t s b (i ) a n d a (i ) a r e t h e filt er coefficien t s, a n d t h e or der of t h e filt er is t h e m a xim u m of n a a n d n b . In MATLAB, you st or e t h ese coefficien t s in t wo vect or s (r ow vect or s by con ven t ion ), on e r ow vect or for t h e n u m er a t or a n d on e for t h e den om in a t or . See F ilt er s a n d Tr a n sfer F u n ct ion s on pa ge 1-15 for m or e det a ils on t h e t r a n sfer fu n ct ion for m .
1-32
Zero-Pole-Gain
Th e fa ct or ed or zero-pole-gain for m of a t r a n sfer fu n ct ion is ( z q (1 ) ) ( z q (2 ) ) L ( z q (n ) ) q(z ) H (z ) = --------- = k ---------------------------------------------------------------------------( z p (1 ) ) ( z p (2 ) ) L ( z p (n ) ) p (z ) By con ven t ion , MATLAB st or es polyn om ia l coefficien t s in r ow vect or s a n d polyn om ia l r oot s in colu m n vect or s. In zer o-pole-ga in for m , t h er efor e, t h e zer o a n d pole loca t ion s for t h e n u m er a t or a n d den om in a t or of a t r a n sfer fu n ct ion r eside in colu m n vect or s. Th e fa ct or ed t r a n sfer fu n ct ion ga in k is a MATLAB sca la r . Th e poly a n d roots fu n ct ion s con ver t bet ween polyn om ia l a n d zer o-pole-ga in r epr esen t a t ion s. F or exa m ple, a sim ple IIR filt er is
b = [2 3 4]; a = [1 3 3 1];
1-33
Not e t h a t b a n d a in t h is ca se r epr esen t t h e t r a n sfer fu n ct ion 2 + 3 z 1 + 4 z 2 2z3 + 3z2 + 4z H (z ) = -----------------------------------------------------= ------------------------------------------1 + 3 z 1 + 3 z 2 + z 3 z3 + 3z2 + 3z + 1 F or b = [2 3 4], t h e roots fu n ct ion m isses t h e zer o for z equ a l t o 0. In fa ct , it m isses poles a n d zer os for z equ a l t o 0 wh en ever t h e in pu t t r a n sfer fu n ct ion h a s m or e poles t h a n zer os, or vice ver sa . Th is is a ccept a ble in m ost ca ses. To cir cu m ven t t h e pr oblem , h owever , sim ply a ppen d zer os t o m a ke t h e vect or s t h e sa m e len gt h befor e u sin g t h e roots fu n ct ion , for exa m ple, b = [b 0].
State-Space
It is a lwa ys possible t o r epr esen t a digit a l filt er , or a syst em of differ en ce equ a t ion s, a s a set of fir st -or der differ en ce equ a t ion s. In m a t r ix or state-space for m , you ca n wr it e t h e equ a t ion s a s x (n + 1 ) = A x (n ) + B u (n ) y (n ) = C x (n ) + D u (n ) wh er e u is t h e in pu t , x is t h e st a t e vect or , a n d y is t h e ou t pu t . F or sin gle-ch a n n el syst em s, A is a n m-by-m m a t r ix wh er e m is t h e or der of t h e filt er , B is a colu m n vect or , C is a r ow vect or , a n d D is a sca la r . St a t e-spa ce n ot a t ion is especia lly con ven ien t for m u lt ich a n n el syst em s wh er e in pu t u a n d ou t pu t y becom e vect or s, a n d B, C, a n d D becom e m a t r ices. St a t e-spa ce r epr esen t a t ion ext en ds ea sily t o t h e MATLAB en vir on m en t . In MATLAB, A, B, C, a n d D a r e r ect a n gu la r a r r a ys; MATLAB t r ea t s t h em a s in dividu a l va r ia bles.
1-34
Ta kin g t h e z -t r a n sfor m of t h e st a t e-spa ce equ a t ion s a n d com bin in g t h em sh ows t h e equ iva len ce of st a t e-spa ce a n d t r a n sfer fu n ct ion for m s. Y (z ) = H (z ) U (z ), wh er e H (z ) = C (z I A ) 1 B + D
Don t be con cer n ed if you a r e n ot fa m ilia r wit h t h e st a t e-spa ce r epr esen t a t ion of lin ea r syst em s. Som e of t h e filt er design a lgor it h m s u se st a t e-spa ce for m in t er n a lly bu t do n ot r equ ir e a n y kn owledge of st a t e-spa ce con cept s t o u se t h em su ccessfu lly. If you r a pplica t ion s u se st a t e-spa ce ba sed sign a l pr ocessin g ext en sively, h owever , con su lt t h e Con t r ol Syst em Toolbox for a com pr eh en sive libr a r y of st a t e-spa ce t ools.
pr ovided H (z ) h a s n o r epea t ed poles. H er e, n is t h e degr ee of t h e den om in a t or polyn om ia l of t h e r a t ion a l t r a n sfer fu n ct ion b (z )/a (z ). If r is a pole of m u lt iplicit y s r , t h en H (z ) h a s t er m s of t h e for m r (j + s r 1 ) r (j + 1 ) r (j ) + L + ------------------------------------------------------------ + --------------------------------- 1 2 1 p (j ) z ( 1 p (j ) z 1 ) ( 1 p (j ) z 1 ) s r Th e residuez fu n ct ion in t h e Sign a l P r ocessin g Toolbox con ver t s t r a n sfer fu n ct ion s t o a n d fr om t h e pa r t ia l fr a ct ion expa n sion for m . Th e z on t h e en d of residuez st a n ds for z -dom a in , or discr et e dom a in . residuez r et u r n s t h e poles in a colu m n vect or p, t h e r esidu es cor r espon din g t o t h e poles in a colu m n vect or r, a n d a n y im pr oper pa r t of t h e or igin a l t r a n sfer fu n ct ion in a r ow vect or k. residuez det er m in es t h a t t wo poles a r e t h e sa m e if t h e m a gn it u de of t h eir differ en ce is sm a ller t h a n 0.1 per cen t of eit h er of t h e poles m a gn it u des. P a r t ia l fr a ct ion expa n sion a r ises in sign a l pr ocessin g a s on e m et h od of fin din g t h e in ver se z -t r a n sfor m of a t r a n sfer fu n ct ion . F or exa m ple, t h e pa r t ia l fr a ct ion expa n sion of 4 + 8 z 1 H (z ) = --------------------------------------1 + 6 z 1 + 8 z 2
1-35
is
b = [4 8]; a = [1 6 8]; [r,p,k] = residuez(b,a) r = 12 8 p = 4 2 k = []
cor r espon din g t o 12 8 H (z ) = -------------------- + -------------------1 + 4 z 1 1 + 2 z 1 To fin d t h e in ver se z -t r a n sfor m of H (z ), fin d t h e su m of t h e in ver se z -t r a n sfor m s of t h e t wo a dden ds of H (z ), givin g t h e ca u sa l im pu lse r espon se h (n ) = 12 ( 4 ) n + 8 ( 2 ) n , To ver ify t h is in MATLAB
imp = [1 0 0 0 0]; resptf = filter(b,a,imp) resptf = 4 32 160 704 2944
n = 0, 1, 2,
1-36
H (z ) =
0 H k (z )
k =1
0 --------------------------------------------------------a + a z 1 + a z 2
k =1 0k 1k 2k
b 0 k + b 1 k z 1 + b 2 k z 2
wh er e L is t h e n u m ber of secon d-or der sect ion s t h a t descr ibe t h e syst em . MATLAB r epr esen t s t h e secon d-or der sect ion for m of a discr et e-t im e syst em a s a n L -by-6 a r r a y sos. E a ch r ow of sos con t a in s a sin gle secon d-or der sect ion , wh er e t h e r ow elem en t s a r e t h e t h r ee n u m er a t or a n d t h r ee den om in a t or coefficien t s t h a t descr ibe t h e secon d-or der sect ion . b 01 b 11 b 21 a 01 a 11 a 21 s os = b 02 b 12 b 22 a 02 a 12 a 22 M M M M M M b0L b1L b2L a0L a1 L a2 L Th er e a r e a n u n cou n t a ble n u m ber of wa ys t o r epr esen t a filt er in secon d-or der sect ion for m . Th r ou gh ca r efu l pa ir in g of t h e pole a n d zer o pa ir s, or der in g of t h e sect ion s in t h e ca sca de, a n d m u lt iplica t ive sca lin g of t h e sect ion s, it is possible t o r edu ce qu a n t iza t ion n oise ga in a n d a void over flow in som e fixed-poin t filt er im plem en t a t ion s. Th e fu n ct ion s zp2sos a n d ss2sos, descr ibed la t er in Lin ea r Syst em Tr a n sfor m a t ion s, per for m pole-zer o pa ir in g, sect ion sca lin g, a n d sect ion or der in g.
Lattice Structure
F or a discr et e N t h or der a ll-pole or a ll-zer o filt er descr ibed by t h e polyn om ia l coefficien t s a (n ), n = 1,2,,N +1, t h er e a r e N cor r espon din g la t t ice st r u ct u r e coefficien t s k (n ), n = 1,2,,N . Th e pa r a m et er s k (n ) a r e a lso ca lled t h e reflection
1-37
coefficien ts of t h e filt er . Given t h ese r eflect ion coefficien t s, you ca n im plem en t a discr et e filt er a s
x(m) , k(1) ... , k(n) y(m)
k(1) z -1 , ... z -1
k(n) ,
F IR La t t ice F ilt er
x(m) k(n)
... k(1)
y(m)
k(n) , z -1 ... ,
k(1) z -1
F or a gen er a l pole-zer o IIR filt er descr ibed by polyn om ia l coefficien t s a a n d b , t h er e a r e bot h la t t ice coefficien t s k (n ) for t h e den om in a t or a a n d la dder coefficien t s v (n ) for t h e n u m er a t or b . Th e la t t ice/la dder filt er m a y be im plem en t ed a s
x(m) + k(N) k(N) g(m) + z -1 + + k(2) k(2) z -1 + + k(1) k(1) z -1
v(N+1) +
v(N) +
v(3) +
v(2) +
v(1) f(m)
1-38
Th e t oolbox fu n ct ion tf2latc a ccept s a n F IR or IIR filt er in polyn om ia l for m a n d r et u r n s t h e cor r espon din g r eflect ion coefficien t s. An exa m ple IIR filt er in polyn om ia l for m is
a = [1.0000 0.6149 0.9899 0.0000 0.0031 0.0082];
Th e m a gn it u de of t h e r eflect ion coefficien t s pr ovides a n ea sy st a bilit y ch eck for a filt er . If a ll t h e r eflect ion coefficien t s cor r espon din g t o a polyn om ia l h a ve m a gn it u de less t h a n 1, a ll of t h a t polyn om ia ls r oot s a r e in side t h e u n it cir cle. Th e fu n ct ion latc2tf ca lcu la t es t h e polyn om ia l coefficien t s for a filt er fr om it s la t t ice (r eflect ion ) coefficien t s. Given t h e r eflect ion coefficien t vect or k(a bove), t h e cor r espon din g polyn om ia l for m is
a = latc2tf(k) a = 1.0000 0.6149 0.9899 0.0000 0.0031 0.0082
Th e la t t ice or la t t ice/la dder coefficien t s ca n be u sed t o im plem en t t h e filt er u sin g t h e fu n ct ion latcfilt.
Convolution Matrix
In sign a l pr ocessin g, con volvin g t wo vect or s or m a t r ices is equ iva len t t o filt er in g on e of t h e in pu t oper a n ds by t h e ot h er . Th is r ela t ion sh ip per m it s t h e r epr esen t a t ion of a digit a l filt er a s a con volu tion m atrix . Given a n y vect or , t h e t oolbox convmtx fu n ct ion gen er a t es a m a t r ix wh ose in n er pr odu ct wit h a n ot h er vect or is equ iva len t t o t h e con volu t ion of t h e t wo vect or s. Th e gen er a t ed m a t r ix r epr esen t s a digit a l filt er t h a t you ca n a pply t o a n y
1-39
vect or of a ppr opr ia t e len gt h ; t h e in n er dim en sion of t h e oper a n ds m u st a gr ee t o com pu t e t h e in n er pr odu ct . Th e con volu t ion m a t r ix for a vect or b, r epr esen t in g t h e n u m er a t or coefficien t s for a digit a l filt er , is
b = [1 2 3]; x = randn(3,1); C = convmtx(b',3) C = 1 2 3 0 0 0 1 2 3 0 0 0 1 2 3
1-40
wh er e u is a vect or of n u in pu t s, x is a n n x -elem en t st a t e vect or , a n d y is a vect or of n y ou t pu t s. In MATLAB, st or e A, B, C, a n d D in sepa r a t e r ect a n gu la r a r r a ys. An equ iva len t r epr esen t a t ion of t h e st a t e-spa ce syst em is t h e La pla ce t r a n sfor m t r a n sfer fu n ct ion descr ipt ion Y (s ) = H (s ) U (s ) wh er e H (s ) = C ( s I A ) 1 B + D F or sin gle-in pu t , sin gle-ou t pu t syst em s, t h is for m is given by + b (n b + 1 ) b (s ) b (1 ) s n b + b (2 ) s n b 1 + L H (s ) = --------- = --------------------------------------------------------------------------------------------a (s ) + a (n a + 1 ) a (1 ) s n a + a (2 ) s n a 1 + L Given t h e coefficien t s of a La pla ce t r a n sfor m t r a n sfer fu n ct ion , residue det er m in es t h e pa r t ia l fr a ct ion expa n sion of t h e syst em . See t h e descr ipt ion of residue in t h e M AT L AB L an gu age R eferen ce M an u al for det a ils. Th e fa ct or ed zer o-pole-ga in for m is ( s z (1 ) ) ( s z (2 ) ) L ( s z (n ) ) z (s ) H (s ) = --------- = k ---------------------------------------------------------------------------( s p (1 ) ) ( s p (2 ) ) L ( s p (n ) ) p (s ) As in t h e discr et e-t im e ca se, MATLAB st or es polyn om ia l coefficien t s in r ow vect or s in descen din g power s of s. MATLAB st or es polyn om ia l r oot s, or zer os a n d poles, in colu m n vect or s.
1-41
Transfer function Transfer function State-space Zero-pole gain Partial fraction Lattice filter Secondorder sections Convolution matrix ss2tf zp2tf poly residuez residue latc2tf sos2tf
Statespace tf2ss
Secondorder sections
ss2sos zp2sos
zp2ss
sos2ss
sos2zp
Ma n y of t h e t oolbox filt er design fu n ct ion s u se t h ese fu n ct ion s in t er n a lly. F or exa m ple, t h e zp2ss fu n ct ion con ver t s t h e poles a n d zer os of a n a n a log pr ot ot ype in t o t h e st a t e-spa ce for m r equ ir ed for cr ea t ion of a Bu t t er wor t h , Ch ebysh ev, or ellipt ic filt er . On ce in st a t e-spa ce for m , t h e filt er design fu n ct ion per for m s a n y r equ ir ed fr equ en cy t r a n sfor m a t ion , t h a t is, it t r a n sfor m s t h e in it ia l lowpa ss design in t o a ba n dpa ss, h igh pa ss, or ba n dst op filt er , or a lowpa ss filt er wit h t h e desir ed cu t off fr equ en cy. See Ch a pt er 6 a n d t h e r efer en ce descr ipt ion s of t h e in dividu a l filt er design fu n ct ion s for m or e det a ils.
1-42
X (k + 1 ) =
+
n =0
kn x (n + 1 ) W n
N 1
1 x (n + 1 ) = ---N
+
k =0
k n X (k + 1 ) W n
In t h ese equ a t ion s, t h e ser ies su bscr ipt s begin wit h 1 in st ea d of 0 beca u se of MATLABs vect or in dexin g sch em e, a n d WN = e
2 $4 j 3 -----1N2
NOTE MATLAB u ses a n ega t ive j for t h e fft fu n ct ion . Th is is a n en gin eer in g con ven t ion ; ph ysics a n d pu r e m a t h em a t ics t ypica lly u se a posit ive j .
fft, wit h a sin gle in pu t a r gu m en t x, com pu t es t h e DF T of t h e in pu t vect or or m a t r ix. If x is a vect or , fft com pu t es t h e DF T of t h e vect or ; if x is a r ect a n gu la r a r r a y, fft com pu t es t h e DF T of ea ch a r r a y colu m n .
1-43
To plot t h e m a gn it u de a n d ph a se
f = (0:length(y)1)*99/length(y); % frequency vector plot(f,m) set(gca,'XTick',[15 40 60 85]); plot(f,p*180/pi) set(gca,'XTick',[15 40 60 85]);
50 40 30 20 10 0 15 40 60 85 -1500 15 40 60 85 -500 0
-1000
A secon d a r gu m en t t o fft specifies a n u m ber of poin t s n for t h e t r a n sfor m , r epr esen t in g DF T len gt h .
y = fft(x,n);
In t h is ca se, fft pa ds t h e in pu t sequ en ce wit h zer os if it is sh or t er t h a n n, or t r u n ca t es t h e sequ en ce if it is lon ger t h a n n. If n is n ot specified, it defa u lt s t o t h e len gt h of t h e in pu t sequ en ce.
1-44
E xecu t ion t im e for fft depen ds on t h e len gt h n of t h e DF T it per for m s: F or a n y n t h a t is a power of t wo, fft u ses t h e h igh -speed r a dix-2 a lgor it h m . Th is r esu lt s in t h e fa st est execu t ion t im e. Addit ion a lly, t h e a lgor it h m for power of t wo n is h igh ly opt im ized for r ea l x, pr ovidin g a 40% speed-u p over t h e com plex ca se. F or a n y com posit e n u m ber n t h a t is n ot a power of t wo, fft u ses a pr im e fa ct or a lgor it h m . Th e speed of t h is a lgor it h m depen ds on bot h t h e size of n a n d n u m ber of pr im e fa ct or s it h a s. Alt h ou gh 1013 a n d 1000 a r e close in m a gn it u de, fft t r a n sfor m s a sequ en ce of len gt h 1000 m u ch m or e qu ickly t h a n a sequ en ce of len gt h 1013. F or a pr im e n u m ber n, fft ca n n ot u se a n F F T a lgor it h m , a n d in st ea d per for m s t h e slower , com pu t a t ion -in t en sive DF T dir ect ly. Th e in ver se discr et e F ou r ier t r a n sfor m fu n ct ion ifft a lso a ccept s a n in pu t sequ en ce a n d, opt ion a lly, t h e n u m ber of desir ed poin t s for t h e t r a n sfor m . Tr y t h e exa m ple below; t h e or igin a l sequ en ce x a n d t h e r econ st r u ct ed sequ en ce a r e iden t ica l (wit h in r ou n din g er r or ).
t = (0:1/255:1); x = sin(2*pi*120*t); y = real(ifft(fft(x)));
Th is t oolbox a lso in clu des fu n ct ion s for t h e t wo-dim en sion a l F F T a n d it s in ver se, fft2 a n d ifft2. Th ese fu n ct ion s a r e u sefu l for t wo-dim en sion a l sign a l or im a ge pr ocessin g; see t h e r efer en ce descr ipt ion s in Ch a pt er 6 for det a ils. It is som et im es con ven ien t t o r ea r r a n ge t h e ou t pu t of t h e fft or fft2 fu n ct ion so t h e zer o fr equ en cy com pon en t is a t t h e cen t er of t h e sequ en ce. Th e MATLAB fu n ct ion fftshift m oves t h e zer o fr equ en cy com pon en t t o t h e cen t er of a vect or or m a t r ix.
1-45
References
Algor it h m developm en t for t h e Sign a l P r ocessin g Toolbox h a s dr a wn h ea vily u pon t h e r efer en ces list ed below. All a r e r ecom m en ded t o t h e in t er est ed r ea der wh o n eeds t o kn ow m or e a bou t sign a l pr ocessin g t h a n is cover ed in t h is m a n u a l.
1 Cr och ier e, R.E ., a n d L.R. Ra bin er . M u lti-R ate S ign al Processin g . E n glewood
1988.
5 Oppen h eim , A.V., a n d R.W. Sch a fer . Discrete-T im e S ign al Processin g .
M u ltitaper an d Con ven tion al Un ivariate T ech n iqu es . Ca m br idge: Ca m br idge Un iver sit y P r ess, 1993.
9 P r oa kis, J .G., a n d D.G. Ma n ola kis. Digital S ign al Processin g: Prin ciples,
Spect r a : A Met h od Ba sed on Tim e Aver a gin g Over Sh or t , Modified P er iodogr a m s. IE E E T ran s. Au d io E lectroacou st . Vol. AU-15 (J u n e 1967). P gs. 70-73.
1-46
2
F ilt er Design
F ilte r Re qu ire m e n ts a n d S p e c ific a tio n . . . . . . . . . . . . . . . . 2-2 IIR F ilte r D e s ig n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4 Cla ssica l IIR F ilt er Design Usin g An a log P r ot ot ypin g . . . . . . . . 2-6 Com pa r ison of Cla ssica l IIR F ilt er Types . . . . . . . . . . . . . . . . . . 2-8 F IR F ilte r D e s ig n . . . . . . . . . . . . . . . . . . . . . . . . . . . . Lin ea r P h a se F ilt er s . . . . . . . . . . . . . . . . . . . . . . . . . . . Win dowin g Met h od . . . . . . . . . . . . . . . . . . . . . . . . . . . . Mu lt iba n d F IR F ilt er Design wit h Tr a n sit ion Ba n ds . Con st r a in ed Lea st Squ a r es F IR F ilt er Design . . . . . . Ar bit r a r y-Respon se F ilt er Design . . . . . . . . . . . . . . . . S p e c ia l To p ic s in IIR F ilte r D e s ig n An a log P r ot ot ype Design . . . . . . . . . . . F r equ en cy Tr a n sfor m a t ion . . . . . . . . . . F ilt er Discr et iza t ion . . . . . . . . . . . . . . . .. .. .. .. .... .... .... .... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... .... .... .... .... .... .... .... .... .... .... 2-16 2-17 2-18 2-22 2-27 2-31 2-37 2-38 2-38 2-41
Re fe re n c e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-45
Filter Design
Th e secon d in pu t a r gu m en t t o butter in dica t es t h e cu t off fr equ en cy, n or m a lized t o h a lf t h e sa m plin g fr equ en cy (t h e Nyqu ist fr equ en cy). Frequency Normalization in the Signal Processing Toolbox All of t h e filt er design fu n ct ion s oper a t e wit h n or m a lized fr equ en cies, so t h ey do n ot r equ ir e t h e syst em sa m plin g r a t e a s a n ext r a in pu t a r gu m en t . Th is t oolbox u ses t h e con ven t ion t h a t u n it fr equ en cy is t h e Nyqu ist fr equ en cy, defin ed a s h a lf t h e sa m plin g fr equ en cy. Th e n or m a lized fr equ en cy, t h er efor e, is a lwa ys in t h e in t er va l 0 5 f 5 1. For a syst em wit h a 1000 H z sa m plin g fr equ en cy, 300 H z is 300/500 = 0.6. To con ver t n or m a lized fr equ en cy t o a n gu la r fr equ en cy a r ou n d t h e u n it cir cle, m u lt iply by $. To con ver t n or m a lized fr equ en cy ba ck t o H er t z, m u lt iply by h a lf t h e sa m ple fr equ en cy.
2-2
Mor e r igor ou s filt er r equ ir em en t s t r a dit ion a lly in clu de pa ssba n d r ipple (Rp, in decibels), st opba n d a t t en u a t ion (Rs, in decibels), a n d t r a n sit ion widt h (WsWp, in H er t z).
1
0.8
Magnitude
0.6
0.4
0.2
0 -1 10
10 Frequency(rad/sec)
10
You ca n design Bu t t er wor t h , Ch ebysh ev t ype I, Ch ebysh ev t ype II, a n d ellipt ic filt er s t h a t m eet t h is t ype of per for m a n ce specifica t ion . Th e t oolbox or der select ion fu n ct ion s est im a t e t h e m in im u m filt er or der t h a t m eet s a given set of r equ ir em en t s. To m eet specifica t ion s wit h m or e r igid con st r a in t s lik e lin ea r ph a se or a r bit r a r y filt er sh a pe, u se t h e F IR a n d dir ect IIR filt er design r ou t in es.
2-3
Filter Design
2-4
Method
Description
Functions
An a log P r ot ot ypin g
Usin g t h e poles a n d zer os of a cla ssica l lowpa ss pr ot ot ype filt er in t h e con t in u ou s (La pla ce) dom a in , obt a in a digit a l filt er t h r ou gh fr equ en cy t r a n sfor m a t ion a n d filt er discr et iza t ion .
Design digit a l filt er dir ect ly in t h e discr et e dom a in by a ppr oxim a t in g a piecewise lin ea r m a gn it u de r espon se. Fin d a digit a l filt er t h a t a ppr oxim a t es a pr escr ibed t im e or fr equ en cy dom a in r espon se.
yulewalk
Pa r a m et r ic Modelin g *
maxflat
* See the System Identification Toolbox for an extensive collection of parametric modeling tools.
2-5
Filter Design
Bu t t er wor t h
Ch ebysh ev t ype I
Ch ebysh ev t ype II
E llipt ic
By defa u lt , ea ch of t h ese fu n ct ion s r et u r n s a lowpa ss filt er ; you n eed on ly specify t h e desir ed cu t off fr equ en cy Wn in n or m a lized fr equ en cy (Nyqu ist fr equ en cy = 1 H z). F or a h igh pa ss filt er , a ppen d t h e st r in g 'high' t o t h e fu n ct ion s pa r a m et er list . F or a ba n dpa ss or ba n dst op filt er , specify Wn a s a t wo-elem en t vect or con t a in in g t h e pa ssba n d edge fr equ en cies, a ppen din g t h e st r in g 'stop' for t h e ba n dst op con figu r a t ion .
2-6
To design a n a n a log filt er , per h a ps for sim u la t ion , u se a t r a ilin g 's' a n d specify cu t off fr equ en cies in r a dia n s/secon d.
[b,a] = butter(5,.4,'s'); % analog Butterworth filter
All filt er design fu n ct ion s r et u r n a filt er in t h e t r a n sfer fu n ct ion , zer o-pole-ga in , or st a t e-spa ce lin ea r syst em m odel r epr esen t a t ion , depen din g on h ow m a n y ou t pu t a r gu m en t s a r e pr esen t . NOTE All cla ssica l IIR lowpa ss filt er s a r e ill-con dit ion ed for ext r em ely low cu t -off fr equ en cies. Th er efor e, in st ea d of design in g a lowpa ss IIR filt er wit h a ver y n a r r ow pa ssba n d, it ca n be bet t er t o design a wider pa ssba n d a n d decim a t e t h e in pu t sign a l.
Th ese a r e u sefu l in con ju n ct ion wit h t h e filt er design fu n ct ion s. Su ppose you wa n t a ba n dpa ss filt er wit h a pa ssba n d fr om 1000 t o 2000 H z, st opba n ds st a r t in g 500 H z a wa y on eit h er side, a 10 kH z sa m plin g fr equ en cy, a t m ost 1 dB
2-7
Filter Design
of pa ssba n d r ipple, a n d a t lea st 60 dB of st opba n d a t t en u a t ion . To m eet t h ese specifica t ion s wit h t h e butter fu n ct ion .
[n,Wn] = buttord([1000 2000]/5000,[500 2500]/5000,1,60) n = 12 Wn = 0.1951 0.4080
[b,a] = butter(n,Wn);
[b,a] = ellip(n,1,60,Wn);
Th ese fu n ct ion s a lso wor k wit h t h e ot h er st a n da r d ba n d con figu r a t ion s, a s well a s for a n a log filt er s; see Ch a pt er 6 for det a ils.
Butterworth Filter
Th e Bu t t er wor t h filt er pr ovides t h e best Ta ylor Ser ies a ppr oxim a t ion t o t h e idea l lowpa ss filt er r espon se a t " = 0 a n d " = *; for a n y or der N , t h e m a gn it u de squ a r ed r espon se h a s 2 N 1 zer o der iva t ives a t t h ese loca t ion s (m axim ally flat
2-8
a t " = 0 a n d " = *). Respon se is m on ot on ic over a ll, decr ea sin g sm oot h ly fr om " = 0 t o " = *. | H (j")| = sqrt(1/2) a t " = 1.
1
0.8
Magnitude
0.6
0.4
0.2
0 -1 10
10 Frequency(rad/sec)
10
0.8
Magnitude
0.6
0.4
0.2
0 -1 10
10 Frequency(rad/sec)
10
2-9
Filter Design
0.8
Magnitude
0.6
0.4
0.2
0 -1 10
10 Frequency(rad/sec)
10
Elliptic Filter
E llipt ic filt er s a r e equ ir ipple in bot h t h e pa ssba n d a n d st opba n d. Th ey gen er a lly m eet filt er r equ ir em en t s wit h t h e lowest or der of a n y su ppor t ed filt er t ype. Given a filt er or der n, pa ssba n d r ipple Rp in decibels, a n d st opba n d r ipple
2-10
" = 1.
1
0.8
Magnitude
0.6
0.4
0.2
0 -1 10
10 Frequency(rad/sec)
10
Bessel Filter
An a log Bessel lowpa ss filt er s h a ve m a xim a lly fla t gr ou p dela y a t zer o fr equ en cy a n d r et a in n ea r ly con st a n t gr ou p dela y a cr oss t h e en t ir e pa ssba n d. F ilt er ed sign a ls t h er efor e m a in t a in t h eir wa vesh a pes in t h e pa ssba n d fr equ en cy r a n ge. F r equ en cy m a pped a n d digit a l Bessel filt er s, h owever , do n ot h a ve t h is m a xim a lly fla t pr oper t y; t h is t oolbox su ppor t s on ly t h e a n a log ca se for t h e com plet e Bessel filt er design fu n ct ion .
2-11
Filter Design
Bessel filt er s gen er a lly r equ ir e a h igh er filt er or der t h a n ot h er filt er s for sa t isfa ct or y st opba n d a t t en u a t ion . | H (j")| < 1 2 a t " = 1 a n d decr ea ses a s n in cr ea ses.
1
0.8
Magnitude
0.6
0.4
0.2
0 -1 10
10 Frequency(rad/sec)
10
NOTE Th e lowpa ss filt er s sh own a bove wer e cr ea t ed wit h t h e a n a log pr ot ot ype fu n ct ion s besselap, buttap, cheb1ap, cheb2ap, a n d ellipap. Th ese fu n ct ion s fin d t h e zer os, poles, a n d ga in of a n or der n a n a log filt er of t h e a ppr opr ia t e t ype wit h cu t off fr equ en cy of 1 r a d/sec. Th e com plet e filt er design fu n ct ion s (besself, butter, cheby1, cheby2, a n d ellip) ca ll t h e pr ot ot ypin g fu n ct ion s a s a fir st st ep in t h e design pr ocess. See Specia l Topics in IIR F ilt er Design on pa ge 2-37 for det a ils. To cr ea t e sim ila r plot s, u se n = 5 a n d, a s n eeded, Rp = 0.5 a n d Rs = 20. F or exa m ple, t o cr ea t e t h e ellipt ic filt er plot :
[z,p,k] = ellipap(5,0.5,20); w = logspace(1,1,1000); h = freqs(k*poly(z),poly(p),w); semilogx(w,abs(h)), grid
2-12
r et u r n s r ow vect or s b a n d a con t a in in g t h e n+1 n u m er a t or a n d den om in a t or coefficien t s of t h e or der n IIR filt er wh ose fr equ en cy-m a gn it u de ch a r a ct er ist ics a ppr oxim a t e t h ose given in vect or s f a n d m. f is a vect or of fr equ en cy poin t s r a n gin g fr om 0 t o 1, wh er e 1 r epr esen t s t h e Nyqu ist fr equ en cy. m is a vect or con t a in in g t h e desir ed m a gn it u de r espon se a t t h e poin t s in f. f a n d m ca n descr ibe a n y piecewise lin ea r sh a pe m a gn it u de r espon se, in clu din g a m u lt iba n d r espon se. Th e F IR cou n t er pa r t of t h is fu n ct ion is fir2, wh ich a lso design s a filt er ba sed on a n a r bit r a r y piecewise lin ea r m a gn it u de r espon se. See F IR F ilt er Design on pa ge 2-16 for det a ils. Not e t h a t yulewalk does n ot a ccept ph a se in for m a t ion , a n d n o st a t em en t s a r e m a de a bou t t h e opt im a lit y of t h e r esu lt in g filt er .
2-13
Filter Design
Design a m u lt iba n d filt er wit h yulewalk, a n d plot t h e desir ed a n d a ct u a l fr equ en cy r espon se.
m = [0 0 1 1 0 0 1 1 0 0]; f = [0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 1]; [b,a] = yulewalk(10,f,m); [h,w] = freqz(b,a,128); plot(f,m,w/pi,abs(h))
1.2
0.8
0.6
0.4
0.2
0 0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
2-14
H owever , maxflat is m or e ver sa t ile, beca u se you ca n design a filt er wit h m or e zer os t h a n poles.
[b,a] = maxflat(3,1,0.25) b = 0.0950 a = 1.0000 -0.2402 0.2849 0.2849 0.0950
Th e t h ir d in pu t t o m a xfla t is t h e h alf-pow er frequ en cy , a fr equ en cy bet ween 0 a n d 1 wit h a desir ed m a gn it u de r espon se of 1 2 . You ca n a lso design lin ea r ph a se filt er s t h a t h a ve t h e m a xim a lly fla t pr oper t y u sin g t h e 'sym' opt ion .
maxflat(4,'sym',0.3) ans = 0.0331 0.2500 0.4337 0.2500 0.0331
F or com plet e det a ils of t h e maxflat a lgor it h m , see Selesn ick a n d Bu r r u s [2].
2-15
Filter Design
Win dowin g
Apply win dow t o t r u n ca t ed in ver se Fou r ier t r a n sfor m of desir ed br ick wa ll filt er E qu ir ipple or lea st squ a r es a ppr oa ch over su b-ba n ds of t h e fr equ en cy r a n ge Min im ize squ a r ed in t egr a l er r or over en t ir e frequ en cy r a n ge su bject t o m a xim u m er r or con st r a in t s
firls,remez,remezord
fircls,fircls1
2-16
Method
Description
Functions cremez
Ar bit r a r y r espon ses, in clu din g n on lin ea r ph a se a n d com plex filt er s Lowpa ss r espon se wit h sm oot h , sin u soida l t r a n sit ion
firrcos
Filter Order n
Symmetry of Coefficients
even : b (k ) = b (n + 2 k ), k = 1 , , n + 1 odd: b ( k ) = b ( n + 2 k ) , k = 1 , , n + 1
Th e ph a se dela y a n d gr ou p dela y of lin ea r ph a se F IR filt er s a r e equ a l a n d con st a n t over t h e fr equ en cy ba n d. F or a n or der n lin ea r ph a se F IR filt er , t h e gr ou p dela y is n /2, a n d t h e filt er ed sign a l is sim ply dela yed by n /2 t im e st eps (a n d t h e m a gn it u de of it s F ou r ier t r a n sfor m is sca led by t h e filt er s m a gn it u de r espon se). Th is pr oper t y pr eser ves t h e wa ve sh a pe of sign a ls in t h e pa ssba n d, t h a t is, t h er e is n o ph a se dist or t ion . Th e fu n ct ion s fir1, fir2, firls, remez, fircls, fircls1, a n d firrcos a ll design t ype I a n d II lin ea r ph a se F IR filt er s by defa u lt . Bot h firls a n d remez design t ype III a n d IV lin ea r ph a se F IR filt er s given a 'hilbert' or 'differentiator' fla g. cremez ca n design a n y t ype of lin ea r ph a se filt er , a n d n on lin ea r ph a se filt er s a s well.
2-17
Filter Design
NOTE Beca u se t h e fr equ en cy r espon se of a t ype II filt er is zer o a t t h e Nyqu ist r a t e (h igh fr equ en cy), fir1 does n ot design t ype II h igh pa ss a n d ba n dst op filt er s. For odd-va lu ed n in t h ese ca ses, fir1 a dds 1 t o t h e or der a n d r et u r n s a t ype I filt er.
Windowing Method
Con sider t h e idea l, or br ick-wa ll, digit a l lowpa ss filt er wit h a cu t off fr equ en cy of #0 r a d/sec. Th is filt er h a s m a gn it u de 1 a t a ll fr equ en cies wit h m a gn it u de less t h a n #0 , a n d m a gn it u de 0 a t fr equ en cies wit h m a gn it u de bet ween #0 a n d $. It s im pu lse r espon se sequ en ce h (n ) is 1 h (n ) = -----2$
6$ H (#) e j # n d #
1 = -----2$
6 # e j # n d #
0
#0
Th is filt er is n ot im plem en t a ble sin ce it s im pu lse r espon se is in fin it e a n d n on ca u sa l. To cr ea t e a fin it e-du r a t ion im pu lse r espon se, t r u n ca t e it by a pplyin g a win dow. By r et a in in g t h e cen t r a l sect ion of im pu lse r espon se in t h is t r u n ca t ion , you obt a in a lin ea r ph a se F IR filt er . F or exa m ple, a len gt h 51 filt er wit h a lowpa ss cu t off fr equ en cy #0 of 0.4 $ r a d/sec is
b = 0.4*sinc(0.4*(25:25));
Th e win dow a pplied h er e is a sim ple r ect a n gu la r or boxca r win dow. By P a r seva ls t h eor em , t h is is t h e len gt h 51 filt er t h a t best a ppr oxim a t es t h e idea l
2-18
lowpa ss filt er , in t h e in t egr a t ed lea st squ a r es sen se. To view it s fr equ en cy r espon se:
[H,w] = freqz(b,1,512,2); plot(w,abs(H)), grid
Truncated Sinc Lowpass FIR Filter 1.2
Magnitude Response
0.8
0.6
0.4
0.2
0 0
0.1
0.2
0.8
0.9
Not e t h e r in gin g a n d r ipples in t h e r espon se, especia lly n ea r t h e ba n d edge. Th is Gibbs effect does n ot va n ish a s t h e filt er len gt h in cr ea ses, bu t a n on r ect a n gu la r win dow r edu ces it s m a gn it u de. Mu lt iplica t ion by a win dow in
2-19
Filter Design
t h e t im e dom a in ca u ses a con volu t ion or sm oot h in g in t h e fr equ en cy dom a in . Apply a len gt h 51 H a m m in g win dow t o t h e filt er .
b = b.*hamming(51)'; [H,w] = freqz(b,1,512,2); plot(w,abs(H)), grid
Hamming Windowed Truncated SINC LP FIR Filter 1.2
0.6
0.4
0.2
0 0
0.1
0.2
0.8
0.9
As you ca n see, t h is gr ea t ly r edu ces t h e r in gin g. Th is im pr ovem en t is a t t h e expen se of t r a n sit ion widt h (t h e win dowed ver sion t a k es lon ger t o r a m p fr om pa ssba n d t o st opba n d) a n d opt im a lit y (t h e win dowed ver sion does n ot m in im ize t h e in t egr a t ed squ a r ed er r or ). Th e fu n ct ion s fir1 a n d fir2 a r e ba sed on t h is win dowin g pr ocess. Given a filt er or der a n d descr ipt ion of a n idea l desir ed filt er , t h ese fu n ct ion s r et u r n a win dowed in ver se F ou r ier t r a n sfor m of t h a t idea l filt er . Bot h u se a H a m m in g win dow by defa u lt , bu t t h ey a ccept a n y win dow fu n ct ion . See t h e Win dows sect ion of Ch a pt er 4 for a n over view of win dows a n d t h eir pr oper t ies.
2-20
Th e st a t em en t s
n = 50; Wn = 0.4; b = fir1(n,Wn);
cr ea t e r ow vect or b con t a in in g t h e coefficien t s of t h e or der n H a m m in g-win dowed filt er . Th is is a lowpa ss, lin ea r ph a se F IR filt er wit h cu t off fr equ en cy Wn. Wn is a n u m ber bet ween 0 a n d 1, wh er e 1 cor r espon ds t o t h e Nyqu ist fr equ en cy, h a lf t h e sa m plin g fr equ en cy. (Un like ot h er m et h ods, h er e Wn cor r espon ds t o t h e 6 dB poin t .) F or a h igh pa ss filt er , sim ply a ppen d t h e st r in g 'high' t o t h e fu n ct ion s pa r a m et er list . F or a ba n dpa ss or ba n dst op filt er , specify Wn a s a t wo-elem en t vect or con t a in in g t h e pa ssba n d edge fr equ en cies; a ppen d t h e st r in g 'stop' for t h e ba n dst op con figu r a t ion .
b = fir1(n,Wn,window) u ses t h e win dow specified in colu m n vect or window for t h e design . Th e vect or window m u st be n+1 elem en t s lon g. If you do n ot specify a win dow, fir1 a pplies a H a m m in g win dow. Kaiser Window Order Estimation. Th e kaiserord fu n ct ion est im a t es t h e filt er or der , cu t off fr equ en cy, a n d Ka iser win dow bet a pa r a m et er n eeded t o m eet a given set of specifica t ion s. Given a vect or of fr equ en cy ba n d edges a n d a cor r espon din g vect or of m a gn it u des, a s well a s m a xim u m a llowa ble r ipple, kaiserord r et u r n s a ppr opr ia t e in pu t pa r a m et er s for t h e fir1 fu n ct ion . F or det a ils on kaiserord, see t h e r efer en ce descr ipt ion in Ch a pt er 6.
r et u r n r ow vect or b con t a in in g t h e n+1 coefficien t s of t h e or der n F IR filt er wh ose fr equ en cy-m a gn it u de ch a r a ct er ist ics m a t ch t h ose given by vect or s f a n d m. f is a vect or of fr equ en cy poin t s r a n gin g fr om 0 t o 1, wh er e 1 r epr esen t s t h e
2-21
Filter Design
Nyqu ist fr equ en cy. m is a vect or con t a in in g t h e desir ed m a gn it u de r espon se a t t h e poin t s specified in f. (Th e IIR cou n t er pa r t of t h is fu n ct ion is yulewalk, wh ich a lso design s filt er s ba sed on a r bit r a r y piecewise lin ea r m a gn it u de r espon ses. See IIR F ilt er Design for det a ils.)
Th e syn t a x for firls a n d remez is t h e sa m e; t h e on ly differ en ce is t h eir m in im iza t ion sch em es. Th e n ext exa m ple sh ows h ow filt er s design ed wit h firls a n d remez r eflect t h ese differ en t sch em es.
Basic Configurations
Th e defa u lt m ode of oper a t ion of firls a n d remez is t o design t ype I or t ype II lin ea r ph a se filt er s, depen din g on wh et h er t h e or der you desir e is even or odd, r espect ively. A lowpa ss exa m ple wit h a ppr oxim a t e a m plit u de 1 fr om 0 t o 0.4 H z, a n d a ppr oxim a t e a m plit u de 0 fr om 0.5 t o 1.0 H z is
n f a b = = = = 20; [0 .4 .5 1]; [1 1 0 0]; remez(n,f,a); % filter order % frequency band edges % desired amplitudes
2-22
F r om 0.4 t o 0.5 H z, remez per for m s n o er r or m in im iza t ion ; t h is is a t r a n sit ion ba n d or don t ca r e r egion . A t r a n sit ion ba n d m in im izes t h e er r or m or e in t h e ba n ds t h a t you do ca r e a bou t , a t t h e expen se of a slower t r a n sit ion r a t e. In t h is wa y, t h ese t ypes of filt er s h a ve a n in h er en t t r a de-off sim ila r t o F IR design by win dowin g. To com pa r e lea st squ a r es t o equ ir ipple filt er design , u se firls t o cr ea t e a sim ila r filt er .
bb = firls(n,f,a);
0.8
Magnitude
0.6
0.4
0.2
0 -1 10
10 Frequency(rad/sec)
10
You ca n see t h a t t h e filt er design ed wit h remez exh ibit s equ ir ipple beh a vior . Also n ot e t h a t t h e firls filt er h a s a bet t er r espon se over m ost of t h e pa ssba n d a n d st opba n d, bu t a t t h e ba n d edges (f = 0.4 a n d f = 0.5), t h e r espon se is fu r t h er a wa y fr om t h e idea l t h a n t h e remez filt er . Th is sh ows t h a t t h e remez filt er s m axim u m er r or over t h e pa ss- a n d st opba n ds is sm a ller a n d, in fa ct , it is t h e sm a llest possible for t h is ba n d edge con figu r a t ion a n d filt er len gt h . Th in k of fr equ en cy ba n ds a s lin es over sh or t fr equ en cy in t er va ls. remez a n d firls u se t h is sch em e t o r epr esen t a n y piecewise lin ea r desir ed fu n ct ion wit h
2-23
Filter Design
a n y t r a n sit ion ba n ds. firls a n d remez design lowpa ss, h igh pa ss, ba n dpa ss, a n d ba n dst op filt er s; a ba n dpa ss exa m ple is
f = [0 0.3 a = [0 0 0.4 1 0.7 1 0.8 0 1]; 0]; % band edges in pairs % bandpass filter amplitude
Tech n ica lly, t h ese f a n d a vect or s defin e five ba n ds: Two st opba n ds, fr om 0.0 t o 0.3 a n d fr om 0.8 t o 1.0 A pa ssba n d fr om 0.4 t o 0.7 Two t r a n sit ion ba n ds, fr om 0.3 t o 0.4 a n d fr om 0.7 t o 0.8 E xa m ple h igh pa ss a n d ba n dst op filt er s a r e
f = [0 0.7 a = [0 0 f = [0 0.3 a = [1 1 0.8 1 0.4 0 1]; 1]; 0.5 0 % band edges in pairs % highpass filter amplitude 0.8 1 1]; 1]; % band edges in pairs % bandstop filter amplitude
An ot h er possibilit y is a filt er t h a t h a s a s a t r a n sit ion r egion t h e lin e con n ect in g t h e pa ssba n d wit h t h e st opba n d; t h is ca n h elp con t r ol r u n a wa y m a gn it u de r espon se in wide t r a n sit ion r egion s:
f = [0 0.4 0.42 0.48 0.5 1]; a = [1 1 0.8 0.2 0 0]; % passband,linear transition,stopband
2-24
You ca n fin d t h e dela yed H ilber t t r a n sfor m of a sign a l x by pa ssin g it t h r ou gh t h ese filt er s:
Fs = 1000; t = (0:1/Fs:2)'; x = sin(2*pi*300*t); xh = filter(bb,1,x); % % % % sampling frequency two second time vector 300 Hz sine wave example signal Hilbert transform of x
2-25
Filter Design
Th e a n a lyt ic sign a l cor r espon din g t o x is t h e com plex sign a l t h a t h a s x a s it s r ea l pa r t a n d t h e H ilber t t r a n sfor m of x a s it s im a gin a r y pa r t . F or t h is F IR m et h od (a n a lt er n a t ive t o t h e hilbert fu n ct ion ), you m u st dela y x by h a lf t h e filt er or der t o cr ea t e t h e a n a lyt ic sign a l.
xd = [zeros(10,1); x(1:length(x)10)]; % delay 10 samples xa = xd + j*xh; % analytic signal
Th is m et h od does n ot wor k dir ect ly for filt er s of odd or der , wh ich r equ ir e a n on in t eger dela y. In t h is ca se, t h e hilbert fu n ct ion , descr ibed in t h e Specia lized Tr a n sfor m s sect ion in Ch a pt er 4, est im a t es t h e a n a lyt ic sign a l. Alt er n a t ively, u se t h e resample fu n ct ion t o dela y t h e sign a l by a n on in t eger n u m ber of sa m ples.
Differentiators
Differ en t ia t ion of a sign a l in t h e t im e dom a in is equ iva len t t o m u lt iplica t ion of t h e sign a ls F ou r ier t r a n sfor m by a n im a gin a r y r a m p fu n ct ion . Th a t is, t o differ en t ia t e a sign a l, pa ss it t h r ou gh a filt er t h a t h a s a r espon se H (w ) = jw . Appr oxim a t e t h e idea l differ en t ia t or (wit h a dela y) u sin g remez or firls wit h a 'd' or 'differentiator' opt ion .
b = remez(21,[0 1],[0 pi*Fs],'d');
To obt a in t h e cor r ect der iva t ive, sca le by pi*Fs r a d/sec, wh er e Fs is t h e sa m plin g fr equ en cy in H er t z. F or a t ype III filt er , t h e differ en t ia t ion ba n d sh ou ld st op sh or t of t h e Nyqu ist fr equ en cy, a n d t h e a m plit u de vect or m u st r eflect t h a t ch a n ge t o en su r e t h e cor r ect slope.
bb = remez(20,[0 0.9],[0 0.9*pi*Fs],'d');
In t h e 'd' m ode, remez weigh t s t h e er r or by 1/w in n on zer o a m plit u de ba n ds t o m in im ize t h e m a xim u m relative er r or . firls weigh t s t h e er r or by (1/w )2 in n on zer o a m plit u de ba n ds in t h e 'd' m ode.
2-26
2-27
Filter Design
t h e t ech n iqu e en a bles you t o specify a r bit r a r ily sm a ll pea ks r esu lt in g fr om Gibbs ph en om en a . Th er e a r e t wo t oolbox fu n ct ion s t h a t im plem en t t h is design t ech n iqu e.
Description Function fircls fircls1
Con st r a in ed lea st squ a r e m u lt iba n d F IR filt er design . Con st r a in ed lea st squ a r e filt er design for lowpa ss a n d h igh pa ss lin ea r ph a se filt er s
F or det a ils on t h e ca llin g syn t a x for t h ese fu n ct ion s, see t h eir r efer en ce descr ipt ion s in Ch a pt er 6.
ds = 0.008
2-28
0.8
0.6
0.4
0.2
-0.2
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
con st a n t m a gn it u de r espon se. In t h is ca se, you ca n specify a vect or of ba n d edges a n d a cor r espon din g vect or of ba n d a m plit u des. In a ddit ion , you ca n specify t h e m a xim u m a m ou n t of r ipple for ea ch ba n d. F or exa m ple, a ssu m e t h e specifica t ion s for a filt er ca ll for : F r om 0 t o 0.3 (n or m a lized): a m plit u de 0, u pper bou n d 0.005, lower bou n d -0.005 F r om 0.3 t o 0.5: a m plit u de 0.5, u pper bou n d 0.51, lower bou n d 0.49 F r om 0.5 t o 0.7: a m plit u de 0, u pper bou n d 0.03, lower bou n d -0.03 F r om 0.7 t o 0.9: a m plit u de 1, u pper bou n d 1.02, lower bou n d 0.98 F r om 0.9 t o 1: a m plit u de 0, u pper bou n d 0.05, lower bou n d -0.05
2-29
Filter Design
Design a CLS filt er wit h im pu lse r espon se or der 129 t h a t m eet s t h ese specifica t ion s.
n = 129; f = [0 0.3 0.5 0.7 0.9 1]; a = [0 0.5 0 1 0]; up = [0.005 0.51 0.03 1.02 0.05]; lo = [0.005 0.49 0.03 0.98 0.05]; h = fircls(n,f,a,up,lo,'plot');
1.2
0.8
0.6
0.4
0.2
-0.2
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
2-30
P a ssba n d edge for t h e weigh t fu n ct ion of 0.28 (n or m a lized) St opba n d edge for t h e weigh t fu n ct ion of 0.32 Weigh t er r or m in im iza t ion 10 t im es a s m u ch in t h e st opba n d a s in t h e pa ssba n d To a ppr oa ch t h is u sin g fircls1:
n = 55; wo = 0.3; dp = 0.02; ds = 0.004; wp = 0.28; ws = 0.32; k = 10; h = fircls1(n,wo,dp,ds,wp,ws,k,'plot');
0.8
0.6
0.4
0.2
-0.2
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
2-31
Filter Design
Th is design t ech n iqu e m a y be u sed t o pr odu ce n on lin ea r -ph a se F IR filt er s, a sym m et r ic fr equ en cy-r espon se filt er s (wit h com plex coefficien t s), or m or e sym m et r ic filt er s wit h cu st om fr equ en cy r espon ses. Th e design a lgor it h m opt im izes t h e Ch ebysh ev (or m in im a x) er r or u sin g a n ext en ded Rem ez-exch a n ge a lgor it h m for a n in it ia l est im a t e. If t h is exch a n ge m et h od fa ils t o obt a in t h e opt im a l filt er , t h e a lgor it h m swit ch es t o a n a scen t -descen t a lgor it h m t h a t t a kes over t o fin ish t h e con ver gen ce t o t h e opt im a l solu t ion . F or det a ils on t h e ca llin g syn t a x for cremez, see t h e r efer en ce descr ipt ion in Ch a pt er 6.
[5 1] [2 2] [2 1]
1 10 5
A lin ea r -ph a se m u lt iba n d filt er m a y be design ed u sin g t h e pr edefin ed fr equ en cy-r espon se fu n ct ion multiband, a s follows.
b = cremez(38, [1 0.5 0.4 0.3 0.4 0.8], ... {multiband, [5 1 2 2 2 1]}, [1 10 5]);
F or t h e specific ca se of a m u lt iba n d filt er , we ca n u se a sh or t h a n d filt er design n ot a t ion sim ila r t o t h e syn t a x for remez:
b = cremez(38,[1 0.5 0.4 0.3 0.4 0.8], ... [5 1 2 2 2 1], [1 10 5]);
As wit h remez, a vect or of ba n d edges is pa ssed t o cremez. Th is vect or defin es t h e fr equ en cy ba n ds over wh ich opt im iza t ion is per for m ed; n ot e t h a t t h er e a r e t wo t r a n sit ion ba n ds, fr om -0.5 t o -0.4 a n d fr om 0.3 t o 0.4.
2-32
In eit h er ca se, t h e fr equ en cy r espon se is obt a in ed a n d plot t ed u sin g lin ea r sca le.
[h,w] = freqz(b,1,512,whole); plot(w/pi1,fftshift(abs(h)));
Not e t h a t t h e fr equ en cy r espon se h a s been ca lcu la t ed over t h e en t ir e n or m a lized fr equ en cy r a n ge [-1 +1] by pa ssin g t h e opt ion 'whole' t o freqz. In or der t o plot t h e n ega t ive fr equ en cy in for m a t ion in a n a t u r a l wa y, t h e r espon se h a s been wr a pped, ju st a s F F T da t a is, u sin g fftshift.
5
4.5
4 Magnitude Response
3.5
2.5
1.5
1 -1
-0.8
-0.6
-0.4
0.4
0.6
0.8
2-33
Filter Design
Th e filt er r espon se for t h is m u lt iba n d filt er is com plex, wh ich is expect ed beca u se of t h e a sym m et r y in t h e fr equ en cy dom a in . Th e filt er r espon se is
2.5 2 1.5 Real Part 1 0.5 0 -0.5
10
15
20
25
30
35
40
-0.2
10
15
20
25
30
35
40
2-34
Th e r esu lt in g m a gn it u de r espon se is
[h,w] = freqz(b,1,512,'whole'); plot(w/pi1,fftshift(abs(h)));
1.4
1.2
Magnitude Response
0.8
0.6
0.4
0.2
0 -1
-0.8
-0.6
-0.4
0.4
0.6
0.8
Th e gr ou p dela y of t h e filt er r evea ls t h a t t h e offset h a s been r edu ced fr om N/2=30.5 t o N/216=14.5. Now, h owever , t h e gr ou p dela y is n o lon ger fla t in t h e pa ssba n d r egion (plot t ed over t h e n or m a lized fr equ en cy r a n ge 0 t o 0.5 for cla r it y).
17
16
15
14
13
12 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 Normalized frequency (Nyquist == 1) 0.4 0.45 0.5
2-35
Filter Design
If we com pa r e t h is n on lin ea r -ph a se filt er t o a lin ea r -ph a se filt er t h a t h a s exa ct ly 14.5 sa m ples of gr ou p dela y, t h e r esu lt in g filt er is of or der 2*14.5 or 29. Usin g b = cremez(29,[0 0.5 0.55 1],'lowpass'), t h e pa ssba n d a n d st opba n d r ipple is m u ch gr ea t er for t h e or der 29 filt er . Th ese com pa r ison s ca n a ssist you in decidin g wh ich filt er is m or e a ppr opr ia t e for a specific a pplica t ion .
2-36
cheby1
cheby2
ellip
besself
Minimum Order Computation for Classical IIR Filter Design buttord cheb1ord cheb2ord ellipord
Th e butter, cheby1, cheby2, a n d ellip fu n ct ion s a r e su fficien t for m a n y design pr oblem s, a n d t h e lower level fu n ct ion s a r e gen er a lly n ot n eeded. Bu t if you do h a ve a n a pplica t ion wh er e you n eed t o t r a n sfor m t h e ba n d edges of a n a n a log filt er , or discr et ize a r a t ion a l t r a n sfer fu n ct ion , t h is sect ion descr ibes t ools t o do so.
2-37
Filter Design
Frequency Transformation
Th e secon d st ep in t h e a n a log pr ot ot ypin g design t ech n iqu e is t h e fr equ en cy t r a n sfor m a t ion of a lowpa ss pr ot ot ype. Th e t oolbox pr ovides a set of fu n ct ion s t o t r a n sfor m a n a log lowpa ss pr ot ot ypes (wit h cu t off fr equ en cy of 1 r a d/sec) in t o ba n dpa ss, h igh pa ss, ba n dst op, a n d lowpa ss filt er s of t h e desir ed cu t off fr equ en cy.
2-38
Freq. Transformation
Transformation Function [numt,dent] = lp2lp(num,den,Wo) [At,Bt,Ct,Dt] = lp2lp(A,B,C,D,Wo) [numt,dent] = lp2hp(num,den,Wo) [At,Bt,Ct,Dt] = lp2hp(A,B,C,D,Wo)
#0 s ' = -----s
Lowpa ss t o ba n dpa ss # 0 ( s #0 ) 2 + 1 s ' = ------- -----------------------------s #0 B# Lowpa ss t o ba n dst op B# s #0 s ' = ------- -----------------------------#0 ( s # )2 + 1 0
As sh own , a ll of t h e fr equ en cy t r a n sfor m a t ion fu n ct ion s ca n a ccept t wo lin ea r syst em m odels: t r a n sfer fu n ct ion a n d st a t e-spa ce for m . F or t h e ba n dpa ss a n d ba n dst op ca ses #0 = and B # = #2 #1 wh er e #1 is t h e lower ba n d edge a n d #2 is t h e u pper ba n d edge. Th e fr equ en cy t r a n sfor m a t ion fu n ct ion s per for m fr equ en cy va r ia ble su bst it u t ion . In t h e ca se of lp2bp a n d lp2bs, t h is is a secon d-or der su bst it u t ion , so t h e ou t pu t filt er is t wice t h e or der of t h e in pu t . F or lp2lp a n d lp2hp, t h e ou t pu t filt er is t h e sa m e or der a s t h e in pu t . # 1 #2
2-39
Filter Design
To begin design in g a n or der 10 ba n dpa ss Ch ebysh ev t ype I filt er wit h a va lu e of 3 dB for pa ssba n d r ipple
[z,p,k] = cheb1ap(5,3); z, p, a n d k con t a in t h e poles, zer os, a n d ga in of a lowpa ss a n a log filt er wit h cu t off fr equ en cy "c equ a l t o 1 r a d/sec. Use t h e lp2bp fu n ct ion t o t r a n sfor m t h is lowpa ss pr ot ot ype t o a ba n dpa ss a n a log filt er wit h ba n d edges W 1 = $/5 a n d W 2 = $. F ir st , con ver t t h e filt er t o st a t e-spa ce for m so t h e lp2bp fu n ct ion ca n a ccept it . [A,B,C,D] = zp2ss(z,p,k); % Convert to statespace form.
2-40
10
-1
10
-2
10
-3
10
-4
10
-5
10
-6
10
-7
pi/5
pi Frequency (rad/sec)
Filter Discretization
Th e t h ir d st ep in t h e a n a log pr ot ot ypin g t ech n iqu e is t h e t r a n sfor m a t ion of t h e filt er t o t h e discr et e-t im e dom a in . Th e t oolbox pr ovides t wo m et h ods for t h is: t h e im pu lse in va r ia n t a n d bilin ea r t r a n sfor m a t ion s. Th e filt er design fu n ct ion s
2-41
Filter Design
butter, cheby1, cheby2, a n d ellip u se t h e bilin ea r t r a n sfor m a t ion for discr et iza t ion in t h is st ep. Analog to Digital Transformation Transformation Function [numd,dend] = impinvar(num,den,Fs) [zd,pd,kd] = bilinear(z,p,k,Fs,Fp) [numd,dend] = bilinear(num,den,Fs,Fp) [Ad,Bd,Cd,Dd] = bilinear(At,Bt,Ct,Dt,Fs,Fp)
Impulse Invariance
Th e t oolbox fu n ct ion impinvar cr ea t es a digit a l filt er wh ose im pu lse r espon se is t h e sa m ples of t h e con t in u ou s im pu lse r espon se of a n a n a log filt er . Th is fu n ct ion wor ks on ly on filt er s in t r a n sfer fu n ct ion for m . F or best r esu lt s, t h e a n a log filt er sh ou ld h a ve n egligible fr equ en cy con t en t a bove h a lf t h e sa m plin g fr equ en cy, beca u se su ch h igh fr equ en cy con t en t is a lia sed in t o lower ba n ds u pon sa m plin g. Im pu lse in va r ia n ce wor ks for som e lowpa ss a n d ba n dpa ss filt er s, bu t is n ot a ppr opr ia t e for h igh pa ss a n d ba n dst op filt er s.
2-42
-50
-100
-150 0
0.1
0.2
0.8
0.9
200 Phase (degrees) 0 -200 -400 -600 -800 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 Normalized frequency (Nyquist == 1) 0.8 0.9 1
Bilinear Transformation
Th e bilin ea r t r a n sfor m a t ion is a n on lin ea r m a ppin g of t h e con t in u ou s dom a in t o t h e discr et e dom a in ; it m a ps t h e s -pla n e in t o t h e z -pla n e by H (z ) = H (s )
z1 s = k ----------z+1
Bilin ea r t r a n sfor m a t ion m a ps t h e j" a xis of t h e con t in u ou s dom a in t o t h e u n it cir cle of t h e discr et e dom a in a ccor din g t o "4 # = 2 t a n 1 3 --1k2 Th e t oolbox fu n ct ion bilinear im plem en t s t h is oper a t ion , wh er e t h e fr equ en cy wa r pin g con st a n t k is equ a l t o t wice t h e sa m plin g fr equ en cy (2*Fs) by defa u lt a n d equ a l t o 2*pi*Fp/tan(pi*Fp/Fs) if you give bilinear a t r a ilin g a r gu m en t t h a t r epr esen t s a m a t ch fr equ en cy Fp. If a m a t ch fr equ en cy Fp (in H er t z) is
2-43
Filter Design
pr esen t , bilinear m a ps t h e fr equ en cy " = 2 $f p (in r a dia n s/secon d) t o t h e sa m e fr equ en cy in t h e discr et e dom a in , n or m a lized t o t h e sa m plin g r a t e: # = 2 $f p / f s (a lso in r a dia n s/secon d). Th e bilinear fu n ct ion ca n per for m t h is t r a n sfor m a t ion on t h r ee differ en t lin ea r syst em r epr esen t a t ion s: zer o-pole-ga in , t r a n sfer fu n ct ion , a n d st a t e-spa ce for m . Tr y ca llin g bilinear wit h t h e st a t e-spa ce m a t r ices t h a t descr ibe t h e Ch ebysh ev t ype I filt er fr om t h e pr eviou s sect ion , u sin g a sa m plin g fr equ en cy of 2 H z, a n d r et a in in g t h e lower ba n d edge of 0.1 H z.
[Ad,Bd,Cd,Dd] = bilinear(At,Bt,Ct,Dt,2,0.1);
-100
-200
-300 0
0.1
0.2
0.8
0.9
500
Phase (degrees)
-500
-1000 0
0.1
0.2
0.8
0.9
Th e lower ba n d edge is a t 0.1 H z a s expect ed. Not ice, h owever , t h a t t h e u pper ba n d edge is sligh t ly less t h a n 0.5 H z, a lt h ou gh in t h e a n a log dom a in it wa s exa ct ly 0.5 H z. Th is illu st r a t es t h e n on lin ea r n a t u r e of t h e bilin ea r t r a n sfor m a t ion . To cou n t er a ct t h is n on lin ea r it y, it is n ecessa r y t o cr ea t e a n a log dom a in filt er s wit h pr ewa r ped ba n d edges, wh ich m a p t o t h e cor r ect loca t ion s
2-44
u pon bilin ea r t r a n sfor m a t ion . H er e t h e pr ewa r ped fr equ en cies u1 a n d u2 gen er a t e Bw a n d Wo for t h e lp2bp fu n ct ion .
Fs = 2; % sampling frequency (Hertz) u1 = 2*Fs*tan(.1*(2*pi/Fs)/2); % lower band edge (radians/second) u2 = 2*Fs*tan(.5*(2*pi/Fs)/2); % upper band edge (radians/second) Bw = u2u1; % bandwidth Wo = sqrt(u1*u2); % center frequency [At,Bt,Ct,Dt] = lp2bp(A,B,C,D,Wo,Bw);
A digit a l ba n dpa ss filt er wit h cor r ect ba n d edges 0.1 a n d 0.5 t im es t h e Nyqu ist fr equ en cy is
[Ad,Bd,Cd,Dd] = bilinear(At,Bt,Ct,Dt,Fs);
Th e exa m ple ba n dpa ss filt er s fr om t h e la st t wo sect ion s cou ld a lso be cr ea t ed in on e st a t em en t u sin g t h e com plet e IIR design fu n ct ion cheby1. F or in st a n ce, a n a n a log ver sion of t h e exa m ple Ch ebysh ev filt er is
[b,a] = cheby1(5,3,[0.1 0.5]*2*pi,'s');
Not e t h a t t h e ba n d edges a r e in r a dia n s/secon d for a n a log filt er s, wh er ea s for t h e digit a l ca se, fr equ en cy is n or m a lized (t h e Nyqu ist fr equ en cy is equ a l t o 1 H z).
[bz,az] = cheby1(5,3,[0.1 0.5]);
All of t h e com plet e design fu n ct ion s ca ll bilinear in t er n a lly. Th ey pr ewa r p t h e ba n d edges a s n eeded t o obt a in t h e cor r ect digit a l filt er . See Ch a pt er 6 for m or e on t h ese fu n ct ion s.
2-45
Filter Design
References
1 Ka r a m , L.J ., a n d J .H . McClella n . Com plex Ch ebysh ev Appr oxim a t ion for
Design . Proceed in gs of th e IE E E In t. Con f. Acou st., S peech , S ign al Processin g . Vol. 3 (Ma y 1996).
3 Selesn ick, I.W., M. La n g, a n d C.S. Bu r r u s. Con st r a in ed Lea st Squ a r e
Design of F IR F ilt er s wit h ou t Specified Tr a n sit ion Ba n ds. Proceed in gs of th e IE E E In t. Con f. Acou st., S peech , S ign al Processin g . Vol. 2 (Ma y 1995). P gs. 1260-1263.
2-46
3
St a t ist ica l Sign a l P r ocessin g
Co rre la tio n a n d Co v a ria n c e . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2 Bia s a n d Nor m a liza t ion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3 Mu lt iple Ch a n n els . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4 S p e c tra l An a ly s is . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Welch s Met h od . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Mu lt it a per Met h od . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Yu le-Wa lker AR Met h od . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bu r g Met h od . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Cova r ia n ce a n d Modified Cova r ia n ce Met h ods . . . . . . . . . . . . . MUSIC a n d E igen vect or An a lysis Met h ods . . . . . . . . . . . . . . . . 3-5 . 3-6 3-16 3-19 3-20 3-22 3-23
Re fe re n c e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-27
wh er e x n a n d y n a r e st a t ion a r y r a n dom pr ocesses, -* < n < * , a n d E { } is t h e expect ed va lu e oper a t or . Th e cr oss-cova r ia n ce sequ en ce is t h e m ea n -r em oved cr oss-cor r ela t ion sequ en ce C x y (m ) = E {( x n x ) ( y * n + m * x ) } or , in t er m s of t h e cr oss-cor r ela t ion , C x y (m ) = 7 x y (m ) x * y In pr a ct ice, you m u st est im a t e t h ese sequ en ces, beca u se it is possible t o a ccess on ly a fin it e segm en t of t h e in fin it e-len gt h r a n dom pr ocess. A com m on est im a t e ba sed on N sa m ples of x n a n d y n is t h e det er m in ist ic cr oss-cor r ela t ion sequ en ce (a lso ca lled t h e t im e-a m bigu it y fu n ct ion ) ( & * xn yn +m & R x y (m ) = ' n =0 & & * y x ( m ) % R
N m 1
m 80
m <0
3-2
F or exa m ple,
x = [1 1 1 1 1]'; y = x; xyc = xcorr(x,y) xyc = 1.0000 2.0000 3.0000 4.0000 5.0000 4.0000 3.0000 2.0000 1.0000
Not ice t h a t t h e r esu lt in g sequ en ce is t wice t h e len gt h of t h e in pu t sequ en ce m in u s 1. Th u s, t h e N t h elem en t is t h e cor r ela t ion a t la g 0. Also n ot ice t h e t r ia n gu la r pu lse of t h e ou t pu t t h a t r esu lt s wh en con volvin g t wo squ a r e pu lses. Th e xcov fu n ct ion est im a t es a u t ocova r ia n ce a n d cr oss-cova r ia n ce sequ en ces. Th is fu n ct ion h a s t h e sa m e opt ion s a n d eva lu a t es t h e sa m e su m a s xcorr, bu t fir st r em oves t h e m ea n s of x a n d y.
x y (m ) } = E {R
+
n =0
E {x n y * n + m } = ( N m ) 7 x y (m )
3-3
xcorr pr ovides t h e u n bia sed est im a t e, dividin g by N -| m | , wh en you specify a n 'unbiased' fla g a ft er t h e in pu t sequ en ces. xcorr(x,y,'unbiased')
Alt h ou gh t h is est im a t e is u n bia sed, t h e en d poin t s (n ea r -(N -1) a n d N -1) su ffer fr om la r ge va r ia n ce beca u se xcorr com pu t es t h em u sin g on ly a few da t a poin t s. A possible t r a de-off is t o sim ply divide by N u sin g t h e 'biased' fla g.
xcorr(x,y,'biased')
Wit h t h is sch em e, on ly t h e sa m ple of t h e cor r ela t ion a t 0 la g (t h e N t h ou t pu t elem en t ) is u n bia sed. Th is est im a t e is oft en m or e desir a ble t h a n t h e u n bia sed on e beca u se it a voids r a n dom la r ge va r ia t ion s a t t h e en d poin t s of t h e cor r ela t ion sequ en ce.
xcorr pr ovides on e ot h er n or m a liza t ion sch em e. Th e syn t a x xcorr(x,y,'coeff')
Multiple Channels
F or a m u lt ich a n n el sign a l, xcorr a n d xcov est im a t e t h e a u t ocor r ela t ion a n d cr oss-cor r ela t ion a n d cova r ia n ce sequ en ces for a ll of t h e ch a n n els a t on ce. If S is a n M -by-N sign a l m a t r ix r epr esen t in g N ch a n n els in it s colu m n s, xcorr(S) r et u r n s a (2 M -1)-by-N 2 m a t r ix wit h t h e a u t ocor r ela t ion s a n d cr oss-cor r ela t ion s of t h e ch a n n els of S in it s N 2 colu m n s. If S is a 3-ch a n n el sign a l
S = [s1 s2 s3]
Two r ela t ed fu n ct ion s, cov a n d corrcoef, a r e a va ila ble in t h e st a n da r d MATLAB en vir on m en t . Th ey est im a t e cova r ia n ce a n d n or m a lized cova r ia n ce r espect ively bet ween t h e differ en t ch a n n els a t la g 0 a n d a r r a n ge t h em in a squ a r e m a t r ix.
3-4
Spectral Analysis
Spectral Analysis
Spect r a l a n a lysis seeks t o descr ibe t h e fr equ en cy con t en t of a sign a l, r a n dom pr ocess, or syst em , ba sed on a fin it e set of da t a . E st im a t ion of power spect r a is u sefu l in a va r iet y of a pplica t ion s, in clu din g t h e det ect ion of sign a ls bu r ied in wide-ba n d n oise. Th e pow er spectral d en sity (P SD) of a st a t ion a r y r a n dom pr ocess x n is r ela t ed m a t h em a t ica lly t o t h e cor r ela t ion sequ en ce by t h e discr et e-t im e F ou r ier t r a n sfor m ,
*
P x x ( #) =
+
m = *
7 x x (m ) e j # m
Th is fu n ct ion of fr equ en cy h a s t h e pr oper t y t h a t it s in t egr a l over a fr equ en cy ba n d is equ a l t o t h e power of t h e sign a l x n in t h a t ba n d. Th e P SD is a specia l ca se of t h e cross spectral d en sity (CSD) fu n ct ion , defin ed bet ween t wo sign a ls x n a n d y n a s
*
P x y ( #) =
+
m = *
7 x y (m ) e j # m
As is t h e ca se for t h e cor r ela t ion a n d cova r ia n ce sequ en ces, t h e t oolbox estim ates t h e P SD a n d CSD beca u se sign a l len gt h s a r e fin it e. Th e va r iou s m et h ods of P SD est im a t ion ca n be iden t ified a s param etric or n on param etric. On e t ech n iqu e offer ed in t h e Sign a l P r ocessin g Toolbox is t h e popu la r n on pa r a m et r ic sch em e developed by Welch [5]. Th is is com plem en t ed by m or e m oder n n on pa r a m et r ic t ech n iqu es su ch a s t h e m u ltitaper m eth od (MTM) a n d t h e m u ltiple sign al classification (MUSIC) or eigen vector (E V) m eth od , wh ich is well su it ed for lin e spect r a (da t a m a de u p of sin u soids). Th e Y u le-W alk er au toregressive (AR) m eth od is a pa r a m et r ic m et h od t h a t est im a t es t h e a u t ocor r ela t ion fu n ct ion t o solve for t h e AR m odel pa r a m et er s. Th e B u rg m eth od is a n ot h er pa r a m et r ic spect r a l est im a t ion m et h od t h a t m in im izes t h e for wa r d a n d ba ck wa r d lin ea r pr edict ion er r or s wh ile sa t isfyin g t h e Levin son -Du r bin r ecu r sion . Th ese m et h ods a r e list ed in t h e t a ble below wit h t h e cor r espon din g t oolbox fu n ct ion n a m e. Th e n u m ber below ea ch m et h od n a m e in dica t es t h e pa ge t h a t descr ibes t h e m et h od in gr ea t er det a il. See
3-5
Bu r g (3-20)
Au t or egr essive (AR) spect r a l est im a t ion of a t im e-ser ies by m in im iza t ion of lin ea r pr edict ion er r or s Au t or egr essive (AR) spect r a l est im a t ion of a t im e-ser ies by m in im iza t ion of t h e for wa r d pr edict ion er r or s Au t or egr essive (AR) spect r a l est im a t ion of a t im e-ser ies by m in im iza t ion of t h e for wa r d a n d ba ckwa r d pr edict ion er r or s Spect r a l est im a t e fr om com bin a t ion of m u lt iple or t h ogon a l win dows (or t a per s) Mu lt iple sign a l cla ssifica t ion or eigen vect or m et h od Aver a ged per iodogr a m s of over la pped, win dowed sign a l sect ion s Au t or egr essive (AR) spect r a l est im a t e of a t im e-ser ies fr om it s est im a t ed a u t ocor r ela t ion fu n ct ion
Cova r ia n ce (3-22)
pcov
Modified Cova r ia n ce (3-22) Mu lt it a per (3-16) MUSIC (3-23) Welch (3-6) Yu le-Wa lk er AR (3-19)
pmcov
pmtm
Welchs Method
On e wa y of est im a t in g t h e power spect r u m of a pr ocess is t o sim ply fin d t h e discr et e-t im e F ou r ier t r a n sfor m of t h e sa m ples of t h e pr ocess (u su a lly don e on
3-6
Spectral Analysis
a gr id wit h a n F F T) a n d t a k e t h e m a gn it u de squ a r ed of t h e r esu lt . An exa m ple 1001-elem en t sign a l xn, wh ich con sist s of t wo sin u soids plu s n oise, is given by
Fs = 1000; % sampling frequency t = 0:1/Fs:1; % one second worth of samples xn = sin(2*pi*50*t) + 2*sin(2*pi*120*t) + randn(size(t));
A cr u de est im a t e of t h e P SD of xn is
Pxx = abs(fft(xn,1024)).^2/1001;
Th is est im a t e is ca lled t h e period ogram . Sca le t h e m a gn it u de squ a r ed of t h e F F T by t h e squ a r e of t h e n or m of t h e da t a win dow a pplied t o t h e sign a l (in t h is ca se, a len gt h 1001 r ect a n gu la r win dow) t o en su r e t h a t t h e est im a t e is asym ptotically u n biased . Th a t is, a s t h e n u m ber of sa m ples in cr ea ses, t h e expect ed va lu e of t h e per iodogr a m a ppr oa ch es t h e t r u e P SD. Th e pr oblem wit h t h e per iodogr a m est im a t e is t h a t it s va r ia n ce is la r ge (on t h e or der of t h e P SD squ a r ed) a n d does n ot decr ea se a s t h e n u m ber of sa m ples in cr ea ses. Th e followin g t wo exa m ples sh ow t h is; a s F F T len gt h in cr ea ses, t h e per iodogr a m does n ot becom e sm oot h er .
Pxx_short = abs(fft(xn,256)).^2/256; plot((0:255)/256*Fs,10*log10(Pxx_short)) plot((0:1023)/1024*Fs,10*log10(Pxx))
Redu ce t h e va r ia n ce of t h e P SD est im a t e by br ea kin g t h e sign a l in t o n on over la ppin g sect ion s a n d a ver a gin g t h e per iodogr a m s of t h ese sect ion s.
Pxx = (abs(fft(xn( 1:256))).^2 + abs(fft(xn(257:512))).^2 + ... abs(fft(xn(513:768))).^2 ) / (256*3); plot((0:255)/256*Fs,10*log10(Pxx))
Averaged Periodogram (no overlap) 25
Power Spectrum (dB)
20 15 10 5 0 -5 -10 0 100 200 300 400 500 600 Frequency (Hz) 700 800 900 1000
3-7
Short Periodogram 30
Power Spectrum (dB)
20 10 0 -10 -20 0
100
200
300
400
700
800
900
1000
30
Power Spectrum (dB)
20 10 0 -10 -20 -30 0 100 200 300 400 500 600 Frequency (Hz) 700 800 900 1000
Th is a ver a ged est im a t e h a s on e t h ir d t h e va r ia n ce of t h e len gt h 256 per iodogr a m sh own ea r lier . Th e m or e sect ion s you a ver a ge, t h e lower t h e va r ia n ce of t h e r esu lt . H owever , t h e sign a l len gt h lim it s t h e n u m ber of sect ion s
3-8
Spectral Analysis
possible (t o t h r ee sect ion s of len gt h 256 in t h e pr eviou s exa m ple). To obt a in m or e sect ion s, br ea k t h e sign a l in t o over la ppin g sect ion s.
Pxx = (abs(fft(xn( 1:256))).^2 + abs(fft(xn(129:384))).^2 + ... abs(fft(xn(257:512))).^2 + abs(fft(xn(385:640))).^2 + ... abs(fft(xn(513:768))).^2 + ... abs(fft(xn(641:896))).^2 ) / (256*6); plot((0:255)/256*Fs,10*log10(Pxx))
Averaged Periodogram (128 sample overlap) 25
Power Spectrum (dB)
20 15 10 5 0 -5 -10 0 100 200 300 400 500 600 Frequency (Hz) 700 800 900 1000
In t h is ca se t h e sect ion s a r e st a t ist ica lly depen den t , r esu lt in g in h igh er va r ia n ce; t h u s t h er e is a t r a de-off bet ween t h e n u m ber of sect ion s a n d t h e over la p r a t e. An ot h er wa y t o im pr ove t h e per iodogr a m est im a t e is t o a pply a n on r ect a n gu la r da t a win dow t o t h e sect ion s befor e com pu t in g t h e per iodogr a m , r esu lt in g in a m od ified period ogram . Th is r edu ces t h e effect of sect ion depen den ce du e t o over la p, beca u se t h e win dow is t a per ed t o 0 on t h e edges. Also, a n on r ect a n gu la r win dow dim in ish es t h e side-lobe in t er fer en ce or spect r a l lea k a ge wh ile in cr ea sin g t h e widt h of spect r a l pea ks. Wit h a su it a ble win dow (su ch a s H a m m in g, H a n n in g, or Ka iser ), over la p r a t es of a bou t h a lf t h e sect ion len gt h h a ve been fou n d t o lower t h e va r ia n ce of t h e est im a t e sign ifica n t ly.
3-9
20 15 10 5 0 -5 -10 0 100 200 300 400 500 600 Frequency (Hz) 700 800 900 1000
Not ice in t h is plot t h a t t h e spect r a l pea ks h a ve widen ed, a n d t h e n oise floor , or level of t h e n oise, seem s t o be t h e fla t t est of a n y est im a t e so fa r . Th is m et h od of a ver a ged, m odified per iodogr a m s is Welch s m et h od of P SD est im a t ion . Th e fu n ct ion s pwelch a n d csd pr ovide con t r ol over a ll t h e pa r a m et er s discu ssed so fa r (F F T len gt h , win dow, a n d a m ou n t of over la p) in com pu t in g t h e P SD a n d CSD of sign a ls u sin g Welch s m et h od. F or a m or e det a iled discu ssion of Welch s m et h od of P SD est im a t ion , see Ka y [1] a n d Welch [5].
3-10
Spectral Analysis
Pxx h a s u n it s of power per u n it fr equ en cy in t er va l. F or exa m ple, if t h e or igin a l sequ en ce xn h a s u n it s of volt s, Pxx h a s u n it s of Wa t t s/H z.
To r ecr ea t e t h e la st exa m ple a ccu r a t ely, specify 128 a s t h e n u m ber of sa m ples t o over la p:
nfft = 256; % length of FFT window = hanning(256); % window function noverlap = 128; % number of samples overlap Pxx = pwelch(xn,nfft,Fs,window,noverlap); Pxx is sca led by t h e r ecipr oca l of t h e sa m plin g fr equ en cy, 1/Fs. pwelch wit h ou t a n y ou t pu t s gen er a t es a plot of t h e P SD over t h e fr equ en cy r a n ge [0,Fs/2): pwelch(xn,nfft,Fs,window,noverlap)
Welchs Spectral Estimate Pxx(f) / fs !5 !10 Power Spectral Density (dB) !15 !20 !25 !30 !35 !40 0
50
100
150
200
350
400
450
500
All t h e spect r a l est im a t ion fu n ct ion s a llow you t o specify a n em pt y m a t r ix, [], in pla ce of a n in pu t a r gu m en t t o u se t h e defa u lt va lu e of t h a t a r gu m en t . In t h e com m a n d a bove, beca u se t h e va lu es for nfft a n d window a r e a ct u a lly t h e sa m e a s t h e defa u lt s, you cou ld r epla ce t h em bot h wit h t h e em pt y m a t r ix.
[Pxx,f] = pwelch(xn,[],Fs,[],noverlap);
3-11
Sin ce t h e sign a l xn is r ea l, pwelch r et u r n s on ly t h e fr equ en cies fr om 0 t h r ou gh t h e Nyqu ist fr equ en cy. In con t r a st , t h e ea r lier F F T exa m ple gen er a t ed P SD est im a t es r a n gin g fr om 0 t h r ou gh Fs.
6$ P x x(.) W (# .) d .
Beca u se t h e expect ed va lu e is n ot equ a l t o t h e t r u e P SD, t h e est im a t e is biased . Th is qu a n t it y is t h e con volu t ion of t h e t r u e P SD wit h t h e squ a r ed m a gn it u de of t h e win dows discr et e-t im e F ou r ier t r a n sfor m W (#), sca led by t h e squ a r ed n or m of t h e win dow. Th e sca lin g fa ct or is t h e su m of t h e squ a r es of t h e win dow fu n ct ion : w
2
+ w (n ) 2
Th is sa ys t h a t if P xx (#) h a s a pea k of h eigh t 1 a t a pa r t icu la r fr equ en cy #0 , t h e est im a t e will h a ve a ppr oxim a t e h eigh t W (0 ) 2 w 2 a t t h a t fr equ en cy, pr ovided t h e win dow W (#) is n a r r ow wit h r espect t o t h e spa cin g bet ween t h e pea k a n d ot h er spect r a l fea t u r es. So, t o obt a in a n est im a t e wh ich on a ver a ge r eflect s t h e h eigh t of t h e or igin a l pea ks, m u lt iply t h e r esu lt of pwelch by
3-12
Spectral Analysis
norm(w)^2/sum(w)^2, wh er e w is t h e win dow vect or . Th is sca lin g is in depen den t of win dow len gt h a n d sh a pe. F or exa m ple: w1 = hanning(256); w2 = hanning(500); [Pxx1,f1] = pwelch(xn,256,Fs,w1,128); [Pxx2,f2] = pwelch(xn,1024,Fs,w2,250); subplot(2,1,1) plot(f1,10*log10(Pxx1*norm(w1)^2/sum(w1)^2)) axis([0 500 70 20]); grid subplot(2,1,2) plot(f2,10*log10(Pxx2*norm(w2)^2/sum(w2)^2)) axis([0 500 70 20]); grid
!20 !30 !40 !50 !60 !70 0 !20 !30 !40 !50 !60 !70 0 100 200 300 400 500 100 200 300 400 500
In bot h plot s, wh ich sh ow t h e spect r u m a t posit ive fr equ en cies on ly (t h e n ega t ive fr equ en cies a r e t h e sa m e), t h e h igh er fr equ en cy pea k h a s a va lu e of 0 dB, a n d t h e lower fr equ en cy pea k is a t -6 dB. Th e 120 H z sin u soid h eigh t of 0 dB cor r espon ds t o a squ a r ed a m plit u de of 1. Th is r esu lt s fr om t h e sin u soid of a m plit u de 2 h a vin g com plex expon en t ia l com pon en t s of a m plit u de 1 a t bot h posit ive a n d n ega t ive fr equ en cy. Sim ila r ly, t h e 50 H z sin u soid h a s bot h posit ive a n d n ega t ive fr equ en cy com pon en t s wit h squ a r ed a m plit u de of (! )2 = " , or 10 *log10(.25) = -6 dB, a s sh own in t h e plot . Also, n ot e t h a t t h e secon d plot r eflect s a sligh t ly lower n oise floor , wh ich is t h e r esu lt of a lon ger win dow len gt h .
3-13
Confidence Intervals
Bot h t h e pwelch a n d csd fu n ct ion s ca n com pu t e con fiden ce in t er va ls. Sim ply pr ovide a n in pu t a r gu m en t p, wh ich specifies t h e per cen t a ge of t h e con fiden ce in t er va l.
[Pxx,Pxxc,f] = pwelch(x,nfft,Fs,window,noverlap,p) [Pxy,Pxyc,f] = csd(x,y,nfft,Fs,window,noverlap,p) p m u st be a sca la r bet ween 0 a n d 1. Th e fu n ct ion s a ssu m e ch i-squ a r ed dist r ibu t ed per iodogr a m s of n on over la ppin g sect ion s in com pu t in g t h e con fiden ce in t er va ls. (Th is a ssu m pt ion is va lid wh en t h e sign a l is a Ga u ssia n dist r ibu t ed r a n dom pr ocess.) P r ovided t h ese a ssu m pt ion s a r e cor r ect , t h er e is a p*100% pr oba bilit y t h a t t h e con fiden ce in t er va l [PxxPxxc(:,1) Pxx+Pxxc(:,2)]
cover s t h e t r u e P SD. If t h e sect ion s over la p, t h e con fiden ce in t er va l is n ot r elia ble a n d t h e fu n ct ion s displa y a wa r n in g m essa ge.
3-14
Spectral Analysis
Th is m et h od est im a t es bot h m a gn it u de a n d ph a se in for m a t ion . Th e tfe fu n ct ion u ses Welch s m et h od t o com pu t e t h e CSD a n d P SD a n d t h en for m s t h eir qu ot ien t for t h e t r a n sfer fu n ct ion est im a t e. Use tfe t h e sa m e wa y t h a t you u se t h e csd fu n ct ion . F ilt er t h e sign a l xn wit h a n F IR filt er , t h en plot t h e a ct u a l m a gn it u de r espon se a n d t h e est im a t ed r espon se.
h = ones(1,10)/10; % moving average filter yn = filter(h,1,xn); [HEST,f] = tfe(xn,yn,256,Fs,256,128,'none'); H = freqz(h,1,f,Fs); subplot(2,1,1); plot(f,abs(H)); title('Actual Transfer Function Magnitude'); subplot(2,1,2); plot(f,abs(HEST)); title('Transfer Function Magnitude Estimate'); xlabel('Frequency (Hz)');
Actual Transfer Function Magnitude 1 0.8 0.6 0.4 0.2 0 0 1 0.8 0.6 0.4 0.2 0 0 100 200 300 Frequency (Hz) 400 500 100 200 300 400 500
Coherence Function
Th e m a gn it u de-squ a r ed coh er en ce bet ween t wo sign a ls x (n ) a n d y (n ) is P x y ( #) 2 C x y (#) = ---------------------------------P x x (#) P y y (#)
3-15
Th is qu ot ien t is a r ea l n u m ber bet ween 0 a n d 1 t h a t m ea su r es t h e cor r ela t ion bet ween x (n ) a n d y (n ) a t t h e fr equ en cy #. Th e cohere fu n ct ion t a kes sequ en ces x a n d y, com pu t es t h eir P SDs a n d CSD, a n d r et u r n s t h e qu ot ien t of t h e m a gn it u de squ a r ed of t h e CSD a n d t h e pr odu ct of t h e P SDs. It s opt ion s a n d oper a t ion a r e sim ila r t o t h e csd a n d tfe fu n ct ion s. Th e coh er en ce fu n ct ion of xn a n d t h e filt er ou t pu t yn ver su s fr equ en cy is
cohere(xn,yn,256,Fs,256,128,'none')
Coherence Function 1
50
100
150
200
250 Frequency
300
350
400
450
500
If t h e in pu t sequ en ce len gt h , win dow len gt h , a n d over la p a r e su ch t h a t cohere oper a t es on on ly a sin gle r ecor d, t h e fu n ct ion r et u r n s a ll on es.
Multitaper Method
Th e m u ltitaper m eth od (MTM) u ses or t h ogon a l win dows (or t a per s) t o obt a in a ppr oxim a t ely in depen den t est im a t es of t h e power spect r u m a n d t h en com bin es t h em t o yield a n est im a t e. Th is est im a t e exh ibit s m or e degr ees of fr eedom a n d a llows for ea sier qu a n t ifica t ion of t h e bia s a n d va r ia n ce t r a de-offs, com pa r ed t o con ven t ion a l per iodogr a m m et h ods. Ma n y con ven t ion a l spect r a l est im a t es u se a sin gle t a per (or win dow), wit h som e ir r et r ieva ble loss of in for m a t ion a t t h e begin n in g a n d t h e en d of t h e ser ies. In t h e m u lt it a per m et h od, a ddit ion a l t a per s a r e u sed t o r ecover som e of t h e lost in for m a t ion . Th is br ief discu ssion of t h e m u lt it a per m et h od pr ovides a n in t u it ive look a t t h e a lgor it h m t o a ssist in det er m in in g wh en t o u se it . F or a m or e det a iled a n d t h or ou gh expla n a t ion , see P er civa l a n d Wa lden [3]. Th e sim ple pa r a m et er for t h e m u lt it a per m et h od is t h e t im e-ba n dwidt h pr odu ct , N W . Th is pa r a m et er is a r esolu t ion pa r a m et er dir ect ly r ela t ed t o t h e n u m ber of t a per s u sed t o com pu t e t h e spect r u m . Th er e a r e a lwa ys 2 *N W -1 t a per s u sed t o for m t h e est im a t e. Th is m ea n s t h a t , a s N W in cr ea ses, t h er e a r e
3-16
Spectral Analysis
m or e est im a t es of t h e power spect r u m , a n d t h e va r ia n ce of t h e est im a t e decr ea ses. H owever , t h e ba n dwidt h of ea ch t a per is a lso pr opor t ion a l t o N W , so a s N W in cr ea ses, ea ch est im a t e exh ibit s m or e spect r a l lea ka ge (i.e., wider pea ks) a n d t h e over a ll spect r a l est im a t e is m or e bia sed. F or ea ch da t a set , t h er e is u su a lly a va lu e for N W t h a t a llows a n opt im a l t r a de-off bet ween bia s a n d va r ia n ce. Usin g pmtm on t h e da t a fr om t h e pr eviou s sect ion , xn, yields
Fs = 1000; t = 0:1/Fs:1; randn('seed',0) xn = sin(2*pi*50*t) + 2*sin(2*pi*120*t) + randn(size(t)); [P,f] = pmtm(xn,4,1024,Fs); plot(f,10*log10(P)) axis([30 150 20 30])
30 25 20 15
% plot in decibels
Magnitude (dB)
3-17
% plot in decibels
Magnitude (dB)
Not e t h a t t h e a r ea u n der t h e pea k s r em a in s a bou t t h e sa m e, a s ca n be seen wh en bot h a r e plot t ed t oget h er on a lin ea r sca le.
plot(f,[P P1]) axis([30 150 0 400])
400 350 300 250
Magnitude
40
60
120
140
3-18
Spectral Analysis
Not e t h a t t ot a l power is on ly a ppr oxim a t ely con ser ved in t h is ca se. Th is is beca u se t h e a da pt ive weigh t in g pr ocedu r e t h a t is u sed t o m in im ize lea k a ge does n ot st r ict ly con ser ve t ot a l power . Th is m et h od is m or e expen sive com pu t a t ion a lly t h a n Welch s m et h od, beca u se of t h e cost of com pu t in g t h e discr et e pr ola t e sph er oida l sequ en ces (DP SSs, a lso kn own a s Slepia n sequ en ces). F or lon g da t a ser ies (10,000 poin t s or m or e), it is u sefu l t o com pu t e t h e DP SSs on ce a n d sa ve t h em in a MAT-file. Th e M-files dpsssave, dpssload, dpssdir, a n d dpssclear a r e pr ovided, t o k eep a da t a ba se of sa ved DP SSs in t h e MAT-file dpss.mat.
Yule-Walker AR Method
Th e Y u le-Walk er A R m eth od is a n a u t or egr essive t ech n iqu e for spect r a l den sit y est im a t ion (see Ma r ple [2], Ch a pt er 7, a n d P r oa kis[4], Sect ion 12.3.2). Th is m et h od solves for t h e AR m odel pa r a m et er s by t h e a u t ocor r ela t ion m et h od. Th e Yu le-Wa lker AR est im a t e is obt a in ed by solu t ion of t h e n or m a l equ a t ion s. r (1 ) r (2 )
*
r (n )
* *
r (2 ) r (1 ) L r (n 1 ) M O O M r (n ) L r (2 ) r (1 )
a (2 ) r (2 ) a (3 ) r (3 ) = M M a (n + 1 ) r (n + 1 )
H er e, a = [1 a (2) ... a (n +1)] is a vect or of a u t or egr essive coefficien t s, t h e elem en t s of vect or r = [r (1) r (2) ... r (n +1)] a r e cor r ela t ion s, a n d t h e left -h a n d side a u t ocor r ela t ion m a t r ix is H er m it ia n Toeplit z a n d posit ive defin it e.
3-19
Th e spect r a l den sit y est im a t e is 1 P YuleAR(f ) = ---------------------H a e (f ) 2 wh er e e (f ) is a com plex sin u soid. Th e t oolbox fu n ct ion pyulear im plem en t s t h e Yu le-Wa lk er AR m et h od. F or exa m ple, com pa r e t h e spect r u m of a speech sign a l u sin g Welch s m et h od a n d t h e Yu le-Wa lk er AR m et h od:
load mtlb [P1,f] = pwelch(mtlb,1024,Fs,256); [P2,f] = pyulear(mtlb,14,1024,Fs); % 14th order model plot(f,10*log10(P1),':',f,10*log10(P2)); grid ylabel('Magnitude (dB)'); xlabel('Frequency (Hz)'); legend('Welch','YuleWalker AR')
!20 Welch YuleWalker AR !30
!50
!60
!70
!80
!90 0
500
1000
3000
3500
4000
Th e solid Yu le-Wa lker AR spect r u m is sm oot h er t h a n t h e per iodogr a m beca u se of t h e sim ple u n der lyin g a ll-pole m odel.
Burg Method
Th e Bu r g m et h od for AR spect r a l est im a t ion is ba sed on m in im izin g t h e for wa r d a n d ba ckwa r d pr edict ion er r or s wh ile sa t isfyin g t h e Levin son -Du r bin r ecu r sion (see Ma r ple[2], Ch a pt er 7, a n d P r oa kis[4], Sect ion 12.3.3). In con t r a st t o ot h er AR est im a t ion m et h ods, t h e Bu r g m et h od a voids ca lcu la t in g
3-20
Spectral Analysis
t h e a u t ocor r ela t ion fu n ct ion , a n d in st ea d est im a t es t h e r eflect ion coefficien t s dir ect ly. Th e pr im a r y a dva n t a ges of t h e Bu r g m et h od a r e r esolvin g closely spa ced sin u soids in sign a ls wit h low n oise levels, a n d est im a t in g sh or t da t a r ecor ds, in wh ich ca se t h e AR power spect r a l den sit y est im a t es a r e ver y close t o t h e t r u e va lu es. In a ddit ion , t h e Bu r g m et h od en su r es a st a ble AR m odel a n d is com pu t a t ion a lly efficien t . Th e a ccu r a cy of t h e Bu r g m et h od is lower for h igh -or der m odels, lon g da t a r ecor ds, a n d h igh sign a l-t o-n oise r a t ios (wh ich ca n ca u se lin e splittin g , or t h e gen er a t ion of ext r a n eou s pea ks in t h e spect r u m est im a t e). Th e spect r a l den sit y est im a t e com pu t ed by t h e Bu r g m et h od is a lso su scept ible t o fr equ en cy sh ift s (r ela t ive t o t h e t r u e fr equ en cy) r esu lt in g fr om t h e in it ia l ph a se of n oisy sin u soida l sign a ls. Th is effect is m a gn ified wh en a n a lyzin g sh or t da t a sequ en ces. Th e t oolbox fu n ct ion pburg im plem en t s t h e Bu r g m et h od. Com pa r e t h e spect r u m of t h e speech sign a l gen er a t ed by bot h t h e Bu r g m et h od a n d t h e Yu le-Wa lk er AR m et h od. Th ey a r e ver y sim ila r for la r ge sign a l len gt h s.
load mtlb [P1,f] = pburg(mtlb(1:512),14,1024,Fs); % 14th order model [P2,f] = pyulear(mtlb(1:512),14,1024,Fs); % 14th order model plot(f,10*log10(P1),':',f,10*log10(P2)); grid ylabel('Magnitude (dB)'); xlabel('Frequency (Hz)'); legend('Burg','YuleWalker AR')
!20 Burg YuleWalker AR !30
!50
!60
!70
!80
!90 0
500
1000
3000
3500
4000
3-21
Not e t h a t , a s t h e m odel or der for t h e Bu r g m et h od is r edu ced, a fr equ en cy sh ift du e t o t h e in it ia l ph a se of t h e sin u soids will becom e a ppa r en t .
3-22
Spectral Analysis
Com pa r e t h e spect r u m of t h e speech sign a l gen er a t ed by bot h t h e cova r ia n ce m et h od a n d t h e m odified cova r ia n ce m et h od. Th ey a r e n ea r ly iden t ica l, even for a sh or t sign a l len gt h .
load mtlb [P1,f] = pcov(mtlb(1:64),14,1024,Fs);% 14th order model [P2,f] = pmcov(mtlb(1:64),14,1024,Fs);% 14th order model plot(f,10*log10(P1),':',f,10*log10(P2)); grid ylabel('Magnitude (dB)'); xlabel('Frequency (Hz)'); legend('Covariance','Modified Covariance')
!40 Covariance Modified Covariance !50
!70
!80
!90
!100 0
500
1000
3000
3500
4000
3-23
Eigenanalysis Overview
Con sider a n u m ber of com plex sin u soids em bedded in wh it e n oise. You ca n wr it e t h e a u t ocor r ela t ion m a t r ix R for t h is syst em a s t h e su m of t h e sign a l a u t ocor r ela t ion m a t r ix (S ) a n d t h e n oise a u t ocor r ela t ion m a t r ix (W ). R = S +W Th er e is a close r ela t ion sh ip bet ween t h e eigen vect or s of t h e sign a l a u t ocor r ela t ion m a t r ix a n d t h e sign a l a n d n oise su bspa ces. Th e eigen vect or s v of S spa n t h e sa m e sign a l su bspa ce a s t h e sign a l vect or s. If t h e syst em con t a in s M com plex sin u soids a n d t h e or der of t h e a u t ocor r ela t ion m a t r ix is p , eigen vect or s v M +1 t h r ou gh v p +1 spa n t h e n oise su bspa ce of t h e a u t ocor r ela t ion m a t r ix.
Frequency Estimator Functions. To gen er a t e t h eir fr equ en cy est im a t es, eigen a n a lysis m et h ods ca lcu la t e fu n ct ion s of t h e vect or s in t h e sign a l a n d n oise su bspa ces. Bot h t h e MUSIC a n d E V t ech n iqu es ch oose a fu n ct ion t h a t t h eor et ica lly goes t o in fin it y a t on e of t h e sin u soida l fr equ en cies in t h e in pu t sign a l. Usin g digit a l t ech n ology, t h e r esu lt in g est im a t e h a s sh a r p pea ks a t t h e fr equ en cies of in t er est ; t h is m ea n s t h a t t h er e won t be in fin it y va lu es in t h e vect or s.
wh er e N is t h e size of t h e eigen vect or s a n d e (f ) is a com plex sin u soid vect or : e (f ) = [ 1 exp (j 2 $ f ) exp (j 2 $ f ; 2 ) exp (j 2 $ f ; 4 ) exp (j 2 $ f ; ( n 1 )) ] H v r epr esen t s t h e eigen vect or s of t h e in pu t sign a ls cor r ela t ion m a t r ix; v k is t h e k t h eigen vect or . H is t h e con ju ga t e t r a n spose oper a t or . Th e eigen vect or s u sed in t h e su m cor r espon d t o t h e sm a llest eigen va lu es a n d spa n t h e n oise su bspa ce (p is t h e size of t h e sign a l su bspa ce).
H e (f ) is equ iva len t t o a F ou r ier t r a n sfor m (t h e vect or e (f ) Th e expr ession v k con sist s of com plex expon en t ia ls). Th is for m is u sefu l for n u m er ic com pu t a t ion beca u se t h e F F T ca n be com pu t ed for ea ch v k a n d t h en t h e squ a r ed m a gn it u des ca n be su m m ed.
3-24
Spectral Analysis
Th e pmusic fu n ct ion in t h is t oolbox u ses t h e svd (sin gu la r va lu e decom posit ion ) fu n ct ion in t h e sign a l ca se a n d t h e eig fu n ct ion for a n a lyzin g t h e cor r ela t ion m a t r ix a n d a ssign in g eigen vect or s t o t h e sign a l or n oise su bspa ces. Wh en svd is u sed, pmusic n ever com pu t es t h e cor r ela t ion m a t r ix explicit ly, bu t t h e sin gu la r va lu es a r e t h e eigen va lu es.
3-25
F or com plet e det a ils on u sin g t h e thresh pa r a m et er , see t h e r efer en ce descr ipt ion of pmusic in Ch a pt er 6.
3-26
References
References
1 Ka y, S.M. M od ern S pectral E stim ation . E n glewood Cliffs, NJ : P r en t ice H a ll,
1988.
2 Ma r ple, S.L. Digital S pectral A n alysis . E n glewood Cliffs, NJ : P r en t ice H a ll,
1987.
3 P er civa l, D.B., a n d A.T. Wa lden . S pectral A n alysis for Ph ysical Application s:
M u ltitaper an d Con ven tion al Un ivariate T ech n iqu es . Ca m br idge: Ca m br idge Un iver sit y P r ess, 1993.
4 P r oa kis, J .G., a n d D.G. Ma n ola kis. Digital S ign al Processin g: Prin ciples,
Spect r a : A Met h od Ba sed on Tim e Aver a gin g Over Sh or t , Modified P er iodogr a m s. IE E E T ran s. A u d io E lectroacou st . Vol. AU-15 (J u n e 1967). P gs. 70-73.
3-27
3-28
4
Specia l Topics
Win d o w s . . . . . . . . . . . . . . . . Ba sic Sh a pes . . . . . . . . . . . . . Gen er a lized Cosin e Win dows Ka iser Win dow . . . . . . . . . . . Ch ebysh ev Win dow . . . . . . . . . . . . . ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... .... .... .... .... .... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... .... .... .... .... .... . . . . . 4-2 4-2 4-4 4-4 4-9
P a ra m e tric Mo d e lin g . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10 Tim e-Dom a in Ba sed Modelin g . . . . . . . . . . . . . . . . . . . . . . . . . . 4-11 F r equ en cy-Dom a in Ba sed Modelin g . . . . . . . . . . . . . . . . . . . . . 4-16 Re s a m p lin g . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-20 Ce p s tru m An a ly s is . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-23 In ver se Com plex Cepst r u m . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-25 F F T-B a s e d Tim e -F re qu e n c y An a ly s is . . . . . . . . . . . . . . . . . 4-27 Me d ia n F ilte rin g . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-28 Co m m u n ic a tio n s Ap p lic a t io n s . . . . . . . . . . . . . . . . . . . . . . . 4-29 D e c o n v o lu t io n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-33 S p e c ia lize d Tra n s fo rm s Ch ir p z-Tr a n sfor m . . . . . . Discr et e Cosin e Tr a n sfor m H ilber t Tr a n sfor m . . . . . . . ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... .... .... .... .... ... ... ... ... ... ... ... ... ... ... ... ... .... .... .... .... 4-34 4-34 4-36 4-38
Re fe re n c e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-40
Special Topics
Windows
In bot h digit a l filt er design a n d power spect r u m est im a t ion , t h e ch oice of a win dowin g fu n ct ion ca n pla y a n im por t a n t r ole in det er m in in g t h e qu a lit y of over a ll r esu lt s. Th e m a in r ole of t h e win dow is t o da m p ou t t h e effect s of t h e Gibbs ph en om en on t h a t r esu lt s fr om t r u n ca t ion of a n in fin it e ser ies. Th e t oolbox win dow fu n ct ion s a r e sh own in t h e t a ble below.
Window Function bartlett blackman boxcar chebwin hamming hanning kaiser triang
Ba r t let t win dow Bla ckm a n win dow Rect a n gu la r win dow Ch ebysh ev win dow H a m m in g win dow H a n n in g win dow Ka iser win dow Tr ia n gu la r win dow
Basic Shapes
Th e ba sic win dow is t h e rectan gu lar w in d ow , a vect or of on es of t h e a ppr opr ia t e len gt h . A r ect a n gu la r win dow of len gt h 50 is
n = 50; w = boxcar(n);
Th is t oolbox st or es win dows in colu m n vect or s by con ven t ion , so a n equ iva len t expr ession is
w = ones(50,1);
Th e B artlett (or t r ia n gu la r ) w in d ow is t h e con volu t ion of t wo r ect a n gu la r win dows. Th e fu n ct ion s bartlett a n d triang com pu t e sim ila r t r ia n gu la r win dows, wit h t h r ee im por t a n t differ en ces. Th e bartlett fu n ct ion a lwa ys
4-2
Windows
r et u r n s a win dow wit h t wo zer os on t h e en ds of t h e sequ en ce, so t h a t for n odd, t h e cen t er sect ion of bartlett(n+2) is equ iva len t t o triang(n):
bartlett(7) ans = 0 0.3333 0.6667 1.0000 0.6667 0.3333 0 triang(5) ans = 0.3333 0.6667 1.0000 0.6667 0.3333
F or n even , bartlett is st ill t h e con volu t ion of t wo r ect a n gu la r sequ en ces. Th er e is n o st a n da r d defin it ion for t h e t r ia n gu la r win dow for n even ; t h e slopes of t h e lin e segm en t s of triangs r esu lt a r e sligh t ly st eeper t h a n t h ose of bartletts in t h is ca se:
w = bartlett(8); [w(2:7) triang(6)] ans = 0.2857 0.5714 0.8571 0.8571 0.5714 0.2857 0.1667 0.5000 0.8333 0.8333 0.5000 0.1667
Th e fin a l differ en ce bet ween t h e Ba r t let t a n d t r ia n gu la r win dows is eviden t in t h e F ou r ier t r a n sfor m s of t h ese fu n ct ion s. Th e F ou r ier t r a n sfor m of a Ba r t let t
4-3
Special Topics
win dow is n ega t ive for n even . Th e F ou r ier t r a n sfor m of a t r ia n gu la r win dow, h owever , is a lwa ys n on n ega t ive. Th is differ en ce ca n be im por t a n t wh en ch oosin g a win dow for som e spect r a l est im a t ion t ech n iqu es, su ch a s t h e Bla ck m a n -Tu key m et h od. Bla ckm a n -Tu k ey for m s t h e spect r a l est im a t e by ca lcu la t in g t h e F ou r ier t r a n sfor m of t h e a u t ocor r ela t ion sequ en ce. Th e r esu lt in g est im a t e m igh t be n ega t ive a t som e fr equ en cies if t h e win dows F ou r ier t r a n sfor m is n ega t ive (see Ka y [1], pg. 80).
wh er e A, B, a n d C a r e con st a n t s you defin e. Th e con cept beh in d t h ese win dows is t h a t by su m m in g t h e in dividu a l t er m s t o for m t h e win dow, t h e low fr equ en cy pea k s in t h e fr equ en cy dom a in com bin e in su ch a wa y a s t o decr ea se sidelobe h eigh t . Th is h a s t h e side effect of in cr ea sin g t h e m a in lobe widt h . Th e H a m m in g a n d H a n n in g win dows a r e t wo-t er m gen er a lized cosin e win dows, given by A = 0.54, B = 0.46 for H a m m in g a n d A = 0.5, B = 0.5 for H a n n in g (C = 0 in bot h ca ses). Th e hamming a n d hanning fu n ct ion s, r espect ively, com pu t e t h ese win dows. Not e t h a t t h e defin it ion of t h e gen er a lized cosin e win dow sh own in t h e ea r lier MATLAB code yields zer os a t sa m ples 1 a n d n for A = 0.5 a n d B = 0.5. To elim in a t e t h ese zer os on t h e edges of t h e win dow, hanning u ses a cosin e of fr equ en cy 2 $/(N +1) in st ea d of 2 $/(N -1). Th e Bla ck m a n win dow is a popu la r t h r ee-t er m win dow, given by A = 0.42, B = 0.5, C = 0.08. Th e blackman fu n ct ion com pu t es t h is win dow.
Kaiser Window
Th e Kaiser w in d ow is a n a ppr oxim a t ion t o t h e pr ola t e-sph er oida l win dow, for wh ich t h e r a t io of t h e m a in lobe en er gy t o t h e sidelobe en er gy is m a xim ized. F or a Ka iser win dow of a pa r t icu la r len gt h , t h e pa r a m et er = con t r ols t h e sidelobe h eigh t . F or a given =, t h e sidelobe h eigh t is fixed wit h r espect t o win dow len gt h .
4-4
Windows
Th e st a t em en t kaiser(n,beta) com pu t es a len gt h n Ka iser win dow wit h pa r a m et er beta. E xa m ples of Ka iser win dows wit h len gt h 50 a n d va r iou s va lu es for t h e beta pa r a m et er a r e
n = 50; w1 = kaiser(n,1); w2 = kaiser(n,4); w3 = kaiser(n,9); [W1,f] = freqz(w1/sum(w1),1,512,2); [W2,f] = freqz(w2/sum(w2),1,512,2); [W3,f] = freqz(w3/sum(w3),1,512,2); plot(f,20*log10(abs([W1 W2 W3])))
Three Kaiser Window Responses 0 -20 -40
-60 -80 -100 -120 -140 -160 -180 0 beta = 1 beta = 2 beta = 3
0.1
0.2
0.8
0.9
4-5
Special Topics
As = in cr ea ses, t h e sidelobe h eigh t decr ea ses a n d t h e m a in lobe widt h in cr ea ses. To see h ow t h e sidelobe h eigh t st a ys t h e sa m e for a fixed = pa r a m et er a s t h e len gt h is va r ied, t r y
w1 = kaiser(50,4); w2 = kaiser(20,4); w3 = kaiser(101,4); [W1,f] = freqz(w1/sum(w1),1,512,2); [W2,f] = freqz(w2/sum(w2),1,512,2); [W3,f] = freqz(w3/sum(w3),1,512,2); plot(f,20*log10(abs([W1 W2 W3])))
Three Kaiser Window Responses, Beta Fixed 0 length = 50 length = 20 length = 101 -20
-40
-60
-80
-100
-120 0
0.1
0.2
0.8
0.9
4-6
Windows
Th e kaiserord fu n ct ion est im a t es t h e filt er or der , cu t off fr equ en cy, a n d Ka iser win dow bet a pa r a m et er n eeded t o m eet a given set of fr equ en cy dom a in specifica t ion s.
4-7
Special Topics
Th e r ipple in t h e pa ssba n d is r ou gh ly t h e sa m e a s t h e r ipple in t h e st opba n d. As you ca n see fr om t h e fr equ en cy r espon se, t h is filt er n ea r ly m eet s t h e specifica t ion s.
[H,f] = freqz(h,1,512,2); plot(f,20*log10(abs(H))), grid
FIR Design using Kaiser Window 20
0.2
-20 Magnitude (dB)
40 dB
-40
-60
-80
-100 0
0.1
0.2
0.8
0.9
4-8
Windows
Chebyshev Window
Th e Ch ebysh ev win dow m in im izes t h e m a in lobe widt h , given a pa r t icu la r sidelobe h eigh t . It is ch a r a ct er ized by a n equ ir ipple beh a vior , t h a t is, it s sidelobes a ll h a ve t h e sa m e h eigh t . Th e chebwin fu n ct ion , wit h len gt h a n d sidelobe h eigh t pa r a m et er s, com pu t es a Ch ebysh ev win dow.
n = 51; Rs = 40; % sidelobe height in decibels w = chebwin(n,Rs); stem(w)
Length 51 Chebyshev Window 1 0.8 0.6 0.4 0.2 0 0
10
15
20
25 30 Sample Number
35
40
45
50
As sh own in t h e plot , t h e Ch ebysh ev win dow h a s la r ge spik es a t it s ou t er sa m ples. P lot t h e fr equ en cy r espon se t o see t h e equ ir ipples a t -40 dB.
[W,f] = freqz(w,1,512,2); plot(f,20*log10(abs(W)/sum(w))), grid
Chebyshev Window Magnitude Response 0
-20
-40
-60
-80 0
0.1
0.2
0.8
0.9
F or a det a iled discu ssion of t h e ch a r a ct er ist ics a n d a pplica t ion s of t h e va r iou s win dow t ypes, see [2] Oppen h eim a n d Sch a fer , pgs. 444-462, a n d [3] P a r ks a n d Bu r r u s, pgs. 71-73.
4-9
Special Topics
Parametric Modeling
P a r a m et r ic m odelin g t ech n iqu es fin d t h e pa r a m et er s for a m a t h em a t ica l m odel descr ibin g a sign a l, syst em , or pr ocess. Th ese t ech n iqu es u se kn own in for m a t ion a bou t t h e syst em t o det er m in e t h e m odel. Applica t ion s for pa r a m et r ic m odelin g in clu de speech a n d m u sic syn t h esis, da t a com pr ession , h igh -r esolu t ion spect r a l est im a t ion , com m u n ica t ion s, m a n u fa ct u r in g, a n d sim u la t ion . Th e t oolbox pa r a m et r ic m odelin g fu n ct ion s oper a t e wit h t h e r a t ion a l t r a n sfer fu n ct ion m odel. Given a ppr opr ia t e in for m a t ion a bou t a n u n kn own syst em (im pu lse or fr equ en cy r espon se da t a , or in pu t a n d ou t pu t sequ en ces), t h ese fu n ct ion s fin d t h e coefficien t s of a lin ea r syst em t h a t m odels t h e syst em . On e im por t a n t a pplica t ion of t h e pa r a m et r ic m odelin g fu n ct ion s is in t h e design of filt er s t h a t h a ve a pr escr ibed t im e or fr equ en cy r espon se. Th ese fu n ct ion s pr ovide a da t a -or ien t ed a lt er n a t ive t o t h e IIR a n d F IR filt er design fu n ct ion s discu ssed in Ch a pt er 2. H er e is a su m m a r y of t h e pa r a m et r ic m odelin g fu n ct ion s in t h is t oolbox. Not e t h a t t h e Syst em Iden t ifica t ion Toolbox pr ovides a m or e ext en sive collect ion of pa r a m et r ic m odelin g fu n ct ion s.
4-10
Parametric Modeling
Domain
Description
Tim e
Gen er a t e a ll-pole filt er coefficien t s t h a t m odel a n in pu t da t a sequ en ce u sin g t h e Levin son -Du r bin a lgor it h m . Gen er a t e a ll-pole filt er coefficien t s t h a t m odel a n in pu t da t a sequ en ce by m in im izin g t h e for wa r d pr edict ion er r or. Gen er a t e a ll-pole filt er coefficien t s t h a t m odel a n in pu t da t a sequ en ce by m in im izin g t h e for wa r d a n d ba ckwa r d pr edict ion er r or s. Gen er a t e a ll-pole filt er coefficien t s t h a t m odel a n in pu t da t a sequ en ce u sin g a n est im a t e of t h e a u t ocor r ela t ion fu n ct ion . Lin ea r P r edict ive Codin g. Gen er a t e a ll-pole r ecu r sive filt er wh ose im pu lse r espon se m a t ch es a given sequ en ce. Gen er a t e IIR filt er wh ose im pu lse r espon se m a t ch es a given sequ en ce. F in d IIR filt er wh ose ou t pu t , given a specified in pu t sequ en ce, m a t ch es a given ou t pu t sequ en ce. Gen er a t e digit a l or a n a log filt er coefficien t s given com plex fr equ en cy r espon se da t a .
Fr equ en cy
Beca u se yulewalk is gea r ed explicit ly t owa r d ARMA filt er design , it is discu ssed in Ch a pt er 2. pburg a n d pyulear a r e discu ssed in Ch a pt er 3 a lon g wit h t h e ot h er (n on pa r a m et r ic) spect r a l est im a t ion m et h ods.
4-11
Special Topics
Linear Prediction
Lin ea r pr edict ion m odelin g a ssu m es t h a t ea ch ou t pu t sa m ple of a sign a l, x(k), is a lin ea r com bin a t ion of t h e pa st n ou t pu t s (t h a t is, it ca n be lin ea r ly pr edict ed fr om t h ese ou t pu t s), a n d t h a t t h e coefficien t s a r e con st a n t fr om sa m ple t o sa m ple. x (k ) = a (2 ) x (k 1 ) a (3 ) x (k 2 ) L a (n + 1 ) x (k n ) An nt h -or der a ll-pole m odel of a sign a l x is
a = lpc(x,n)
To illu st r a t e lpc, cr ea t e a sa m ple sign a l t h a t is t h e im pu lse r espon se of a n a ll-pole filt er wit h a ddit ive wh it e n oise.
randn('seed',0) x = impz(1,[1 0.1 0.1 0.1 0.1],10) + randn(10,1)/10;
4-12
Parametric Modeling
You cou ld for m t h e lin ea r pr edict ion coefficien t s wit h ot h er a ssu m pt ion s by pa ssin g a differ en t cor r ela t ion est im a t e t o levinson, su ch a s t h e u n bia sed cor r ela t ion est im a t e.
r = xcorr(x,'unbiased'); r(1:length(x)1) = []; % remove corr. at negative lags a = levinson(r,4) a = 1.0000 0.0554 0.0462 0.0974 0.2115
fin ds t h e n u m er a t or a n d den om in a t or coefficien t s of a n IIR filt er wh ose im pu lse r espon se a ppr oxim a t es t h e sequ en ce x.
prony im plem en t s t h e m et h od descr ibed in [3] P a r k s a n d Bu r r u s
(pgs. 226-228). Th is m et h od u ses a va r ia t ion of t h e cova r ia n ce m et h od of AR m odelin g t o fin d t h e den om in a t or coefficien t s a, a n d t h en fin ds t h e n u m er a t or coefficien t s b for wh ich t h e r esu lt in g filt er s im pu lse r espon se m a t ch es exa ct ly t h e fir st nb + 1 sa m ples of x. Th e filt er is n ot n ecessa r ily st a ble, bu t it ca n pot en t ia lly r ecover t h e coefficien t s exa ct ly if t h e da t a sequ en ce is t r u ly a n a u t or egr essive m ovin g a ver a ge (ARMA) pr ocess of t h e cor r ect or der . NOTE Th e fu n ct ion s prony a n d stmcb (descr ibed n ext ) a r e m or e a ccu r a t ely descr ibed a s ARX m odels in syst em iden t ifica t ion t er m in ology. ARMA m odelin g a ssu m es n oise on ly a t t h e in pu t s, wh ile ARX a ssu m es a n ext er n a l in pu t . prony a n d stmcb kn ow t h e in pu t sign a l: it is a n im pu lse for prony a n d is a r bit r a r y for stmcb.
4-13
Special Topics
A m odel for t h e t est sequ en ce x (fr om t h e ea r lier lpc exa m ple) u sin g a t h ir d-or der IIR filt er is
[b,a] = prony(x,3,3) b = 1.1165 a = 1.0000 0.1619 0.4765 0.4940 0.2181 0.6084 0.5369
Th e impz com m a n d sh ows h ow well t h is filt er s im pu lse r espon se m a t ch es t h e or igin a l sequ en ce.
format long [x impz(b,a,10)] ans = 1.11649535105007 0.03731609173676 0.08249198453223 0.04583930972315 0.14255125351637 0.20400424807471 0.02685697779814 0.18956307836948 0.02717716288172 0.08057060786906 1.11649535105007 0.03731609173676 0.08249198453223 0.04583930972315 0.02829072973977 0.01433198229497 0.01148698991026 0.02266475846451 0.00206242734272 0.00545783754743
Not ice t h a t t h e fir st fou r sa m ples m a t ch exa ct ly. F or a n exa m ple of exa ct r ecover y, r ecover t h e coefficien t s of a Bu t t er wor t h filt er fr om it s im pu lse r espon se.
[b,a] = butter(4,.2); h = impz(b,a,26); [bb,aa] = prony(h,4,4);
Tr y t h is exa m ple; you ll see t h a t bb a n d aa m a t ch t h e or igin a l filt er coefficien t s t o wit h in a t oler a n ce of 10 -13 .
4-14
Parametric Modeling
In t h is exa m ple, stmcb cor r ect ly iden t ifies t h e syst em u sed t o cr ea t e y fr om x. Th e St eiglit z-McBr ide m et h od is a fa st it er a t ive a lgor it h m t h a t solves for t h e n u m er a t or a n d den om in a t or coefficien t s sim u lt a n eou sly in a n a t t em pt t o m in im ize t h e sign a l er r or bet ween t h e filt er ou t pu t a n d t h e given ou t pu t sign a l. Th is a lgor it h m u su a lly con ver ges r a pidly, bu t m igh t n ot con ver ge if t h e m odel or der is t oo la r ge. As for prony, stmcbs r esu lt in g filt er is n ot n ecessa r ily st a ble du e t o it s exa ct m odelin g a ppr oa ch .
stmcb pr ovides con t r ol over sever a l im por t a n t a lgor it h m ic pa r a m et er s; m odify t h ese pa r a m et er s if you a r e h a vin g t r ou ble m odelin g t h e da t a . To ch a n ge t h e n u m ber of it er a t ion s fr om t h e defa u lt of five a n d pr ovide a n in it ia l est im a t e for t h e den om in a t or coefficien t s n = 10; % number of iterations a = lpc(x,3); % initial estimates for denominator [b,a] = stmcb(x,3,3,n,a);
4-15
Special Topics
Th e fu n ct ion u ses a n a ll-pole m odel cr ea t ed wit h prony a s a n in it ia l est im a t e wh en you do n ot pr ovide on e of you r own . To com pa r e t h e fu n ct ion s lpc, prony, a n d stmcb, com pu t e t h e sign a l er r or in ea ch ca se
a1 = lpc(x,3); [b2,a2] = prony(x,3,3); [b3,a3] = stmcb(x,3,3); [ ximpz(1,a1,10) ximpz(b2,a2,10) ans = 0.1165 0.0058 0.0535 0.0151 0.1473 0.2005 0.0233 0.1901 0.0275 0.0808 sum(ans.^2) ans = 0.1226 0.0834 0.0182 0 0 0.0000 0.0000 0.1143 0.1897 0.0154 0.1669 0.0251 0.0751 0 0.0190 0.0818 0.0176 0.0476 0.0869 0.0103 0.0093 0.0294 0.0022
ximpz(b3,a3,10) ]
In com pa r in g m odelin g ca pa bilit ies for a given or der IIR m odel, t h e la st r esu lt sh ows t h a t for t h is exa m ple, stmcb per for m s best , followed by prony, t h en lpc. Th is r ela t ive per for m a n ce is t ypica l of t h e m odelin g fu n ct ion s.
4-16
Parametric Modeling
To r ecover t h e or igin a l filt er coefficien t s fr om t h e fr equ en cy r espon se of a sim ple digit a l filt er
[b,a] = butter(4,.4) b = 0.0466 a = 1.0000 0.7821 0.6800 0.1827 0.0301 [h,w] = freqz(b,a,64); [bb,aa] = invfreqz(h,w,4,4) bb = 0.0466 aa = 1.0000 0.7821 0.6800 0.1827 0.0301 0.1863 0.2795 0.1863 0.0466 % compute frequency resp. % model: nb = 4, na = 4 0.1863 0.2795 0.1863 0.0466 % design Butterworth lowpass
Th e vect or of fr equ en cies w h a s t h e u n it s in r a ds/sa m ple, a n d t h e fr equ en cies n eed n ot be equ a lly spa ced. invfreqz fin ds a filt er of a n y or der t o fit t h e fr equ en cy da t a ; a t h ir d-or der exa m ple is
[bb,aa] = invfreqz(h,w,3,3) bb = 0.0464 aa = 1.0000 0.9502 0.7382 0.2006 0.1785 0.2446 0.1276 % find third-order IIR
Bot h invfreqs a n d invfreqz design filt er s wit h r ea l coefficien t s; for a da t a poin t a t posit ive fr equ en cy f, t h e fu n ct ion s fit t h e fr equ en cy r espon se a t bot h f a n d f.
4-17
Special Topics
By defa u lt invfreqz u ses a n equ a t ion er r or m et h od t o iden t ify t h e best m odel fr om t h e da t a . Th is fin ds b a n d a in
n
m in
b, a
+ w t (k ) h (k ) A (w (k )) B (w (k )) 2
k =1
by cr ea t in g a syst em of lin ea r equ a t ion s a n d solvin g t h em wit h MATLABs \ oper a t or . H er e A (w (k )) a n d B (w (k )) a r e t h e F ou r ier t r a n sfor m s of t h e polyn om ia ls a a n d b r espect ively a t t h e fr equ en cy w (k ), a n d n is t h e n u m ber of fr equ en cy poin t s (t h e len gt h of h a n d w). w t (k ) weigh t s t h e er r or r ela t ive t o t h e er r or a t differ en t fr equ en cies. Th e syn t a x
invfreqz(h,w,nb,na,wt)
in clu des a weigh t in g vect or . In t h is m ode, t h e filt er r esu lt in g fr om invfreqz is n ot gu a r a n t eed t o be st a ble.
invfreqz pr ovides a su per ior (ou t pu t -er r or ) a lgor it h m t h a t solves t h e dir ect pr oblem of m in im izin g t h e weigh t ed su m of t h e squ a r ed er r or bet ween t h e a ct u a l fr equ en cy r espon se poin t s a n d t h e desir ed r espon se
n
m in
b, a
+ w t (k ) h (k ) ------------------A (w (k ))
k =1
B (w (k ))
4-18
Parametric Modeling
Th e r esu lt in g filt er is a lwa ys st a ble. Gr a ph ica lly com pa r e t h e r esu lt s of t h e fir st a n d secon d a lgor it h m s t o t h e or igin a l Bu t t er wor t h filt er .
[H1,w1] = freqz(b,a,'magnitude','linear','phase','no'); [H2,w2] = freqz(bb,aa,'magnitude','linear','phase','no'); [H3,w3] = freqz(bbb,aaa,'magnitude','linear','phase','no'); plot(w1/pi,abs(H1),w2/pi,abs(H2),'--',w3/pi,abs(H3),':') legend('Original','First Estimate','Second Estimate'); grid on
1.4 Original First Estimate Second Estimate
1.2
0.8
0.6
0.4
0.2
0 0
0.2
0.4
0.6
0.8
4-19
Special Topics
Resampling
Th e t oolbox pr ovides a n u m ber of fu n ct ion s t h a t r esa m ple a sign a l a t a h igh er or lower r a t e.
Operation Function resample decimate interp upfirdn spline interp1
Resa m ple a t n ew r a t e Decim a t ion In t er pola t ion Apply F IR filt er wit h r esa m plin g Cu bic splin e in t er pola t ion Ot h er 1-D in t er pola t ion
Th e resample fu n ct ion ch a n ges t h e sa m plin g r a t e for a sequ en ce t o a n y r a t e t h a t is a r a t io of t wo in t eger s. Th e ba sic syn t a x for resample is
y = resample(x,p,q)
wh er e t h e fu n ct ion r esa m ples t h e sequ en ce x a t p/q t im es t h e or igin a l sa m plin g r a t e. Th e len gt h of t h e r esu lt y is p/q t im es t h e len gt h of x. On e r esa m plin g a pplica t ion is t h e con ver sion of digit ized a u dio sign a ls fr om on e sa m plin g r a t e t o a n ot h er , su ch a s fr om 48 k H z (t h e Digit a l Au dio Ta pe st a n da r d) t o 44.1 kH z (t h e Com pa ct Disc st a n da r d). In t h e n ext exa m ple, t h e sa m plin g r a t es a r e differ en t bu t t h e idea is t h e sa m e.
4-20
Resampling
Th e exa m ple file con t a in s a len gt h 4001 vect or of speech sa m pled a t 7418 H z.
clear load mtlb whos Name Fs mtlb Size 1x1 4001x1 Bytes 8 32008 Class double array double array
To pla y t h is speech sign a l on a wor k st a t ion t h a t ca n on ly pla y sou n d a t 8192 H z, u se t h e rat fu n ct ion t o fin d in t eger s p a n d q t h a t yield t h e cor r ect r esa m plin g fa ct or .
[p,q] = rat(8192/Fs,.0001) p = 127 q = 115
Sin ce p/q*Fs = 8192.05 H z, t h e t oler a n ce of 0.0001 is a ccept a ble; t o r esa m ple t h e sign a l a t ver y close t o 8192 H z.
y = resample(mtlb,p,q); resample a pplies a lowpa ss filt er t o t h e in pu t sequ en ce t o pr even t a lia sin g du r in g r esa m plin g. It design s t h is filt er u sin g t h e firls fu n ct ion wit h a Ka iser win dow. Th e syn t a x resample(x,p,q,l,beta)
con t r ols t h e filt er s len gt h a n d t h e bet a pa r a m et er of t h e Ka iser win dow. Alt er n a t ively, u se t h e fu n ct ion intfilt t o design a n in t er pola t ion filt er b a n d u se it wit h
resample(x,p,q,b)
4-21
Special Topics
Th e decimate a n d interp fu n ct ion s do t h e sa m e t h in g a s resample wit h p = 1 a n d q = 1, r espect ively. Th ese fu n ct ion s pr ovide differ en t a n t i-a lia s filt er in g opt ion s, a n d t h ey in cu r a sligh t sign a l dela y du e t o filt er in g. Th e interp fu n ct ion is sign ifica n t ly less efficien t t h a n t h e resample fu n ct ion wit h q = 1. Th e t oolbox a lso con t a in s a fu n ct ion , upfirdn, t h a t a pplies a n F IR filt er t o a n in pu t sequ en ce a n d ou t pu t s t h e filt er ed sequ en ce a t a differ en t sa m ple r a t e t h a n it s or igin a l r a t e. See Mu lt ir a t e F ilt er Ba n k Im plem en t a t ion on pa ge 1-19 a n d t h e r efer en ce descr ipt ion of upfirdn in Ch a pt er 6 for m or e det a ils. Th e st a n da r d MATLAB en vir on m en t con t a in s a fu n ct ion , spline, t h a t wor k s wit h ir r egu la r ly spa ced da t a . Th e MATLAB fu n ct ion interp1 per for m s in t er pola t ion , or t a ble looku p, u sin g va r iou s m et h ods in clu din g lin ea r a n d cu bic in t er pola t ion . See t h e on lin e M A T L AB Fu n ction R eferen ce for in for m a t ion on spline a n d interp1.
4-22
Cepstrum Analysis
Cepstrum Analysis
Cepst r u m a n a lysis is a n on lin ea r sign a l pr ocessin g t ech n iqu e wit h a va r iet y of a pplica t ion s in a r ea s su ch a s speech a n d im a ge pr ocessin g. Th e Sign a l P r ocessin g Toolbox pr ovides t h r ee fu n ct ion s for cepst r u m a n a lysis.
Operation Function cceps rceps icceps
Th e com plex cepst r u m for a sequ en ce x is ca lcu la t ed by fin din g t h e com plex n a t u r a l loga r it h m of t h e F ou r ier t r a n sfor m of x , t h en t h e in ver se F ou r ier t r a n sfor m of t h e r esu lt in g sequ en ce. 1 = -----x 2$
6$ log [ X (e j #) ] e j # n d #
Th e t oolbox fu n ct ion cceps per for m s t h is oper a t ion , est im a t in g t h e com plex cepst r u m for a n in pu t sequ en ce. It r et u r n s a r ea l sequ en ce t h e sa m e size a s t h e in pu t sequ en ce
xhat = cceps(x)
Th e com plex cepst r u m t r a n sfor m a t ion is cen t r a l t o t h e t h eor y a n d a pplica t ion of h om om orph ic system s , t h a t is, syst em s t h a t obey cer t a in gen er a l r u les of su per posit ion . See [2] Oppen h eim a n d Sch a fer for a discu ssion of t h e com plex cepst r u m a n d h om om or ph ic t r a n sfor m a t ion s, wit h det a ils on speech pr ocessin g a pplica t ion s. Tr y u sin g cceps in a n ech o det ect ion a pplica t ion . F ir st , cr ea t e a 45 H z sin e wa ve sa m pled a t 100 H z
t = 0:0.01:1.27; s1 = sin(2*pi*45*t);
4-23
Special Topics
Add a n ech o of t h e sign a l, wit h h a lf t h e a m plit u de, 0.2 secon ds a ft er t h e begin n in g of t h e sign a l.
s2 = s1 + 0.5*[zeros(1,20) s1(1:108)];
0.5
-0.5
-1
-1.5 0
0.2
0.4
0.6
0.8
1.2
1.4
Not e t h a t t h e com plex cepst r u m sh ows a pea k a t 0.2 secon ds, in dica t in g t h e ech o. Th e real cepstru m of a sign a l x , som et im es ca lled sim ply t h e cepst r u m , is ca lcu la t ed by det er m in in g t h e n a t u r a l loga r it h m of m a gn it u de of t h e F ou r ier t r a n sfor m of x , t h en obt a in in g t h e in ver se F ou r ier t r a n sfor m of t h e r esu lt in g sequ en ce 1 c x = -----2$
6$ log X (e j #) e j # n d #
4-24
Cepstrum Analysis
Th e t oolbox fu n ct ion rceps per for m s t h is oper a t ion , r et u r n in g t h e r ea l cepst r u m for a sequ en ce x. Th e r et u r n ed sequ en ce is a r ea l-va lu ed vect or t h e sa m e size a s t h e in pu t vect or .
y = rceps(x)
By defin it ion , you ca n n ot r econ st r u ct t h e or igin a l sequ en ce fr om it s r ea l cepst r u m t r a n sfor m a t ion , a s t h e r ea l cepst r u m is ba sed on ly on t h e m a gn it u de of t h e F ou r ier t r a n sfor m for t h e sequ en ce (see [2]). Th e rceps fu n ct ion , h owever , ca n r econ st r u ct a m in im u m -ph a se ver sion of t h e or igin a l sequ en ce by a pplyin g a win dowin g fu n ct ion in t h e cepst r a l dom a in . To obt a in bot h t h e r ea l cepst r u m a n d t h e m in im u m ph a se r econ st r u ct ion for a sequ en ce, u se
[y,ym] = rceps(x)
0.0366
0.0788
0.1386
4-25
Special Topics
5.0000
6.0000
7.0000
NOTE Wit h a n y m odifica t ion of t h e com plex cepst r u m , t h e or igin a l dela y t er m m ay n o lon ger be va lid. Use t h e icceps fu n ct ion wit h ca r e.
4-26
Frequency
3000 2500 2000 1500 1000 500 0 0 0.2 0.4 0.6 0.8 1 Time 1.2 1.4 1.6 1.8
4-27
Special Topics
Median Filtering
Th e fu n ct ion medfilt1 im plem en t s on e-dim en sion a l m edia n filt er in g, a n on lin ea r t ech n iqu e t h a t a pplies a slidin g win dow t o a sequ en ce. Th e m edia n filt er r epla ces t h e cen t er va lu e in t h e win dow wit h t h e m edia n va lu e of a ll t h e poin t s wit h in t h e win dow [4]. In com pu t in g t h is m edia n , medfilt1 a ssu m es zer os beyon d t h e in pu t poin t s. Wh en t h e n u m ber of elem en t s n in t h e win dow is even , medfilt1 sor t s t h e n u m ber s, t h en t a kes t h e a ver a ge of t h e ((n1)/2 & ((n1)/2)+1) elem en t s. Two sim ple exa m ples wit h fou r t h - a n d t h ir d-or der m edia n filt er s a r e
medfilt1([4 3 5 2 8 9 1],4) ans = 1.500 3.500 3.500 4.000 6.500 5.000 4.500 medfilt1([4 3 5 2 8 9 1],3) ans = 3 4 3 5 8 8 1
See t h e Im age Processin g T oolbox Users Gu id e for in for m a t ion on t wo-dim en sion a l m edia n filt er in g.
4-28
Communications Applications
Communications Applications
Th e t oolbox pr ovides t h r ee fu n ct ion s for com m u n ica t ion s sim u la t ion .
Operation Function modulate demod vco
Modu la t ion Dem odu la t ion Volt a ge con t r olled oscilla t ion
M od u lation va r ies t h e a m plit u de, ph a se, or fr equ en cy of a carrier sign al wit h r efer en ce t o a m essage sign al . Th e modulate fu n ct ion m odu la t es a m essa ge sign a l wit h a specified m odu la t ion m et h od. Th e ba sic syn t a x for t h e modulate fu n ct ion is
y = modulate(x,Fc,Fs,'method',opt)
wh er e : x is t h e m essa ge sign a l. Fc is t h e ca r r ier fr equ en cy. Fs is t h e sa m plin g fr equ en cy. method is a fla g for t h e desir ed m odu la t ion m et h od. opt is a n y a ddit ion a l a r gu m en t t h a t t h e m et h od r equ ir es. (Not a ll m odu la t ion m et h ods r equ ir e a n opt ion a r gu m en t .) Th e t a ble below su m m a r izes t h e m odu la t ion m et h ods pr ovided; see Ch a pt er 6 for com plet e det a ils on ea ch .
Method amdsbsc or am amdsbtc Description
Am plit u de m odu la t ion , dou ble side-ba n d, su ppr essed ca r r ier Am plit u de m odu la t ion , dou ble side-ba n d, t r a n sm it t ed ca r r ier
4-29
Special Topics
Description
Am plit u de m odu la t ion , sin gle side-ba n d F r equ en cy m odu la t ion P h a se m odu la t ion P u lse t im e m odu la t ion P u lse widt h m odu la t ion Qu a dr a t u r e a m plit u de m odu la t ion
If t h e in pu t x is a n a r r a y r a t h er t h a n a vect or , modulate m odu la t es ea ch colu m n of t h e a r r a y. To obt a in t h e t im e vect or t h a t modulate u ses t o com pu t e t h e m odu la t ed sign a l, specify a secon d ou t pu t pa r a m et er .
[y,t] = modulate(x,Fc,Fs,'method',opt)
Th e demod fu n ct ion per for m s d em od u lation , t h a t is, it obt a in s t h e or igin a l m essa ge sign a l fr om t h e m odu la t ed sign a l. Th e syn t a x for demod is
x = demod(y, Fc,Fs,'method',opt) demod u ses a n y of t h e m et h ods sh own for modulate, bu t t h e syn t a x for qu a dr a t u r e a m plit u de dem odu la t ion r equ ir es t wo ou t pu t pa r a m et er s. [X1,X2] = demod(y,Fc,Fs,'qam')
If t h e in pu t y is a n a r r a y, demod dem odu la t es a ll colu m n s. Tr y m odu la t in g a n d dem odu la t in g a sign a l. A 50 H z sin e wa ve sa m pled a t 1000 H z is
t = (0:1/1000:2); x = sin(2*pi*50*t);
4-30
Communications Applications
Wit h a ca r r ier fr equ en cy of 200 H z, t h e m odu la t ed a n d dem odu la t ed ver sion s of t h is sign a l a r e
y = modulate(x,200,1000,'am'); z = demod(y,200,1000,'am');
0.05
0.1
0.15
0.05
0.1
0.15
0.05
0.1
Th e volt a ge con t r olled oscilla t or fu n ct ion vco cr ea t es a sign a l t h a t oscilla t es a t a fr equ en cy det er m in ed by t h e in pu t vect or . Th e ba sic syn t a x for vco is
y = vco(x,Fc,Fs)
4-31
Special Topics
In t h is ca se, vco sca les t h e fr equ en cy m odu la t ion r a n ge so va lu es of x on t h e in t er va l [1 1] m a p t o oscilla t ion s of fr equ en cy on [Fmin Fmax]. If t h e in pu t x is a n a r r a y, vco pr odu ces a n a r r a y wh ose colu m n s oscilla t e a ccor din g t o t h e colu m n s of x. See F F T-Ba sed Tim e-F r equ en cy An a lysis on pa ge 4-27 for a n exa m ple u sin g t h e vco fu n ct ion .
4-32
Deconvolution
Deconvolution
Decon volu tion , or polyn om ia l division , is t h e in ver se oper a t ion of con volu t ion . Decon volu t ion is u sefu l in r ecover in g t h e in pu t t o a kn own filt er , given t h e filt er ed ou t pu t . Th is m et h od is ver y sen sit ive t o n oise in t h e coefficien t s, h owever , so u se ca u t ion in a pplyin g it . Th e syn t a x for deconv is
[q,r] = deconv(b,a)
wh er e b is t h e polyn om ia l dividen d, a is t h e divisor , q is t h e qu ot ien t , a n d r is t h e r em a in der . To t r y deconv, fir st con volve t wo sim ple vect or s a a n d b (see Ch a pt er 1 for a descr ipt ion of t h e con volu t ion fu n ct ion )
a = [1 2 3]; b = [4 5 6]; c = conv(a,b) c = 4 13 28 27 18
See t h e S ystem Id en tification T oolbox Users Gu id e for a dva n ced a pplica t ion s of sign a l decon volu t ion .
4-33
Special Topics
Specialized Transforms
In a ddit ion t o t h e discr et e F ou r ier t r a n sfor m (DF T) descr ibed in Ch a pt er 1, t h e Sign a l P r ocessin g Toolbox a n d t h e MATLAB en vir on m en t t oget h er pr ovide t h e followin g t r a n sfor m fu n ct ion s: Th e ch ir p z -t r a n sfor m (CZT), u sefu l in eva lu a t in g t h e z -t r a n sfor m a lon g con t ou r s ot h er t h a n t h e u n it cir cle. Th e ch ir p z -t r a n sfor m is a lso m or e efficien t t h a n t h e DF T a lgor it h m for t h e com pu t a t ion of pr im e-len gt h t r a n sfor m s, a n d it is u sefu l in com pu t in g a su bset of t h e DF T for a sequ en ce. Th e discr et e cosin e t r a n sfor m (DCT), closely r ela t ed t o t h e DF T. Th e DCTs en er gy com pa ct ion pr oper t ies a r e u sefu l for a pplica t ion s lik e sign a l codin g. Th e H ilber t t r a n sfor m , wh ich fa cilit a t es t h e for m a t ion of t h e a n a lyt ic sign a l. Th e a n a lyt ic sign a l is u sefu l in t h e a r ea of com m u n ica t ion s, pa r t icu la r ly in ba n dpa ss sign a l pr ocessin g.
Chirp z-Transform
Th e ch ir p z -t r a n sfor m , or CZT, com pu t es t h e z -t r a n sfor m a lon g spir a l con t ou r s in t h e z -pla n e for a n in pu t sequ en ce. Un like t h e DF T, t h e CZT is n ot con st r a in ed t o oper a t e a lon g t h e u n it cir cle, bu t ca n eva lu a t e t h e z -t r a n sfor m a lon g con t ou r s descr ibed by z l = A W l , l = 0 , , M 1 wh er e A is t h e com plex st a r t in g poin t , W is a com plex sca la r descr ibin g t h e com plex r a t io bet ween poin t s on t h e con t ou r , a n d M is t h e len gt h of t h e t r a n sfor m .
4-34
Specialized Transforms
On e possible spir a l is
A = 0.8*exp(j*pi/6); W = 0.995*exp(j*pi*.05); M = 91; z = A*(W.^((0:M1))); zplane([],z.')
0.5
Imaginary part
-0.5
An in t er est in g a n d u sefu l spir a l set is m even ly spa ced sa m ples a r ou n d t h e u n it cir cle, pa r a m et er ized by A = 1 a n d W = exp(j*pi/M). Th e z -t r a n sfor m on t h is con t ou r is sim ply t h e DF T, obt a in ed by
y = czt(x) czt is fa st er t h a n t h e fft fu n ct ion for com pu t in g t h e DF T of sequ en ces wit h cer t a in odd len gt h s, pa r t icu la r ly lon g pr im e-len gt h sequ en ces. (Tr y com pa r in g t h e execu t ion t im e for t h e fft a n d czt fu n ct ion s for a sequ en ce of len gt h 1013.)
4-35
Special Topics
y (k ) = wh er e
+
n =1
k = 1 , , N
n =1 25n 5N
Th e DCT is closely r ela t ed t o t h e discr et e F ou r ier t r a n sfor m ; t h e DF T is a ct u a lly on e st ep in t h e com pu t a t ion of t h e DCT for a sequ en ce. Th e DCT, h owever , h a s bet t er en ergy com paction pr oper t ies, wit h ju st a few of t h e t r a n sfor m coefficien t s r epr esen t in g t h e m a jor it y of t h e en er gy in t h e sequ en ce. Th e en er gy com pa ct ion pr oper t ies of t h e DCT m a k e it u sefu l in a pplica t ion s su ch a s da t a com m u n ica t ion s. Th e fu n ct ion idct com pu t es t h e in ver se DCT for a n in pu t sequ en ce, r econ st r u ct in g a sign a l fr om a com plet e or pa r t ia l set of DCT coefficien t s. Th e in ver se discr et e cosin e t r a n sfor m is
N
x (n ) = wh er e
-, + w (k ) y (k ) cos -----------------------------------------2N
k =1
$( 2 n 1 )( k 1 )
n = 1 , , N
k =1 25k 5N
4-36
Specialized Transforms
Beca u se of t h e en er gy com pa ct ion m en t ion ed a bove, it is possible t o r econ st r u ct a sign a l fr om on ly a fr a ct ion of it s DCT coefficien t s. F or exa m ple, gen er a t e a 10 H z sin u soida l sequ en ce, sa m pled a t 1000 H z.
t = (0:1/999:1); x = sin(2*pi*25*t);
Com pu t e t h e DCT of t h is sequ en ce a n d r econ st r u ct t h e sign a l u sin g on ly t h ose com pon en t s wit h va lu e gr ea t er t h a n 53 (12 of t h e or igin a l 1000 DCT coefficien t s).
y = dct(x); y2 = find(abs(y) < 53); y(y2) = zeros(size(y2)); z = idct(y); % % % % compute DCT use 12 coefs. zero out points < 53 reconstruct signal using inverse DCT
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
4-37
Special Topics
t h a t is, t h e n or m of t h e differ en ce bet ween t h e or igin a l a n d r econ st r u ct ed sign a ls, divided by t h e n or m of t h e or igin a l sign a l. In t h is ca se, t h e r ela t ive er r or of r econ st r u ct ion is 0.1778. Th e r econ st r u ct ed sign a l r et a in s a ppr oxim a t ely 82% of t h e en er gy in t h e or igin a l sign a l.
Hilbert Transform
Th e t oolbox fu n ct ion hilbert com pu t es t h e H ilber t t r a n sfor m for a r ea l in pu t sequ en ce x a n d r et u r n s a com plex r esu lt of t h e sa m e len gt h
y = hilbert(x)
wh er e t h e r ea l pa r t of y is t h e or igin a l r ea l da t a a n d t h e im a gin a r y pa r t is t h e a ct u a l H ilber t t r a n sfor m . y is som et im es ca lled t h e an alytic sign al , in r efer en ce t o t h e con t in u ou s-t im e a n a lyt ic sign a l. A key pr oper t y of t h e discr et e-t im e a n a lyt ic sign a l is t h a t it s z -t r a n sfor m is 0 on t h e lower h a lf of t h e u n it cir cle. Ma n y a pplica t ion s of t h e a n a lyt ic sign a l a r e r ela t ed t o t h is pr oper t y; for exa m ple, t h e a n a lyt ic sign a l is u sefu l in a voidin g a lia sin g effect s for ba n dpa ss sa m plin g oper a t ion s. Th e m a gn it u de of t h e a n a lyt ic sign a l is t h e com plex en velope of t h e or igin a l sign a l.
4-38
Specialized Transforms
Th e H ilber t t r a n sfor m is r ela t ed t o t h e a ct u a l da t a by a 90 ph a se sh ift ; sin es becom e cosin es a n d vice ver sa . To plot a por t ion of da t a (solid lin e) a n d it s H ilber t t r a n sfor m (dot t ed lin e)
t = (0:1/1023:1); x = sin(2*pi*60*t); y = hilbert(x); plot(t(1:50),real(y(1:50))), hold on plot(t(1:50),imag(y(1:50)),':'), hold off
1 0.8 0.6 0.4 0.2 0 -0.2 -0.4 -0.6 -0.8 -1 0 0.01 0.02 0.03 0.04 0.05
Th e a n a lyt ic sign a l is u sefu l in ca lcu la t in g in stan tan eou s attribu tes of a t im e ser ies, t h e a t t r ibu t es of t h e ser ies a t a n y poin t in t im e. Th e in st a n t a n eou s a m plit u de of t h e in pu t sequ en ce is t h e a m plit u de of t h e a n a lyt ic sign a l. Th e in st a n t a n eou s ph a se a n gle of t h e in pu t sequ en ce is t h e (u n wr a pped) angle of t h e a n a lyt ic sign a l; t h e in st a n t a n eou s fr equ en cy is t h e t im e r a t e of ch a n ge of t h e in st a n t a n eou s ph a se a n gle. You ca n ca lcu la t e t h e in st a n t a n eou s fr equ en cy u sin g diff, a s descr ibed in t h e on lin e M A T L AB Fu n ction R eferen ce.
4-39
Special Topics
References
1 Ka y, S.M. M od ern S pectral E stim ation . E n glewood Cliffs, NJ : P r en t ice H a ll,
1988.
2 Oppen h eim , A.V., a n d R.W. Sch a fer . Discrete-T im e S ign al Processin g .
4-40
5
In t er a ct ive Tools
S P To o l: An In te ra c tiv e S ig n a l P ro c e s s in g E n v iro n m e n t . 5-2 U s in g S P To o l . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3 U s in g t h e S ig n a l B ro w s e r: In te ra c tiv e S ig n a l An a ly s is . 5-43 U s in g t h e F ilte r D e s ig n e r: In te ra c tiv e F ilte r D e s ig n . . . 5-59 U s in g t h e F ilte r Vie w e r: In te ra c tiv e F ilt e r An a ly s is . . . 5-84 U s in g t h e S p e c tru m Vie w e r: In te ra c tiv e P S D An a ly s is . 5-97 Ex a m p le : Ge n e ra tio n o f B a n d lim ite d N o is e . . . . . . . . . . 5-113
Interactive Tools
Overview
SP Tool is a gr a ph ica l en vir on m en t for a n a lyzin g a n d m a n ipu la t in g digit a l sign a ls, filt er s, a n d spect r a . It is t h e st a r t in g poin t for u sin g t h e in t er a ct ive sign a l pr ocessin g en vir on m en t . In SP Tool, you ca n im por t sign a ls, filt er s, a n d spect r a eit h er fr om t h e wor kspa ce or a s MAT-files. Th r ou gh SP Tool, you a ccess fou r a ddit ion a l GUI t ools t h a t pr ovide a n in t egr a t ed en vir on m en t for sign a l br owsin g, filt er design , a n a lysis, a n d im plem en t a t ion . Th e fou r com pon en t s of t h e in t er a ct ive sign a l pr ocessin g en vir on m en t in clu de: Th e S ign al B row ser , wh ich pr ovides a gr a ph ica l view of t h e sign a l object s cu r r en t ly select ed in SP Tool a n d en a bles you t o displa y, m ea su r e, a n a lyze, a n d pr in t t h ese sign a ls in t er a ct ively Th e Filter Design er , wh ich en a bles you t o cr ea t e a n d edit lowpa ss, h igh pa ss, ba n dpa ss, a n d ba n dst op F IR a n d IIR digit a l filt er s of va r iou s len gt h s a n d t ypes u sin g t h e filt er design fu n ct ion s of t h e Sign a l P r ocessin g Toolbox Th e Filter View er , wh ich en a bles you t o view va r iou s ch a r a ct er ist ics of a filt er t h a t you ve im por t ed or design ed, in clu din g it s m a gn it u de a n d ph a se r espon ses, gr ou p dela y, zer o-pole plot , a n d im pu lse a n d st ep r espon ses Th e S pectru m View er , wh ich en a bles you t o cr ea t e, view, m odify, a n d pr in t spect r a in t er a ct ively, a n d t o per for m gr a ph ica l a n a lysis of fr equ en cy dom a in da t a u sin g a va r iet y of com m on m et h ods of spect r a l est im a t ion
5-2
Using SPTool
Using SPTool
SP Tool is t h e da t a m a n a gem en t t ool for t h e in t er a ct ive GUI en vir on m en t of t h e Sign a l P r ocessin g Toolbox. Usin g SP Tool you ca n : Loa d a sa ved session Im por t a sign a l, filt er , or spect r u m Du plica t e or clea r a sign a l, filt er , or spect r u m Ch a n ge t h e n a m e of a sign a l, filt er , or spect r u m Ch a n ge t h e sa m plin g fr equ en cy of a sign a l or filt er Act iva t e t h e Sign a l Br owser , F ilt er Viewer , F ilt er Design er , or Spect r u m Viewer Sa ve a session Use t h e Win d o w m en u t o ch a n ge t o a n y open MATLAB figu r e win dow
Opening SPTool
Open SP Tool fr om t h e MATLAB com m a n d win dow by t ypin g
sptool
a n d pr essin g En te r .
Quick Start
On ce SP Tool is open , you ca n im por t da t a fr om t h e wor kspa ce or a file. You ca n t h en view it in t h e Sign a l Br owser or gen er a t e it s spect r u m in t h e Spect r u m Viewer . To get st a r t ed r igh t a wa y, wor k t h r ou gh t h e followin g exa m ple. Th en con t in u e t h r ou gh t h is ch a pt er t o lea r n t h e det a ils of u sin g SP Tool a n d it s com pon en t t ools. Or , you ca n sk ip t h e exa m ple, r ea d t h r ou gh t h e r est of t h is sect ion (fr om Ba sic SP Tool F u n ct ion s t o Usin g t h e Sign a l Br owser : In t er a ct ive Sign a l An a lysis), a n d t h en wor k t h r ou gh t h e exa m ple.
5-3
Interactive Tools
1 Select Im p o rt fr om t h e F ile m en u .
You ca n eit h er en t er a MAT-file n a m e or pr ess B ro w s e t o open t h e file dia log box a n d select a MAT-file.
4 To get st a r t ed, t ype t h e file n a m e mtlb a n d pr ess Ta b or En te r . Not e t h a t
SP Tool a dds t h e .mat ext en sion a u t om a t ica lly. Th e da t a fr om t h e file you select ed is displa yed in t h e F ile Co n te n ts list . In t h is exa m ple, mtlb is t h e sign a l da t a a n d Fs is t h e sa m plin g fr equ en cy. Not ice t h a t sig1 is displa yed in t h e N a m e field. Th is is t h e defa u lt n a m e of t h e im por t ed sign a l.
5 Click on mtlb t o select it , a n d t h en pr ess t h e a r r ow a t t h e left of t h e D a ta
F re qu e n c y field.
Fs is t r a n sfer r ed t o t h e S a m p lin g F re qu e n c y field.
5-4
Using SPTool
7 P r ess OK .
Th e sign a l h a s been im por t ed in t o SP Tool wit h t h e n a m e sig1. You ca n look a t t h is sign a l in t h e Sign a l Br owser by pr essin g t h e Vi e w bu t t on u n der S ig n a ls . You ca n look a t t h e fr equ en cy con t en t of t h e sign a l in t h e Spect r u m Viewer by pr essin g t h e Cre a te bu t t on u n der S p e c tra a n d t h en pr essin g Ap p ly in t h e Spect r u m Viewer .
5-5
Interactive Tools
File Menu
Open Session. Select Op e n S e s s io n fr om t h e F ile m en u t o loa d a sa ved session file. An SP Tool session is sa ved in a file wit h a n .spt ext en sion . Import. Select Im p o rt fr om t h e F ile m en u t o im por t a sign a l, filt er , or spect r u m in t o SP Tool fr om eit h er t h e wor kspa ce or fr om a file. You ca n im por t va r ia bles fr om a n y MAT-file in t o SP Tool. See Im por t in g Sign a ls, F ilt er s, a n d Spect r a on pa ge 5-7 a n d E xa m ple: Im por t in g Sign a l Da t a fr om a MAT-F ile on pa ge 5-3 for m or e in for m a t ion . Export. Select Ex p o rt fr om t h e F ile m en u t o expor t sign a ls, filt er s, a n d spect r a t o t h e MATLAB wor k spa ce a s st r u ct u r e va r ia bles. See Sa vin g Sign a l Da t a on pa ge 5-57, Sa vin g F ilt er Da t a on pa ge 5-79, a n d Sa vin g Spect r u m Da t a on pa ge 5-110 for com plet e in for m a t ion . Save Session. Select S a v e S e s s io n a n d S a v e S e s s i o n As fr om t h e F i le m en u t o sa ve t h e cu r r en t session . S a v e S e s s i o n over wr it es t h e exist in g session file. S a v e S e s s i o n As sa ves t h e cu r r en t session wit h a n a m e you specify. An SP Tool session is sa ved in a MAT-file wit h a n .spt ext en sion . Preferences. Select P re fe re n c e s fr om t h e F ile m en u t o cu st om ize pr efer en ces for t h e beh a vior of a ll t h e Sign a l P r ocessin g GUI t ools. See Cu st om izin g P r efer en ces on pa ge 5-20 for a com plet e discu ssion . Close. Select Clo s e fr om t h e F i le m en u t o close SP Tool a n d a ll ot h er a ct ive Sign a l P r ocessin g GUI t ools. SP Tool pr om pt s you t o sa ve if you h a ve n ot r ecen t ly sa ved t h e cu r r en t session .
Wh en you close SP Tool, a ll sign a l a n d filt er cu st om iza t ion a n d r u ler in for m a t ion set in a n y of t h e GUI t ools a r e lost . Set t in gs you ch a n ged a n d sa ved u sin g t h e P re fe re n c e s dia log box in SP Tool a r e u sed t h e n ext t im e you open SP Tool.
Help Menu
Overview Select Ov e rv ie w fr om t h e F ile m en u t o get gen er a l h elp on SP Tool a n d t h e Sign a l P r ocessin g Toolbox GUI en vir on m en t . Th is a lso gives you a ccess t o t h e MATLAB H elp Desk.
5-6
Using SPTool
Context Sensitive Select Co n te x t S e n s itiv e fr om t h e F ile m en u for h elp on a specific pa r t of SP Tool. Wh en you click on Co n te x t S e n s itiv e , t h e m ou se poin t er becom es a n a r r ow wit h a qu est ion m a r k sym bol. You ca n t h en click on a n yt h in g in SP Tool, in clu din g m en u it em s, t o fin d ou t wh a t it is a n d h ow t o u se it .
Load the contents of a file into the File Contents list by clicking here, and either typing a filename in the box and pressing Tab or Enter, or pressing Browse and selecting a MAT-file.
5-7
Interactive Tools
1 Click t h e F ro m Wo rk s p a c e r a dio bu t t on .
list in t o SP Tool. See Im por t in g Wor kspa ce Con t en t s a n d F ile Con t en t s below.
a n d pr ess Ta b or En te r . or P r ess B ro w s e , a n d t h en fin d a n d select t h e file you wa n t t o im por t u sin g t h e F ile Sea r ch win dow. P r ess OK . Th e da t a fr om t h e file you select ed is displa yed in t h e F i le Co n te n ts list .
3 You ca n n ow im por t on e or m or e va r ia bles fr om t h e F i le Co n te n ts list in t o
5-8
Using SPTool
5-11, a n d Im por t in g a Spect r u m on pa ge 5-13 for det a ils on cu st om izin g va r ia bles t h a t a r e im por t ed in t o SP Tool.
1 Click on a va r ia ble n a m e in t h e Wo rk s p a c e Co n te n ts list or t h e
If t h e va r ia ble is n ot a sa ved da t a object fr om SP Tool, select t h e a ppr opr ia t e da t a t ype (S ig n a l , F ilte r , or S p e c tru m ) fr om t h e Im p o rt As pop-u p m en u a n d t ype a n a m e in t o t h e N a m e field.
If t h e va r ia ble is a sa ved da t a object fr om SP Tool, it s n a m e is displa yed in t h e N a m e field, a n d it s t ype (S ig n a l , F ilte r , or S p e c tru m ) is a u t om a t ica lly select ed in t h e Im p o rt As pop-u p m en u .
2 P r ess t h e a r r ow a t t h e left of t h e D a ta field. Th e select ed va r ia ble is
t r a n sfer r ed t o t h e D a ta field. NOTE You ca n a lso t ype a va r ia ble n a m e in t o t h e D a ta field dir ect ly.
eit h er :
a Click on a va r ia ble in t h e Wo rk s p a c e Co n te n ts list or F i le Co n te n ts list
wh ose va lu e is a sa m plin g fr equ en cy, a n d t h en pr ess t h e a r r ow a t t h e left of t h e S a m p lin g F re qu e n c y field. Th e select ed va r ia ble is t r a n sfer r ed t o t h e S a m p lin g F re qu e n c y field. or
b Type a va lu e or va r ia ble n a m e in t h e S a m p lin g F re qu e n c y field.
5-9
Interactive Tools
4 P r ess OK .
NOTE Wh en you r e im por t in g fr om t h e wor kspa ce, you ca n specify eit h er a va r ia ble or a va lu e for ea ch da t a field. Wh en you r e im por t in g fr om a disk, you ca n on ly specify va r ia bles.
A va r ia ble n a m e for t h e sign a l da t a (or t h e sign a l da t a va lu es) in t h e D a ta field A va r ia ble or a va lu e for t h e sign a ls sa m plin g fr equ en cy in t h e S a m p lin g F re q u e n c y field
5-10
Using SPTool
Importing a Filter. Wh en you im por t a filt er , fir st select t h e a ppr opr ia t e filt er for m fr om t h e F o rm pop-u p m en u .
E a ch filt er for m r equ ir es differ en t va r ia bles. F or Tra n s fe r F u n c tio n , you specify t h e filt er by it s t r a n sfer fu n ct ion r epr esen t a t ion : B (z ) b (1 ) + b (2 ) z 1 + L + b (m + 1 ) z m H (z ) = ---------- = ----------------------------------------------------------------------------------- 1 A (z ) + a (n + 1 ) z n a (1 ) + a (2 ) z + L - Th e N u m e ra to r field specifies a va r ia ble n a m e or va lu e for t h e n u m er a t or coefficien t vect or b , wh ich con t a in s m +1 coefficien t s in descen din g power s of z. - Th e D e n o m in a to r field specifies a va r ia ble n a m e or va lu e for t h e den om in a t or coefficien t vect or a , wh ich con t a in s n +1 coefficien t s in descen din g power s of z. F or S ta te S p a c e , you specify t h e filt er by it s st a t e-spa ce r epr esen t a t ion : x = Ax + Bu y = Cx + Du Th e A-Ma tri x , B -Ma trix , C-Ma tri x , a n d D -Ma tri x fields specify a va r ia ble n a m e or a va lu e for ea ch m a t r ix in t h is syst em . F or Ze ro s , P o le s , Ga i n , you specify t h e filt er by it s zer o-pole-ga in r epr esen t a t ion :
5-11
Interactive Tools
( z z ( 1 ) )( z z ( 2 ) )L (z z (m )) Z (z ) H (z ) = ---------- = k -------------------------------------------------------------------------------(z p ( 1 ) )( z p ( 2 ) )L (z p (n )) P (z ) - Th e Ze ro s field specifies a va r ia ble n a m e or va lu e for t h e zer os vect or z , wh ich con t a in s t h e loca t ion s of m zer os . - Th e P o le s field specifies a va r ia ble n a m e or va lu e for t h e zer os vect or p , wh ich con t a in s t h e loca t ion s of n poles . - Th e Ga in field specifies a va r ia ble n a m e or va lu e for t h e ga in k . F or 2n d Ord e r S e c tio n s you specify t h e filt er by it s secon d-or der sect ion r epr esen t a t ion :
L L
H (z ) =
0
k =1
H k (z ) =
0
k =1
b 0 k + b 1 k z 1 + b 2 k z 2 --------------------------------------------------------1 + a 1 k z 1 + a 2 k z 2
Th e S OS Ma trix field specifies a va r ia ble n a m e or a va lu e for t h e L -by-6 SOS m a t r ix b 01 b 11 b 21 1 a 11 a 21 s os = b 02 b 12 b 22 1 a 12 a 22 M M M b0L b1L b2L M M M 1 a1L a2L
wh ose r ows con t a in t h e n u m er a t or a n d den om in a t or coefficien t s b ik a n d a ik of t h e secon d-or der sect ion s of H (z ): F or ever y filt er , you specify: A va r ia ble n a m e or a va lu e for t h e filt er s sa m plin g fr equ en cy in t h e S a m p lin g F re qu e n c y field
5-12
Using SPTool
A va r ia ble n a m e or a va lu e for t h e power spect r a l den sit y (P SD) vect or in t h e P S D field A va r ia ble n a m e or a va lu e for t h e fr equ en cy vect or in t h e F re q. Ve c to r field
Th e P SD va lu es in t h e P S D vect or cor r espon d t o t h e fr equ en cies con t a in ed in t h e F re q. Ve cto r vect or ; t h e t wo vect or s m u st h a ve t h e sa m e len gt h .
5-13
Interactive Tools
5-14
Using SPTool
Spect r a a r e displa yed wit h t h e spectru m type [auto]: An au to-spectru m ([auto]) is a spect r u m wh ose sou r ce is a sin gle sign a l, a s opposed t o t h e cr oss-spect r u m of t wo ch a n n els of da t a . spectrum[auto] is t h e on ly spect r u m t ype in SP Tool.
5-15
Interactive Tools
Select D u p lic a te a n d dr a g t o ch oose t h e sign a l, filt er , or spect r u m you wa n t t o copy. Wh en you select a da t a object t o du plica t e it , a n ew da t a object of t h e sa m e t ype is a u t om a t ica lly cr ea t ed. Th e n ew da t a object is n a m ed a s a copy of t h e select ed da t a object . It is pla ced a t t h e bot t om of t h e list a n d is select ed. You ca n ch a n ge it s n a m e u sin g N a m e fr om t h e Ed it m en u .
Clear. Use Cle a r fr om t h e Ed it m en u t o delet e t h e select ed sign a l, filt er , or spect r u m fr om SP Tool.
Select Cle a r a n d dr a g t o ch oose t h e sign a l, filt er , or spect r u m you wa n t t o r em ove. Th e da t a object is delet ed fr om t h e cu r r en t SP Tool session .
Name. Use N a m e fr om t h e Ed it m en u t o give t h e select ed sign a l, filt er , or spect r u m a n ew, u n iqu e n a m e.
1 Select N a m e ... a n d dr a g t o ch oose t h e sign a l, filt er , or spect r u m you wa n t t o
Sampling Frequency. Use S a m p lin g F re q u e n c y fr om t h e Ed i t m en u t o su pply a sa m plin g fr equ en cy for a select ed sign a l or filt er . Th e sa m plin g fr equ en cy m a y be a n u m ber , su ch a s 1, 0.001, or 1/5000, or a va lid MATLAB expr ession in clu din g wor kspa ce va r ia bles, su ch a s Fs, 1/Ts, or cos(0.1*pi).
5-16
Using SPTool
Viewing a Signal
Use t h e Sign a l Vie w bu t t on t o m a ke t h e Sign a l Br owser a ct ive a n d view on e or m or e im por t ed sign a ls. Th e Sign a l Br owser pr ovides t ools for gr a ph ica l a n a lysis of t h e select ed sign a l(s). Select on e or m or e sign a ls fr om t h e S ig n a ls list a n d pr ess t h e Vi e w bu t t on in t h e sign a l pa n el. Th e Sign a l Br owser displa ys t h e select ed sign a l(s). See Usin g t h e Sign a l Br owser : In t er a ct ive Sign a l An a lysis on pa ge 5-43 for a fu ll descr ipt ion of Sign a l Br owser fu n ct ion s a n d oper a t ion s.
Viewing a Filter
Use t h e Vie w bu t t on in t h e F ilte rs pa n el t o m a ke t h e F ilt er Viewer a ct ive a n d view im por t ed filt er s or filt er s design ed/edit ed in t h e F ilt er Design er . Th e F ilt er Viewer pr ovides t ools for a n a lyzin g filt er s; you ca n in vest iga t e t h e m a gn it u de r espon se, ph a se, gr ou p dela y, zer os a n d poles, a n d im pu lse a n d st ep r espon ses of t h e select ed filt er s. Select on e or m or e filt er s fr om t h e F i lte rs list a n d pr ess t h e Vie w bu t t on in t h e filt er pa n el. Th e F ilt er Viewer displa ys t h e select ed filt er s. See Usin g t h e F ilt er Viewer : In t er a ct ive F ilt er An a lysis on pa ge 5-84 for a fu ll descr ipt ion of F ilt er Viewer fu n ct ion s a n d oper a t ion s.
Designing a Filter
New Design. Use t h e F ilt er N e w D e s ig n bu t t on t o m a ke t h e F ilt er Design er a ct ive a n d design a filt er . Th e F ilt er Design er let s you cr ea t e F IR a n d IIR digit a l filt er s of va r iou s len gt h s a n d t ypes u sin g t h e filt er design fu n ct ion s in t h e Sign a l P r ocessin g Toolbox.
P r ess t h e N e w D e s ig n bu t t on in t h e F i lte r pa n el. Th e F ilt er Design er displa ys a filt er cr ea t ed wit h t h e defa u lt set t in gs a n d a ssign s it a defa u lt n a m e of filtn, wh er e n is a u n iqu e sequ en t ia l iden t ifyin g digit . On ce t h e defa u lt filt er is cr ea t ed, you ca n u se it a s is or edit it wit h t h e F ilt er Design er . You ca n r en a m e it u sin g N a m e fr om t h e Ed it m en u .
5-17
Interactive Tools
Edit Design. Use t h e F ilte r pa n els Ed i t D e s ig n bu t t on t o m a ke t h e F ilt er Design er a ct ive a n d edit a filt er . Im por t ed filt er s a lwa ys open in t h e P ole/Zer o E dit or .
Select on e or m or e filt er s fr om t h e F i lte rs list a n d pr ess t h e Ed it D e s ig n bu t t on in t h e filt er pa n el. Th e F ilt er Design er displa ys t h e fir st of t h e select ed filt er s. Th e ot h er select ed filt er s ca n be edit ed, on e a t a t im e, by select in g t h em fr om t h e F ilte r pop-u p m en u . See Usin g t h e F ilt er Design er : In t er a ct ive F ilt er Design on pa ge 5-59 for a fu ll descr ipt ion of F ilt er Design er fu n ct ion s a n d oper a t ion s.
Applying a Filter
Use t h e Ap p ly F ilte r bu t t on t o a pply a filt er t o a select ed sign a l. Th is cr ea t es a n ew sign a l:
1 Select on e sign a l fr om t h e S ig n a ls list a n d on e filt er fr om t h e F ilte rs list a n d
pr ess t h e Ap p ly F i lte r bu t t on in t h e filt er pa n el. Th e Ap p ly F ilte r dia log box is displa yed. Drag to select the algorithm you want to use. Type the new signal name here.
2 Select t h e filt er in g a lgor it h m fr om t h e Alg o rith m pop-u p m en u , t ype t h e
n a m e for t h e n ew sign a l in t h e Ou tp u t S ig n a l field, a n d pr ess OK . Th e a va ila ble filt er a lgor it h m s a r e: - Tr a n sposed dir ect -for m II (u ses t h e filter fu n ct ion ) - Zer o-ph a se IIR (u ses t h e filtfilt fu n ct ion ) - F F T-ba sed F IR (u ses t h e fftfilt fu n ct ion ) Th e select ed filt er is a pplied t o t h e select ed in pu t sign a l a n d t h e n ew ou t pu t sign a l is list ed in t h e S i g n a ls list .
5-18
Using SPTool
Creating a Spectrum
Use t h e Cre a te bu t t on t o a ct iva t e t h e Spect r u m Viewer a n d gen er a t e a defa u lt spect r u m of a select ed sign a l. On ce you ve gen er a t ed a spect r u m , you ca n view it in a va r iet y of wa ys, m ea su r e it , a n d m odify it in t h e Spect r u m Viewer .
1 Select on e sign a l fr om t h e S ig n a ls list a n d pr ess t h e Cre a te bu t t on in t h e
S p e c tra pa n el.
Th e Spect r u m Viewer is a ct iva t ed a n d a spect r u m object wit h defa u lt pa r a m et er s is cr ea t ed in t h e S p e c tra pa n el. Th e P SD da t a is n ot com pu t ed or displa yed yet . Th e n ewly cr ea t ed spect r u m object h a s a defa u lt n a m e of specn, wh er e n is a u n iqu e sequ en t ia l iden t ifyin g digit . On ce t h e spect r u m object is cr ea t ed, you ca n u se it wit h t h e defa u lt set t in gs, or con t in u e t o edit it in t h e Spect r u m Viewer . You ca n r en a m e it u sin g N a m e fr om t h e Ed it m en u .
2 Modify t h e spect r u m pa r a m et er s (e.g., Me th o d a n d N fft ) a s desir ed. 3 P r ess Ap p ly in t h e Spect r u m Viewer t o com pu t e t h e spect r u m da t a . Th is
bu t t on is en a bled wh en t h e spect r u m h a s ju st been cr ea t ed or wh en you h a ve ch a n ged on e or m or e pa r a m et er s in t h e Spect r u m Viewer . Th e u pda t ed spect r u m is displa yed in t h e Spect r u m Viewer . See Usin g t h e Spect r u m Viewer : In t er a ct ive P SD An a lysis on pa ge 5-97 for a fu ll descr ipt ion of Spect r u m Viewer pa r a m et er s a n d displa ys.
Viewing a Spectrum
Select on e or m or e spect r a fr om t h e S p e c tra list a n d pr ess Vie w in t h e S p e c tra pa n el. Th e Spect r u m Viewer displa ys t h e select ed spect r u m or spect r a .
Updating a Spectrum
Use t h e U p d a te bu t t on t o u pda t e t h e select ed spect r u m so t h a t it r eflect s t h e da t a in t h e cu r r en t ly select ed sign a l.
1 Select on e sign a l fr om t h e S ig n a ls list a n d on e spect r u m fr om t h e S p e c tra
list a n d pr ess U p d a te in t h e S p e c tra pa n el. Th e spect r a l da t a fr om t h e cu r r en t spect r u m is r em oved fr om t h e Spect r u m Viewer . Th e Spect r u m Viewer is a ct iva t ed. No spect r u m is displa yed yet .
5-19
Interactive Tools
t h e u pda t e. Th e spect r u m is r egen er a t ed wit h t h e sa m e pa r a m et er s bu t u sin g t h e da t a in t h e cu r r en t ly select ed sign a l. Th is fea t u r e is u sefu l wh en you h a ve a lt er ed a sign a l (by filt er in g it , for exa m ple), a n d wa n t t o u pda t e t h e exist in g spect r u m t o r eflect t h e ch a n ge.
Customizing Preferences
Use P re fe re n c e s fr om t h e F ile m en u t o cu st om ize displa ys a n d cer t a in pa r a m et er s for SP Tool a n d it s fou r com pon en t t ools. Th e n ew set t in gs a r e sa ved on disk a n d a r e u sed wh en you r est a r t MATLAB. In t h e P re fe re n c e s pa n els, you ca n : Select color s a n d m a r ker s for r u ler s, a n d set t h e in it ia l r u ler st yle Select color a n d lin e st yle sequ en ce for displa yed sign a ls Con figu r e a xis la bels, a n d en a ble/disa ble r u ler s, pa n n er , a n d m ou se zoom in t h e Sign a l Br owser Con figu r e a xis pa r a m et er s, a n d en a ble/disa ble r u ler s a n d m ou se zoom in t h e Spect r u m Viewer Con figu r e filt er a n d a xis pa r a m et er s a n d en a ble/disa ble m ou se zoom in t h e F ilt er Viewer Con figu r e t ilin g pr efer en ces in t h e F ilt er Viewer Specify F F T len gt h , a n d en a ble/disa ble m ou se zoom a n d gr id in t h e F ilt er Design er E n a ble/disa ble u se of a defa u lt session file Con figu r e filt er s for expor t t o t h e Con t r ol Syst em Toolbox (for u ser s of t h a t pr odu ct ) E n a ble/disa ble sea r ch for plu g-in s a t st a r t -u p Wh en you fir st select P re fe re n c e s , t h e P re fe re n c e s dia log box displa ys t h e Ru le rs pa n el. You ca n ch a n ge t h e set t in gs for r u ler s, or ch oose on a n y of t h e ot h er set t in gs ca t egor ies t o cu st om ize ot h er set t in gs. Click on ce on a set t in gs ca t egor y t o select it .
5-20
Using SPTool
Th e followin g sect ion s descr ibe a ll of t h e set t in gs you ca n m odify. Th e illu st r a t ion s sh ow t h e defa u lt set t in gs for ea ch ca t egor y. F or a ddit ion a l in for m a t ion on pr efer en ce set t in gs, u se t h e He lp ... bu t t on a t t h e bot t om of t h e P re fe re n c e s dia log box.
Ruler Settings
Th e R u le rs pr efer en ces a pply t o t h e r u ler s in t h e Sign a l Br owser , Spect r u m Viewer , a n d F ilt er Viewer . Th ese pr efer en ces a lso a pply t o pr in t ou t s fr om t h e Sign a l Br owser a n d Spect r u m Viewer .
Ruler Color. Specifies t h e color of t h e r u ler s. Color is specified a s a st r in g (e.g., 'r') or RGB t r iple (e.g., [1 0 0]). Ruler Marker. Specifies t h e m a r k er u sed in t h e t r a ck a n d slope r u ler s. Marker Size. Specifies t h e size of t h e r u ler m a r ker in poin t s. Th is ca n be a n y posit ive va lu e. Initial Type. Specifies t h e t ype of r u ler (h or izon t a l, ver t ica l, t r a ck, or slope) t h a t
is select ed wh en you fir st open t h e Sign a l Br owser , Spect r u m Viewer , or F ilt er Viewer .
5-21
Interactive Tools
Color Settings
Th e Co lo rs pr efer en ces a pply t o sign a ls displa yed in t h e Sign a l Br owser , Spect r u m Viewer , a n d F ilt er Viewer . Th ese pr efer en ces a lso a pply t o pr in t ou t s fr om t h e Sign a l Br owser a n d Spect r u m Viewer .
Color Order. Specifies t h e color or der t o cycle t h r ou gh for da t a plot t ed in t h e Sign a l Br owser , Spect r u m Viewer , a n d F ilt er Viewer . Th e defa u lt is t h e a xis color or der .
Type in a n ew va lu e or va lu e st r in g t o ch a n ge t h e color or der . Color is specified a s a st r in g (e.g., 'r') or RGB t r iple (e.g., [1 0 0]), a n n -by-3 m a t r ix of n color s, or a n n -by-1 cell a r r a y of su ch object s.
Line Style Order. Specifies t h e lin e st yles t o cycle t h r ou gh for da t a plot t ed in t h e
Sign a l Br owser , Spect r u m Viewer , a n d F ilt er Viewer . Th e defa u lt is t h e a xis lin e st yle or der . Type in a n ew st r in g va lu e (e.g., '--') or a n a r r a y of st r in gs (e.g., {'-','--',':'}) t o ch a n ge t h e lin e st yle or der .
5-22
Using SPTool
X Label, Y Label. Type in a st r in g for t h e x -a xis la bel a n d t h e y -a xis la bel in t h e Sign a l Br owser . Th e defa u lt is Time for t h e x -a xis. Rulers. Click in t h e ch eck box t o displa y (ch ecked) or h ide (u n ch eck ed) t h e r u ler bu t t on s a n d t h e r u ler pa n el in t h e Sign a l Br owser . See Ru ler Con t r ols on pa ge 5-33 for det a ils on u sin g t h e r u ler s in t h e Sign a l Br owser . Panner. Click in t h e ch eck box t o displa y (ch eck ed) or h ide (u n ch ecked) t h e
pa n n er in t h e Sign a l Br owser . See P a n n er Displa y on pa ge 5-52 for det a ils on u sin g t h e pa n n er in t h e Sign a l Br owser .
Stay in Zoom-mode After Zoom. Click in t h e ch eck box t o en a ble (ch ecked) or disa ble (u n ch eck ed) zoom per sist en ce in t h e Sign a l Br owser . See Zoom Con t r ols on pa ge 5-31 for det a ils on zoom con t r ols in t h e Sign a l Br owser .
5-23
Interactive Tools
Magnitude Axis Scaling. Specifies t h e sca lin g u n it s for t h e m a gn it u de (y ) a xis in t h e Spect r u m Viewer . Sca lin g u n it s ca n be d e c i be ls or lin e a r . Frequency Axis Scaling. Specifies t h e sca lin g u n it s for t h e fr equ en cy (x ) a xis in t h e Spect r u m Viewer . Sca lin g u n it s ca n be lin e a r or lo g . Frequency Axis Range. Specifies t h e n u m er ica l r a n ge for t h e fr equ en cy (x ) a xis in t h e Spect r u m Viewer . Sca lin g opt ion s a r e [0,F s /2] , [0,F s ] , or [-F s /2,F s /2] . Rulers. Click in t h e ch eck box t o displa y (ch eck ed) or h ide (u n ch ecked) t h e r u ler bu t t on s a n d t h e r u ler pa n el in t h e Spect r u m Viewer . See Ru ler Con t r ols on pa ge 5-33 for det a ils on u sin g t h e r u ler s in t h e Spect r u m Viewer . Stay in Zoom-mode After Zoom. Click in t h e ch eck box t o en a ble (ch eck ed) or disa ble (u n ch ecked) zoom per sist en ce in t h e Spect r u m Viewer . See Zoom Con t r ols on pa ge 5-31 for det a ils on zoom con t r ols in t h e Spect r u m Viewer .
5-24
Using SPTool
FFT Length. Specifies t h e n u m ber of poin t s a t wh ich t h e fr equ en cy r espon se is com pu t ed (for t h e m a gn it u de, ph a se, a n d gr ou p dela y plot s). Time Response Length. Specifies t h e t im e r espon se len gt h (in sa m ples) for t h e im pu lse a n d st ep r espon se plot s. An em pt y va lu e, [ ], for a n F IR filt er in dica t es t h a t t h e com plet e r espon se len gt h will be sh own ; a n em pt y va lu e for a n IIR filt er in dica t es t h a t t h e r espon se len gt h will be a u t om a t ica lly det er m in ed u sin g t h e impz fu n ct ion . Magnitude Axis Scaling. Specifies t h e sca lin g u n it s for t h e m a gn it u de (y ) a xis in t h e F ilt er Viewer . Sca lin g u n it s ca n be li n e a r , lo g , or d e c ibe ls . Phase Units. Specifies t h e ph a se u n it s for t h e ph a se r espon se plot . P h a se u n it s ca n be d e g re e s or ra d i a n s . Frequency Axis Scaling. Specifies t h e sca lin g u n it s for t h e fr equ en cy (x ) a xis in t h e F ilt er Viewer . Sca lin g u n it s ca n be li n e a r or lo g . Frequency Axis Range. Specifies t h e n u m er ica l r a n ge for t h e fr equ en cy (x ) a xis in t h e F ilt er Viewer . Sca lin g opt ion s a r e [0,F s /2] , [0,F s ] , or [-F s /2,F s /2] .
5-25
Interactive Tools
Rulers. Click in t h e ch eck box t o displa y (ch eck ed) or h ide (u n ch ecked) t h e r u ler bu t t on s a n d t h e r u ler pa n el in t h e F ilt er Viewer . See Ru ler Con t r ols on pa ge 5-33 for det a ils on u sin g t h e r u ler s in t h e F ilt er Viewer . Stay in Zoom-mode After Zoom. Click in t h e ch eck box t o en a ble (ch eck ed) or disa ble (u n ch ecked) zoom per sist en ce in t h e F ilt er Viewer . See Zoom Con t r ols on pa ge 5-31 for det a ils on zoom con t r ols in t h e F ilt er Viewer .
Click t h e r a dio bu t t on t o select h ow t h e plot s a r e t iled in t h e displa y a r ea . Opt ion s a r e 2-by -3 Grid , 3-by -2 Grid , Ve rti c a l (6-by -1 Grid ) , a n d Ho rizo n ta l (1-by -6 Grid ) . Th is specifies h ow t h e plot s a r e a r r a n ged wh en a ll six plot opt ion s a r e t u r n ed on . Wh en fewer opt ion s a r e t u r n ed on , t h e plot s a r e displa yed a s sym m et r ica lly a s possible.
5-26
Using SPTool
r espon se.
Display grid lines. Tu r n s plot gr id lin es on (ch ecked) or off (u n ch eck ed). Auto Design initial value. Specifies t h e defa u lt set t in g for t h e Au to D e s ig n ch eck box in t h e F ilt er Design er . Wh en t h e F ilt er Design er is fir st la u n ch ed, t h e Au to D e s ig n ch eck box will h a ve t h e sa m e set t in g (ch ecked or u n ch eck ed) a s t h e Au to D e s ig n i n itia l v a lu e ch eck box h er e. Stay in Zoom-mode After Zoom. Tu r n s per sist en t zoom in g on a n d off, a s descr ibed in Zoom Con t r ols on pa ge 5-31.
5-27
Interactive Tools
Default Session. E n a bles (ch ecked) or disa bles (u n ch eck ed) loa din g of a defa u lt session file, wh ich m u st h a ve t h e n a m e startup.spt, wh en st a r t in g SP Tool. An SP Tool session file is a MAT-file (see Usin g M AT L AB ) wit h a .spt
ext en sion . Th e D e fa u lt S e s s io n pr efer en ce on ly a ffect s t h e session con t en t s wh en you st a r t SP Tool. You ca n loa d a n ew session file a ft er st a r t in g SP Tool u sin g t h e Op e n S e s s io n opt ion in t h e SP Tool F ile m en u . You ca n a lso sa ve a session file a t a n y t im e u sin g t h e S a v e S e s s io n opt ion in t h e F ile m en u . If you close SP Tool wit h ou t h a vin g r ecen t ly sa ved a session file, you will be pr om pt ed t o do so. (See F ile Men u on pa ge 5-6.) NOTE Ch a n ges t h a t you m a ke in t h e SP Tool pr efer en ce pa n els a r e saved in a sepa r a t e MAT-file, wh ich is r eloa ded t h e n ext t im e you open SP Tool (see Sa vin g a n d Disca r din g Ch a n ges t o P r efer en ces Set t in gs on pa ge 5-30). Th e D e fa u lt S e s s io n pr efer en ce does n ot a ffect t h ese pr efer en ce set t in gs.
5-28
Using SPTool
Export Filters as TF objects. E n a bles (ch eck ed) or disa bles (u n ch ecked) expor t in g of SP Tool filt er s a s TF (t r a n sfer fu n ct ion ) object s, for u se in t h e Con t r ol Syst em Toolbox (see t h e Con trol S ystem T oolbox Users Gu id e).
NOTE Th is pr efer en ce ca t egor y on ly a ppea r s in t h e in SP Tool P re fe re n c e s dia log box if you h a ve in st a lled t h e Con t r ol Syst em Toolbox.
5-29
Interactive Tools
Plug-Ins Setting
Th e P lu g -In s pr efer en ce let s you sea r ch for plu g-in s wh en SP Tool is st a r t ed u p.
Search for Plug-Ins at start-up. E n a bles (ch ecked) or disa bles (u n ch eck ed) sea r ch in g for in st a lled plu g-in s.
A plu g-in is a n ext en sion t o SP Tool. P lu g-in s in clu de cu st om ized a dd-on pa n els a n d n ew bu t t on s in t h e pa n els in SP Tool, n ew spect r a l m et h ods in t h e Spect r u m Viewer , a n d n ew SP Tool pr efer en ces. You ca n a lso plu g on e or m or e t oolboxes in t o SP Tool. You n eed t o u se t h is set t in g on ly wh en you h a ve in st a lled ext en sion s or h a ve ot h er t oolboxes plu gged in t o SP Tool. To u se SP Tool wit h ext en sion s, ch eck S e a rc h fo r P lu g -i n s a t s ta rt-u p , close SP Tool, a n d r est a r t it .
5-30
Using SPTool
Revert Panel. Ca n cels ch a n ges in t h e cu r r en t pa n el on ly. Set t in gs in t h e cu r r en t pa n el r ever t t o t h e pr eviou s set t in gs. Cancel. Ca n cels ch a n ges in a ll pr efer en ce ca t egor ies a n d closes t h e
If sigprefs.mat does n ot exist , eit h er on t h e cu r r en t MATLAB pa t h or in t h e cu r r en t dir ect or y, you a r e pr om pt ed for a loca t ion t o sa ve t h e file. Th e sa ved set t in gs a r e u sed t h e n ext t im e you open SP Tool.
Zoom Controls
Th e GUI t ools sh a r e a com m on set of zoom con t r ol bu t t on s. Th e Sign a l Br owser a n d Spect r u m Viewer u se t h e sa m e set of com m on zoom con t r ol bu t t on s, wh ich a ffect bot h on -scr een a n d pr in t ed im a ges.
E a ch bu t t on wor ks t h e sa m e wa y in ever y GUI t ool in wh ich it occu r s. In or din a r y u se, you pr ess a bu t t on on ce t o zoom in or ou t of t h e sign a l displa y.
5-31
Interactive Tools
Zoom In-X, Zoom Out-X, Zoom In-Y, and Zoom Out-Y. Click on ce t o per for m on e zoom oper a t ion (in or ou t ) on t h e x - or y -a xis. E a ch zoom oper a t ion ch a n ges t h e a xes lim it s by a fa ct or of t wo on t h e specified a xis, a bou t t h e cen t er of t h e displa yed sign a l. You ca n pr ess r epea t edly on on e or m or e bu t t on s t o con t in u e t o ch a n ge t h e sca le in on e or bot h a xes.
Wh en you zoom in t h e x -a xis (h or izon t a l sca lin g), t h e y lim it s (ver t ica l sca lin g) of t h e m a in a xes a r e n ot ch a n ged. Sim ila r ly, wh en you zoom in t h e y -a xis, t h e x lim it s of t h e m a in a xes a r e n ot ch a n ged.
Full View. Click on ce t o r est or e t h e displa yed sign a l t o it s fu ll r a n ge in bot h a xes. Mouse Zoom. Click on ce t o a ct iva t e zoom m ode. Th e cu r sor ch a n ges t o a cr ossh a ir . You ca n eit h er zoom in wit h ou t specifyin g a zoom win dow, or you ca n u se a zoom r ect a n gle t o select a specific zoom win dow. In eit h er ca se, t h e x- a n d y -a xis a r e a u t om a t ica lly a dju st ed t o displa y t h e select ed sign a l:
To zoom in wit h ou t specifyin g a zoom win dow, click on t h e plot . Th e posit ion of t h e cr ossh a ir is t h e cen t er of a zoom oper a t ion t h a t h a lves bot h t h e x - a n d y -a xis lim it s. To u se a zoom r ect a n gle, click wh er e you wa n t t h e r ect a n gle t o begin , dr a g t h e m ou se dia gon a lly t o wh er e you wa n t it t o en d, a n d r elea se t h e m ou se bu t t on . To get ou t of m ou se zoom m ode wit h ou t zoom in g in or ou t , pr ess t h e Mo u s e Zo o m bu t t on a ga in .
Zoom Persistence. Mou se zoom in g ca n eit h er be on e-tim e or persisten t :
On e-t im e zoom in g is a ct iva t ed wh en you pr ess t h e Mo u s e Zo o m bu t t on . It a u t om a t ica lly t u r n s it self off a ft er you click in t h e displa y a r ea a n d t h e zoom oper a t ion occu r s. Th is is t h e defa u lt for a ll t h e t ools. P er sist en t zoom in g is a lso a ct iva t ed by pr essin g t h e Mo u s e Zo o m bu t t on . It does n ot t u r n off a ft er you click in t h e displa y a r ea a n d a zoom oper a t ion occu r s; you ca n con t in u e t o click a n d zoom wit h ou t r eset t in g t h e Mo u s e Zo o m bu t t on . You ca n ch a n ge wh et h er zoom in g is on e-t im e or per sist en t by select in g
P re fe re n c e s fr om t h e F ile m en u a n d t ogglin g S ta y in Zo o m -m o d e Afte r Zo o m in t h e P re fe re n c e s pa n els for t h e Sign a l Br owser , t h e Spect r u m Viewer ,
5-32
Using SPTool
Wh en S ta y in Zo o m -m o d e Afte r Zo o m is select ed, zoom in g is per sist en t . To t u r n off m ou se zoom in g wh en S ta y in Zo o m -m o d e Afte r Zo o m is select ed, pr ess t h e Mo u s e Zo o m bu t t on .
Passband Zoom (Filter Designer). Click on ce t o zoom in on t h e pa ssba n d of t h e
r espon se. Bot h t h e x - a n d y -lim it s of t h e m a in a xes a r e ch a n ged so t h a t t h e pa ssba n d fills t h e m a in a xes. Th er e is n o st opba n d zoom bu t t on . To zoom t h e st opba n d, u se st a n da r d Mo u s e Zo o m , cen t er in g t h e cr ossh a ir on t h e a r ea of t h e st opba n d you wa n t t o view. If you a r e in pa ssba n d zoom , fir st pr ess F u ll Vie w t o r et u r n t o t h e st a n da r d view.
Ruler Controls
Th e Sign a l Br owser , F ilt er Viewer , a n d Spect r u m Viewer sh a r e a com m on set of r u ler con t r ols. Use t h e r u ler s t o m a ke m ea su r em en t s on t h e sign a ls or spect r a in t h e m a in a xes (displa y) a r ea . Th e r u ler con t r ols give you a va r iet y of wa ys t o r ea d a n d con t r ol t h e va lu es of t h e r u ler s in t h e m a in a xes. Wit h t h e r u ler s you ca n m ea su r e su ch in for m a t ion a s t h e ver t ica l a n d h or izon t a l dist a n ce bet ween fea t u r es in a sign a l or spect r u m , t h e dim en sion s of pea k s a n d va lleys, a n d slope in for m a t ion . In t h e followin g discu ssion , t h e Sign a l Br owser is sh own . Th e r u ler con t r ols in clu de t h e S e le c tio n con t r ols a t t h e t op r igh t of t h e win dow a n d t h e bu t t on s a n d edit boxes in t h e Ru le rs pa n el. Th e con t r ols in t h e F ilt er Viewer a n d Spect r u m Viewer wor k t h e sa m e wa y. Th e con t r ols in t h e Sign a l Br owser a n d t h e Spect r u m Viewer a lso a ffect im a ges pr in t ed fr om t h ese t ools. In t h e F ilt er Viewer , t h e r u ler s a ppea r on on ly on e su bplot a t a t im e. You ca n ch oose wh ich su bplot t h e r u ler s a ppea r on by select in g t h e su bplot fr om t h e pop-u p m en u a t t h e t op of t h e R u le rs pa n el, or by clickin g on a lin e in t h e plot t h a t you wa n t t o m ea su r e. If a su bplot is n ot cu r r en t ly visible wh en you select it s n a m e fr om t h e pop-u p m en u , t h e F ilt er Viewer cr ea t es t h e su bplot a n d pla ces t h e r u ler s in it .
5-33
Interactive Tools
Selection display
Color button
Edit boxes
Rulers panel
Wh en a sign a l (lin e) is select ed, you ca n u se t h e r u ler con t r ols (Ve rtic a l , Ho rizo n ta l , Tra c k , or S lo p e ) a n d t h e P e a k s a n d/or Va lle y s con t r ols on t h e select ed lin e. Th e la bel of t h e select ed sign a l (lin e) is displa yed in t h e S e le c tio n pop-u p m en u . Th er e a r e t wo wa ys t o select a sign a l (lin e): Click on t h e S e le c tio n pop-u p m en u a n d dr a g t o select t h e lin e t o m ea su r e. All sign a ls t h a t a r e cu r r en t ly select ed in SP Tool a r e list ed. Vect or sign a ls in t h e Sign a l Br owser , spect r a in t h e Spect r u m Viewer , a n d filt er s in t h e F ilt er Viewer a r e list ed a s sin gle va r ia bles; in t h e Sign a l Br owser , ea ch colu m n of a t wo-dim en sion a l sign a l m a t r ix is list ed a s a sepa r a t e va r ia ble. Move t h e m ou se poin t er over a n y poin t in t h e lin e you wa n t t o select a n d click on it .
5-34
Using SPTool
Th e la bel of t h e sign a l, in clu din g t h e colu m n n u m ber if t h e lin e is on e colu m n of a m a t r ix, is displa yed in t h e S e le c tio n pop-u p m en u . Th e lin e select ion displa y ch a n ges t o t h e color a n d pa t t er n of t h e select ed sign a l, spect r u m , or filt er .
Line Selection Pop-Up Menu. Use t o select a lin e (vect or sign a l, a r r a y colu m n , filt er , or spect r u m ) t o m ea su r e.
Click on t h e Co lo r bu t t on a t t h e t op r igh t of t h e win dow t o displa y t h e Ed it Lin e pop-u p m en u , wh ich is sh own on t h e left . Th e la bel of t h e select ed lin e is displa yed in t h e La be l field. Click t h e Lin e S ty le pop-u p m en u a n d dr a g t o select a lin e st yle, a s sh own on t h e left . Click a r a dio bu t t on t o select a color . If you select Oth e r , you ca n t ype a color va lu e in t h e En te r c o lo rs p e c box; t h e color va lu e ca n be a st r in g (e.g., 'r') or a n RGB t r iple (e.g., [1 0 0]). Click OK t o a pply t h e lin e st yle a n d color you select ed.
Find Ruler Buttons. Use t h e fin d r u ler bu t t on s t o br in g on e or bot h r u ler s in t o t h e viewin g a r ea of t h e m a in a xes. Wh en bot h r u ler s a r e wit h in t h e sign a l displa y (m a in a xes) a r ea , t h e F i n d R u le r bu t t on s, a t t h e t op r igh t of t h e m a in a xes a r ea , a r e n ot displa yed.
If t h e r u ler s a r e n ot wit h in t h e sign a l displa y a r ea , bot h F in d Ru le r bu t t on s a r e displa yed, a s sh own on t h e r igh t . If on e r u ler is wit h in t h e sign a l displa y a r ea , t h e bu t t on for t h e ot h er r u ler is displa yed, a s sh own on t h e r igh t . Click a F in d Ru le r bu t t on t o br in g t h e specified r u ler in t o t h e displa y a r ea . Wh en a r u ler is visible, you ca n click on it a n d dr a g it t o m a k e a m ea su r em en t on t h e select ed sign a l. See Ma k in g Sign a l Mea su r em en t s on pa ge 5-37 for det a ils on m a n ipu la t in g t h e r u ler s a n d m ea su r in g t h e select ed sign a l.
5-35
Interactive Tools
m ea su r em en t you wa n t t o m a k e: Ve rtic a l , Ho rizo n ta l , Tra c k , or S lo p e . Th e defa u lt set t in g is Tra c k . Click a r u ler con t r ol bu t t on t o select it . Th e Ru le rs pa n el ch a n ges depen din g on wh ich r u ler con t r ol is select ed. See Ma kin g Sign a l Mea su r em en t s on pa ge 5-37 for det a ils on t h e fou r k in ds of m ea su r em en t s you ca n m a ke a n d t h e pa r a m et er s for ea ch on e.
Rulers Panel and Edit Boxes. Th e R u le rs pa n el ch a n ges depen din g on wh ich r u ler con t r ol is select ed: Ve rtic a l , Ho rizo n ta l , Tra c k , or S lo p e . It sh ows t h e pa r a m et er s for t h e select ed r u ler con t r ol. Depen din g on wh ich r u ler con t r ol is select ed, t h e followin g fields a r e displa yed: x 1 , y 1 , x 2 , y 2 , d x , d y , m . Th e pict u r e on t h e left sh ows t h e R u le rs pa n el wh en S lo p e is select ed.
Wh en you pr ess a r u ler con t r ol bu t t on , r u ler s a r e displa yed su per im posed on t h e sign a l(s) in t h e m a in a xes displa y a r ea . Th e r u ler s a r e eit h er ver t ica l (for Ve rtic a l , Tra c k , a n d S lo p e ) or h or izon t a l (for Ho rizo n ta l ). F or Tra c k a n d S lo p e , r u ler m a r k er s a r e a lso displa yed. Th e r u ler s a n d r u ler m a r k er s a r e a ssocia t ed wit h t h e cu r r en t ly select ed sign a l. Th e followin g pict u r e sh ows t h e r u ler s a n d r u ler m a r k er s t h a t a r e displa yed wh en S lo p e is select ed.
To posit ion a r u ler , you ca n click a n d dr a g on it . Wh en you dr a g a r u ler , t h e pa r a m et er s in t h e Ru le rs pa n el ch a n ge t o r eflect t h e m ea su r em en t s on t h e select ed sign a l. You ca n a lso posit ion a r u ler by specifyin g pa r a m et er s in t h e edit boxes in t h e Ru le rs pa n el. Th e pa r a m et er s a r e eit h er t h e x 1 a n d x 2 va lu es or t h e y 1 a n d y 2 va lu es, depen din g on wh ich r u ler con t r ol is select ed.
5-36
Using SPTool
Type t h e va lu e or va r ia ble for t h e r u ler pa r a m et er in t h e x 1 a n d x 2 boxes or t h e y 1 a n d y 2 boxes. See Ma k in g Sign a l Mea su r em en t s on pa ge 5-37 for det a ils on m a n ipu la t in g t h e r u ler s a n d t h e pa r a m et er s you ca n m ea su r e wit h ea ch on e.
Peaks and Valleys. Use t h ese bu t t on s t o sh ow or h ide t h e loca l m a xim a a n d/or loca l m in im a of t h e cu r r en t ly select ed sign a l, filt er r espon se, or spect r u m . On ly pea ks or va lleys, or bot h pea k s a n d va lleys m a y be displa yed.
Click P e a k s t o t oggle sh owin g (down ) or h idin g (u p) t h e m a xim a of t h e sign a l. Click Va lle y s t o t oggle sh owin g (down ) or h idin g (u p) t h e m in im a of t h e sign a l. In t r a ck a n d slope m ode (see Ma k in g Sign a l Mea su r em en t s on pa ge 5-37), t h e r u ler s a r e con st r a in ed t o t h e pea k s or va lleys. In h or izon t a l a n d ver t ica l m ode, t h e pea ks a n d va lleys a r e on ly visu a l a n d do n ot a ffect t h e beh a vior of t h e r u ler s.
Save Rulers Button. On ce you ve set u p a n d m a de a cer t a in set of m ea su r em en t s, you m a y fin d it u sefu l t o sa ve t h em for fu t u r e r efer en ce. Use t h e S a v e Ru le rs bu t t on t o sa ve a st r u ct u r e in t h e MATLAB wor kspa ce wit h t h e fields x1, y1, x2, y2, dx, dy, m, peaks, a n d valleys. Un defin ed va lu es a r e set t o NaN.
1 Click S a v e R u le rs t o sa ve t h e cu r r en t m ea su r em en t s a s a va r ia ble in t h e
5-36.
5-37
Interactive Tools
dr a ggin g it :
a Move t h e m ou se over t h e r u ler (1 or 2) t h a t you wa n t t o dr a g.
Th e h a n d cu r sor is displa yed wh en you r e over a r u ler , wit h t h e r u ler n u m ber in side it :
b Click a n d dr a g t h e r u ler t o wh er e you wa n t it on t h e sign a l.
Depen din g on wh ich r u ler con t r ol is select ed, you ca n dr a g t h e r u ler t o t h e r igh t a n d left (Ve rti c a l , Tra c k , a n d S lo p e ) or u p a n d down (Ho rizo n ta l ). As you dr a g a r u ler , t h e Ru le rs pa n el sh ows t h e cu r r en t posit ion of bot h r u ler s. Depen din g on wh ich r u ler con t r ol is select ed, t h e followin g fields a r e displa yed: x 1 , y 1 , x 2 , y 2 , d x , d y , m . Th ese fields will a lso be displa yed in pr in t ou t s fr om t h e Sign a l Br owser , u n less you su ppr ess t h em . See P r in t in g Sign a l Da t a on pa ge 5-54 a n d P r in t in g Spect r u m Da t a on pa ge 5-107 for det a ils on pr in t in g fr om t h ese t ools. You ca n a lso posit ion a r u ler by t ypin g it s x 1 a n d x 2 or y 1 a n d y 2 va lu es in t h e Ru le rs pa n el, a s descr ibed on pa ge 5-36.
Ruler Controls: Vertical. Th er e a r e t wo ver t ica l r u ler s, ca lled r u ler 1 a n d r u ler 2. Wh en ver t ica l r u ler s a r e in u se, t h e m ea su r em en t s displa yed in t h e R u le rs
5-38
Using SPTool
P r ess Ve rtic a l t o pu t t h e r u ler s in ver t ica l m ode. In ver t ica l m ode, you m a y ch a n ge t h e x -va lu es of t h e r u ler s (t h a t is, t h eir h or izon t a l posit ion ). As t h e x 1 a n d x 2 va lu es ch a n ge, t h e va lu e of d x ch a n ges a u t om a t ica lly. Ch a n ge t h e x 1 a n d x 2 va lu es in on e of t wo wa ys: Dr a g t h e r u ler s t o t h e left a n d t h e r igh t wit h t h e m ou se E n t er t h eir va lu es in t h e x 1 a n d x 2 edit boxes in t h e R u le rs pa n el
Ruler Controls: Horizontal. Th er e a r e t wo h or izon t a l r u ler s, ca lled r u ler 1 a n d r u ler 2. Wh en h or izon t a l r u ler s a r e in u se, t h e m ea su r em en t s displa yed in t h e
5-39
Interactive Tools
P r ess Ho rizo n ta l t o pu t t h e r u ler s in h or izon t a l m ode. In h or izon t a l m ode, you m a y ch a n ge t h e y -va lu es of t h e r u ler s (t h a t is, t h eir ver t ica l posit ion ). As t h e y 1 a n d y 2 va lu es ch a n ge, t h e va lu e of d y ch a n ges a u t om a t ica lly. Ch a n ge t h e y 1 a n d y 2 va lu es in on e of t wo wa ys: Dr a ggin g t h e r u ler s u p a n d down wit h t h e m ou se E n t er in g t h eir va lu es in t h e y 1 a n d y 2 edit boxes in t h e Ru le rs pa n el
Ruler Controls: Track. Th er e a r e t wo ver t ica l r u ler s, ca lled r u ler 1 a n d r u ler 2, wit h a m a r ker on ea ch t h a t sh ows t h e y -va lu es of t h e sign a l a t t h e x -va lu es of t h e r u ler s. Wh en t r a ck r u ler s a r e in u se, t h e m ea su r em en t s displa yed in t h e Ru le rs pa n el a r e x 1 (t h e posit ion of r u ler 1 on t h e x -a xis), y 1 (t h e posit ion of
5-40
Using SPTool
r u ler 1 on t h e y -a xis), x 2 (t h e posit ion of r u ler 2 on t h e x -a xis), y 2 (t h e posit ion of r u ler 2 on t h e y -a xis), d x (t h e va lu e of x 2 -x 1 ), a n d d y (t h e va lu e of y 2 -y 1 ).
P r ess Tra c k t o pu t t h e r u ler s in t r a ck m ode. You ca n ch a n ge t h e t r a ck m a r ker in t h e R u le rs pa n el fr om t h e P re fe re n c e s dia log box; see Ru ler Set t in gs on pa ge 5-21. In t r a ck m ode, you m a y ch a n ge t h e x -va lu es of t h e r u ler s (t h a t is, t h eir h or izon t a l posit ion ). As t h e x 1 a n d x 2 va lu es ch a n ge, t h e va lu es of y 1 , y 2 , d x , a n d d y ch a n ge a u t om a t ica lly. Ch a n ge t h e x 1 a n d x 2 va lu es in on e of t wo wa ys: Dr a ggin g t h e r u ler s t o t h e left a n d t h e r igh t wit h t h e m ou se E n t er in g t h eir va lu es in t h e x 1 a n d x 2 edit boxes in t h e R u le rs pa n el
Ruler Controls: Slope. Th er e a r e t wo ver t ica l r u ler s, ca lled r u ler 1 a n d r u ler 2, wit h t h e slope lin e pa ssin g t h r ou gh t h e y -a xis in t er sect ion s of t h e t wo ver t ica l r u ler s a n d t h e sign a l. Th e r u ler s a lso t r a ck t h e sign a l wit h m a r ker s on ea ch r u ler t h a t sh ows t h e y -va lu es of t h e sign a l a t t h e x -va lu es of t h e r u ler s. Th e lin e con n ect in g (x 1 , y 1 ) a n d (x 2 , y 2 ) is in clu ded in t h e m a in plot , so you ca n a ppr oxim a t e der iva t ives a n d slopes of t h e sign a l.
5-41
Interactive Tools
Wh en slope r u ler s a r e in u se, t h e m ea su r em en t s displa yed in t h e Ru le rs pa n el a r e x 1 (t h e posit ion of r u ler 1 on t h e x-a xis), y 1 (t h e posit ion of r u ler 1 on t h e y -a xis), x 2 (t h e posit ion of r u ler 2 on t h e x-a xis), y 2 (t h e posit ion of r u ler 2 on t h e y -a xis), d x (t h e va lu e of x 2 - x 1 ), d y (t h e va lu e of y 2 - y 1 ), a n d m (equ a l t o d y / d x , t h e slope of t h e lin e bet ween x 1 a n d x 2 ).
P r ess S lo p e t o pu t t h e r u ler s in slope m ode. In slope m ode, you m a y ch a n ge t h e x -va lu es of t h e r u ler s (t h a t is, t h eir h or izon t a l posit ion ). As t h e x 1 a n d x 2 va lu es ch a n ge, t h e va lu es of d y a n d m ch a n ge a u t om a t ica lly. Ch a n ge t h e x 1 a n d x 2 va lu es in on e of t wo wa ys: Dr a ggin g t h e r u ler s t o t h e left a n d t h e r igh t wit h t h e m ou se E n t er in g t h eir va lu es in t h e x 1 a n d x 2 edit boxes in t h e Ru le rs pa n el
5-42
Th e Sign a l Br owser is a ct iva t ed a n d t h e select ed sign a l(s) a r e loa ded in t o t h e Sign a l Br owser a n d displa yed.
5-43
Interactive Tools
Panner
5-44
Menus
File Menu. Use P a g e S e tu p ... fr om t h e F ile m en u t o open t h e st a n da r d MATLAB P a g e S e tu p dia log box, in wh ich you ca n set t h e or ien t a t ion , size a n d posit ion , lim it s, a n d color of you r pr in t ou t .
See Usin g M AT L A B Graph ics for m or e in for m a t ion a bou t t h e P a g e S e tu p dia log box. Use P ri n t P re v ie w ... fr om t h e F ile m en u t o open a MATLAB figu r e win dow wit h a pr eview of t h e in for m a t ion fr om t h e Sign a l Br owser win dow t h a t will a ppea r in you r pr in t ou t . See Sign a l Br owser Set t in gs on pa ge 5-23 a n d P r in t in g Sign a l Da t a on pa ge 5-54 for det a ils a bou t pr in t in g fr om t h e Sign a l Br owser . Use P ri n t... fr om t h e F i le m en u t o open t h e st a n da r d pr in t dia log box, fr om wh ich you ca n pr in t you r sign a l da t a . Use Clo s e fr om t h e F ile m en u t o close t h e Sign a l Br owser . All sign a l select ion a n d r u ler in for m a t ion will be lost . (You m a y wa n t t o sa ve r u ler in for m a t ion t o t h e wor kspa ce u sin g t h e S a v e R u le rs ... bu t t on , a s descr ibed on pa ge 5-37.) Set t in gs you ch a n ged a n d sa ved u sin g t h e P re fe re n c e s dia log box in SP Tool a r e sa ved a n d u sed t h e n ext t im e you open a Sign a l Br owser .
5-45
Interactive Tools
P la y wor ks on ly wh en you h a ve sou n d ca pa bilit ies on you r com pu t er . If you r com pu t er does n ot h a ve sou n d ca pa bilit ies, t h is m en u ch oice does n ot h in g.
Th e en t ir e select ed sign a l is pla yed a t eit h er Fs (t h e sa m plin g fr equ en cy of t h e sign a l) or a t t h e defa u lt pla t for m sa m plin g fr equ en cy if Fs is less t h a n 25 H z. Th e r ea l pa r t a n d t h e im a gin a r y pa r t of a com plex sign a l a r e pla yed in sepa r a t e ch a n n els.
Window Menu. Use t h e Win d o w m en u t o select a cu r r en t ly open MATLAB
win dow.
Zoom Controls
Th e a va ila ble zoom con t r ols in t h e Sign a l Br owser a r e Mo u s e Zo o m , F u ll Vie w , Zo o m In -Y, Zo o m Ou t-Y, Zo o m In -X, a n d Zo o m Ou t-X. See Zoom Con t r ols on pa ge 5-31 for det a ils on u sin g t h e zoom con t r ols in t h e Sign a l Br owser . Zoom per sist en ce is off by defa u lt in t h e Sign a l Br owser ; u se t h e Sign a l Br owser set t in gs pa n el in t h e P re fe re n c e s dia log box in SP Tool t o t oggle zoom per sist en ce on a n d off. See Sign a l Br owser Set t in gs on pa ge 5-23.
Help Button
To u se con t ext -sen sit ive h elp, pr ess t h e He lp bu t t on . Th e m ou se poin t er becom es a n a r r ow wit h a qu est ion m a r k sym bol. You ca n t h en click on a n yt h in g in t h e Sign a l Br owser , in clu din g m en u it em s, t o fin d ou t wh a t it is a n d h ow t o u se it .
5-46
Th is m en u is en a bled wh en a t lea st on e of t h e sign a l va r ia bles select ed in SP Tool is com plex. Th e Com plex Displa y m ode a ffect s a ll of t h e va r ia bles in t h e cu r r en t select ion , even t h ose t h a t a r e st r ict ly r ea l. Click a n d dr a g t o select t h e plot t in g m ode.
5-47
Interactive Tools
Wh en t h er e is on ly on e sign a l displa yed, it s pr oper t ies a r e r eflect ed in t h e displa y m a n a gem en t con t r ols a n d it s m ea su r em en t s a r e displa yed in t h e r u ler displa y pa n el. Wh en m or e t h a n on e sign a l is displa yed, select t h e lin e you wa n t t o focu s on . Wh en a sign a l is select ed, you ca n u se t h e r u ler con t r ols on t h e select ed lin e (see Ma kin g Sign a l Mea su r em en t s on pa ge 5-37), you ca n ch oose h ow t o displa y t h e sign a l (see Displa y Ma n a gem en t Con t r ols on pa ge 5-47), a n d you ca n pla y t h e sign a l (see Opt ion s Men u on pa ge 5-46). Th e la bel of t h e select ed sign a l (lin e) is displa yed in t h e S e le c tio n pop-u p m en u . Use on e of t h r ee wa ys t o select a sign a l (lin e) in t h e Sign a l Br owser : Click on t h e S e le c tio n pop-u p m en u a n d dr a g t o select t h e lin e t o m ea su r e. Move t h e m ou se poin t er over a n y poin t in t h e lin e in t h e m a in a xes displa y a n d click on it . Move t h e m ou se poin t er over a n y poin t in t h e lin e in t h e pa n n er a n d click on it . See Select in g a Lin e t o Mea su r e on pa ge 5-34 for det a ils.
Axes Labels. By defa u lt , t h e x -a xis in t h e Sign a l Br owser is la beled Time. You ca n ch a n ge t h e x -a xis la bel a n d a dd a y -a xis la bel u sin g t h e S ig n a l B ro w s e r set t in gs pa n el in t h e P re fe re n c e s dia log box in SP Tool. See Sign a l Br owser Set t in gs on pa ge 5-23. Click-and-Drag Panning. You ca n u se t h e m ou se t o pa n a r ou n d t h e m a in a xes displa y; click on a lin e in t h e m a in a xes, h old down t h e m ou se bu t t on , a n d dr a g t h e m ou se.
Panner
Th e pa n n er gives a pa n or a m ic view of t h e sign a l(s) displa yed in t h e m a in a xes. Th e pa n n er a lwa ys displa ys t h e en t ir e sign a l sa m ple. Wh en you zoom in on t h e m a in a xes, a pa t ch in t h e pa n n er sh ows t h e sect ion of t h e plot t h a t is cu r r en t ly in view in t h e m a in a xes. Click-a n d-dr a g t h e pa t ch in t h e pa n n er win dow t o pa n dyn a m ica lly a cr oss t h e sign a l da t a in t h e m a in a xes. You ca n a lso select a lin e by clickin g on it in t h e pa n n er ; t h e select ed lin e is h igh ligh t ed in bot h t h e pa n n er a n d in t h e m a in a xes displa y a r ea .
5-48
See P a n n er Displa y on pa ge 5-52 for m or e det a ils. Th e pa n n er is displa yed by defa u lt in t h e Sign a l Br owser ; you ca n t u r n off t h e pa n n er in t h e Sign a l Br owser set t in gs pa n el in t h e P re fe re n c e s dia log box in SP Tool. See Sign a l Br owser Set t in gs on pa ge 5-23.
5-49
Interactive Tools
Wh en t h e va r ia ble is a vect or , on e sign a l is displa yed, a s in t h e exa m ple a bove. It is a u t om a t ica lly select ed a n d it s n a m e, size, t ype, a n d sa m plin g fr equ en cy a r e displa yed a bove t h e m a in a xes displa y; t h e n a m e is a lso h igh ligh t ed in t h e S e le c tio n pop-u p m en u . Wh en m or e t h a n on e sign a l is select ed, ea ch sign a l is displa yed in a differ en t color in bot h t h e m a in a xes displa y a n d t h e pa n n er .
Th e n a m es of a ll sign a ls a r e displa yed a bove t h e m a in a xes displa y. Th e fir st sign a l in t h e list is a u t om a t ica lly select ed in bot h t h e m a in a xes displa y a n d t h e pa n n er , it s n a m e is h igh ligh t ed in t h e S e le c tio n pop-u p m en u , a n d it s color is sh own in t h e S e le c tio n displa y.
5-50
To displa y a differ en t a r r a y colu m n , or m or e t h a n on e colu m n of t h e a r r a y, pr ess t h e Arra y S i g n a ls bu t t on a n d specify t h e colu m n s t o be displa yed (see Ar r a y Sign a ls Bu t t on on pa ge 5-47). All displa yed colu m n s of a n a r r a y a r e sh own in t h e sa m e color ; t h e select ed colu m n is em ph a sized wit h a h ea vier lin e
5-51
Interactive Tools
Panner Display
Th e pa n n er displa ys t h e en t ir e sign a l sa m ple a t a ll t im es.
5-52
Wh en t h e sign a l in t h e m a in a xes is zoom ed, t h e pa r t of t h e sign a l t h a t is sh own in t h e m a in a xes is sh own in t h e pa n n er wit h a win dow a r ou n d it .
E a ch t im e you zoom , t h e pa n n er is u pda t ed t o fr a m e t h e r egion of da t a displa yed in t h e m a in a xes. Click-a n d-dr a g on t h e pa n n er win dow t o m ove it . As t h e win dow m oves over t h e sign a l in t h e pa n n er , t h e sign a l in t h e m a in a xes a r ea is pa n n ed.
Manipulating Displays
Changing Signal Displays. Th e sign a ls a r e displa yed in t h e defa u lt lin e color s a n d defa u lt lin e st yles. You ca n ch a n ge t h e defa u lt s u sin g t h e Co lo r Ord e r a n d Lin e S ty le Ord e r fields in t h e Co lo rs set t in gs pa n el (see Color Set t in gs on pa ge 5-22). Changing the Sample Interval. You ca n ch a n ge t h e sa m ple in t er va l by select in g
P re fe re n c e s dia log box in SP Tool, you ca n set opt ion a l x -a xis a n d y -a xis la bels,
5-53
Interactive Tools
en a ble a n d disa ble t h e displa y of t h e r u ler s a n d t h e pa n n er , a n d t oggle zoom per sist en ce. See Sign a l Br owser Set t in gs on pa ge 5-23.
5-54
Th e plot s of on e or m or e sign a ls, a s displa yed in t h e m a in a xes a r ea Th e pa n n er displa y of t h e sign a l(s) displa yed in t h e m a in a xes a r ea Th e r u ler m ea su r em en t s of t h e select ed sign a l You ca n pr eview you r pr in t ou t by ch oosin g P ri n t P re v ie w ... fr om t h e F ile m en u in t h e Sign a l Br owser win dow. Th is open s t h e S i g n a l B ro w s e r P rin t P re v ie w win dow, sh own below wit h defa u lt set t in gs for sign a l mtlb.
Th e Clo s e bu t t on on t h e S i g n a l B ro w s e r P rin t P re v ie w win dow closes t h e pr in t pr eview win dow a n d r et u r n s you t o t h e Sign a l Br owser . Th e P ri n t... bu t t on on t h e S ig n a l B ro w s e r P ri n t P re v ie w win dow open s t h e st a n da r d pr in t dia log box, fr om wh ich you ca n pr in t t h e con t en t s of you r pr in t pr eview win dow. If you ch oose t o pr in t fr om t h e pr in t dia log, bot h t h a t dia log a n d t h e S ig n a l B ro w s e r P rin t P re v ie w win dow will close, a n d t h e con t en t s of t h e pr in t pr eview will pr in t . If you ch oose n ot t o pr in t , t h e pr in t dia log a n d t h e S i g n a l B ro w s e r P rin t P re v ie w win dow will close, a n d you will r et u r n t o t h e Sign a l Br owser . An y ch a n ges you m a ke, befor e open in g t h e pr in t pr eview win dow, t h a t a ffect t h e displa y of da t a in t h e Sign a l Br owser (see Viewin g a n d E xplor in g Sign a ls
5-55
Interactive Tools
on pa ge 5-49) will a ffect t h e displa y of da t a in t h e S ig n a l B ro w s e r P ri n t P re v i e w win dow in exa ct ly t h e sa m e wa y. F or exa m ple, in t h e pr in t pr eview sh own below: Th e plot of t h e mtlb da t a h a s been m ou se zoom ed (see Zoom Con t r ols on pa ge 5-31). Th e pa n n er displa y r eflect s t h e cu r r en t zoom level by en closin g t h e zoom ed por t ion of t h e wh ole sign a l in a win dow (see P a n n er Displa y on pa ge 5-52). Th e r u ler s h a ve been m oved in t o t h e zoom ed a r ea a n d t h e r u ler con t r ols h a ve been ch a n ged fr om Tra c k t o S lo p e (see Ru ler Con t r ols on pa ge 5-33). Th e r u ler m ea su r em en t s displa yed r eflect t h e ch a n ges t o t h e r u ler s in t h e displa y a r ea (see Ma kin g Sign a l Mea su r em en t s on pa ge 5-37).
Ch a n ges you m a k e in t h e P re fe re n c e s dia log box in SP Tool, befor e open in g t h e pr in t pr eview win dow, will a lso a ffect t h e S ig n a l B ro w s e r P rin t P re v ie w win dow in t h e sa m e wa y t h a t t h ey a ffect t h e Sign a l Br owser it self. F or exa m ple, in t h e pr in t pr eview sh own below, t h e pa n n er displa y a n d t h e r u ler m ea su r em en t s h a ve been su ppr essed, a n d t h e a xis la bels h a ve been ch a n ged,
5-56
by ch a n ges t o t h e Sign a l Br owser pr efer en ces (see Sign a l Br owser Set t in gs on pa ge 5-23).
NOTE Th e HandleVisibility pr oper t y of t h e P ri n t P re v ie w figu r e win dow is set t o 'on'. Th is a llows you t o m odify t h e pr eview u sin g H a n dle Gr a ph ics com m a n ds fr om t h e MATLAB com m a n d lin e or t h e P lot E dit or t ools (see Usin g M AT L AB Graph ics for m or e in for m a t ion ). Ch a n ges t h a t you m a ke in t h e pr eview win dow pr in t exa ct ly a s t h ey a ppea r on t h e scr een ; h owever, t h ey a r e n ot saved wh en t h e P rin t P re v ie w figu r e win dow is closed.
5-57
Interactive Tools
Im por t in g Sign a ls, F ilt er s, a n d Spect r a on pa ge 5-7). La bel t h e im por t ed sign a l sig1.
2 E xpor t t h e sign a l. Select Ex p o rt... fr om t h e F ile m en u . 3 In t h e Ex p o rt dia log box, select sig1 a n d pr ess t h e Ex p o rt to Wo rk s p a c e
bu t t on .
4 Type who a t t h e MATLAB com m a n d lin e t o look a t t h e va r ia bles in t h e
wor kspa ce. Th e va r ia ble ca lled sig1 is t h e sign a l st r u ct u r e you expor t ed fr om SP Tool.
5 Type sig1 a t t h e com m a n d lin e t o list t h e fields of t h e sign a l st r u ct u r e.
Th e data a n d Fs fields of t h e sign a l st r u ct u r e con t a in t h e in for m a t ion t h a t defin es t h e sign a l. Th e ot h er fields a r e u sed in t er n a lly by SP Tool a n d a r e su bject t o ch a n ge in fu t u r e r elea ses: Th e data field is a vect or or a r r a y con t a in in g t h e sign a ls da t a . Th e Fs field con t a in s t h e sa m ple fr equ en cy of t h e sign a l in H er t z.
5-58
5-59
Interactive Tools
Menus
File Menu. Use Clo s e fr om t h e F ile m en u t o close t h e F ilt er Design er . Set t in gs you ch a n ged a n d sa ved u sin g t h e P re fe re n c e s dia log box in SP Tool a r e sa ved a n d u sed t h e n ext t im e you open t h e F ilt er Design er . Window Menu. Use t h e Win d o w m en u t o select a MATLAB figu r e win dow.
5-60
General controls
Apply the specifications, or revert to the previous specifications Magnitude response and pole-zero display area
Measurements
Zoom Controls
Th e a va ila ble zoom con t r ols in t h e F ilt er Design er a r e Zo o m In -Y, Zo o m Ou t-Y, Zo o m In -X, Zo o m Ou t-X, P a s s B a n d , F u ll Vie w , a n d Mo u s e Zo o m .
See Zoom Con t r ols on pa ge 5-31 for det a ils on u sin g t h e zoom con t r ols. Zoom per sist en ce is off by defa u lt in t h e F ilt er Design er ; u se t h e F ilt er Design er set t in gs pa n el in t h e P re fe re n c e s dia log box t o t oggle zoom per sist en ce on a n d off. See F ilt er Design er Set t in gs on pa ge 5-27.
Help Button
To u se con t ext -sen sit ive h elp, pr ess t h e He lp bu t t on . Th e m ou se poin t er becom es a n a r r ow wit h a qu est ion m a r k sym bol. You ca n t h en click on a n y
5-61
Interactive Tools
General Controls
Ben ea t h t h e zoom con t r ols a r e sever a l gen er a l con t r ols for filt er design a n d displa y. Som e of t h ese con t r ols a r e a va ila ble on ly wh en a n opt im a l filt er design m et h od (e.g., Equ i rip p le F IR , B u tte rw o rth IIR ) is select ed fr om t h e Alg o rith m m en u , a n d a r e n ot a va ila ble wh en t h e P o le /Ze ro Ed ito r is select ed.
Algorithm. Use t h e Alg o rith m pop-u p m en u t o select a design m et h od for t h e cu r r en t filt er . Th e fir st seven opt ion s in t h e Alg o rith m m en u t h e optim al d esign m eth od s a ll design filt er s ba sed on a h igh -level specifica t ion of filt er m a gn it u de r espon se ch a r a ct er ist ics (su ch a s pa ssba n d fr equ en cies or st opba n d a t t en u a t ion ). Th e filt er ch a r a ct er ist ics a r e specified n u m er ica lly in t h e S p e c i fi c a tio n s pa n el or gr a ph ica lly on t h e m a gn it u de r espon se plot .
Th e eigh t h opt ion , P o le /Ze ro Ed i to r , is n ot a n opt im a l design m et h od bu t a llows low-level specifica t ion of t h e filt er s t r a n sfer fu n ct ion via n u m er ica l or gr a ph ica l pole-zer o pla cem en t .
Optimal design methods Transfer function pole-zero placement Wh en you select on e of t h e opt im a l design m et h ods fr om t h e m en u , t h e m a gn it u de r espon se plot , S p e c i fic a tio n s pa n el, a n d Me a s u re m e n ts pa n el a ll u pda t e t o r eflect t h e design pa r a m et er s a va ila ble for t h a t m et h od. Wh en you select P o le /Ze ro Ed ito r , t h e m a gn it u de r espon se plot is r epla ced by t h e z -pla n e for pole-zer o pla cem en t .
Auto Design (optimal design methods only). Wh en t h e Au to D e s ig n ch eck box is ch ecked, t h e filt er s m a gn it u de r espon se is r edr a wn wh en ever you ch a n ge a filt er specifica t ion , eit h er by en t er in g a va lu e in t h e S p e c i fi c a tio n s pa n el or by dr a ggin g a specifica t ion lin e on t h e plot . Wh en t h e box is n ot ch eck ed, t h e n ew r espon se is com pu t ed a n d r edr a wn on ly wh en you pr ess t h e Ap p ly bu t t on or r elea se t h e specifica t ion lin e. Au to D e s ig n is in it ia lly off by defa u lt ; u se t h e
5-62
F ilte r D e s ig n e r set t in gs pa n el in t h e P re fe re n c e s dia log box t o ch a n ge t h is defa u lt set t in g. See F ilt er Design er Set t in gs on pa ge 5-27.
Sampling Frequency. Th e S a m p li n g F re q u e n c y field a llows you t o specify t h e filt er s sa m plin g fr equ en cy in H er t z. To ch a n ge t h e sa m plin g fr equ en cy, t ype a va lu e in t h e box a n d pr ess En te r . Th is is t h e sa m e a s ch a n gin g t h e sa m plin g fr equ en cy by select in g S a m p lin g F re qu e n c y ... fr om t h e SP Tool Ed it m en u (see E dit in g Da t a Object s in SP Tool on pa ge 5-15). Th e fr equ en cy a xis of t h e m a gn it u de r espon se plot is u pda t ed t o r eflect t h e n ew sa m plin g fr equ en cy. Ch a n gin g t h e S a m p lin g F re qu e n c y in t h e P ole/Zer o E dit or does n ot a lt er t h e pole-zer o plot , bu t does sca le t h e cor r espon din g m a gn it u de plot in t h e F ilt er Viewer (if t h e Viewer is open ). Overlay Spectrum (design methods only). Th e F ilt er Design er a llows you t o over la y a sign a l spect r u m on t h e filt er s m a gn it u de r espon se plot . P r ess t h e Ov e rla y S p e c tru m ... bu t t on t o displa y a list of t h e cu r r en t spect r a in SP Tool. Select a spect r u m fr om t h e list a n d pr ess OK t o over la y it on t h e cu r r en t m a gn it u de r espon se plot . Not e t h a t t h e spect r u m is plot t ed on t h e exist in g fr equ en cy a xis, wh ich is sca led t o t h e filt er s sa m plin g fr equ en cy.
box is ch eck ed, a ll of t h e filt er design s except Le a s t S qu a re s F IR displa y t h e sa m e set of pa r a m et er s in t h e S p e c ific a ti o n s pa n el. (Th e or der for t h e Le a s t S qu a re s F IR design ca n n ot be a u t om a t ica lly com pu t ed). F or lowpa ss a n d
5-63
Interactive Tools
h igh pa ss ba n d con figu r a t ion s, t h ese pa r a m et er s in clu de t h e pa ssba n d edge fr equ en cy F p, t h e st opba n d edge fr equ en cy F s, t h e pa ssba n d r ipple Rp, a n d t h e st opba n d a t t en u a t ion Rs. F or ba n dpa ss a n d ba n dst op con figu r a t ion s, t h e pa r a m et er s in clu de t h e lower a n d u pper pa ssba n d edge fr equ en cies, F p1 a n d F p2, t h e lower a n d u pper st opba n d edge fr equ en cies, F s1 a n d F s2, t h e pa ssba n d r ipple Rp, a n d t h e st opba n d a t t en u a t ion Rs. F r equ en cy va lu es a r e in H er t z, a n d r ipple a n d a t t en u a t ion va lu es a r e in dB.
Specifications ParametersManual Order Selection. Wh en t h e Min im u m Ord e r box is n ot ch ecked, a n Ord e r pa r a m et er for set t in g t h e filt er or der a ppea r s below it , a n d ea ch filt er design displa ys a u n iqu e set of pa r a m et er s in t h e S p e c i fi c a tio n s pa n el. Th ese a r e sh own in t h e t a ble below, wh er e Wp a n d Ws a r e t h e weigh t s for t h e pa ssba n d a n d st opba n d, Bet a is t h e Ka iser win dow = pa r a m et er , F c is t h e cu t off fr equ en cy, a n d F 3db is t h e -3 dB fr equ en cy.
Lowpass Equiripple FIR Least Squares FIR Kaiser Window FIR Butterworth IIR Chebyshev Type I IIR Chebyshev Type II IIR Elliptic IIR Highpass Bandpass Bandstop
F p1, F p2, F s1, F s2, Wp, Ws F p1, F p2, F s1, F s2, Wp, Ws F p1, F p2, F s1, F s2, Wp, Ws F p1, F p2, F s1, F s2, Wp, Ws F c1, F c2, Bet a F c1, F c2, Bet a F 3db 1, F 3db 2 F 3db 1, F 3db 2 F p1, F p2, Rp F p1, F p2, Rp F s1, F s2, Rs F s1, F s2, Rs F p1, F p2, Rp, Rs F p1, F p2, Rp, Rs
Designing a New Filter With the Design Methods. In gen er a l, follow t h ese st eps t o design a n ew filt er u sin g t h e S p e c i fi c a tio n s pa n el pa r a m et er s:
1 Click-a n d-dr a g t o select a n a ppr opr ia t e opt im a l
fr om t h e Ty p e pop-u p m en u .
3 Type in t h e S p e c ific a ti o n s pa n els edit a ble fields
5-64
disa ble a u t om a t ic filt er or der select ion . Th en t ype a va lu e for t h e Ord e r pa r a m et er . If Au to D e s ig n is n ot ch ecked, pr ess Ap p ly . E dit a n ew filt er or a n exist in g filt er in t h e sa m e wa y. Not e t h a t wh en Au to D e s ig n is disa bled a n d you ch a n ge a filt er s pa r a m et er va lu es, t h e m a gn it u de r espon se plot ch a n ges fr om solid lin es t o da sh ed lin es. Th is in dica t es t h a t t h e plot n o lon ger r eflect s t h e cu r r en t specifica t ion s. Wh en you pr ess t h e Ap p ly bu t t on , t h e n ew r espon se is com pu t ed a n d t h e lin es r ever t t o t h e solid st yle. Wh en Au to D e s ig n is en a bled, t h e plot u pda t es wh en ever you ch a n ge a filt er specifica t ion .
5-65
Interactive Tools
Lowpass Equiripple FIR Least Squares FIR Kaiser Window FIR Butterworth IIR Chebyshev Type I IIR Chebyshev Type II IIR Elliptic IIR
Highpass
Bandpass
Bandstop
Or der, Rp, Rs, Wp, Or der, Rp, Rs, Wp, Or der, Rp, Rs, Wp, Ws Ws Ws Or der ca n n ot be a u t om a t ica lly com pu t ed. Or der, F c, Bet a , Or der, F c, Bet a , Or der, F c1, F c2, Bet a , Rp, Rp, Rs Rp, Rs Rs Or der, Rp, F 3db Or der, Rp, F 3db Or der, Rp, F 3db 1, F 3db 2 Or der, F s Or der, F s Or der, F s1, F s2 Or der, F s Or der, F s Or der, F s1, F s2 Or der, F s Or der, F s Or der, F s1, F s2
Or der, Rp, Rs, Wp, Ws Or der, F c1, F c2, Bet a , Rp, Rs Or der, Rp, F 3db 1, F 3db 2 Or der, F s1, F s2 Or der, F s1, F s2 Or der, F s1, F s2
Measurement Parameters Manual Order Selection. Th e n ext t a ble sh ows t h e pa r a m et er set s t h a t a ppea r in t h e Me a s u re m e n ts pa n el wh en Mi n im u m Ord e r is n ot select ed. Th e m ea su r em en t s t h a t ca n be in t er a ct ively ch a n ged by dr a ggin g t h e r ed m ea su r em en t lin es on t h e r espon se plot a r e sh own sh a ded.
Lowpass Equiripple FIR Least Squares FIR Kaiser Window FIR Butterworth IIR Chebyshev Type I IIR Chebyshev Type II IIR Elliptic IIR Highpass Bandpass Bandstop
Rp, Rs Rp, Rs Fp1, Fp2, Fs1, Fs2, R p, R s Fp1, Fp2, Fs1, Fs2, R p, R s Fs1, Fs2, R s Fp1, Fp2, R p F s1, F s2
Rp, Rs Rp, Rs Fp1, Fp2, Fs1, Fs2, R p, R s Fp1, Fp2, Fs1, Fs2, R p, R s Fs1, Fs2, R s Fp1, Fp2, R p F s1, F s2
5-66
Th e va lu e you en t er in t h e Ga in edit box specifies t h e ga in , k . Th e Co o rd i n a t e s pop-u p m en u let s you posit ion t h e poles a n d zer os u sin g eit h er pola r or r ect a n gu la r m ea su r em en t s. Wh en P o la r is select ed, you ca n specify t h e coor din a t es of t h e cu r r en t ly select ed pole or zer o by en t er in g va lu es in t h e Ma g a n d An g le edit boxes. Th e r esu lt in g loca t ion of t h e select ed pole or zer o is z = Me
j.
wh er e M is t h e m a gn it u de specified by Ma g , a n d . is t h e a n gle in r a dia n s specified by An g le . Wh en R e c ta n g u la r is select ed, you ca n specify t h e coor din a t es of t h e cu r r en t ly select ed pole or zer o by en t er in g va lu es in t h e X a n d Y edit boxes. Th e r esu lt in g loca t ion of t h e select ed pole or zer o is z = X + jY Th e Co n ju g a te p a ir ch eckbox con t r ols wh et h er t h e cu r r en t select ion is a com plex con ju ga t e pa ir of poles or zer os, or a lon e pole or zer o. Wh en a lon e pole or zer o is select ed on t h e pole-zer o plot , t h e Co n ju g a te p a ir ch eckbox is in a ct ive. If you n ow en a ble t h e Co n ju g a te p a ir ch eckbox by clickin g it , a n ew con ju ga t e pole or zer o (a s a ppr opr ia t e) is cr ea t ed t o com plet e t h e pa ir . Wh en a con ju ga t e pa ir of poles or zer os is select ed on t h e plot (by click in g on e of t h e pa ir ), t h e Co n ju g a te p a ir ch eckbox is a ct ive. If you n ow disa ble t h e Co n ju g a te p a ir ch eckbox by click in g it , t h e con ju ga t e pa ir is br oken in t o t wo lon e poles or zer os a t t h e sa m e posit ion s, a n d on ly on e of t h ese r em a in s select ed. Wh en t h e Co n ju g a te p a ir ch eckbox is select ed, t h e coor din a t es you specify (in eit h er a n gu la r or r ect a n gu la r for m ) con t r ol t h e loca t ion of t h e cu r r en t ly select ed com plex con ju ga t e pa ir of poles or zer os, wit h loca t ion s z = X jY or z = Me
j .
Designing a New Filter with the Pole/Zero Editor. In gen er a l, follow t h ese st eps t o design a n ew filt er u sin g t h e S p e c ific a tio n s pa n el pa r a m et er s:
5-67
Interactive Tools
Pole Zero
on on e of t h e
or
t h e Co o rd in a te s pop-u p m en u .
5 Specify t h e n ew loca t ion (s) of t h e select ed pole, zer o, or con ju ga t e pa ir by
t ypin g va lu es in t o t h e Ma g a n d An g le (for a n gu la r coor din a t es) or X a n d Y (for r ect a n gu la r coor din a t es) edit boxes.
6 Use t h e Co n ju g a te p a i r ch eck box t o cr ea t e a con ju ga t e pa ir fr om a lon e pole
or zer o or t o br ea k a con ju ga t e pa ir in t o t wo in dividu a l poles or zer os. E dit a n ew filt er or a n exist in g filt er in t h e sa m e wa y. TIP Keep t h e F ilt er Viewer open wh ile design in g a filt er wit h t h e Pole/Zer o E dit or. An y ch a n ges t h a t you m a k e t o t h e filt er t r a n sfer fu n ct ion in t h e Pole/Zer o E dit or a r e t h en sim u lt a n eou sly r eflect ed in t h e r espon se plot s of t h e Filt er Viewer.
5-68
Ma x i m u m P h a s e , wh ich in dica t es t h a t bet ween 1 a n d m zer os a r e on t h e u n it cir cle, wh ile t h e r est of t h e zer os a r e ou t side t h e u n it cir cle zi 8 1 i = 1 , , m
Wh en t h e Me a s u re m e n ts pa n el does n ot in dica t e a n y of t h e a bove con dit ion s, zer os a r e bot h in side a n d ou t side t h e u n it cir cle. Add Poles Pointer Add Zeros Pointer Wh en a n ew pole or zer o is bein g pla ced on t h e plot (u sin g t h e Ad d P o le s or Ad d Ze ro s t ools, descr ibed on pa ge 5-72) t h e Me a s u re m e n ts pa n el sh ows a ddit ion a l posit ion in g in for m a t ion . Aft er pr essin g eit h er t h e Ad d P o le s or Ad d Ze ro s bu t t on , a n d befor e clickin g on t h e plot t o pla ce t h e n ew pole(s) or zer o(s), t h e Me a s u re m e n ts pa n el displa ys t h e pr ecise posit ion of t h e poin t er over t h e plot a r ea .
5-69
Interactive Tools
You ca n zoom in on t h e displa yed filt er in t h e m a gn it u de plot (see Zoom Con t r ols on pa ge 5-31) a n d you ca n dr a g t h e specifica t ion lin es t o r edesign t h e displa yed filt er visu a lly (see t h e n ext sect ion ).
Specification Lines. You ca n r edesign a filt er by m a n ipu la t in g t h e gr een specifica t ion lin es in t h e m a gn it u de plot . Usin g t h e specifica t ion lin es, you ca n ch a n ge t h e pa ssba n d r ipple, st opba n d a t t en u a t ion , a n d edge fr equ en cies of a filt er :
Set pa ssba n d r ipple or st opba n d a t t en u a t ion by clickin g on a gr een lin e a n d dr a ggin g it u p or down . Th e Rp a n d Rs va lu es displa yed in t h e S p e c ific a tio n s pa n el ch a n ge a s you dr a g. If Au to D e s ig n is ch ecked, t h e r espon se plot a lso u pda t es a s you dr a g t h e lin es. If Au to D e s i g n is disa bled, t h e r espon se plot u pda t es wh en you r elea se t h e m ou se. NOTE Wit h IIR filt er s you ca n on ly dr a g t h e lower pa ssba n d ba r a n d t h e st opba n d ba r. Th e u pper pa ssba n d ba r is fixed a t 0. Set edge fr equ en cies eit h er by clickin g on t h e edge of a h orizon tal gr een lin e (t h e m ou se poin t er ch a n ges t o ) a n d dr a ggin g t h e edge t o a n ew fr equ en cy, or by click in g a n ywh er e on a vertical gr een lin e (if t h e F ilt er Design er pr ovides on e) a n d dr a ggin g it h or izon t a lly t o a n ew fr equ en cy. Th e F p a n d F s va lu es displa yed in t h e S p e c ific a tio n s pa n el ch a n ge a s you dr a g. If Au to D e s ig n is ch ecked, t h e r espon se plot a lso u pda t es a s you dr a g t h e lin es. If Au to D e s i g n is disa bled, t h e r espon se plot u pda t es wh en you r elea se t h e m ou se. See Redesign in g a F ilt er Usin g t h e Ma gn it u de P lot on pa ge 5-78 for det a ils.
Measurement Lines. A n u m ber of t h e filt er design s pr ovide r u ler s on t h e r espon se plot t h a t a llow you t o m ea su r e r espon se m a gn it u de levels. Th ese m ea su r em en t lin es, wh ich a ppea r in r ed on t h e plot , a r e a va ila ble for t h e Ka iser win dow, Bu t t er wor t h , Ch ebysh ev t ype I, a n d Ch ebysh ev t ype II filt er s wh en t h e Min im u m Ord e r ch eck box is n ot select ed. As you dr a g a m ea su r em en t lin e, t h e cor r espon din g va lu es in t h e Me a s u re m e n ts pa n el ch a n ge t o r eflect t h e m ea su r em en t lin es cu r r en t posit ion .
5-70
Wh en t wo or m or e pole sym bols (or t wo or m or e zer o sym bols) a r e pla ced dir ect ly on t op of ea ch ot h er , a n u m ber is displa yed n ext t o t h e sym bols (on t h e left for poles, a n d on t h e r igh t for zer os) in dica t in g t h e n u m ber of poles or zer os a t t h a t loca t ion (e.g., ). Th is n u m ber m a k es it ea sy t o k eep t r a ck of a ll t h e poles a n d zer os in t h e plot a r ea , even wh en sever a l a r e su per im posed on ea ch ot h er a n d a r e n ot visu a lly differ en t ia ble. Not e, h owever , t h a t t h is n u m ber does n ot in dica t e t h e m u ltiplicity of t h e poles or zer os t o wh ich it is a t t a ch ed.
5-71
Interactive Tools
To h elp det ect wh et h er a set of poles or zer os a r e t r u ly m u lt iples, u se t h e zoom t ools t o m a gn ify t h e r egion a r ou n d t h e poles or zer os in qu est ion . Beca u se n u m er ica l lim it a t ion s u su a lly pr even t a n y set of poles or zer os fr om sh a r in g exactly t h e sa m e va lu e, a t a h igh en ou gh zoom level even t r u ly m u lt iple poles or zer os a ppea r dist in ct fr om ea ch ot h er . A com m on wa y t o a ssess wh et h er a pa r t icu la r gr ou p of poles or zer os con t a in s m u lt iples is by com pa r in g t h e m u t u a l pr oxim it y of t h e gr ou p m em ber s a ga in st a select ed t h r esh old va lu e. As a n exa m ple, t h e residuez fu n ct ion defin es a pole or zer o a s bein g a m u lt iple of a n ot h er pole or zer o if t h e a bsolu t e dist a n ce sepa r a t in g t h em is less t h a n 0.1% of t h e la r ger pole or zer os m a gn it u de.
Tools. Th e P ole/Zer o E dit or pr ovides sever a l t ools t o a ssist wit h pole-zer o pla cem en t . Th e t ools a r e loca t ed a t t h e t op left of t h e pole-zer o plot a r ea . Icon Name
Dr a g Poles/Zer os Tool
Description
Use t h is t ool t o select a n d dr a g poles a n d zer os on t h e plot . Use t h is t ool t o a dd poles t o t h e plot . Sim ply click on t h e plot wh er e you wa n t t o pla ce t h e n ew pole (or con ju ga t e pa ir, wh en t h e Co n ju g a te p a i r ch eckbox is select ed). Use t h is t ool t o a dd zer os t o t h e plot . Sim ply click on t h e plot wh er e you wa n t t o pla ce t h e n ew zer o (or con ju ga t e pa ir, wh en t h e Co n ju g a te p a i r ch eckbox is select ed). Use t h is t ool t o delet e poles a n d zer os fr om t h e plot . Sim ply click on a n y pole or zer o t o delet e it . Wh en you click on a set of poles or zer o occu pyin g t h e sa m e loca t ion , on ly t h e t op-m ost pole or zer o is r em oved. You ca n a lso u se t h e D e le te or B a c k s p a c e key on t h e keyboa r d t o delet e t h e cu r r en t ly select ed pole or zer o.
At t h e bot t om of t h e plot a r ea , t h er e a r e t wo a ddit ion a l bu t t on s, S e n d To B a c k a n d D e le te All . Use S e n d To B a c k wh en you a r e u n a ble t o select a pole or zer o beca u se a n ot h er pole or zer o is in t h e wa y. Select t h e in t er fer in g pole or zer o on t h e plot , a n d pr ess S e n d To B a c k t o m ove t h a t pole or zer o beh in d a ll ot h er sym bols on t h e plot (i.e., la st in t h e st a ck in g or der ). You ca n t h en select t h e desir ed pole or zer o wit h ou t t h e in t er fer en ce of t h e ot h er sym bol.
5-72
Th e D e le te All bu t t on delet es ever y pole a n d zer o in t h e plot a r ea . NOTE Th e D e le te All oper a t ion ca n n ot be u n don e. On ce a ll t h e poles a n d zer os a r e r em oved, t h ey ca n n ot be r est or ed.
m en u .
2 Select ba n d p a s s fr om t h e Ty p e pop-u p m en u a s t h e con figu r a t ion . 3 Set t h e filt er s sa m plin g fr equ en cy t o 2000 H z by en t er in g t h is va lu e in t h e
S a m p li n g F re q u e n c y t ext box.
4 P r ess Ap p ly t o r edr a w t h e r espon se wit h t h ese set t in gs.
5-73
Interactive Tools
Th ese fields r espect ively defin e t h e lower a n d u pper pa ssba n d edge fr equ en cies in H er t z.
7 Set F s 1 t o 200 a n d F s 2 t o 625.
Th ese fields r espect ively defin e t h e lower a n d u pper st opba n d edge fr equ en cies in H er t z.
8 Set Rp (pa ssba n d r ipple) t o 4 a n d Rs (st opba n d a t t en u a t ion ) t o 30.
R p a n d Rs a r e specified in dB.
9 P r ess t h e Ap p ly bu t t on .
Th e F ilt er Design er ca lls fir1 t o cr ea t e t h e filt er u sin g a Ka iser win dow. Th e F ilt er Design er u pda t es t h e m a gn it u de plot t o sh ow t h e n ew filt er s m a gn it u de r espon se.
5-74
5-75
Interactive Tools
pop-u p m en u .
2 Select h ig h p a s s fr om t h e Ty p e m en u a s t h e con figu r a t ion . 3 Set t h e filt er s sa m ple fr equ en cy t o 2000 H z by en t er in g t h is va lu e in t h e
5 Ch eck t h e Min i m u m Ord e r ch eck box. 6 Set F p (pa ssba n d edge fr equ en cy) t o 800 a n d F s (st opba n d edge fr equ en cy)
t o 700.
F p a n d F s a r e specified in H er t z.
7 Set Rp (pa ssba n d r ipple) t o 2.5 a n d Rs (st opba n d a t t en u a t ion ) t o 35.
R p a n d Rs a r e specified in dB.
8 P r ess Ap p ly t o dr a w t h e m a gn it u de r espon se. 9 Deselect Min im u m Ord e r a n d specify a filt er or der of 7. P r ess Ap p ly t o
5-76
To zoom in on plot det a ils, u se t h e zoom con t r ol bu t t on s a s descr ibed in Zoom Con t r ols on pa ge 5-31.
5-77
Interactive Tools
5-78
Not e t h a t t h e Ord e r va lu e in t h e Me a s u re m e n ts pa n el ch a n ges beca u se a h igh er filt er or der is n eeded t o m eet t h e n ew specifica t ion s.
ca lled filt1.
2 Select Ex p o rt... fr om t h e F ile m en u . 3 In t h e Ex p o rt fro m S P To o l dia log box, select filt1 a n d pr ess t h e Ex p o rt
to Wo rk s p a c e bu t t on .
4 Type who a t t h e MATLAB com m a n d lin e t o look a t t h e va r ia bles in t h e
wor kspa ce. Th e va r ia ble ca lled filt1 is t h e filt er st r u ct u r e you expor t ed fr om SP Tool.
5 At t h e com m a n d lin e t ype filt1 t o list t h e fields of t h e filt er st r u ct u r e.
Th e tf, Fs, a n d specs fields of t h e filt er st r u ct u r e con t a in t h e in for m a t ion t h a t descr ibes t h e filt er . Th ese fields a r e discu ssed below. Th e ot h er fields in t h e st r u ct u r e a r e u sed in t er n a lly by SP Tool, a n d a r e su bject t o ch a n ge in fu t u r e r elea ses.
tf. Th e tf field is a st r u ct u r e con t a in in g t h e t r a n sfer fu n ct ion r epr esen t a t ion of t h e filt er :
5-79
Interactive Tools
bot h in descen din g power s of z B (z ) b (1 ) + b (2 ) z 1 + L + b (n b + 1 ) z m H (z ) = ---------- = ------------------------------------------------------------------------------------- 1 A (z ) + a (n a + 1 ) z n a (1 ) + a (2 ) z + L wh er e b is a vect or con t a in in g t h e coefficien t s fr om t h e tf.num field, a is a vect or con t a in in g t h e coefficien t s fr om t h e tf.den field, m is t h e n u m er a t or or der , a n d n is t h e den om in a t or or der . You ca n ch a n ge t h e filt er r epr esen t a t ion fr om t h e defa u lt t r a n sfer fu n ct ion t o a n ot h er for m by u sin g t h e tf2ss or tf2zp fu n ct ion s.
Fs. Th e Fs field con t a in s t h e sa m plin g fr equ en cy of t h e filt er in H er t z. specs. Th e specs field is a st r u ct u r e con t a in in g in for m a t ion a bou t t h e filt er design . Th e fir st field, specs.currentModule, con t a in s a st r in g r epr esen t in g
t h e design select ed for t h e filt er in t h e F ilt er Design er s Alg o rith m pop-u p m en u . Th e possible con t en t s of t h e currentModule field, a n d t h e cor r espon din g design s, a r e sh own below.
currentModule fdbutter fdcheby1 fdcheby2 fdellip fdfirls fdkaiser fdremez Algorithm
Bu t t er wor t h IIR Ch ebysh ev Type I IIR Ch ebysh ev Type II IIR E llipt ic IIR Lea st Squ a r es F IR Ka iser Win dow F IR E qu ir ipple F IR
F ollowin g t h e specs.currentModule field, t h er e m a y be u p t o seven a ddit ion a l fields, wit h la bels su ch a s specs.fdremez, specs.fdfirls, et c. Th e design specifica t ion s for t h e m ost r ecen t ly expor t ed filt er a r e con t a in ed in t h e field
5-80
t h e filt er specifica t ion s a r e con t a in ed in t h e fdkaiser field, wh ich is it self a da t a st r u ct u r e. Th e specifica t ion s in clu de t h e pa r a m et er va lu es fr om t h e S p e c i fi c a tio n s pa n el of t h e F ilt er Design er , su ch a s ba n d edges a n d filt er or der . F or exa m ple, t h e Ka iser win dow filt er a bove h a s t h e followin g specifica t ion s st or ed in specs.fdkaiser.
setOrderFlag: 0 type: 1 f: [0 0.1000 0.1500 1] Rp: 3 Rs: 20 Wn: 0.1250 order: 34 Beta: 0 wind: [35x1 double]
Beca u se cer t a in filt er pa r a m et er s a r e u n iqu e t o a pa r t icu la r design , t h is st r u ct u r e h a s a differ en t set of fields for ea ch filt er design . F or exa m ple, t h e Beta field a bove on ly a ppea r s in t h e specs st r u ct u r e if t h e design is a Ka iser win dow F IR filt er . Th e t a ble below list s t h e possible specifica t ion s fields t h a t ca n a ppea r in t h e expor t st r u ct u r e, a n d descr ibes t h eir con t en t s.
Parameter Beta f Description
Ka iser win dow = pa r a m et er. Con t a in s a vect or of ba n d-edge fr equ en cies, n or m a lized t o 1 (i.e., 1 = Nyqu ist ).
5-81
Interactive Tools
Parameter Fpass
Description
Pa ssba n d cu t off fr equ en cies. Sca la r for lowpa ss a n d h igh pa ss design s, t wo-elem en t vect or for ba n dpa ss a n d ba n dst op design s. St opba n d cu t off fr equ en cies. Sca la r for lowpa ss a n d h igh pa ss design s, t wo-elem en t vect or for ba n dpa ss a n d ba n dst op design s. Th e r espon se m a gn it u des cor r espon din g t o t h e ba n d-edge fr equ en cies in f. Filt er or der. Pa ssba n d r ipple (dB) St opba n d a t t en u a t ion (dB) Con t a in s 1 if t h e filt er or der wa s specified m a n u a lly (i.e., t h e Mi n im u m Ord e r box in t h e S p e c ific a tio n s pa n el wa s n ot ch ecked). Con t a in s 0 if t h e filt er or der wa s com pu t ed a u t om a t ica lly. Con t a in s 1 for lowpa ss, 2 for h igh pa ss, 3 for ba n dpa ss, or 4 for ba n dst op. -3 dB fr equ en cy for Bu t t er wor t h IIR design s. Vect or of Ka iser win dow coefficien t s. Cu t off fr equ en cy for t h e Ka iser win dow F IR filt er wh en setOrderFlag = 1. Vect or of weigh t s, on e weigh t per fr equ en cy ba n d.
Fstop
m order Rp Rs setOrderFlag
5-82
1 Act iva t e SP Tool fr om t h e Win d o w m en u . 2 Ma ke su r e t h e filt er s you wa n t t o a n a lyze a r e select ed in t h e F ilte rs list . 3 P r ess Vie w in t h e F ilt er pa n el.
r ea ct iva t e t h e F ilt er Viewer fr om t h e Win d o w m en u in t h e F ilt er Design er . Wh en t h e F ilt er Viewer is open a t t h e sa m e t im e t h a t t h e F ilt er Design er is open , t h ey bot h displa y t h e sa m e filt er . You ca n m ove ba ck a n d for t h bet ween t h e F ilt er Design er a n d t h e F ilt er Viewer u n t il t h e filt er design is fin ish ed. You ca n a pply t h e filt er t o a sign a l by a ct iva t in g SP Tool, select in g t h e filt er in t h e F i lte rs list , a n d t h e sign a l t o a pply it t o fr om t h e S i g n a ls list , a n d pr essin g Ap p ly . See Applyin g a F ilt er on pa ge 5-18 for det a ils. See Usin g t h e F ilt er Viewer : In t er a ct ive F ilt er An a lysis on pa ge 5-84 for m or e in for m a t ion on t h e F ilt er Viewer .
5-83
Interactive Tools
Th e F ilt er Viewer is a ct iva t ed a n d t h e select ed filt er s a r e loa ded in t o t h e F ilt er Viewer a n d displa yed.
5-84
A P lo ts pa n el for select in g wh ich su bplot s displa y in t h e m a in plot s win dow A R u le rs pa n el a n d lin e displa y con t r ols for m a kin g sign a l m ea su r em en t s a n d com pa r ison s A F re qu e n c y Ax i s pa n el for specifyin g x -a xis sca lin g in t h e m a in plot s win dow A filt er iden t ifica t ion pa n el t h a t displa ys in for m a t ion a bou t t h e cu r r en t ly select ed filt er (s) A m a in plot s (displa y) a r ea for viewin g on e or m or e fr equ en cy-dom a in plot s for t h e select ed filt er (s) Zoom con t r ols for get t in g a closer look a t filt er r espon se ch a r a ct er ist ics Wh en you fir st open or a ct iva t e t h e F ilt er Viewer , it displa ys t h e defa u lt plot con figu r a t ion for t h e select ed filt er (s): View (zoom) controls Line display controls
Filter ID panel
Plots panel, including menus for modifying plot characteristics
Th e filt er sm a gn it u de a n d ph a se plot s a r e displa yed. Th e fr equ en cy a xis of t h e plot s is set t o lin e a r , a n d t h e fr equ en cy a xis r a n ge is set t o [0,F s /2] .
5-85
Interactive Tools
You ca n ch oose t o displa y on e or a n y com bin a t ion of t h e six a va ila ble su bplot s by u sin g t h e ch eck boxes in t h e P lo ts pa n el, a n d you ca n m odify m a n y of t h e plot displa y ch a r a ct er ist ics u sin g t h e pop-u p m en u s in t h e P lo ts pa n el a n d t h e F re qu e n c y Ax i s pa n el.
Menus
File Menu. Use Clo s e fr om t h e F ile m en u t o close t h e F ilt er Viewer . Set t in gs you ch a n ged a n d sa ved u sin g t h e P re fe re n c e s dia log box in SP Tool a r e sa ved a n d u sed t h e n ext t im e you open a F ilt er Viewer . Window Menu. Use t h e Win d o w m en u t o select a cu r r en t ly open MATLAB figu r e win dow.
Plots Panel
Th e ch eck boxes in t h is pa n el select t h e su bplot s t o displa y in t h e m a in plot s a r ea . An y com bin a t ion of su bplot s m a y be displa yed. To displa y a su bplot , ch eck t h e box a t t h e left of t h e plot descr ipt ion . Th er e a r e six a va ila ble su bplot s: Ma g n itu d e : displa ys t h e m a gn it u de of t h e fr equ en cy r espon se of t h e cu r r en t ly select ed filt er (s). P h a s e : displa ys t h e ph a se of t h e fr equ en cy r espon se. Gro u p D e la y : displa ys t h e n ega t ive of t h e der iva t ive of t h e ph a se r espon se. Ze ro s a n d P o le s : displa ys t h e poles a n d zer os of t h e filt er t r a n sfer fu n ct ion (s) a n d t h eir pr oxim it y t o t h e u n it cir cle. Im p u ls e R e s p o n s e : displa ys t h e r espon se of t h e cu r r en t ly select ed filt er (s) t o a discr et e-t im e u n it -h eigh t im pu lse a t t =0. S te p Re s p o n s e : displa ys t h e r espon se of t h e cu r r en t ly select ed filt er (s) t o a discr et e-t im e u n it -h eigh t st ep fu n ct ion .
5-86
You ca n cu st om ize t h e displa y ch a r a ct er ist ics of t h e m a gn it u de a n d ph a se su bplot s u sin g t h e Ma g n i tu d e a n d P h a s e pop-u p m en u s. Th e opt ion s in clu de: Ma g n itu d e : Sca lin g for t h e m a gn it u de plot m a y be li n e a r , lo g , or d e c ibe ls . P h a s e : P h a se u n it s m a y be d e g re e s or ra d ia n s . You ca n a lso ch a n ge t h e m a gn it u de a n d ph a se displa y ch a r a ct er ist ics for t h e F ilt er Viewer u sin g t h e F ilt er set t in gs pa n el of t h e P re fe re n c e s dia log box in SP Tool.
Zoom Controls
Th e a va ila ble zoom con t r ols in t h e F ilt er Viewer a r e Mo u s e Zo o m a n d F u ll Vie w . You ca n zoom in depen den t ly in ea ch displa yed su bplot . By defa u lt , per sist en t zoom in g is disa bled in t h e F ilt er Viewer . You ca n t u r n per sist en t zoom in g on fr om t h e F ilte r Vie w e r set t in gs pa n el of t h e P re fe re n c e s dia log box in SP Tool. See Zoom Con t r ols on pa ge 5-31 for det a ils on u sin g t h e zoom con t r ols in t h e F ilt er Viewer .
Help Button
To u se con t ext -sen sit ive h elp, pr ess t h e He lp bu t t on . Th e m ou se poin t er becom es a n a r r ow wit h a qu est ion m a r k sym bol. You ca n t h en click on a n yt h in g
5-87
Interactive Tools
You ca n exper im en t t o fin d t h e t ilin g opt ion t h a t wor ks best for ea ch specific com bin a t ion a n d n u m ber of su bplot s. You ca n zoom in on a su bplot by pr essin g Mo u s e Zo o m a n d t h en clickin g on or dr a ggin g over a select ed a r ea of t h e su bplot . By defa u lt , m ou se zoom in g in t h e F ilt er Viewer is n ot per sist en t ; a ft er you click on ce, t h e zoom m ode is t u r n ed off. You ca n m a ke zoom in g per sist en t by ch eckin g S ta y in Zo o m -m o d e a fte r
5-88
Zo o m in t h e SP Tool P re fe re n c e s dia log box. Th is a llows you t o click r epea t edly in a su bplot t o con t in u e t o zoom in on a pa r t icu la r fea t u r e of t h e displa y.
zoom m ode.
4 Click a ga in in t h e sa m e su bplot , h old down t h e m ou se bu t t on u n t il t h e h a n d
5-89
Interactive Tools
5-90
By defa u lt , t h is plot u ses t h e defa u lt sca lin g (lin e a r ) for bot h a xes a n d t h e defa u lt r a n ge for t h e fr equ en cy a xis. You ca n ch a n ge t h e followin g displa y ch a r a ct er ist ics of t h e m a gn it u de plot : Use t h e Ma g n itu d e pop-u p m en u t o ch oose bet ween lin e a r , lo g , or d e c ibe ls sca lin g of t h e y -a xis. Use t h e S c a le pop-u p m en u t o ch oose bet ween lin e a r a n d lo g sca lin g of t h e x -a xis. Use t h e Ra n g e pop-u p m en u t o ch oose bet ween t h e followin g r a n ges for t h e x -a xis: [0,F s /2] , [0,F s ] , or [-F s /2,F s /2] , wh er e F s r epr esen t s t h e filt er s sa m plin g fr equ en cy.
5-91
Interactive Tools
plot .
2 Click t h e ch eck box n ext t o t h e P h a s e opt ion t o t u r n on t h e ph a se plot a n d
u pda t e t h e displa y.
By defa u lt , t h is plot u ses t h e defa u lt ph a se (d e g re e s ) a n d t h e defa u lt sca lin g a n d r a n ge for t h e fr equ en cy a xis. You ca n ch a n ge t h e followin g displa y ch a r a ct er ist ics of t h e ph a se plot : Use t h e P h a s e pop-u p m en u t o ch oose bet ween displa yin g ph a se in d e g re e s or ra d ia n s . Use t h e S c a le pop-u p m en u t o ch oose bet ween li n e a r a n d lo g sca lin g of t h e x -a xis. Use t h e R a n g e pop-u p m en u t o ch oose bet ween t h e followin g r a n ges for t h e x -a xis: [0,F s /2] , [0,F s ] , or [-F s /2,F s /2] , wh er e F s r epr esen t s t h e filt er s sa m plin g fr equ en cy.
5-92
By defa u lt , t h is plot u ses t h e defa u lt sca lin g a n d r a n ge for t h e fr equ en cy a xis. You ca n ch a n ge t h e followin g displa y ch a r a ct er ist ics of t h e gr ou p dela y plot : Use t h e S c a le pop-u p m en u t o ch oose bet ween lin e a r a n d lo g sca lin g of t h e x -a xis. Use t h e Ra n g e pop-u p m en u t o ch oose bet ween t h e followin g r a n ges for t h e x -a xis: [0,F s /2] , [0,F s ] , or [-F s /2,F s /2] , wh er e F s r epr esen t s t h e h igh est sa m plin g fr equ en cy of t h e cu r r en t ly select ed filt er s.
5-93
Interactive Tools
dela y plot .
2 Click t h e ch eck box n ext t o t h e Ze ro s a n d P o le s opt ion t o t u r n on t h e
5-94
You ca n ch a n ge t h e followin g displa y ch a r a ct er ist ics of t h e im pu lse r espon se plot : E dit t h e Tim e R e s p o n s e Le n g th field in t h e F i lte r Vi e w e r P re fe re n c e s pa n el t o set t h e n u m ber of sa m ples u sed t o displa y t h e im pu lse r espon se.
5-95
Interactive Tools
You ca n ch a n ge t h e followin g displa y ch a r a ct er ist ics of t h e st ep r espon se plot : E dit t h e Tim e Re s p o n s e Le n g th field in t h e F ilte r Vie w e r P re fe re n c e s pa n el t o set t h e n u m ber of sa m ples u sed t o displa y t h e st ep r espon se.
5-96
5-97
Interactive Tools
Parameters panel
5-98
Menus
File Menu. Use P a g e S e tu p ... fr om t h e F ile m en u t o open t h e st a n da r d MATLAB P a g e S e tu p dia log box (see Usin g M AT L AB Graph ics ), in wh ich you ca n set t h e or ien t a t ion , size a n d posit ion , lim it s, a n d color of you r pr in t ou t .
Use P ri n t P re v ie w ... fr om t h e F ile m en u t o open a MATLAB figu r e win dow wit h a pr eview of t h e in for m a t ion fr om t h e Spect r u m Viewer win dow t h a t will a ppea r in you r pr in t ou t . See Spect r u m Viewer Set t in gs on pa ge 5-24 a n d P r in t in g Spect r u m Da t a on pa ge 5-107 for det a ils of pr in t in g fr om t h e Spect r u m Viewer . Use P ri n t... fr om t h e F i le m en u t o open t h e st a n da r d oper a t in g syst em pr in t dia log box, fr om wh ich you ca n pr in t you r spect r u m da t a . Use Clo s e fr om t h e F ile m en u t o close t h e Spect r u m Viewer . All spect r u m select ion a n d r u ler in for m a t ion will be lost . Set t in gs you ch a n ged a n d sa ved u sin g t h e P re fe re n c e s dia log box in SP Tool a r e sa ved a n d u sed t h e n ext t im e you open t h e Spect r u m Viewer .
Options Menu. Use t h ese opt ion s t o ch a n ge sca lin g a n d r a n ge pa r a m et er s for plot s in t h e Spect r u m Viewer .
5-99
Interactive Tools
Th e opt ion s in clu de: Ma g n itu d e S c a le : Sca lin g for t h e m a gn it u de plot m a y be d B or lin e a r . F re q u e n c y R a n g e : Th e r a n ge for t h e fr equ en cy a xis m a y be [0, F s /2] , [0, F s ] , or [-F s /2, F s /2] , wh er e F s is t h e sa m plin g fr equ en cy. If m u lt iple spect r a a r e displa yed, t h e va lu e of F s is t h e m a xim u m of a ll t h e sa m plin g fr equ en cies.
Fs is n ot defin ed for t h e ca se of a spect r u m wh ose sign a l is <None>, t h a t is, a spect r u m wh ose a ssocia t ed sign a l h a s been delet ed fr om SP Tool. In t h is ca se, a va lu e t wice t h e h igh est fr equ en cy in t h e spect r u m s fr equ en cy vect or is ch osen .
Th e fr equ en cy r a n ge ca n n ot be n ega t ive if F re q u e n c y S c a le is set t o lo g . F re q u e n c y S c a le : Sca lin g for t h e fr equ en cy a xis m a y be lin e a r or lo g .
Window Menu. Use t h e Win d o w m en u t o select a cu r r en t ly open MATLAB figu r e win dow.
Signal ID Panel
Th is pa n el displa ys in for m a t ion a bou t t h e sign a l lin ked t o t h e cu r r en t ly select ed spect r u m . Th e in for m a t ion in clu des t h e sign a ls n a m e, size, da t a t ype (real or complex), a n d sa m plin g fr equ en cy. To ch a n ge a n y of t h ese sign a l pr oper t ies, u se SP Tool. To a ssocia t e a com plet ely n ew sign a l wit h a displa yed spect r u m , select t h e sign a l in SP Tool a n d pr ess U p d a te in t h e S p e c tra pa n el.
in h er it it s pa r a m et er s (n ot in clu din g t h e a ssocia t ed sign a l). P r ess In h e rit fro m a n d dr a g t o select t h e spect r u m fr om wh ich you wa n t t o in h er it pa r a m et er s.
Revert. Rest or es t h e pr oper t ies of t h e cu r r en t spect r u m t o wh a t t h ey wer e t h e
la st t im e Ap p ly wa s pr essed.
Apply. Com pu t e a n d displa y t h e a ct ive spect r u m u sin g t h e pa r a m et er s set in t h e P a ra m e te rs pa n el.
5-100
Zoom Controls
Th e a va ila ble zoom con t r ols in t h e Spect r u m Viewer a r e Mo u s e Zo o m , F u ll Vie w , Zo o m In -Y, Zo o m Ou t-Y, Zo o m In -X, a n d Zo o m Ou t-X. See Zoom Con t r ols on pa ge 5-31 for det a ils on u sin g t h e zoom con t r ols in t h e Spect r u m Viewer .
Help Button
To u se con t ext -sen sit ive h elp, pr ess t h e He lp bu t t on . Th e m ou se poin t er becom es a n a r r ow wit h a qu est ion m a r k sym bol. You ca n t h en click on a n yt h in g in t h e Spect r u m Viewer , in clu din g m en u it em s, t o fin d ou t wh a t it is a n d h ow t o u se it .
Wh en t h er e is on ly on e spect r u m displa yed, it s pr oper t ies a r e displa yed in t h e P a ra m e te rs pa n el a n d it s m ea su r em en t s a r e displa yed in t h e R u le rs pa n el. Wh en m or e t h a n on e spect r u m is displa yed, select t h e lin e you wa n t t o focu s on . Wh en a spect r u m is select ed, you ca n u se t h e r u ler con t r ols on t h e select ed lin e (see Ma kin g Sign a l Mea su r em en t s on pa ge 5-37) a n d you ca n m odify it s pa r a m et er s (see below). Th e la bel of t h e select ed spect r u m (lin e) is displa yed in t h e S e le c tio n pop-u p m en u .
5-101
Interactive Tools
Select a spect r u m (lin e) in on e of t wo wa ys: Click on t h e S e le c tio n pop-u p m en u a n d dr a g t o select t h e lin e t o m ea su r e Move t h e m ou se poin t er over a n y poin t in t h e lin e you wa n t t o select a n d click on it See Select in g a Lin e t o Mea su r e on pa ge 5-34 for det a ils.
Click-and-Drag Panning. You ca n u se t h e m ou se t o pa n a r ou n d t h e m a in a xes
displa y: Click on a lin e in t h e m a in a xes, h old down t h e m ou se bu t t on , a n d dr a g t h e m ou se. Click-a n d-dr a g pa n n in g is n ot en a bled in m ou se zoom m ode.
5-102
Use t h e Op tio n s m en u t o select : Lin ea r or decibel sca lin g for t h e m a gn it u de a xis Lin ea r or loga r it h m ic sca lin g for t h e fr equ en cy a xis Th e fr equ en cy r a n ge t o view See Opt ion s Men u on pa ge 5-99 for det a ils. You ca n a lso zoom in on a n y of t h e Spect r u m Viewer s plot s. See Zoom Con t r ols on pa ge 5-31 for det a ils. You ca n set ot h er sca lin g pr oper t ies in t h e P a ra m e te rs pa n el, depen din g on t h e P SD m et h od com pu t a t ion pa r a m et er s you ch oose.
m et h ods: - Bu r g - Cova r ia n ce - FFT - Modified Cova r ia n ce - MTM - MUSIC - Welch - Yu le AR Appr opr ia t e pa r a m et er select ion s a r e displa yed for ea ch m et h od you ch oose.
5-103
Interactive Tools
- Wh en a pa r a m et er is in a pop-u p m en u , click on t h e pa r a m et er la bel a n d dr a g t o select a va lu e fr om t h e m en u . - Wh en a pa r a m et er is in a n edit box, t ype t h e va lu e or va r ia ble in t o t h e box. You ca n a lso m odify t h e pa r a m et er s by u sin g In h e rit fro m t o copy t h e pa r a m et er s of a n ot h er spect r u m in SP Tool. See In h er it fr om on pa ge 5-100 for det a ils.
3 If you ch a n ge you r m in d, you ca n disca r d ch a n ges you m a k e by pr essin g
R e v e rt .
4 To a pply t h e m odified pa r a m et er s, pr ess Ap p ly .
Th e n ew pa r a m et er s a r e a pplied t o t h e select ed spect r u m ; t h e Spect r u m Viewer r eca lcu la t es t h e spect r a l den sit y fu n ct ion a n d displa ys t h e m odified spect r u m .
Ord e r N fft
5-104
Ord e r N fft
N fft
Ord e r N fft
pa r a m et er s: NW N fft
5-105
Interactive Tools
We ig h ts Select on e of t h e followin g fr om t h e pop-u p m en u : - adapt - u n ity - e ig e n Co n f. In t. Ch eck t o com pu t e a con fiden ce in t er va l a n d t ype in a va lu e (see Set t in g Con fiden ce In t er va ls on pa ge 5-107).
MUSIC. F or t h e MUSIC m et h od, you ca n specify t h e followin g pa r a m et er s:
S i g n a l D im . Th re s h o ld N fft N w in d Wi n d o w Ov e rla p Co rr. Ma trix Ch eck if select ed sign a l is a cor r ela t ion m a t r ix. Eig e n v e c to r We i g h ts Ch eck t o select eigen vect or weigh t s.
Welch. F or Welch s m et h od, you ca n specify t h e followin g pa r a m et er s:
5-106
Co n f. In t. Ch eck t o com pu t e a con fiden ce in t er va l a n d t ype in a va lu e (see Set t in g Con fiden ce In t er va ls on pa ge 5-107).
Yule AR. F or t h e Yu le AR m et h od, you ca n specify t h e followin g pa r a m et er s:
Ord e r N fft Co rr. Ma trix Ch eck if select ed sign a l is a cor r ela t ion m a t r ix.
NOTE Con fiden ce in t er va ls a r e r elia ble on ly for n on over la ppin g sect ion s.
5-107
Interactive Tools
box in t h e S p e c tru m Vie w e r pr efer en ces pa n el of t h e P re fe re n c e s dia log box in SP Tool (see Spect r u m Viewer Set t in gs on pa ge 5-24). You ca n pr eview you r pr in t ou t by ch oosin g P rin t P re v ie w ... fr om t h e F ile m en u in t h e Spect r u m Viewer win dow. Th is open s t h e S p e c tru m Vie w e r P rin t P re v i e w win dow, sh own below wit h defa u lt set t in gs for t h e spect r u m mtlbse.
Th e Clo s e bu t t on on t h e S p e c tru m Vie w e r P rin t P re v ie w win dow closes t h e pr in t pr eview win dow a n d r et u r n s you t o t h e Spect r u m Viewer . Th e P rin t... bu t t on on t h e S p e c tru m Vi e w e r P rin t P re v i e w win dow open s t h e st a n da r d pr in t dia log box, fr om wh ich you ca n pr in t t h e con t en t s of you r pr in t pr eview win dow. If you ch oose t o pr in t fr om t h e pr in t dia log, bot h t h a t dia log a n d t h e S p e c tru m Vie w e r P ri n t P re v ie w win dow will close, a n d t h e con t en t s of t h e pr in t pr eview will pr in t . If you ch oose n ot t o pr in t , t h e pr in t dia log a n d t h e S p e c tru m Vie w e r P rin t P re v i e w win dow will close, a n d you will r et u r n t o t h e Spect r u m Viewer . An y ch a n ges you m a ke, pr ior t o open in g t h e pr in t pr eview win dow, t h a t a ffect t h e displa y of da t a in t h e Spect r u m Viewer (see Con t r ollin g a n d Ma n ipu la t in g P lot s on pa ge 5-102) will a ffect t h e displa y of da t a in t h e S p e c tru m Vie w e r
5-108
pr eview sh own below: Da t a fr om t h r ee differ en t sa m ple spect r a h a ve been select ed for displa y in t h e sa m e m a in a xes a r ea (see Open in g t h e F ilt er Viewer on pa ge 5-84). Usin g t h e t ools in t h e Ed it Li n e pop-u p m en u (see Ru ler a n d Lin e Displa y Con t r ols on pa ge 5-101), t h e spect r u m lin es h a ve a ll been ch a n ged t o bla ck a n d t h eir lin e st yles h a ve been differ en t ia t ed, a s is r eflect ed in t h e legen d. Th e plot s of a ll t h r ee spect r a h a ve been zoom ed t o a n in t er va l bet ween t h eir r u ler s (see Zoom Con t r ols on pa ge 5-101). Not e t h a t t h e r u ler m ea su r em en t s displa yed a r e for t h e trainse spect r u m , wh ich is t h e cu r r en t ly select ed spect r u m .
Ch a n ges you m a ke in t h e P re fe re n c e s dia log box in SP Tool will a lso a ffect t h e S p e c tru m Vie w e r P rin t P re v ie w win dow in t h e sa m e wa y t h a t t h ey a ffect t h e Spect r u m Viewer it self. F or exa m ple, in t h e pr in t pr eview sh own below, t h e
5-109
Interactive Tools
r u ler m ea su r em en t s h a ve been su ppr essed by ch a n ges in t h e Spect r u m Viewer pr efer en ces (see Spect r u m Viewer Set t in gs on pa ge 5-24).
NOTE Th e HandleVisibility pr oper t y of t h e P ri n t P re v ie w figu r e win dow is set t o 'on'. Th is a llows you t o m odify t h e pr eview u sin g H a n dle Gr a ph ics com m a n ds fr om t h e MATLAB com m a n d lin e or t h e P lot E dit or t ools (see Usin g M AT L AB Graph ics for m or e in for m a t ion ). For exa m ple, you ca n dr a g t h e legen d t o a differ en t posit ion wit h in t h e figu r e, a s h a s been don e in t h e figu r e sh own a bove Ch a n ges t h a t you m a ke in t h e pr eview win dow pr in t exa ct ly a s t h ey a ppea r on t h e scr een ; h owever, t h ey a r e n ot sa ved wh en t h e P rin t P re v i e w figu r e win dow is closed.
5-110
spect1.
2 In SP Tool, select Ex p o rt... fr om t h e F ile m en u . 3 In t h e Ex p o rt dia log box, select spect1 a n d pr ess t h e Ex p o rt to Wo rk s p a c e
bu t t on .
4 Type who a t t h e MATLAB com m a n d lin e t o look a t t h e va r ia bles in t h e
wor kspa ce. Th e va r ia ble ca lled spect1 is t h e spect r u m st r u ct u r e you expor t ed fr om SP Tool.
5 Type spect1 t o list t h e fields of t h e spect r u m st r u ct u r e.
Th e spect r a l power vect or. Th e spect r a l fr equ en cy vect or. A st r u ct u r e con t a in in g t h e con fiden ce in t er va ls da t a : Th e confid.level field con t a in s t h e ch osen con fiden ce level. Th e confid.Pc field con t a in s t h e spect r a l power da t a for t h e con fiden ce in t er va ls. Th e confid.enable field con t a in s a 1 if con fiden ce levels a r e en a bled for t h e spect r u m .
signalLabel Fs
5-111
Interactive Tools
5-112
x = randn(5000,1);
2 Act iva t e SP Tool by t ypin g:
sptool
5-113
Interactive Tools
Not ice t h a t t h e va r ia ble x is displa yed in t h e Wo rk s p a c e Co n te n ts list . (If it is n ot , click t h e F ro m Wo rk s p a c e r a dio bu t t on t o displa y t h e con t en t s of t h e wor kspa ce.)
4 Na m e t h e sign a l a n d im por t it in t o SP Tool: a Ma ke su r e t h a t S i g n a l is select ed in t h e Im p o rt As pop-u p m en u . b Click in t h e D a ta field a n d t ype x.
You ca n a lso m ove t h e va r ia ble x in t o t h e D a ta field by click in g on x in t h e Wo rk s p a c e Co n te n ts list a n d t h en click in g on t h e a r r ow t o t h e left of t h e D a ta field.
c
P r ess OK .
5-114
Design a Filter
You ca n im por t a n exist in g filt er in t o SP Tool, or you ca n design a n d edit a n ew filt er u sin g t h e F ilt er Design er . In t h is st ep, you ll cr ea t e a defa u lt filt er a n d cu st om ize it in t h e F ilt er Design er .
1 P r ess N e w D e s ig n in SP Tool t o a ct iva t e t h e F ilt er Design er a n d gen er a t e a
defa u lt filt er . Th e F ilt er Design er win dow is displa yed wit h t h e defa u lt filt er filt1.
2 Ch a n ge t h e filt er sa m plin g fr equ en cy t o 5000 by en t er in g t h is va lu e in t h e
Set t h e pa ssba n d edge fr equ en cies by en t er in g 750 for F p 1 a n d 1250 for F p2.
F s2.
5-115
Interactive Tools
Wh en t h e n ew filt er is com pu t ed, t h e m a gn it u de r espon se of t h e filt er is displa yed wit h a solid lin e in t h e m a in a xes displa y a r ea .
5-116
1 Act iva t e SP Tool fr om t h e Win d o w m en u in t h e F ilt er Design er . 2 Click t o select t h e sign a l noise[vector] fr om t h e S ig n a ls list a n d click t o
blnoise.
5 P r ess OK .
Th e filt er is a pplied t o t h e select ed sign a l. Th e n ew, filt er ed sign a l blnoise[vector] is displa yed in t h e S i g n a ls list .
5-117
Interactive Tools
Th e Sign a l Br owser is a ct iva t ed a n d bot h sign a ls a r e displa yed in t h e m a in a xes displa y a r ea . In it ia lly, t h e noise sign a l cover s u p t h e ba n dlim it ed blnoise sign a l, bu t you ca n see t h a t bot h sign a ls a r e displa yed beca u se t h e n a m es of bot h sign a ls a r e sh own a bove t h e m a in a xes displa y a r ea .
Th e m a in a xes displa y a r ea is r edispla yed. Now you ca n see t h e blnoise sign a l su per im posed on t op of t h e noise sign a l. Th e sign a ls a r e displa yed in differ en t color s in bot h t h e m a in a xes displa y a r ea a n d t h e pa n n er . Not ice
5-118
t h a t t h e color of t h e lin e in t h e S e le c tio n displa y ch a n ges t o cor r espon d t o t h e color of t h e sign a l t h a t you ve select ed.
Th e sign a l t h a t s displa yed in t h e S e le c ti o n pop-u p m en u a n d in t h e S e le c tio n displa y is t h e a ct ive sign a l. Wh en you select P la y , or u se t h e r u ler s, t h e a ct ive sign a l is t h e on e t h a t is pla yed or m ea su r ed.
4 To h ea r t h e a ct ive sign a l, select P la y fr om t h e Op tio n s m en u . 5 To h ea r t h e ot h er sign a l, select it a s in st ep 3 a bove (you ca n a lso select t h e
t h e visu a l con t r a st bet ween t h e sign a ls by set t in g t h e lin e color for noise t o
5-119
Interactive Tools
gr a y a n d t h e lin e color for blnoise t o wh it e. (See Ru ler Con t r ols on pa ge 5-33 for det a ils on u sin g t h ese con t r ols.) Use t h e Sign a l Br owser pa n el in t h e P re fe re n c e s dia log box in SP Tool t o su ppr ess pr in t in g of bot h t h e pa n n er a n d t h e r u ler set t in gs. (See Sign a l Br owser Set t in gs on pa ge 5-23 for det a ils on t h ese pr efer en ces.) To pr in t bot h sign a ls, a s seen in t h e pict u r e below, select P ri n t... fr om t h e F ile m en u in t h e Sign a l Br owser .
Br owser .
2 Click on t h e noise[vector] sign a l in t h e S ig n a ls list of SP Tool t o select it .
5-120
Th e Spect r u m Viewer is a ct iva t ed, a n d a spect r u m object (spect1) cor r espon din g t o t h e noise sign a l is cr ea t ed in t h e S p e c tra list . Th e spect r u m is n ot com pu t ed or displa yed yet .
4 P r ess Ap p ly in t h e Spect r u m Viewer t o com pu t e a n d displa y spect1. Th e
Not ice t h a t t h e spect r u m s sign a l iden t ifica t ion in for m a t ion in clu din g it s n a m e, it s t ype, a n d it s sa m plin g fr equ en cy is displa yed a bove t h e P a ra m e te rs pa n el, a n d t h e spect r u m s n a m e is displa yed bot h a bove t h e m a in a xes displa y a r ea a n d in t h e S e le c tio n pop-u p m en u . Th e spect r u m est im a t e is wit h in 2 or 3 dB of 0, so t h e n oise h a s a fa ir ly fla t spect r u m .
5 Rea ct iva t e SP Tool by select in g it fr om t h e Win d o w m en u in t h e Spect r u m
Viewer .
6 Click on t h e blnoise sign a l in t h e S ig n a ls list of SP Tool t o select it .
5-121
Interactive Tools
Th e Spect r u m Viewer is a ga in a ct iva t ed, a n d a spect r u m object (spect2) cor r espon din g t o t h e blnoise sign a l is cr ea t ed in t h e S p e c tra list . Th e spect r u m is n ot com pu t ed or displa yed yet .
8 P r ess Ap p ly in t h e Spect r u m Viewer t o displa y spect2.
Th e n ew spect r u m s sign a l iden t ifica t ion in for m a t ion in clu din g it s n a m e, it s t ype, a n d it s sa m plin g fr equ en cy is displa yed a bove t h e P a ra m e te rs pa n el, a n d t h e spect r u m s n a m e is displa yed bot h a bove t h e m a in a xes displa y a r ea a n d in t h e S e le c tio n pop-u p m en u . Th is spect r u m is fla t bet ween 750 a n d 1250 H z a n d h a s 75 dB less power in t h e st opba n d r egion s of filt1.
9 Rea ct iva t e SP Tool a ga in , a s in st ep 5 a bove.
5-122
1 0 S h ift -click on spect1 a n d spect2 in t h e S p e c tra list t o select t h em bot h . 1 1 P r ess Vie w in t h e S p e c tra pa n el t o r ea ct iva t e t h e Spect r u m Viewer a n d
pop-u p m en u , or click on t h e spect r u m in t h e m a in a xes displa y a r ea . Th e color of t h e lin e in t h e S e le c tio n displa y ch a n ges t o cor r espon d t o t h e color of t h e spect r u m t h a t you ve select ed. Th e spect r u m t h a t s displa yed in t h e S e le c tio n pop-u p m en u a n d in t h e S e le c tio n displa y is t h e a ct ive spect r u m . Wh en you u se t h e r u ler s or ch a n ge pa r a m et er s, t h e a ct ive spect r u m is t h e on e t h a t is m ea su r ed or m odified.
1 3 Befor e pr in t in g t h e t wo spect r a t oget h er , u se t h e select ion a n d r u ler con t r ols
t o differ en t ia t e t h e t wo plot s by lin e st yle, r a t h er t h a n by color . Dr a g t h e r u ler s t o dem a r k t h e st opba n d edge fr equ en cies a n d ch a n ge t h e r u ler s fr om
5-123
Interactive Tools
Tra c k t o Ve rtic a l . (See Ru ler Con t r ols on pa ge 5-33 for det a ils on u sin g t h ese con t r ols.)
Select P rin t P re v i e w ... fr om t h e F i le m en u in t h e Spect r u m Viewer . F r om t h e S p e c tru m Vie w e r P rin t P re v ie w win dow, dr a g t h e legen d ou t of t h e a xes displa y a r ea so t h a t it doesn t obscu r e pa r t of t h e plot . To pr in t bot h sign a ls, a s seen in t h e pict u r e below, select t h e P rin t... bu t t on on t h e S p e c tru m Vie w e r P rin t P re v i e w win dow.
5-124
6
Refer en ce
Reference
Th is ch a pt er con t a in s det a iled descr ipt ion s of a ll Sign a l P r ocessin g Toolbox fu n ct ion s. It begin s wit h a list of fu n ct ion s gr ou ped by su bject a r ea a n d con t in u es wit h t h e r efer en ce en t r ies in a lph a bet ica l or der . F or m or e in for m a t ion , see t h e on lin e M AT L AB Fu n ction R eferen ce.
Waveform Generation and Plotting chirp diric gauspuls pulstran rectpuls sawtooth sinc square strips tripuls
Swept -fr equ en cy cosin e gen er a t or. Dir ich let or per iodic sin c fu n ct ion . Ga u ssia n -m odu la t ed sin u soida l pu lse gen er a t or. P u lse t r a in gen er a t or. Sa m pled a per iodic r ect a n gle gen er a t or. Sa wt oot h or t r ia n gle wa ve gen er a t or. Sin c fu n ct ion . Squ a r e wave gen er a t or. St r ip plot . Sa m pled a per iodic t r ia n gle gen er a t or.
Filter Analysis and Implementation abs angle conv conv2 fftfilt filter
Absolu t e va lu e (m a gn it u de). P h a se a n gle. Con volu t ion a n d polyn om ia l m u lt iplica t ion . Two-dim en sion a l con volu t ion . F F T-ba sed F IR filt er in g u sin g t h e over la p-a dd m et h od. F ilt er da t a wit h a r ecu r sive (IIR) or n on r ecu r sive (F IR) filt er.
6-2
Filter Analysis and Implementation filter2 filtfilt filtic freqs freqspace freqz grpdelay impz latcfilt sgolayfilt sosfilt unwrap zplane
Two-dim en sion a l digit a l filt er in g. Zer o-ph a se digit a l filt er in g. F in d in it ia l con dit ion s for a t r a n sposed dir ect for m II filt er im plem en t a t ion . F r equ en cy r espon se of a n a log filt er s. F r equ en cy spa cin g for fr equ en cy r espon se. F r equ en cy r espon se of digit a l filt er s. Aver a ge filt er delay (gr ou p delay). Im pu lse r espon se of digit a l filt er s. La t t ice a n d la t t ice-la dder filt er im plem en t a t ion . Savit zky-Gola y filt er in g. Secon d-or der (biqu a dr a t ic) IIR filt er in g. Un wr a p ph a se a n gles. Zer o-pole plot .
Con ver sion of a u t ocor r ela t ion sequ en ce t o pr edict ion polyn om ia l. Con ver sion of a u t ocor r ela t ion sequ en ce t o r eflect ion coefficien t s. Con volu t ion m a t r ix. La t t ice filt er t o t r a n sfer fu n ct ion con ver sion .
6-3
Reference
Linear System Transformations poly2ac poly2rc rc2ac rc2poly residuez sos2ss sos2tf sos2zp ss2sos ss2tf ss2zp tf2latc tf2sos tf2ss tf2zp zp2sos zp2ss zp2tf
Con ver sion of pr edict ion polyn om ia l t o a u t ocor r ela t ion sequ en ce. Con ver sion of pr edict ion polyn om ia l t o r eflect ion coefficien t s. Con ver sion of r eflect ion coefficien t s t o a u t ocor r ela t ion sequ en ce. Con ver sion of r eflect ion coefficien t s t o pr edict ion polyn om ia l. z-t r a n sfor m pa r t ia l-fr a ct ion expa n sion . Con ver sion of secon d-or der sect ion s t o st a t e-spa ce. Con ver sion of secon d-or der sect ion s t o t r a n sfer fu n ct ion . Con ver sion of secon d-or der sect ion s t o zer o-pole-ga in . Con ver sion of st a t e-spa ce t o secon d-or der sect ion s. Con ver sion of st a t e-spa ce t o t r a n sfer fu n ct ion . Con ver sion of st a t e-spa ce t o zer o-pole-ga in . Con ver sion of t r a n sfer fu n ct ion t o la t t ice filt er. Con ver sion of t r a n sfer fu n ct ion t o secon d-or der sect ion s. Con ver sion of t r a n sfer fu n ct ion t o st a t e-spa ce. Con ver sion of t r a n sfer fu n ct ion t o zer o-pole-ga in . Con ver sion of zer o-pole-ga in t o secon d-or der sect ion s. Con ver sion of zer o-pole-ga in t o st a t e-spa ce. Con ver sion of zer o-pole-ga in t o t r a n sfer fu n ct ion .
6-4
IIR Filter DesignClassical and Direct besself butter cheby1 cheby2 ellip maxflat yulewalk
Bessel a n a log filt er design . Bu t t er wor t h a n a log a n d digit a l filt er design . Ch ebysh ev t ype I filt er design (pa ssba n d r ipple). Ch ebysh ev t ype II filt er design (st opba n d r ipple). E llipt ic (Ca u er ) filt er design . Gen er a lized digit a l Bu t t er wor t h filt er design . Recu r sive digit a l filt er design .
Bu t t er wor t h filt er or der select ion . Ch ebysh ev t ype I filt er or der select ion . Ch ebysh ev t ype II filt er or der select ion . E llipt ic filt er or der select ion .
Com plex a n d n on lin ea r-ph a se equ ir ipple F IR filt er design . Win dow-ba sed fin it e im pu lse r espon se filt er design st a n da r d r espon se. Win dow-ba sed fin it e im pu lse r espon se filt er design a r bit r a r y r espon se. Con st r a in ed lea st squ a r e F IR filt er design for m u lt iba n d filt er s.
6-5
Reference
FIR Filter Design fircls1 firls firrcos intfilt kaiserord remez remezord sgolay
Con st r a in ed lea st squ a r e filt er design for lowpa ss a n d h igh pa ss lin ea r ph a se F IR filt er s. Lea st squ a r e lin ea r-ph a se F IR filt er design . Ra ised cosin e F IR filt er design . In t er pola t ion F IR filt er design . E st im a t e pa r a m et er s for a n F IR filt er design wit h Ka iser win dow. Pa r ks-McClella n opt im a l F IR filt er design . Pa r ks-McClella n opt im a l F IR filt er or der est im a t ion . Sa vit zk y-Golay filt er design .
Transforms czt dct dftmtx fft fft2 fftshift hilbert idct ifft ifft2
Ch ir p z-t r a n sfor m . Discr et e cosin e t r a n sfor m (DCT). Discr et e Fou r ier t r a n sfor m m a t r ix. On e-dim en sion a l fa st Fou r ier t r a n sfor m . Two-dim en sion a l fa st Fou r ier t r a n sfor m . Rea r r a n ge t h e ou t pu t s of t h e F F T fu n ct ion s. H ilber t t r a n sfor m . In ver se discr et e cosin e t r a n sfor m . On e-dim en sion a l in ver se fa st Fou r ier t r a n sfor m . Two-dim en sion a l in ver se fa st Fou r ier t r a n sfor m .
6-6
Statistical Signal Processing cohere corrcoef cov csd pburg pcov pmcov pmtm pmusic pwelch pyulear tfe xcorr xcorr2 xcov
E st im a t e m a gn it u de squ a r ed coh er en ce fu n ct ion bet ween t wo sign a ls. Cor r ela t ion coefficien t m a t r ix. Cova r ia n ce m a t r ix. E st im a t e t h e cr oss spect r a l den sit y (CSD) of t wo sign a ls. Power spect r u m est im a t e u sin g t h e Bu r g m et h od. Power spect r u m est im a t e u sin g t h e cova r ia n ce m et h od. Power spect r u m est im a t e u sin g t h e m odified cova r ia n ce m et h od. Power spect r u m est im a t e u sin g t h e m u lt it a per m et h od (MTM). Power spect r u m est im a t e u sin g MUSIC eigen vect or m et h od. E st im a t e t h e power spect r a l den sit y (P SD) of a sign a l u sin g Welch s m et h od. Power spect r u m est im a t e u sin g Yu le-Wa lker AR m et h od. Tr a n sfer fu n ct ion est im a t e fr om in pu t a n d ou t pu t . Cr oss-cor r ela t ion fu n ct ion est im a t e. Two-dim en sion a l cr oss-cor r ela t ion . Cr oss-cova r ia n ce fu n ct ion est im a t e (equ a l t o m ea n -r em oved cr oss-cor r ela t ion ).
6-7
Reference
Ba r t let t win dow. Bla ckm a n win dow. Rect a n gu la r win dow. Ch ebysh ev win dow. H a m m in g win dow. H a n n in g win dow. Ka iser win dow. Tr ia n gu la r win dow.
Parametric Modeling arburg arcov armcov aryule invfreqs invfreqz levinson lpc prony
Com pu t e a n est im a t e of AR m odel pa r a m et er s u sin g t h e Bu r g m et h od. Com pu t e a n est im a t e of AR m odel pa r a m et er s u sin g t h e cova r ia n ce m et h od. Com pu t e a n est im a t e of AR m odel pa r a m et er s u sin g t h e m odified cova r ia n ce m et h od. Com pu t e a n est im a t e of AR m odel pa r a m et er s u sin g t h e Yu le-Wa lk er m et h od. Con t in u ou s-t im e (a n a log) filt er iden t ifica t ion fr om fr equ en cy da t a . Discr et e-t im e filt er iden t ifica t ion fr om fr equ en cy da t a . Levin son -Du r bin r ecu r sion . Lin ea r pr edict ion coefficien t s. P r on ys m et h od for t im e dom a in IIR filt er design .
6-8
Rever se Levin son -Du r bin r ecu r sion . Lin ea r m odel u sin g St eiglit z-McBr ide it er a t ion .
Specialized Operations buffer cceps cplxpair decimate deconv demod dpss dpssclear dpssdir dpssload dpsssave icceps interp medfilt1 modulate polystab rceps
Bu ffer a sign a l vect or in t o a m a t r ix of da t a fr a m es. Com plex cepst r a l a n a lysis. Gr ou p com plex n u m ber s in t o com plex con ju ga t e pa ir s. Decr ea se t h e sa m plin g r a t e for a sequ en ce (decim a t ion ). Decon volu t ion a n d polyn om ia l division . Dem odu la t ion for com m u n ica t ion s sim u la t ion . Discr et e pr ola t e sph er oida l sequ en ces (Slepia n sequ en ces). Rem ove discr et e pr ola t e sph er oida l sequ en ces fr om da t a ba se. Discr et e pr ola t e sph er oida l sequ en ces da t a ba se dir ect or y. Loa d discr et e pr ola t e sph er oida l sequ en ces fr om da t a ba se. Save discr et e pr ola t e sph er oida l sequ en ces in da t a ba se. In ver se com plex cepst r u m . In cr ea se sa m plin g r a t e by a n in t eger fa ct or (in t er pola t ion ). On e-dim en sion a l m edia n filt er in g. Modu la t ion for com m u n ica t ion s sim u la t ion . St a bilize polyn om ia l. Rea l cepst r u m a n d m in im u m ph a se r econ st r u ct ion .
6-9
Reference
Ch a n ge sa m plin g r a t e by a n y r a t ion a l fa ct or. Tim e-depen den t fr equ en cy a n a lysis (spect r ogr a m ). Upsa m ple, a pply a n F IR filt er, a n d down sa m ple. Volt a ge con t r olled oscilla t or.
Bessel a n a log lowpa ss filt er pr ot ot ype. Bu t t er wor t h a n a log lowpa ss filt er pr ot ot ype. Ch ebysh ev t ype I a n a log lowpa ss filt er pr ot ot ype. Ch ebysh ev t ype II a n a log lowpa ss filt er pr ot ot ype. E llipt ic a n a log lowpa ss filt er pr ot ot ype.
Lowpa ss t o ba n dpa ss a n a log filt er t r a n sfor m a t ion . Lowpa ss t o ba n dst op a n a log filt er t r a n sfor m a t ion . Lowpa ss t o h igh pa ss a n a log filt er t r a n sfor m a t ion . Lowpa ss t o lowpa ss a n a log filt er t r a n sfor m a t ion .
6-10
Bilin ea r t r a n sfor m a t ion m et h od of a n a log-t o-digit a l filt er con ver sion . Im pu lse in va r ia n ce m et h od of a n a log-t o-digit a l filt er con ver sion .
6-11
abs
Purpose Syntax Description
6a bs
Absolu t e va lu e (m a gn it u de).
y = abs(x) y = abs(x) r et u r n s t h e a bsolu t e va lu e of t h e elem en t s of x. If x is com plex, abs
If x is a MATLAB st r in g, abs r et u r n s t h e n u m er ic va lu es of t h e ASCII ch a r a ct er s in t h e st r in g. Th e displa y for m a t of t h e st r in g ch a n ges; t h e in t er n a l r epr esen t a t ion does n ot . Th e abs fu n ct ion is pa r t of t h e st a n da r d MATLAB la n gu a ge.
Example
P lot t h e m a gn it u de:
f = (0:length(y)1)'/length(y)*100; plot(f,m) % frequency vector
See Also
angle
P h a se a n gle.
6-12
ac2poly
Purpose Syntax Description
6a c2poly
Con ver sion of a u t ocor r ela t ion sequ en ce t o pr edict ion polyn om ia l.
a = ac2poly(r) [a,efinal] = ac2poly(r) a = ac2poly(r) fin ds t h e pr edict ion polyn om ia l, a, cor r espon din g t o t h e a u t ocor r ela t ion sequ en ce r. a is t h e sa m e len gt h a s r, a n d a(1) = 1. [a,efinal] = ac2poly(r) r et u r n s t h e fin a l pr edict ion er r or , efinal.
Example
See Also
Con ver sion of a u t ocor r ela t ion sequ en ce t o r eflect ion coefficien t s. Con ver sion of pr edict ion polyn om ia l t o a u t ocor r ela t ion sequ en ce. Con ver sion of pr edict ion polyn om ia l t o r eflect ion coefficien t s.
References
[1] Ka y, S.M. M od ern S pectral E stim ation . E n glewood Cliffs, NJ : P r en t ice-H a ll, 1988.
6-13
ac2rc
Purpose Syntax Description See Also
6a c2rc
Con ver sion of a u t ocor r ela t ion sequ en ce t o r eflect ion coefficien t s.
[k,r0] = ac2rc(r) [k,r0] = ac2rc(r) fin ds t h e r eflect ion coefficien t s, k, cor r espon din g t o t h e a u t ocor r ela t ion sequ en ce r. r0 con t a in s t h e zer o-la g a u t ocor r ela t ion . ac2poly poly2rc rc2ac
Con ver sion of a u t ocor r ela t ion sequ en ce t o pr edict ion polyn om ia l. Con ver sion of pr edict ion polyn om ia l t o r eflect ion coefficien t s. Con ver sion of r eflect ion coefficien t s t o a u t ocor r ela t ion sequ en ce.
References
[1] Ka y, S.M. M od ern S pectral E stim ation . E n glewood Cliffs, NJ : P r en t ice-H a ll, 1988.
6-14
angle
Purpose Syntax Description
6a n gle
P h a se a n gle.
p = angle(h) p = angle(h) r et u r n s t h e ph a se a n gles, in r a dia n s, of t h e elem en t s of com plex vect or or a r r a y h. Th e ph a se a n gles lie bet ween -$ a n d $.
Example
P lot t h e ph a se:
f = (0:length(y)1)'/length(y)*100; plot(f,p) % frequency vector
Algorithm
See Also
abs
Absolu t e va lu e (m a gn it u de).
6-15
arburg
Purpose Syntax
6a r bu r g
Description
e e H ( z ) = ----------- = --------------------------------------------------------------------1 p A (z ) 1 + a 2 z + + a (p + 1 )z Sin ce t h e m et h od ch a r a ct er izes t h e in pu t da t a u sin g a n a ll-pole m odel, t h e cor r ect ch oice of t h e m odel or der p is im por t a n t .
[a,e] = arburg(x,p) r et u r n s t h e va r ia n ce est im a t e, e, of t h e wh it e n oise
in pu t t o t h e AR m odel.
[a,e,k] = arburg(x,p) r et u r n s a vect or , k, of r eflect ion coefficien t s.
See Also
Com pu t e a n est im a t e of AR m odel pa r a m et er s u sin g t h e cova r ia n ce m et h od. Com pu t e a n est im a t e of AR m odel pa r a m et er s u sin g t h e m odified cova r ia n ce m et h od. Com pu t e a n est im a t e of AR m odel pa r a m et er s u sin g t h e Yu le-Wa lker m et h od. Lin ea r pr edict ion coefficien t s. Power spect r u m est im a t e u sin g t h e Bu r g m et h od. P r on ys m et h od for t im e dom a in IIR filt er design .
6-16
arcov
Purpose Syntax Description
6a r cov
syst em dr iven by wh it e n oise. Th is m et h od m in im izes t h e for wa r d pr edict ion er r or in t h e lea st -squ a r es sen se. Vect or a con t a in s t h e n or m a lized est im a t e of t h e AR syst em pa r a m et er s, A (z ), in descen din g power s of z . e e H ( z ) = ----------- = --------------------------------------------------------------------1 p A (z ) 1 + a 2 z + + a (p + 1 )z Beca u se t h e m et h od ch a r a ct er izes t h e in pu t da t a u sin g a n a ll-pole m odel, t h e cor r ect ch oice of t h e m odel or der p is im por t a n t .
[a,e] = arcov(x,p) r et u r n s t h e va r ia n ce est im a t e, e, of t h e wh it e n oise in pu t
t o t h e AR m odel.
See Also
Com pu t e a n est im a t e of AR m odel pa r a m et er s u sin g t h e Bu r g m et h od. Com pu t e a n est im a t e of AR m odel pa r a m et er s u sin g t h e m odified cova r ia n ce m et h od. Com pu t e a n est im a t e of AR m odel pa r a m et er s u sin g t h e Yu le-Wa lker m et h od. Lin ea r pr edict ion coefficien t s. Power spect r u m est im a t e u sin g t h e cova r ia n ce m et h od. P r on ys m et h od for t im e dom a in IIR filt er design .
6-17
armcov
Purpose Syntax Description
6a r m cov
e e H ( z ) = ----------- = --------------------------------------------------------------------1 p A (z ) 1 + a 2 z + + a (p + 1 )z Beca u se t h e m et h od ch a r a ct er izes t h e in pu t da t a u sin g a n a ll-pole m odel, t h e cor r ect ch oice of t h e m odel or der p is im por t a n t .
[a,e] = armcov(x,p) r et u r n s t h e va r ia n ce est im a t e, e, of t h e wh it e n oise
in pu t t o t h e AR m odel.
See Also
Com pu t e a n est im a t e of AR m odel pa r a m et er s u sin g t h e Bu r g m et h od. Com pu t e a n est im a t e of AR m odel pa r a m et er s u sin g t h e cova r ia n ce m et h od. Com pu t e a n est im a t e of AR m odel pa r a m et er s u sin g t h e Yu le-Wa lker m et h od. Lin ea r pr edict ion coefficien t s. Power spect r u m est im a t e u sin g t h e m odified cova r ia n ce m et h od. P r on ys m et h od for t im e dom a in IIR filt er design .
6-18
aryule
Purpose Syntax
6a r yu le
Description
e e H ( z ) = ----------- = --------------------------------------------------------------------1 p A (z ) 1 + a 2 z + + a (p + 1 )z Beca u se t h e m et h od ch a r a ct er izes t h e in pu t da t a u sin g a n a ll-pole m odel, t h e cor r ect ch oice of t h e m odel or der p is im por t a n t .
[a,e] = aryule(x,p) r et u r n s t h e va r ia n ce est im a t e, e, of t h e wh it e n oise
in pu t t o t h e AR m odel.
[a,e,k] = aryule(x,p) r et u r n s a vect or , k, of r eflect ion coefficien t s.
See Also
Com pu t e a n est im a t e of AR m odel pa r a m et er s u sin g t h e Bu r g m et h od. Com pu t e a n est im a t e of AR m odel pa r a m et er s u sin g t h e cova r ia n ce m et h od. Com pu t e a n est im a t e of AR m odel pa r a m et er s u sin g t h e m odified cova r ia n ce m et h od. Lin ea r pr edict ion coefficien t s. P r on ys m et h od for t im e dom a in IIR filt er design . Power spect r u m est im a t e u sin g Yu le-Wa lker AR m et h od.
6-19
bartlett
Purpose Syntax Description
6ba r tlet t
Th e coefficien t s of a Ba r t let t win dow a r e: F or n odd (k 1 ) (2 --------------------, & n 1 w [k ] = ' (k 1 ) &2 2 --------------------, % n 1 F or n even (k 1 ) (2 --------------------, & n 1 w [k ] = ' (n k ) &2 --------------------, % n 1 n 1 5 k 5 -2 n --+15k 5n 2 n +1 1 5 k 5 -----------2 n +1 ------------5k 5n 2
Th e Ba r t let t win dow is ver y sim ila r t o a t r ia n gu la r win dow a s r et u r n ed by t h e triang fu n ct ion . Th e Ba r t let t win dow a lwa ys en ds wit h zer os a t sa m ples 1 a n d n, h owever , wh ile t h e t r ia n gu la r win dow is n on zer o a t t h ose poin t s. F or n odd, t h e cen t er n2 poin t s of bartle9tt(n) a r e equ iva len t t o triang(n2).
See Also
Bla ck m a n win dow. Rect a n gu la r win dow. Ch ebysh ev win dow. H a m m in g win dow. H a n n in g win dow. Ka iser win dow. Tr ia n gu la r win dow.
References
[1] Oppen h eim , A.V., a n d R.W. Sch a fer . Discrete-T im e S ign al Processin g. E n glewood Cliffs, NJ : P r en t ice-H a ll, 1989.
6-20
besselap
Purpose Syntax Description
6bessela p
[z,p,k] = besselap(n) [z,p,k] = besselap(n) r et u r n s t h e zer os, poles, a n d ga in of a n or der n Bessel a n a log lowpa ss filt er pr ot ot ype. It r et u r n s t h e poles in t h e len gt h n colu m n vect or p a n d t h e ga in in sca la r k. z is a n em pt y m a t r ix, beca u se t h er e a r e n o zer os. n m u st be less t h a n or equ a l t o 25. Th e t r a n sfer fu n ct ion is
k H (s ) = ---------------------------------------------------------------------------( s p (1 ) ) ( s p (2 ) ) L ( s p (n ) )
besselap n or m a lizes t h e poles a n d ga in so t h a t a t low fr equ en cy a n d h igh fr equ en cy t h e Bessel pr ot ot ype is a sym pt ot ica lly equ iva len t t o t h e Bu t t er wor t h pr ot ot ype of t h e sa m e or der [1]. Th e m a gn it u de of t h e filt er is less t h a n sqrt(1/2) a t t h e u n it y cu t off fr equ en cy "c = 1.
An a log Bessel filt er s a r e ch a r a ct er ized by a gr ou p dela y t h a t is m a xim a lly fla t a t zer o fr equ en cy a n d a lm ost con st a n t t h r ou gh ou t t h e pa ssba n d. Th e gr ou p dela y a t zer o fr equ en cy is ( 2 n )!4 3 ------------1 2nn!2
1 n
besselap fin ds t h e filt er r oot s fr om a look-u p t a ble con st r u ct ed u sin g t h e Sym bolic Ma t h Toolbox. besself buttap cheb1ap cheb2ap ellipap
Bessel a n a log filt er design . Bu t t er wor t h a n a log lowpa ss filt er pr ot ot ype. Ch ebysh ev t ype I a n a log lowpa ss filt er pr ot ot ype. Ch ebysh ev t ype II a n a log lowpa ss filt er pr ot ot ype. E llipt ic a n a log lowpa ss filt er pr ot ot ype.
References
[1] Ra bin er , L.R., a n d B. Gold. T h eory an d Application of Digital S ign al Processin g. E n glewood Cliffs, NJ : P r en t ice-H a ll, 1975. P gs. 228-230.
6-21
besself
Purpose Syntax
6besself
Description
B (s ) b (1 ) s n + b (2 ) s n 1 + L + b (n + 1 ) H (s ) = ---------- = --------------------------------------------------------------------------------n n 1 A (s ) +L + a (n + 1 ) s + a (2 ) s Cu toff frequ en cy is t h e fr equ en cy a t wh ich t h e m a gn it u de r espon se of t h e filt er begin s t o decr ea se sign ifica n t ly. F or besself, t h e cu t off fr equ en cy Wn m u st be gr ea t er t h a n 0. Th e m a gn it u de r espon se of a Bessel filt er design ed by besself is a lwa ys less t h a n sqrt(1/2) a t t h e cu t off fr equ en cy, a n d it decr ea ses a s t h e or der n in cr ea ses. If Wn is a t wo-elem en t vect or , Wn = [w1 w2] wit h w1 < w2, besself(n,Wn) r et u r n s a n or der 2*n ba n dpa ss a n a log filt er wit h pa ssba n d w1 < # < w2.
[b,a] = besself(n,Wn,'ftype') design s a h igh pa ss or ba n dst op filt er , wh er e ftype is
high for a h igh pa ss a n a log filt er wit h cu t off fr equ en cy Wn stop for a n or der 2*n ba n dst op a n a log filt er if Wn is a t wo-elem en t vect or ,
Wn = [w1 w2]
Th e st opba n d is w1 < # < w2. Wit h differ en t n u m ber s of ou t pu t a r gu m en t s, besself dir ect ly obt a in s ot h er r ea liza t ion s of t h e a n a log filt er . To obt a in zer o-pole-ga in for m , u se t h r ee ou t pu t a r gu m en t s:
6-22
besself
[z,p,k] = besself(n,Wn) or [z,p,k] = besself(n,Wn,'ftype') besself r et u r n s t h e zer os a n d poles in len gt h n or 2*n colu m n vect or s z a n d p a n d t h e ga in in t h e sca la r k.
x = Ax + Bu y = Cx + Du a n d u is t h e in pu t , x is t h e st a t e vect or , a n d y is t h e ou t pu t .
Example
Design a fift h -or der a n a log lowpa ss Bessel filt er t h a t su ppr esses fr equ en cies gr ea t er t h a n 10,000 r a d/sec a n d plot t h e fr equ en cy r espon se of t h e filt er u sin g freqs:
[b,a] = besself(5,10000); freqs(b,a)
10
0
Frequency Response
Magnitude
10
-5 2
10
10
10 Frequency (radians)
10
200
Phase (degrees)
-200 2 10
10
10 Frequency (radians)
10
6-23
besself
Limitations
Lowpa ss Bessel filt er s h a ve a m on ot on ica lly decr ea sin g m a gn it u de r espon se, a s do lowpa ss Bu t t er wor t h filt er s. Com pa r ed t o t h e Bu t t er wor t h , Ch ebysh ev, a n d ellipt ic filt er s, t h e Bessel filt er h a s t h e slowest r olloff a n d r equ ir es t h e h igh est or der t o m eet a n a t t en u a t ion specifica t ion . F or h igh or der filt er s, t h e st a t e-spa ce for m is t h e m ost n u m er ica lly a ccu r a t e, followed by t h e zer o-pole-ga in for m . Th e t r a n sfer fu n ct ion coefficien t for m is t h e lea st a ccu r a t e; n u m er ica l pr oblem s ca n a r ise for filt er or der s a s low a s 15.
Algorithm
fu n ct ion .
2 It con ver t s t h e poles, zer os, a n d ga in in t o st a t e-spa ce for m . 3 It t r a n sfor m s t h e lowpa ss filt er in t o a ba n dpa ss, h igh pa ss, or ba n dst op filt er
See Also
Bessel a n a log lowpa ss filt er pr ot ot ype. Bu t t er wor t h a n a log a n d digit a l filt er design . Ch ebysh ev t ype I filt er design (pa ssba n d r ipple). Ch ebysh ev t ype II filt er design (st opba n d r ipple). E llipt ic (Ca u er ) filt er design .
6-24
bilinear
Purpose Syntax
6bilin ea r
Description
Th e bilin ear tran sform ation is a m a t h em a t ica l m a ppin g of va r ia bles. In digit a l filt er in g, it is a st a n da r d m et h od of m a ppin g t h e s or a n a log pla n e in t o t h e z or digit a l pla n e. It t r a n sfor m s a n a log filt er s, design ed u sin g cla ssica l filt er design t ech n iqu es, in t o t h eir discr et e equ iva len t s. Th e bilin ea r t r a n sfor m a t ion m a ps t h e s -pla n e in t o t h e z -pla n e by H (z ) = H (s )
z 1 s = 2 f s ----------z +1
Th is t r a n sfor m a t ion m a ps t h e j " a xis (fr om " = -* t o + *) r epea t edly a r ou n d t h e u n it cir cle (exp(j #), fr om # = >$ t o $) by "4 # = 2 t a n 1 3 ------1 2 f s2
bilinear ca n a ccept a n opt ion a l pa r a m et er Fp t h a t specifies pr ewa r pin g. Fp, in
H er t z, in dica t es a m a t ch fr equ en cy, t h a t is, a fr equ en cy for wh ich t h e fr equ en cy r espon ses befor e a n d a ft er m a ppin g m a t ch exa ct ly. In pr ewa r ped m ode, t h e bilin ea r t r a n sfor m a t ion m a ps t h e s -pla n e in t o t h e z -pla n e wit h H (z ) = H (s )
2 $f p (z 1 ) - ---------------s = ----------------------f p4 (z + 1 ) t a n 3 $ --1 f s2
6-25
bilinear
Wit h t h e pr ewa r pin g opt ion , bilinear m a ps t h e j " a xis (fr om " = -* t o + *) r epea t edly a r ou n d t h e u n it cir cle (exp(j #), fr om # = >$ t o $) by fp 44 3 " t a n 3 $ ---1 fs2: 9 # = 2 t a n 1 9 ---------------------------2 $f p : 9 : 1 2 In pr ewa r ped m ode, bilinear m a t ch es t h e fr equ en cy 2 $f p (in r a dia n s per secon d) in t h e s -pla n e t o t h e n or m a lized fr equ en cy 2 $f p/f s (in r a dia n s per secon d) in t h e z -pla n e. Th e bilinear fu n ct ion wor ks wit h t h r ee differ en t lin ea r syst em r epr esen t a t ion s: zer o-pole-ga in , t r a n sfer fu n ct ion , a n d st a t e-spa ce for m .
Zero-Pole-Gain
[zd,pd,kd] = bilinear(z,p,k,Fs) a n d [zd,pd,kd] = bilinear(z,p,k,Fs,Fp) con ver t t h e s -dom a in t r a n sfer fu n ct ion specified by z, p, a n d k t o a discr et e equ iva len t . In pu t s z a n d p a r e colu m n vect or s con t a in in g t h e zer os a n d poles, a n d k is a sca la r ga in . Fs is t h e sa m plin g fr equ en cy in H er t z. bilinear r et u r n s t h e discr et e equ iva len t in colu m n vect or s zd a n d pd a n d sca la r kd. Fp is t h e opt ion a l m a t ch fr equ en cy, in H er t z, for pr ewa r pin g.
Transfer Function
[numd,dend] = bilinear(num,den,Fs) a n d [numd,dend] = bilinear(num,den,Fs,Fp) con ver t a n s -dom a in t r a n sfer fu n ct ion given by num a n d den t o a discr et e equ iva len t . Row vect or s num a n d den specify t h e coefficien t s of t h e n u m er a t or a n d den om in a t or , r espect ively, in descen din g power s of s
+ n u m (n n ) s + n u m (n n + 1 ) n u m (s ) n u m (1 ) s n n + L ------------------- = -----------------------------------------------------------------------------------------------------------------d en (s ) + d en (n d ) s + d en (n d + 1 ) d en (1 ) s n d + L
6-26
bilinear
Fs is t h e sa m plin g fr equ en cy in H er t z. bilinear r et u r n s t h e discr et e equ iva len t in r ow vect or s numd a n d dend in descen din g power s of z (a scen din g power s of z -1 ). Fp is t h e opt ion a l m a t ch fr equ en cy, in H er t z, for pr ewa r pin g.
State-Space
[Ad,Bd,Cd,Dd] = bilinear(A,B,C,D,Fs) a n d [Ad,Bd,Cd,Dd] = bilinear(A,B,C,D,Fs,Fp) con ver t t h e con t in u ou s-t im e
Fs is t h e sa m plin g fr equ en cy in H er t z. bilinear r et u r n s t h e discr et e equ iva len t in m a t r ices Ad, Bd, Cd, Dd. Fp is t h e opt ion a l m a t ch fr equ en cy, in H er t z, for pr ewa r pin g.
Algorithm
bilinear u ses on e of t wo a lgor it h m s, depen din g on t h e for m a t of t h e in pu t lin ea r syst em you su pply. On e a lgor it h m wor ks on t h e zer o-pole-ga in for m a t a n d t h e ot h er on t h e st a t e-spa ce for m a t . F or t r a n sfer fu n ct ion r epr esen t a t ion s, bilinear con ver t s t o st a t e-spa ce for m , per for m s t h e t r a n sfor m a t ion , a n d con ver t s t h e r esu lt in g st a t e-spa ce syst em ba ck t o t r a n sfer fu n ct ion for m .
Zero-Pole-Gain Algorithm
F or a syst em in zer o-pole-ga in for m , bilinear per for m s fou r st eps:
1 If Fp is pr esen t , k = 2*pi*Fp/tan(pi*Fp/Fs); ot h er wise k = 2*Fs. 2 It st r ips a n y zer os a t plu s or m in u s in fin it y u sin g
z = z(find(finite(z)));
6-27
bilinear
3 It t r a n sfor m s t h e zer os, poles, a n d ga in u sin g
a n d den om in a t or or der .
State-Space Algorithm
F or a syst em in st a t e-spa ce for m , bilinear per for m s t wo st eps:
1 If Fp is pr esen t , k = 2*pi*Fp/tan(pi*Fp/Fs); else k = 2*Fs. 2 It com pu t es Ad, Bd, Cd, a n d Dd in t er m s of A, B, C, a n d D u sin g
B
1
1 4 3 3 14 4 1 - C I -- A D d = 3 -B +D 1k2 1 1k2 2
bilinear im plem en t s t h ese r ela t ion s u sin g con ven t ion a l MATLAB st a t em en t s. Th e sca la r r is a r bit r a r y; bilinear u ses sqrt(2/k) t o en su r e good
Diagnostics
bilinear r equ ir es t h a t t h e n u m er a t or or der be n o gr ea t er t h a n t h e den om in a t or or der . If t h is is n ot t h e ca se, bilinear displa ys: Numerator cannot be higher order than denominator.
F or bilinear t o dist in gu ish bet ween t h e zer o-pole-ga in a n d t r a n sfer fu n ct ion lin ea r syst em for m a t s, t h e fir st t wo in pu t pa r a m et er s m u st be vect or s wit h t h e sa m e or ien t a t ion in t h ese ca ses. If t h is is n ot t h e ca se, bilinear displa ys:
First two arguments must have the same orientation.
6-28
bilinear
See Also
Im pu lse in va r ia n ce m et h od of a n a log-t o-digit a l filt er con ver sion . Lowpa ss t o ba n dpa ss a n a log filt er t r a n sfor m a t ion . Lowpa ss t o ba n dst op a n a log filt er t r a n sfor m a t ion . Lowpa ss t o h igh pa ss a n a log filt er t r a n sfor m a t ion . Lowpa ss t o lowpa ss a n a log filt er t r a n sfor m a t ion .
References
[1] P a r ks, T.W., a n d C.S. Bu r r u s. Digital Filter Design . New Yor k: J oh n Wiley & Son s, 1987. P gs. 209-213. [2] Oppen h eim , A.V., a n d R.W. Sch a fer . Discrete-T im e S ign al Processin g. E n glewood Cliffs, NJ : P r en t ice-H a ll, 1989. P gs. 415-430.
6-29
blackman
Purpose Syntax Description
6bla ck m a n
equ a t ion for a Bla ck m a n win dow is k 14 k 14 - + 0.08 cos 3 4 $ ------------ , w [ k ] = 0.42 0.5 cos 3 2 $ -----------1 n 12 1 n 12 k = 1 , , n
Bla ckm a n win dows h a ve sligh t ly wider cen t r a l lobes a n d less sideba n d lea k a ge t h a n equ iva len t len gt h H a m m in g a n d H a n n in g win dows.
w = blackman(n,sflag) r et u r n s a n n-poin t Bla ck m a n win dow u sin g t h e win dow sa m plin g specified by sflag, wh ich ca n be eit h er 'periodic' or 'symmetric' (t h e defa u lt ). Wh en 'periodic' is specified, blackman com pu t es a len gt h n+1 win dow a n d r et u r n s t h e fir st n poin t s.
Algorithm Diagnostics
6-30
blackman
See Also
Ba r t let t win dow. Rect a n gu la r win dow. Ch ebysh ev win dow. H a m m in g win dow. H a n n in g win dow. Ka iser win dow. Tr ia n gu la r win dow.
References
[1] Oppen h eim , A.V., a n d R.W. Sch a fer . Discrete-T im e S ign al Processin g. E n glewood Cliffs, NJ : P r en t ice-H a ll, 1989.
6-31
boxcar
Purpose Syntax Description
6boxca r
Ba r t let t win dow. Bla ck m a n win dow. Ch ebysh ev win dow. H a m m in g win dow. H a n n in g win dow. Ka iser win dow. Tr ia n gu la r win dow.
References
[1] Oppen h eim , A.V., a n d R.W. Sch a fer . Discrete-T im e S ign al Processin g. E n glewood Cliffs, NJ : P r en t ice-H a ll, 1989.
6-32
buffer
Purpose Syntax
6bu ffer
Description
F or 0< p< n (over la p), buffer r epea t s t h e fin a l p sa m ples of ea ch fr a m e a t t h e begin n in g of t h e followin g fr a m e. F or exa m ple, if x=1:30 a n d n=7, a n over la p of p=3 looks lik e t h is:
y = 0 0 0 1 2 3 4 2 3 4 5 6 7 8 6 7 8 9 10 11 12 10 11 12 13 14 15 16 14 15 16 17 18 19 20 18 19 20 21 22 23 24 22 23 24 25 26 27 28 26 27 28 29 30 0 0
Th e fir st fr a m e st a r t s wit h p zer os (t h e defa u lt in it ia l con dit ion ), a n d t h e n u m ber of colu m n s in y is ceil(L/(np)).
6-33
buffer
F or p< 0 (u n der la p), buffer skips p sa m ples bet ween con secu t ive fr a m es. F or exa m ple, if x=1:30 a n d n=7, a bu ffer wit h u n der la p of p=3 looks lik e t h is:
y = 1 2 3 4 5 6 7 11 12 13 14 15 16 17 21 22 23 24 25 26 27
skipped
8 9 10
18 19 20
28 29 30
F or 0< p< n (over la p), opt specifies a len gt h -p vect or t o in ser t befor e x(1) in t h e bu ffer . Th is vect or ca n be con sider ed a n in itial con d ition , wh ich is n eeded wh en t h e cu r r en t bu ffer in g oper a t ion is on e in a sequ en ce of con secu t ive bu ffer in g oper a t ion s. To m a in t a in t h e desir ed fr a m e over la p fr om on e bu ffer t o t h e n ext , opt sh ou ld con t a in t h e fin a l p sa m ples of t h e pr eviou s bu ffer in t h e sequ en ce. See Con t in u ou s Bu ffer in g below. By defa u lt , opt is zeros(p,1) for a n over la ppin g bu ffer . Set opt t o 'nodelay' t o sk ip t h e in it ia l con dit ion a n d begin fillin g t h e bu ffer im m edia t ely wit h x(1). In t h is ca se, L m u st be length(p) or lon ger . F or exa m ple, if x=1:30 a n d n=7, a bu ffer wit h over la p of p=3 look s like t h is:
y = 1 2 3 4 5 6 7 5 6 7 8 9 10 11 9 10 11 12 13 14 15 13 14 15 16 17 18 19 17 18 19 20 21 22 23 21 22 23 24 25 26 27 25 26 27 28 29 30 0
F or p< 0 (u n der la p), opt is a n in t eger va lu e in t h e r a n ge [0,p] specifyin g t h e n u m ber of in it ia l in pu t sa m ples, x(1:opt), t o sk ip befor e a ddin g sa m ples t o
6-34
buffer
t h e bu ffer . Th e fir st va lu e in t h e bu ffer is t h er efor e x(opt+1). By defa u lt , opt is zer o for a n u n der la ppin g bu ffer . Th is opt ion is especia lly u sefu l wh en t h e cu r r en t bu ffer in g oper a t ion is on e in a sequ en ce of con secu t ive bu ffer in g oper a t ion s. To m a in t a in t h e desir ed fr a m e u n der la p fr om on e bu ffer t o t h e n ext , opt sh ou ld equ a l t h e differ en ce bet ween t h e t ot a l n u m ber of poin t s t o skip bet ween fr a m es (p) a n d t h e n u m ber of poin t s t h a t wer e available t o be sk ipped in t h e pr eviou s in pu t t o buffer. If t h e pr eviou s in pu t h a d fewer t h a n p poin t s t h a t cou ld be skipped a ft er fillin g t h e fin a l fr a m e of t h a t bu ffer , t h e r em a in in g opt poin t s n eed t o be r em oved fr om t h e fir st fr a m e of t h e cu r r en t bu ffer . See Con t in u ou s Bu ffer in g below for a n exa m ple of h ow t h is wor ks in pr a ct ice.
[y,z] = buffer(...) pa r t it ion s t h e len gt h -L sign a l vect or x in t o fr a m es of len gt h n, a n d ou t pu t s on ly t h e fu ll fr a m es in y. If y is a n over la ppin g bu ffer , it h a s n r ows a n d m colu m n s, wh er e m = floor(L/(np)) % when length(opt) = p
or
m = floor((Ln)/(np))+1 % when opt = 'nodelay'
If t h e n u m ber of sa m ples in t h e in pu t vect or (a ft er t h e a ppr opr ia t e over la ppin g or u n der la ppin g oper a t ion s) exceeds t h e n u m ber of pla ces a va ila ble in t h e n-by-m bu ffer , t h e r em a in in g sa m ples in x a r e ou t pu t in vect or z, wh ich for a n over la ppin g bu ffer h a s len gt h
length(z) = L m*(np) % when length(opt) = p
or
length(z) = L ((m1)*(np)+n) % when opt = 'nodelay'
6-35
buffer
Ou t pu t z sh a r es t h e sa m e or ien t a t ion (r ow or colu m n ) a s x. If t h er e a r e n o r em a in in g sa m ples in t h e in pu t a ft er t h e bu ffer wit h t h e specified over la p or u n der la p is filled, z is a n em pt y vect or .
[y,z,opt] = buffer(...) r et u r n s t h e la st p sa m ples of a over la ppin g bu ffer in ou t pu t opt. In a n u n der la ppin g bu ffer , opt is t h e differ en ce bet ween t h e t ot a l n u m ber of poin t s t o skip bet ween fr a m es (p) a n d t h e n u m ber of poin t s in x t h a t wer e available t o be skipped a ft er fillin g t h e la st fr a m e:
F or 0< p< n (over la p), opt (a s a n ou t pu t ) con t a in s t h e fin a l p sa m ples in t h e la st fr a m e of t h e bu ffer . Th is vect or ca n be u sed a s t h e in itial con d ition for a su bsequ en t bu ffer in g oper a t ion in a sequ en ce of con secu t ive bu ffer in g oper a t ion s. Th is a llows t h e desir ed fr a m e over la p t o be m a in t a in ed fr om on e bu ffer t o t h e n ext . See Con t in u ou s Bu ffer in g below. F or p< 0 (u n der la p), opt (a s a n ou t pu t ) is t h e differ en ce bet ween t h e t ot a l n u m ber of poin t s t o skip bet ween fr a m es (p) a n d t h e n u m ber of poin t s in x t h a t wer e available t o be sk ipped a ft er fillin g t h e la st fr a m e.
opt = m*(np) + opt L % for z = empty vector
wh er e opt on t h e r igh t -h a n d side is t h e in pu t a r gu m en t t o buffer, a n d opt on t h e left -h a n d side is t h e ou t pu t a r gu m en t . H er e m is t h e n u m ber of colu m n s in t h e bu ffer , wh ich is
m = floor((Lopt)/(np)) + (rem((Lopt),(np)) >= n)
Not e t h a t for a n u n der la ppin g bu ffer ou t pu t opt is a lwa ys zer o wh en ou t pu t z con t a in s da t a . Th e opt ou t pu t for a n u n der la ppin g bu ffer is especia lly u sefu l wh en t h e cu r r en t bu ffer in g oper a t ion is on e in a sequ en ce of con secu t ive bu ffer in g oper a t ion s. Th e opt ou t pu t fr om ea ch bu ffer in g oper a t ion specifies t h e n u m ber of sa m ples t h a t n eed t o be sk ipped a t t h e st a r t of t h e n ext bu ffer in g oper a t ion t o m a in t a in t h e desir ed fr a m e u n der la p fr om on e bu ffer t o t h e n ext . If fewer t h a n p poin t s wer e a va ila ble t o be sk ipped a ft er fillin g t h e fin a l fr a m e of t h e cu r r en t bu ffer , t h e r em a in in g opt poin t s n eed t o be r em oved fr om t h e fir st fr a m e of t h e n ext bu ffer . In a sequ en ce of bu ffer in g oper a t ion s, t h e opt ou t pu t fr om ea ch oper a t ion sh ou ld be u sed a s t h e opt in pu t t o t h e su bsequ en t bu ffer in g oper a t ion . Th is en su r es t h a t t h e desir ed fr a m e over la p or u n der la p is m a in t a in ed fr om bu ffer
6-36
buffer
t o bu ffer , a s well a s fr om fr a m e t o fr a m e wit h in t h e sa m e bu ffer . See Con t in u ou s Bu ffer in g below for a n exa m ple of h ow t h is wor k s in pr a ct ice.
Continuous Buffering
In a con t in u ou s bu ffer in g oper a t ion , t h e vect or in pu t t o t h e buffer fu n ct ion r epr esen t s on e fr a m e in a sequ en ce of fr a m es t h a t m a k e u p a discr et e sign a l. Th ese sign a l fr a m es ca n or igin a t e in a fr a m e-ba sed da t a a cqu isit ion pr ocess, or wit h in a fr a m e-ba sed a lgor it h m lik e t h e F F T. As a n exa m ple, you m igh t a cqu ir e da t a fr om a n A/D ca r d in fr a m es of 64 sa m ples. In t h e sim plest ca se, you cou ld r ebu ffer t h e da t a in t o fr a m es of 16 sa m ples; buffer wit h n= 16 cr ea t es a bu ffer of fou r fr a m es fr om ea ch 64-elem en t in pu t fr a m e. Th e r esu lt is t h a t t h e sign a l of fr a m e size 64 h a s been con ver t ed t o a sign a l of fr a m e size 16; n o sa m ples wer e a dded or r em oved. In t h e gen er a l ca se wh er e t h e or igin a l sign a l fr a m e size, L, is n ot equ a lly divisible by t h e n ew fr a m e size, n, t h e over flow fr om t h e la st fr a m e n eeds t o be ca pt u r ed a n d r ecycled in t o t h e followin g bu ffer . You ca n do t h is by it er a t ively ca llin g buffer on in pu t x wit h t h e t wo-ou t pu t -a r gu m en t syn t a x:
[y,z] = buffer([z;x],n) [y,z] = buffer([z,x],n) % for column vector x % for row vector x
Th is sim ply ca pt u r es a n y bu ffer over flow in z, a n d pr epen ds t h e da t a t o t h e su bsequ en t in pu t in t h e n ext ca ll t o buffer. Aga in , t h e in pu t sign a l, x, of fr a m e size L, h a s been con ver t ed t o a sign a l of fr a m e size n wit h ou t a n y in ser t ion or delet ion of sa m ples. Not e t h a t con t in u ou s bu ffer in g ca n n ot be don e wit h t h e sin gle-ou t pu t syn t a x y = buffer(...), beca u se t h e la st fr a m e of y in t h is ca se is zer o pa dded, wh ich a dds n ew sa m ples t o t h e sign a l. Con t in u ou s bu ffer in g in t h e pr esen ce of over la p a n d u n der la p is h a n dled wit h t h e opt pa r a m et er , wh ich is u sed a s bot h a n in pu t a n d ou t pu t t o buffer. Th e followin g t wo exa m ples dem on st r a t e h ow t h e opt pa r a m et er sh ou ld be u sed.
Examples
6-37
buffer
Im a gin e t h a t t h e fr a m es (colu m n s) in t h e m a t r ix ca lled data a r e t h e sequ en t ia l ou t pu t s of a da t a a cqu isit ion boa r d sa m plin g a ph ysica l sign a l: data(:,1) is t h e fir st D/A ou t pu t , con t a in in g t h e fir st 11 sign a l sa m ples; data(:,2) is t h e secon d ou t pu t , con t a in in g t h e n ext 11 sign a l sa m ples, a n d so on . You wa n t t o r ebu ffer t h is sign a l fr om t h e a cqu ir ed fr a m e size of 11 t o a fr a m e size of 4 wit h a n over la p of 1. To do t h is, you will r epea t edly ca ll buffer t o oper a t e on ea ch su ccessive in pu t fr a m e, u sin g t h e opt pa r a m et er t o m a in t a in con sist en cy in t h e over la p fr om on e bu ffer t o t h e n ext . Set t h e bu ffer pa r a m et er s.
n = p = opt z = 4; 1; = 5; []; % % % % new frame size overlap value of y(1) initialize the carry-over vector
Now r epea t edly ca ll buffer, ea ch t im e pa ssin g in a n ew sign a l fr a m e fr om data. Not e t h a t over flow sa m ples (r et u r n ed in z) a r e ca r r ied over a n d pr epen ded t o t h e in pu t in t h e su bsequ en t ca ll t o buffer.
for i=1:size(data,2), x = data(:,i); % Loop over each source frame (column) % A single frame of the D/A output
[y,z,opt] = buffer([z;x],n,p,opt); disp(y); pause end % Do something with the buffer of data
6-38
buffer
Overflow (z)
i=1
[1:11]
[10 11]
i=2
[10 11 12:22]
21
12 13 14 15 24 25 26 27
15 16 17 18 27 28 29 30
[22]
i=3
[22 23:33]
21
33
[]
i=4
[34:44]
33
42
33 34 35 36
36 37 38 39
39 40 41 42
[43 44]
Not e t h a t t h e size of t h e ou t pu t m a t r ix, y, ca n va r y by a sin gle colu m n fr om on e it er a t ion t o t h e n ext . Th is is t ypica l for bu ffer in g oper a t ion s wit h over la p or u n der la p.
Aga in , im a gin e t h a t data(:,1) is t h e fir st D/A ou t pu t , con t a in in g t h e fir st 11 sign a l sa m ples; data(:,2) is t h e secon d ou t pu t , con t a in in g t h e n ext 11 sign a l sa m ples, a n d so on . You wa n t t o r ebu ffer t h is sign a l fr om t h e a cqu ir ed fr a m e size of 11 t o a fr a m e size of 4 wit h a n u n der la p of 2. To do t h is, you will r epea t edly ca ll buffer t o oper a t e on ea ch su ccessive in pu t fr a m e, u sin g t h e opt pa r a m et er t o m a in t a in con sist en cy in t h e u n der la p fr om on e bu ffer t o t h e n ext .
6-39
buffer
Set t h e bu ffer pa r a m et er s:
n = p = opt z = 4; 2; = 1; []; % % % % new frame size underlap skip the first input element, x(1) initialize the carry-over vector
Now r epea t edly ca ll buffer, ea ch t im e pa ssin g in a n ew sign a l fr a m e fr om data. Not e t h a t over flow sa m ples (r et u r n ed in z) a r e ca r r ied over a n d pr epen ded t o t h e in pu t in t h e su bsequ en t ca ll t o buffer.
for i=1:size(data,2), x = data(:,i); % Loop over each source frame (column) % A single frame of the D/A output
[y,z,opt] = buffer([z;x],n,p,opt); disp(y); pause end % Do something with the buffer of data
6-40
buffer
Overflow (z)
skip
i=1
[1:11]
2 8 3 9 4 10 5 11 6 7
[]
skip
12 13 14 15 16 17 18 19 20 21 22 23 26 27 28 29
skip
i=2
[12:22]
[20 21 22]
skip
skip
i=3
[20 21 22 23:33]
[32 33]
24 30 25 31
skip
Diagnostics
E r r or m essa ges a r e displa yed wh en p8n or length(opt)-length(p) in a n over la ppin g bu ffer ca se:
Frame overlap P must be less than the buffer size N. Initial conditions must be specified as a length-P vector.
See Also
reshape
Resh a pe a r r ay.
6-41
buttap
Purpose Syntax Description
6bu t ta p
Bu t t er wor t h a n a log lowpa ss filt er pr ot ot ype. It r et u r n s t h e poles in t h e len gt h n colu m n vect or p a n d t h e ga in in sca la r k. z is a n em pt y m a t r ix, beca u se t h er e a r e n o zer os. Th e t r a n sfer fu n ct ion is z (s ) k H (s ) = --------- = ---------------------------------------------------------------------------( s p (1 ) ) ( s p (2 ) ) L ( s p (n ) ) p (s ) Bu t t er wor t h filt er s a r e ch a r a ct er ized by a m a gn it u de r espon se t h a t is m a xim a lly fla t in t h e pa ssba n d a n d m on ot on ic over a ll. In t h e lowpa ss ca se, t h e fir st 2 n1 der iva t ives of t h e squ a r ed m a gn it u de r espon se a r e zer o a t # = 0. Th e squ a r ed m a gn it u de r espon se fu n ct ion is H ( #)
2
1 = ----------------------------------1 + ( # #0 ) 2 n
cor r espon din g t o a t r a n sfer fu n ct ion wit h poles equ a lly spa ced a r ou n d a cir cle in t h e left h a lf pla n e. Th e m a gn it u de r espon se a t t h e cu t off fr equ en cy #0 is a lwa ys 1/sqrt(2), r ega r dless of t h e filt er or der . buttap set s #0 t o 1 for a n or m a lized r esu lt .
Algorithm
See Also
Bessel a n a log lowpa ss filt er pr ot ot ype. Bu t t er wor t h a n a log a n d digit a l filt er design . Ch ebysh ev t ype I a n a log lowpa ss filt er pr ot ot ype. Ch ebysh ev t ype II a n a log lowpa ss filt er pr ot ot ype. E llipt ic a n a log lowpa ss filt er pr ot ot ype.
References
[1] P a r ks, T.W., a n d C.S. Bu r r u s. Digital Filter Design . New Yor k: J oh n Wiley & Son s, 1987. Ch a pt er 7.
6-42
butter
Purpose Syntax
6bu t t er
Description
Bu t t er wor t h filt er s. Bu t t er wor t h filt er s a r e ch a r a ct er ized by a m a gn it u de r espon se t h a t is m a xim a lly fla t in t h e pa ssba n d a n d m on ot on ic over a ll. Bu t t er wor t h filt er s sa cr ifice r olloff st eepn ess for m on ot on icit y in t h e pa ss- a n d st opba n ds. Un less t h e sm oot h n ess of t h e Bu t t er wor t h filt er is n eeded, a n ellipt ic or Ch ebysh ev filt er ca n gen er a lly pr ovide st eeper r olloff ch a r a ct er ist ics wit h a lower filt er or der .
Digital Domain
[b,a] = butter(n,Wn) design s a n or der n lowpa ss digit a l Bu t t er wor t h filt er wit h cu t off fr equ en cy Wn. It r et u r n s t h e filt er coefficien t s in len gt h n + 1 r ow vect or s b a n d a, wit h coefficien t s in descen din g power s of z :
B (z ) b (1 ) + b (2 ) z 1 + L + b (n + 1 ) z n H (z ) = ---------- = -------------------------------------------------------------------------------- 1 A (z ) + a (n + 1 ) z n 1 + a (2 ) z + L Cu toff frequ en cy is t h a t fr equ en cy wh er e t h e m a gn it u de r espon se of t h e filt er is sqrt(1/2). F or butter, t h e cu t off fr equ en cy Wn m u st be a n u m ber bet ween 0 a n d 1, wh er e 1 cor r espon ds t o h a lf t h e sa m plin g fr equ en cy (t h e Nyqu ist fr equ en cy). If Wn is a t wo-elem en t vect or , Wn = [w1 w2], butter r et u r n s a n or der 2*n digit a l ba n dpa ss filt er wit h pa ssba n d w1 < # < w2.
[b,a] = butter(n,Wn,'ftype') design s a h igh pa ss or ba n dst op filt er , wh er e ftype is
6-43
butter
high for a h igh pa ss digit a l filt er wit h cu t off fr equ en cy Wn stop for a n or der 2*n ba n dst op digit a l filt er if Wn is a t wo-elem en t vect or ,
Wn = [w1 w2]
Th e st opba n d is w1 < # < w2. Wit h differ en t n u m ber s of ou t pu t a r gu m en t s, butter dir ect ly obt a in s ot h er r ea liza t ion s of t h e filt er . To obt a in zer o-pole-ga in for m , u se t h r ee ou t pu t a r gu m en t s:
[z,p,k] = butter(n,Wn) or [z,p,k] = butter(n,Wn,'ftype') butter r et u r n s t h e zer os a n d poles in len gt h n colu m n vect or s z a n d p, a n d t h e ga in in t h e sca la r k.
x [n + 1 ] = A x [n ] + B u [n ] y [n ] = C x [n ] + D u [n ] a n d u is t h e in pu t , x is t h e st a t e vect or , a n d y is t h e ou t pu t .
Analog Domain
[b,a] = butter(n,Wn,'s') design s a n or der n lowpa ss a n a log Bu t t er wor t h filt er wit h cu t off fr equ en cy Wn. It r et u r n s t h e filt er coefficien t s in t h e len gt h n + 1 r ow vect or s b a n d a, in descen din g power s of s :
B (s ) b (1 ) s n + b (2 ) s n 1 + L + b (n + 1 ) H (s ) = ---------- = --------------------------------------------------------------------------------A (s ) + a (n + 1 ) s n + a (2 ) s n 1 + L
butters cu t off fr equ en cy Wn m u st be gr ea t er t h a n 0.
If Wn is a t wo-elem en t vect or wit h w1 < w2, butter(n,Wn,'s') r et u r n s a n or der 2*n ba n dpa ss a n a log filt er wit h pa ssba n d w1 < # < w2.
6-44
butter
wh er e ftype is high for a h igh pa ss a n a log filt er wit h cu t off fr equ en cy Wn stop for a n or der 2*n ba n dst op a n a log filt er if Wn is a t wo-elem en t vect or ,
Wn = [w1 w2]
Th e st opba n d is w1 < # < w2. Wit h differ en t n u m ber s of ou t pu t a r gu m en t s, butter dir ect ly obt a in s ot h er r ea liza t ion s of t h e a n a log filt er . To obt a in zer o-pole-ga in for m , u se t h r ee ou t pu t a r gu m en t s:
[z,p,k] = butter(n,Wn,'s') or [z,p,k] = butter(n,Wn,'ftype','s') r et u r n s t h e zer os a n d poles in len gt h n or 2*n colu m n vect or s z a n d p a n d t h e ga in in t h e sca la r k.
x = Ax + Bu y = Cx + Du a n d u is t h e in pu t , x is t h e st a t e vect or , a n d y is t h e ou t pu t .
Examples
F or da t a sa m pled a t 1000 H z, design a 9t h -or der h igh pa ss Bu t t er wor t h filt er wit h cu t off fr equ en cy of 300 H z:
[b,a] = butter(9,300/500,'high');
6-45
butter
0 !100 !200 !300 !400 0 200 100 200 300 Frequency (Hz) 400 500
Phase (degrees)
0 !200 !400 !600 !800 0 100 200 300 Frequency (Hz) 400 500
Design a 10t h -or der ba n dpa ss Bu t t er wor t h filt er wit h a pa ssba n d fr om 100 t o 200 H z a n d plot it s im pu lse r espon se, or u n it sam ple respon se:
n = 5; Wn = [100 200]/500; [b,a] = butter(n,Wn); [y,t] = impz(b,a,101); stem(t,y)
0.2 0.15 0.1 0.05 0 -0.05 -0.1 -0.15 -0.2 -0.25 0
10
20
30
40
50
60
70
80
90
100
6-46
butter
Limitations
F or h igh or der filt er s, t h e st a t e-spa ce for m is t h e m ost n u m er ica lly a ccu r a t e, followed by t h e zer o-pole-ga in for m . Th e t r a n sfer fu n ct ion coefficien t for m is t h e lea st a ccu r a t e; n u m er ica l pr oblem s ca n a r ise for filt er or der s a s low a s 15.
butter u ses a five-st ep a lgor it h m :
1 It fin ds t h e lowpa ss a n a log pr ot ot ype poles, zer os, a n d ga in u sin g t h e buttap
Algorithm
fu n ct ion .
2 It con ver t s t h e poles, zer os, a n d ga in in t o st a t e-spa ce for m . 3 It t r a n sfor m s t h e lowpa ss filt er in t o a ba n dpa ss, h igh pa ss, or ba n dst op filt er
in t o a digit a l filt er t h r ou gh a bilin ea r t r a n sfor m a t ion wit h fr equ en cy pr ewa r pin g. Ca r efu l fr equ en cy a dju st m en t gu a r a n t ees t h a t t h e a n a log filt er s a n d t h e digit a l filt er s will h a ve t h e sa m e fr equ en cy r espon se m a gn it u de a t Wn or w1 a n d w2.
5 It con ver t s t h e st a t e-spa ce filt er ba ck t o t r a n sfer fu n ct ion or zer o-pole-ga in
See Also
Bessel a n a log filt er design . Bu t t er wor t h a n a log lowpa ss filt er pr ot ot ype. Bu t t er wor t h filt er or der select ion . Ch ebysh ev t ype I filt er design (pa ssba n d r ipple). Ch ebysh ev t ype II filt er design (st opba n d r ipple). E llipt ic (Ca u er ) filt er design . Gen er a lized digit a l Bu t t er wor t h filt er design .
6-47
buttord
Purpose Syntax Description
6bu t tor d
Pa ssba n d cor n er fr equ en cy. Wp, t h e cu t off fr equ en cy, h a s a va lu e bet ween 0 a n d 1, wh er e 1 cor r espon ds t o h a lf t h e sa m plin g fr equ en cy (t h e Nyqu ist fr equ en cy). St opba n d cor n er fr equ en cy. Ws is in t h e sa m e u n it s a s Wp; it h a s a va lu e bet ween 0 a n d 1, wh er e 1 cor r espon ds t o h a lf t h e sa m plin g fr equ en cy (t h e Nyqu ist fr equ en cy). Passba n d r ipple, in decibels. Th is va lu e is th e m axim u m permissible passban d loss in decibels. The passba n d is 0 < w < Wp. St opba n d a t t en u a t ion , in decibels. Th is va lu e is t h e n u m ber of decibels t h e st opba n d is down fr om t h e pa ssba n d. Th e st opba n d is Ws < w < 1.
Ws
Rp Rs
Digital Domain
[n,Wn] = buttord(Wp,Ws,Rp,Rs) r et u r n s t h e or der n of t h e lowest or der digit a l Bu t t er wor t h filt er t h a t loses n o m or e t h a n Rp dB in t h e pa ssba n d a n d h a s a t lea st Rs dB of a t t en u a t ion in t h e st opba n d. Th e pa ssba n d r u n s fr om 0 t o Wp a n d t h e st opba n d r u n s fr om Ws t o 1, t h e Nyqu ist fr equ en cy. buttord a lso r et u r n s Wn, t h e Bu t t er wor t h cu t off fr equ en cy t h a t a llows butter t o a ch ieve t h e given specifica t ion s (t h e -3 dB fr equ en cy).
Use buttord for h igh pa ss, ba n dpa ss, a n d ba n dst op filt er s. F or h igh pa ss filt er s, Wp is gr ea t er t h a n Ws. F or ba n dpa ss a n d ba n dst op filt er s, Wp a n d Ws a r e t wo-elem en t vect or s t h a t specify t h e cor n er fr equ en cies a t bot h edges of t h e filt er , lower fr equ en cy edge fir st . F or t h e ba n d filt er s, buttord r et u r n s Wn a s a t wo-elem en t r ow vect or for in pu t t o butter. If filt er specifica t ion s ca ll for a ba n dpa ss or ba n dst op filt er wit h u n equ a l r ipple in ea ch of t h e pa ssba n ds or st opba n ds, design t h e filt er a s sepa r a t e lowpa ss a n d h igh pa ss sect ion s a n d ca sca de t h e t wo filt er s t oget h er .
6-48
buttord
Analog Domain
[n,Wn] = buttord(Wp,Ws,Rp,Rs,'s') fin ds t h e m in im u m or der n a n d cu t off fr equ en cies Wn for a n a n a log filt er . In t h is ca se t h e fr equ en cies in Wp a n d Ws a r e in r a dia n s per secon d a n d m a y be gr ea t er t h a n 1.
Use buttord for h igh pa ss, ba n dpa ss, a n d ba n dst op filt er s, a s descr ibed u n der Digit a l Dom a in .
Examples
F or da t a sa m pled a t 1000 H z, design a lowpa ss filt er wit h less t h a n 3 dB of a t t en u a t ion fr om 0 t o 100 H z, a n d a t t en u a t ion a t lea st 15 dB fr om 150 H z t o t h e Nyqu ist fr equ en cy. P lot t h e filt er s fr equ en cy r espon se:
Wp = 100/500; Ws = 150/500; [n,Wn] = buttord(Wp,Ws,3,15) n = 4 Wn = 0.2042 [b,a] = butter(n,Wn); freqz(b,a,512,1000); title('n=4 Butterworth Lowpass Filter')
n = 4 Butterworth Lowpass Filter 100 0 -100 -200 -300 0
50
100
150
350
400
450
500
Phase (degrees)
50
100
150
350
400
450
500
6-49
buttord
Next design a ba n dpa ss filt er wit h pa ssba n d of 100 H z t o 200 H z, less t h a n 3 dB of a t t en u a t ion a t t h e pa ssba n d cor n er s, a n d a t t en u a t ion down 30 dB by 50 H z ou t on bot h sides of t h e pa ssba n d:
Wp = [100 200]/500; Ws = [50 250]/500; Rp = 3; Rs = 30; [n,Wn] = buttord(Wp,Ws,Rp,Rs); [b,a] = butter(n,Wn); freqz(b,a,128,1000)
Magnitude Response (dB) 100 0 -100 -200 -300 0
50
100
150
350
400
450
500
-500
-1000 0
50
100
150
350
400
450
500
Algorithm
buttords or der pr edict ion for m u la is descr ibed in [1]. It oper a t es in t h e a n a log
dom a in for bot h a n a log a n d digit a l ca ses. F or t h e digit a l ca se, it con ver t s t h e fr equ en cy pa r a m et er s t o t h e s -dom a in befor e est im a t in g t h e or der a n d n a t u r a l fr equ en cy, t h en con ver t s ba ck t o t h e z -dom a in .
buttord in it ia lly develops a lowpa ss filt er pr ot ot ype by t r a n sfor m in g t h e pa ssba n d fr equ en cies of t h e desir ed filt er t o 1 r a d/sec (for low- a n d h igh pa ss filt er s) a n d t o -1 a n d 1 r a d/sec (for ba n dpa ss a n d ba n dst op filt er s). It t h en com pu t es t h e m in im u m or der r equ ir ed for a lowpa ss filt er t o m eet t h e st opba n d specifica t ion .
6-50
buttord
See Also
Bu t t er wor t h a n a log a n d digit a l filt er design . Ch ebysh ev t ype I filt er or der select ion . Ch ebysh ev t ype II filt er or der select ion . E llipt ic filt er or der select ion . E st im a t e pa r a m et er s for a n F IR filt er design wit h Ka iser win dow.
References
[1] Ra bin er , L.R., a n d B. Gold. T h eory an d Application of Digital S ign al Processin g. E n glewood Cliffs, NJ : P r en t ice-H a ll, 1975. P g. 227.
6-51
cceps
Purpose Syntax
6cceps
Description
Cepst r a l a n a lysis is a n on lin ea r sign a l pr ocessin g t ech n iqu e t h a t is a pplied m ost com m on ly in speech pr ocessin g a n d h om om or ph ic filt er in g [1].
xhat = cceps(x) r et u r n s t h e com plex cepst r u m of t h e (a ssu m ed r ea l) sequ en ce x. Th e in pu t is a lt er ed, by t h e a pplica t ion of a lin ea r ph a se t er m , t o h a ve n o ph a se discon t in u it y a t $ r a dia n s. Th a t is, it is cir cu la r ly sh ift ed (a ft er zer o pa ddin g) by som e sa m ples, if n ecessa r y, t o h a ve zer o ph a se a t $ r a dia n s. [xhat,nd] = cceps(x) r et u r n s t h e n u m ber of sa m ples nd of (cir cu la r ) dela y a dded t o x pr ior t o fin din g t h e com plex cepst r u m . [xhat,nd,xhat1] = cceps(x) r et u r n s a secon d com plex cepst r u m , com pu t ed u sin g a n a lt er n a t e r oot in g a lgor it h m , in xhat1. Th e a lt er n a t e m et h od ([1] p.795) is u sefu l for sh or t sequ en ces t h a t ca n be r oot ed a n d do n ot h a ve zer os on t h e u n it cir cle. F or t h ese sign a ls, xhat1 ca n pr ovide a ver ifica t ion of xhat. [...] = cceps(x,n) zer o pa ds x t o len gt h n a n d r et u r n s t h e len gt h n com plex
cepst r u m of x.
Algorithm
cceps, in it s ba sic for m , is a n M-file im plem en t a t ion of a lgor it h m 7.1 in [2]. A len gt h y F or t r a n pr ogr a m r edu ces t o t h r ee lin es of MATLAB code: h = fft(x); logh = log(abs(h)) + sqrt(1)*rcunwrap(angle(h)); y = real(ifft(logh)); rcunwrap is a specia l ver sion of unwrap t h a t su bt r a ct s a st r a igh t lin e fr om t h e
ph a se.
6-52
cceps
See Also
In ver se com plex cepst r u m . H ilber t t r a n sfor m . Rea l cepst r u m a n d m in im u m ph a se r econ st r u ct ion . Un wr a p ph a se a n gles.
References
[1] Oppen h eim , A.V., a n d R.W. Sch a fer . Discrete-T im e S ign al Processin g. E n glewood Cliffs, NJ : P r en t ice-H a ll, 1989. [2] IE E E . Program s for Digital S ign al Processin g . IE E E P r ess. New Yor k: J oh n Wiley & Son s, 1979.
6-53
cheb1ap
Purpose Syntax Description
6ch eb1a p
is z (s ) k H (s ) = --------- = ---------------------------------------------------------------------------( s p (1 ) ) ( s p (2 ) ) L ( s p (n ) ) p (s ) Ch ebysh ev t ype I filt er s a r e equ ir ipple in t h e pa ssba n d a n d m on ot on ic in t h e st opba n d. Th e poles a r e even ly spa ced a bou t a n ellipse in t h e left h a lf pla n e. Th e Ch ebysh ev t ype I cu t off fr equ en cy # 0 is set t o 1.0 for a n or m a lized r esu lt . Th is is t h e fr equ en cy a t wh ich t h e pa ssba n d en ds a n d t h e filt er h a s m a gn it u de r espon se of 10 -Rp/20 .
See Also
Bessel a n a log lowpa ss filt er pr ot ot ype. Bu t t er wor t h a n a log a n d digit a l filt er design . Ch ebysh ev t ype I a n a log lowpa ss filt er pr ot ot ype. Ch ebysh ev t ype I filt er design (pa ssba n d r ipple). E llipt ic a n a log lowpa ss filt er pr ot ot ype.
References
[1] P a r ks, T.W., a n d C.S. Bu r r u s. Digital Filter Design . New Yor k: J oh n Wiley & Son s, 1987. Ch a pt er 7.
6-54
cheb1ord
Purpose Syntax Description
6ch eb1or d
Pa ssba n d cor n er fr equ en cy. Wp, t h e cu t off fr equ en cy, h a s a va lu e bet ween 0 a n d 1, wh er e 1 cor r espon ds t o h a lf t h e sa m plin g fr equ en cy (t h e Nyqu ist fr equ en cy). St opba n d cor n er fr equ en cy. Ws is in t h e sa m e u n it s a s Wp; it h a s a va lu e bet ween 0 a n d 1, wh er e 1 cor r espon ds t o h a lf t h e sa m plin g fr equ en cy (t h e Nyqu ist fr equ en cy). Passba n d r ipple, in decibels. This value is the m axim um per m issible pa ssban d loss in decibels. Th e passba n d is 0 < w < Wp. St opba n d a t t en u a t ion , in decibels. Th is va lu e is t h e n u m ber of decibels t h e st opba n d is down fr om t h e pa ssba n d. Th e st opba n d is Ws < w < 1.
Ws
Rp Rs
Digital Domain
[n,Wn] = cheb1ord(Wp,Ws,Rp,Rs) r et u r n s t h e or der n of t h e lowest or der Ch ebysh ev filt er t h a t loses n o m or e t h a n Rp dB in t h e pa ssba n d a n d h a s a t lea st Rs dB of a t t en u a t ion in t h e st opba n d. Th e pa ssba n d r u n s fr om 0 t o Wp a n d t h e st opba n d r u n s fr om Ws t o 1, t h e Nyqu ist fr equ en cy. cheb1ord a lso r et u r n s Wn, t h e Ch ebysh ev t ype I cu t off fr equ en cy t h a t a llows cheby1 t o a ch ieve t h e given specifica t ion s.
Use cheb1ord for lowpa ss, h igh pa ss, ba n dpa ss, a n d ba n dst op filt er s. F or h igh pa ss filt er s, Wp > Ws. F or ba n dpa ss a n d ba n dst op filt er s, Wp a n d Ws a r e t wo-elem en t vect or s t h a t specify t h e cor n er fr equ en cies a t bot h edges of t h e filt er , lower fr equ en cy edge fir st . F or t h e ba n d filt er s, cheb1ord r et u r n s Wn a s a t wo-elem en t r ow vect or for in pu t t o cheby1. If filt er specifica t ion s ca ll for a ba n dpa ss or ba n dst op filt er wit h u n equ a l r ipple in ea ch of t h e pa ssba n ds or st opba n ds, design t h e filt er a s sepa r a t e lowpa ss a n d h igh pa ss sect ion s a n d ca sca de t h e t wo filt er s t oget h er .
6-55
cheb1ord
Analog Domain
[n,Wn] = cheb1ord(Wp,Ws,Rp,Rs,'s') fin ds t h e m in im u m or der n a n d cu t off fr equ en cies Wn for a n a n a log filt er . In t h is ca se t h e fr equ en cies in Wp a n d Ws a r e in r a dia n s per secon d a n d m a y be gr ea t er t h a n 1.
Use cheb1ord for lowpa ss, h igh pa ss, ba n dpa ss, a n d ba n dst op filt er s, a s descr ibed u n der Digit a l Dom a in .
Examples
F or da t a sa m pled a t 1000 H z, design a lowpa ss filt er wit h less t h a n 3 dB of a t t en u a t ion fr om 0 t o 100 H z a n d a t t en u a t ion a t lea st 15 dB fr om 150 H z t o t h e Nyqu ist fr equ en cy:
Wp = 100/500; Ws = 150/500; Rp = 3; Rs = 15; [n,Wn] = cheb1ord(Wp,Ws,Rp,Rs) n = 3 Wn = 0.2000 [b,a] = cheby1(n,Rp,Wn); freqz(b,a,512,1000); title('n=3 Chebyshev Type I Lowpass Filter')
n = 3 Chebyshev Type I Lowpass Filter
Magnitude Response (dB)
50 0 -50 -100 -150 -200 0 50 100 150 200 250 300 Frequency (Hertz) 350 400 450 500
0
Phase (degrees)
-100
-200
-300 0
50
100
150
350
400
450
500
6-56
cheb1ord
Next design a ba n dpa ss filt er wit h a pa ssba n d of 100 H z t o 200 H z, less t h a n 3 dB of a t t en u a t ion t h r ou gh ou t t h e pa ssba n d, a n d 30 dB st opba n ds 50 H z ou t on bot h sides of t h e pa ssba n d:
Wp = [100 200]/500; Ws = [50 250]/500; Rp = 3; Rs = 30; [n,Wn] = cheb1ord(Wp,Ws,Rp,Rs) n = 4 Wn = 0.2000 0.4000 [b,a] = cheby1(n,Rp,Wn); freqz(b,a,512,1000); title('n=4 Chebyshev Type I Bandpass Filter')
n = 4 Chebyshev Type I Bandpass Filter
-100
-200
-300 0
50
100
150
350
400
450
500
Phase (degrees)
50
100
150
350
400
450
500
Algorithm
cheb1ord u ses t h e Ch ebysh ev lowpa ss filt er or der pr edict ion for m u la descr ibed
in [1]. Th e fu n ct ion per for m s it s ca lcu la t ion s in t h e a n a log dom a in for bot h a n a log a n d digit a l ca ses. F or t h e digit a l ca se, it con ver t s t h e fr equ en cy pa r a m et er s t o t h e s -dom a in befor e t h e or der a n d n a t u r a l fr equ en cy est im a t ion pr ocess, t h en con ver t s t h em ba ck t o t h e z -dom a in .
6-57
cheb1ord
cheb1ord in it ia lly develops a lowpa ss filt er pr ot ot ype by t r a n sfor m in g t h e pa ssba n d fr equ en cies of t h e desir ed filt er t o 1 r a d/sec (for low- or h igh pa ss filt er s) or t o -1 a n d 1 r a d/sec (for ba n dpa ss or ba n dst op filt er s). It t h en com pu t es t h e m in im u m or der r equ ir ed for a lowpa ss filt er t o m eet t h e st opba n d specifica t ion .
See Also
Bu t t er wor t h filt er or der select ion . Ch ebysh ev t ype I filt er design (pa ssba n d r ipple). Ch ebysh ev t ype II filt er or der select ion . E llipt ic filt er or der select ion . E st im a t e pa r a m et er s for a n F IR filt er design wit h Ka iser win dow.
References
[1] Ra bin er , L.R., a n d B. Gold. T h eory an d Application of Digital S ign al Processin g . E n glewood Cliffs, NJ : P r en t ice-H a ll, 1975. P g. 241.
6-58
cheb2ap
Purpose Syntax Description
6ch eb2a p
( s z (1 ) ) ( s z (2 ) ) L ( s z (n ) ) z (s ) H (s ) = --------- = k ---------------------------------------------------------------------------( s p (1 ) ) ( s p (2 ) ) L ( s p (n ) ) p (s ) Ch ebysh ev t ype II filt er s a r e m on ot on ic in t h e pa ssba n d a n d equ ir ipple in t h e st opba n d. Th e pole loca t ion s a r e t h e in ver se of t h e pole loca t ion s of cheb1ap, wh ose poles a r e even ly spa ced a bou t a n ellipse in t h e left h a lf pla n e. Th e Ch ebysh ev t ype II cu t off fr equ en cy #0 is set t o 1 for a n or m a lized r esu lt . Th is is t h e fr equ en cy a t wh ich t h e st opba n d begin s a n d t h e filt er h a s m a gn it u de r espon se of 10 -Rs/20 .
Algorithm
Ch ebysh ev t ype II filt er s a r e som et im es ca lled in verse Ch ebysh ev filt er s beca u se of t h eir r ela t ion sh ip t o Ch ebysh ev t ype I filt er s. Th e cheb2ap fu n ct ion is a m odifica t ion of t h e Ch ebysh ev t ype I pr ot ot ype a lgor it h m :
1 cheb2ap r epla ces t h e fr equ en cy va r ia ble # wit h 1/#, t u r n in g t h e lowpa ss
See Also
Bessel a n a log lowpa ss filt er pr ot ot ype. Bu t t er wor t h a n a log lowpa ss filt er pr ot ot ype. Ch ebysh ev t ype I a n a log lowpa ss filt er pr ot ot ype. Ch ebysh ev t ype II filt er design (st opba n d r ipple). E llipt ic a n a log lowpa ss filt er pr ot ot ype.
References
[1] P a r ks, T.W., a n d C.S. Bu r r u s. Digital Filter Design . New Yor k: J oh n Wiley & Son s, 1987. Ch a pt er 7.
6-59
cheb2ord
Purpose Syntax Description
6ch eb2or d
[n,Wn] = cheb2ord(Wp,Ws,Rp,Rs) [n,Wn] = cheb2ord(Wp,Ws,Rp,Rs,'s') cheb2ord select s t h e m in im u m or der digit a l or a n a log Ch ebysh ev t ype II filt er
Pa ssba n d cor n er fr equ en cy. Wp, t h e cu t off fr equ en cy, h a s a va lu e bet ween 0 a n d 1, wh er e 1 cor r espon ds t o h a lf t h e sa m plin g fr equ en cy (t h e Nyqu ist fr equ en cy). St opba n d cor n er fr equ en cy. Ws is in t h e sa m e u n it s a s Wp; it h a s a va lu e bet ween 0 a n d 1, wh er e 1 cor r espon ds t o h a lf t h e sa m plin g fr equ en cy (t h e Nyqu ist fr equ en cy). Passba n d r ipple, in decibels. Th is va lu e is th e m axim u m permissible passban d loss in decibels. The passba n d is 0 < w < Wp. St opba n d a t t en u a t ion , in decibels. Th is va lu e is t h e n u m ber of decibels t h e st opba n d is down fr om t h e pa ssba n d. Th e st opba n d is Ws < w < 1.
Ws
Rp Rs
Digital Domain
[n,Wn] = cheb2ord(Wp,Ws,Rp,Rs) r et u r n s t h e or der n of t h e lowest or der Ch ebysh ev filt er t h a t loses n o m or e t h a n Rp dB in t h e pa ssba n d a n d h a s a t lea st Rs dB of a t t en u a t ion in t h e st opba n d. Th e pa ssba n d r u n s fr om 0 t o Wp a n d t h e st opba n d r u n s fr om Ws t o 1, t h e Nyqu ist fr equ en cy. cheb2ord a lso r et u r n s Wn, t h e Ch ebysh ev t ype II cu t off fr equ en cy t h a t a llows cheby2 t o a ch ieve t h e given specifica t ion s.
Use cheb2ord for lowpa ss, h igh pa ss, ba n dpa ss, a n d ba n dst op filt er s. F or h igh pa ss filt er s, Wp is gr ea t er t h a n Ws. F or ba n dpa ss a n d ba n dst op filt er s, Wp a n d Ws a r e t wo-elem en t vect or s t h a t specify t h e cor n er fr equ en cies a t bot h edges of t h e filt er , lower fr equ en cy edge fir st . F or t h e ba n d filt er s, cheb2ord r et u r n s Wn a s a t wo-elem en t r ow vect or for in pu t t o cheby2. If filt er specifica t ion s ca ll for a ba n dpa ss or ba n dst op filt er wit h u n equ a l r ipple in ea ch of t h e pa ssba n ds or st opba n ds, design t h e filt er a s sepa r a t e lowpa ss a n d h igh pa ss sect ion s a n d ca sca de t h e t wo filt er s t oget h er .
6-60
cheb2ord
Analog Domain
[n,Wn] = cheb2ord(Wp,Ws,Rp,Rs,'s') fin ds t h e m in im u m or der n a n d cu t off fr equ en cies Wn for a n a n a log filt er . In t h is ca se t h e fr equ en cies in Wp a n d Ws a r e in r a dia n s per secon d a n d m a y be gr ea t er t h a n 1.
Use cheb2ord for lowpa ss, h igh pa ss, ba n dpa ss, a n d ba n dst op filt er s, a s descr ibed u n der Digit a l Dom a in .
Examples
F or da t a sa m pled a t 1000 H z, design a lowpa ss filt er wit h less t h a n 3 dB of a t t en u a t ion fr om 0 t o 100 H z, a n d a t t en u a t ion a t lea st 15 dB fr om 150 H z t o t h e Nyqu ist fr equ en cy:
Wp = 100/500; Ws = 150/500; Rp = 3; Rs = 15; [n,Wn] = cheb2ord(Wp,Ws,Rp,Rs) n = 3 Wn = 0.2609 [b,a] = cheby2(n,Rs,Wn); freqz(b,a,512,1000); title('n=3 Chebyshev Type II Lowpass Filter')
n = 3 Chebyshev Type II Lowpass Filter
20 0 -20 -40 -60 -80 0 50 100 150 200 250 300 Frequency (Hertz) 350 400 450 500
Phase (degrees)
50
100
150
350
400
450
500
6-61
cheb2ord
Next design a ba n dpa ss filt er wit h a pa ssba n d of 100 H z t o 200 H z, less t h a n 3 dB of a t t en u a t ion t h r ou gh ou t t h e pa ssba n d, a n d 30 dB st opba n ds 50 H z ou t on bot h sides of t h e pa ssba n d:
Wp = [100 200]/500; Ws = [50 250]/500; Rp = 3; Rs = 30; [n,Wn] = cheb2ord(Wp,Ws,Rp,Rs) n = 4 Wn = 0.1633 0.4665
50
100
150
350
400
450
500
400
Phase (degrees)
50
100
150
350
400
450
500
Algorithm
cheb2ord u ses t h e Ch ebysh ev lowpa ss filt er or der pr edict ion for m u la descr ibed
in [1]. Th e fu n ct ion per for m s it s ca lcu la t ion s in t h e a n a log dom a in for bot h a n a log a n d digit a l ca ses. F or t h e digit a l ca se, it con ver t s t h e fr equ en cy pa r a m et er s t o t h e s -dom a in befor e t h e or der a n d n a t u r a l fr equ en cy est im a t ion pr ocess, t h en con ver t s t h em ba ck t o t h e z -dom a in .
6-62
cheb2ord
cheb2ord in it ia lly develops a lowpa ss filt er pr ot ot ype by t r a n sfor m in g t h e st opba n d fr equ en cies of t h e desir ed filt er t o 1 r a d/sec (for low- a n d h igh pa ss filt er s) a n d t o -1 a n d 1 r a d/sec (for ba n dpa ss a n d ba n dst op filt er s). It t h en com pu t es t h e m in im u m or der r equ ir ed for a lowpa ss filt er t o m eet t h e pa ssba n d specifica t ion .
See Also
Bu t t er wor t h filt er or der select ion . Ch ebysh ev t ype I filt er or der select ion . Ch ebysh ev t ype II filt er design (st opba n d r ipple). E llipt ic filt er or der select ion . E st im a t e pa r a m et er s for a n F IR filt er design wit h Ka iser win dow.
References
[1] Ra bin er , L.R., a n d B. Gold. T h eory an d Application of Digital S ign al Processin g. E n glewood Cliffs, NJ : P r en t ice-H a ll, 1975. P g. 241.
6-63
chebwin
Purpose Syntax Description
6ch ebwin
Ch ebysh ev win dow wh ose F ou r ier t r a n sfor m m a gn it u de sidelobe r ipple is r dB below t h e m a in lobe m a gn it u de.
See Also
Ba r t let t win dow. Bla ck m a n win dow. Rect a n gu la r win dow. H a m m in g win dow. H a n n in g win dow. Ka iser win dow. Tr ia n gu la r win dow.
References
[1] IE E E . Program s for Digital S ign al Processin g. IE E E P r ess. New Yor k: J oh n Wiley & Son s, 1979. P r ogr a m 5.2.
6-64
cheby1
Purpose Syntax
6ch eby1
Description
Ch ebysh ev t ype I filt er s. Ch ebysh ev t ype I filt er s a r e equ ir ipple in t h e pa ssba n d a n d m on ot on ic in t h e st opba n d. Type I filt er s r oll off fa st er t h a n t ype II filt er s, bu t a t t h e expen se of gr ea t er devia t ion fr om u n it y in t h e pa ssba n d.
Digital Domain
[b,a] = cheby1(n,Rp,Wn) design s a n or der n lowpa ss digit a l Ch ebysh ev filt er wit h cu t off fr equ en cy Wn a n d Rp dB of r ipple in t h e pa ssba n d. It r et u r n s t h e filt er coefficien t s in t h e len gt h n+1 r ow vect or s b a n d a, wit h coefficien t s in descen din g power s of z :
B (z ) b (1 ) + b (2 ) z 1 + L + b (n + 1 ) z n H (z ) = ---------- = --------------------------------------------------------------------------------A (z ) + a (n + 1 ) z n 1 + a (2 ) z 1 + L Cu toff frequ en cy is t h e fr equ en cy a t wh ich t h e m a gn it u de r espon se of t h e filt er is equ a l t o Rp dB. F or cheby1, t h e cu t off fr equ en cy Wn is a n u m ber bet ween 0 a n d 1, wh er e 1 cor r espon ds t o h a lf t h e sa m plin g fr equ en cy (t h e Nyqu ist fr equ en cy). Sm a ller va lu es of pa ssba n d r ipple Rp lea d t o wider t r a n sit ion widt h s (sh a llower r olloff ch a r a ct er ist ics). If Wn is a t wo-elem en t vect or , Wn = [w1 w2], cheby1 r et u r n s a n or der 2*n ba n dpa ss filt er wit h pa ssba n d w1 < # < w2.
[b,a] = cheby1(n,Rp,Wn,'ftype') design s a h igh pa ss or ba n dst op filt er ,
wh er e ftype is
6-65
cheby1
high for a h igh pa ss digit a l filt er wit h cu t off fr equ en cy Wn stop for a n or der 2*n ba n dst op digit a l filt er if Wn is a t wo-elem en t vect or ,
Wn = [w1 w2]
Th e st opba n d is w1 < # < w2. Wit h differ en t n u m ber s of ou t pu t a r gu m en t s, cheby1 dir ect ly obt a in s ot h er r ea liza t ion s of t h e filt er . To obt a in zer o-pole-ga in for m , u se t h r ee ou t pu t a r gu m en t s:
[z,p,k] = cheby1(n,Rp,Wn) or [z,p,k] = cheby1(n,Rp,Wn,'ftype') r et u r n s t h e zer os a n d poles in len gt h n colu m n vect or s z a n d p a n d t h e ga in in t h e sca la r k.
x [n + 1 ] = A x [n ] + B u [n ] y [n ] = C x [n ] + D u [n ] a n d u is t h e in pu t , x is t h e st a t e vect or , a n d y is t h e ou t pu t .
Analog Domain
[b,a] = cheby1(n,Rp,Wn,'s') design s a n or der n lowpa ss a n a log Ch ebysh ev t ype I filt er wit h cu t off fr equ en cy Wn. It r et u r n s t h e filt er coefficien t s in len gt h n + 1 r ow vect or s b a n d a, in descen din g power s of s :
B (s ) b (1 ) s n + b (2 ) s n 1 + L + b (n + 1 ) H (s ) = ---------- = --------------------------------------------------------------------------------A (s ) + a (n + 1 ) s n + a (2 ) s n 1 + L Cu toff frequ en cy is t h e fr equ en cy a t wh ich t h e m a gn it u de r espon se of t h e filt er is Rp dB. F or cheby1, t h e cu t off fr equ en cy Wn m u st be gr ea t er t h a n 0. If Wn is a t wo-elem en t vect or , Wn = [w1 w2], wit h w1 < w2, t h en cheby1(n,Rp,Wn,'s') r et u r n s a n or der 2*n ba n dpa ss a n a log filt er wit h pa ssba n d w1 < # < w2.
6-66
cheby1
filt er , wh er e ftype is high for a h igh pa ss a n a log filt er wit h cu t off fr equ en cy Wn stop for a n or der 2*n ba n dst op a n a log filt er if Wn is a t wo-elem en t vect or ,
Wn = [w1 w2]
Th e st opba n d is w1 < # < w2. You ca n su pply differ en t n u m ber s of ou t pu t a r gu m en t s for cheby1 t o dir ect ly obt a in ot h er r ea liza t ion s of t h e a n a log filt er . To obt a in zer o-pole-ga in for m , u se t h r ee ou t pu t a r gu m en t s:
[z,p,k] = cheby1(n,Rp,Wn,'s') or [z,p,k] = cheby1(n,Rp,Wn,'ftype','s') r et u r n s t h e zer os a n d poles in len gt h n or 2*n colu m n vect or s z a n d p a n d t h e ga in in t h e sca la r k.
as x = Ax + Bu y = Cx + Du a n d u is t h e in pu t , x is t h e st a t e vect or , a n d y is t h e ou t pu t .
Examples
F or da t a sa m pled a t 1000 H z, design a 9t h -or der lowpa ss Ch ebysh ev t ype I filt er wit h 0.5 dB of r ipple in t h e pa ssba n d a n d a cu t off fr equ en cy of 300 H z:
[b,a] = cheby1(9,0.5,300/500);
6-67
cheby1
50
100
150
350
400
450
500
Phase (degrees)
-200 -400 -600 -800 -1000 0 50 100 150 200 250 300 Frequency (Hertz) 350 400 450 500
Design a 10t h -or der ba n dpa ss Ch ebysh ev t ype I filt er wit h a pa ssba n d fr om 100 t o 200 H z a n d plot it s im pu lse r espon se:
n = 10; Rp = 0.5; Wn = [100 200]/500; [b,a] = cheby1(n,Rp,Wn); [y,t] = impz(b,a,101); stem(t,y)
Impulse Response of n = 10 Chebyshev Type I Filter 0.15
0.1
0.05
-0.05
-0.1
-0.15
-0.2 0
10
20
30
40
50
60
70
80
90
100
6-68
cheby1
Limitations
F or h igh or der filt er s, t h e st a t e-spa ce for m is t h e m ost n u m er ica lly a ccu r a t e, followed by t h e zer o-pole-ga in for m . Th e t r a n sfer fu n ct ion for m is t h e lea st a ccu r a t e; n u m er ica l pr oblem s ca n a r ise for filt er or der s a s low a s 15.
cheby1 u ses a five-st ep a lgor it h m :
1 It fin ds t h e lowpa ss a n a log pr ot ot ype poles, zer os, a n d ga in u sin g t h e
Algorithm
cheb1ap fu n ct ion .
2 It con ver t s t h e poles, zer os, a n d ga in in t o st a t e-spa ce for m . 3 It t r a n sfor m s t h e lowpa ss filt er in t o a ba n dpa ss, h igh pa ss, or ba n dst op filt er
in t o a digit a l filt er t h r ou gh a bilin ea r t r a n sfor m a t ion wit h fr equ en cy pr ewa r pin g. Ca r efu l fr equ en cy a dju st m en t gu a r a n t ees t h a t t h e a n a log filt er s a n d t h e digit a l filt er s will h a ve t h e sa m e fr equ en cy r espon se m a gn it u de a t Wn or w1 a n d w2.
5 It con ver t s t h e st a t e-spa ce filt er ba ck t o t r a n sfer fu n ct ion or zer o-pole-ga in
See Also
Bessel a n a log filt er design . Bu t t er wor t h a n a log a n d digit a l filt er design . Ch ebysh ev t ype I a n a log lowpa ss filt er pr ot ot ype. Ch ebysh ev t ype I filt er or der select ion . Ch ebysh ev t ype II filt er design (st opba n d r ipple). E llipt ic (Ca u er ) filt er design .
6-69
cheby2
Purpose Syntax
6ch eby2
Description
Ch ebysh ev t ype II filt er s. Ch ebysh ev t ype II filt er s a r e m on ot on ic in t h e pa ssba n d a n d equ ir ipple in t h e st opba n d. Type II filt er s do n ot r oll off a s fa st a s t ype I filt er s, bu t a r e fr ee of pa ssba n d r ipple.
Digital Domain
[b,a] = cheby2(n,Rs,Wn) design s a n or der n lowpa ss digit a l Ch ebysh ev t ype II filt er wit h cu t off fr equ en cy Wn a n d st opba n d r ipple Rs dB down fr om t h e pea k pa ssba n d va lu e. It r et u r n s t h e filt er coefficien t s in t h e len gt h n + 1 r ow vect or s b a n d a, wit h coefficien t s in descen din g power s of z :
B (z ) b (1 ) + b (2 ) z 1 + L + b (n + 1 ) z n H (z ) = ---------- = --------------------------------------------------------------------------------A (z ) + a (n + 1 ) z n 1 + a (2 ) z 1 + L Cu toff frequ en cy is t h e begin n in g of t h e st opba n d, wh er e t h e m a gn it u de r espon se of t h e filt er is equ a l t o Rs dB. F or cheby2, t h e cu t off fr equ en cy Wn is a n u m ber bet ween 0 a n d 1, wh er e 1 cor r espon ds t o h a lf t h e sa m plin g fr equ en cy (t h e Nyqu ist fr equ en cy). La r ger va lu es of st opba n d a t t en u a t ion Rs lea d t o wider t r a n sit ion widt h s (sh a llower r olloff ch a r a ct er ist ics). If Wn is a t wo-elem en t vect or , Wn = [w1 w2], cheby2 r et u r n s a n or der 2*n ba n dpa ss filt er wit h pa ssba n d w1 < # < w2.
[b,a] = cheby2(n,Rs,Wn,'ftype') design s a h igh pa ss or ba n dst op filt er ,
wh er e ftype is
6-70
cheby2
high for a h igh pa ss digit a l filt er wit h cu t off fr equ en cy Wn stop for a n or der 2*n ba n dst op digit a l filt er if Wn is a t wo-elem en t vect or , Wn = [w1 w2]. Th e st opba n d is w1 < # < w2. Wit h differ en t n u m ber s of ou t pu t a r gu m en t s, cheby2 dir ect ly obt a in s ot h er r ea liza t ion s of t h e filt er . To obt a in zer o-pole-ga in for m , u se t h r ee ou t pu t a r gu m en t s:
[z,p,k] = cheby2(n,Rs,Wn) or [z,p,k] = cheby2(n,Rs,Wn,'ftype') r et u r n s t h e zer os a n d poles in len gt h n colu m n vect or s z a n d p a n d t h e ga in in t h e sca la r k.
x [n + 1 ] = A x [n ] + B u [n ] y [n ] = C x [n ] + D u [n ] a n d u is t h e in pu t , x is t h e st a t e vect or , a n d y is t h e ou t pu t .
Analog Domain
[b,a] = cheby2(n,Rs,Wn,'s') design s a n or der n lowpa ss a n a log Ch ebysh ev t ype II filt er wit h cu t off fr equ en cy Wn. It r et u r n s t h e filt er coefficien t s in t h e len gt h n + 1 r ow vect or s b a n d a, wit h coefficien t s in descen din g power s of s :
B (s ) b (1 ) s n + b (2 ) s n 1 + L + b (n + 1 ) H (s ) = ---------- = --------------------------------------------------------------------------------A (s ) + a (n + 1 ) s n + a (2 ) s n 1 + L Cu toff frequ en cy is t h e fr equ en cy a t wh ich t h e m a gn it u de r espon se of t h e filt er is equ a l t o Rs dB. F or cheby2, t h e cu t off fr equ en cy Wn m u st be gr ea t er t h a n 0. If Wn is a t wo-elem en t vect or , Wn = [w1 w2], wit h w1 < w2, t h en cheby2(n,Rs,Wn,'s') r et u r n s a n or der 2*n ba n dpa ss a n a log filt er wit h pa ssba n d w1 < # < w2.
6-71
cheby2
[b,a] = cheby2(n,Rs,Wn,'ftype','s') design s a h igh pa ss or ba n dst op
filt er , wh er e ftype is high for a h igh pa ss a n a log filt er wit h cu t off fr equ en cy Wn stop for a n or der 2*n ba n dst op a n a log filt er if Wn is a t wo-elem en t vect or ,
Wn = [w1 w2]
Th e st opba n d is w1 < # < w2. Wit h differ en t n u m ber s of ou t pu t a r gu m en t s, cheby2 dir ect ly obt a in s ot h er r ea liza t ion s of t h e a n a log filt er . To obt a in zer o-pole-ga in for m , u se t h r ee ou t pu t a r gu m en t s:
[z,p,k] = cheby2(n,Rs,Wn,'s') or [z,p,k] = cheby2(n,Rs,Wn,'ftype','s') r et u r n s t h e zer os a n d poles in len gt h n or 2*n colu m n vect or s z a n d p a n d t h e ga in in t h e sca la r k.
x = Ax + Bu y = Cx + Du a n d u is t h e in pu t , x is t h e st a t e vect or , a n d y is t h e ou t pu t .
Examples
F or da t a sa m pled a t 1000 H z, design a n in t h -or der lowpa ss Ch ebysh ev t ype II filt er wit h st opba n d a t t en u a t ion 20 dB down fr om t h e pa ssba n d a n d a cu t off fr equ en cy of 300 H z:
[b,a] = cheby2(9,20,300/500);
6-72
cheby2
100 0 -100 -200 -300 -400 0 50 100 150 200 250 300 Frequency (Hertz) 350 400 450 500
Design a fift h -or der ba n dpa ss Ch ebysh ev t ype II filt er wit h pa ssba n d fr om 100 t o 200 H z a n d plot t h e im pu lse r espon se of t h e filt er :
n = 5; r = 20; Wn = [100 200]/500; [b,a] = cheby2(n,r,Wn); [y,t] = impz(b,a,101); stem(t,y)
Impulse Response of n = 5 Chebyshev Type II Filter 0.2
0.15
0.1
0.05
-0.05
-0.1
-0.15
-0.2 0
10
20
30
40
50
60
70
80
90
100
6-73
cheby2
Limitations
F or h igh or der filt er s, t h e st a t e-spa ce for m is t h e m ost n u m er ica lly a ccu r a t e, followed by t h e zer o-pole-ga in for m . Th e t r a n sfer fu n ct ion coefficien t for m is t h e lea st a ccu r a t e; n u m er ica l pr oblem s ca n a r ise for filt er or der s a s low a s 15.
cheby2 u ses a five-st ep a lgor it h m :
1 It fin ds t h e lowpa ss a n a log pr ot ot ype poles, zer os, a n d ga in u sin g t h e
Algorithm
cheb2ap fu n ct ion .
2 It con ver t s poles, zer os, a n d ga in in t o st a t e-spa ce for m . 3 It t r a n sfor m s t h e lowpa ss filt er in t o a ba n dpa ss, h igh pa ss, or ba n dst op filt er
in t o a digit a l filt er t h r ou gh a bilin ea r t r a n sfor m a t ion wit h fr equ en cy pr ewa r pin g. Ca r efu l fr equ en cy a dju st m en t gu a r a n t ees t h a t t h e a n a log filt er s a n d t h e digit a l filt er s will h a ve t h e sa m e fr equ en cy r espon se m a gn it u de a t Wn or w1 a n d w2.
5 It con ver t s t h e st a t e-spa ce filt er ba ck t o t r a n sfer fu n ct ion or zer o-pole-ga in
See Also
Bessel a n a log filt er design . Bu t t er wor t h a n a log a n d digit a l filt er design . Ch ebysh ev t ype II a n a log lowpa ss filt er pr ot ot ype. Ch ebysh ev t ype II filt er or der select ion . Ch ebysh ev t ype I filt er design (pa ssba n d r ipple). E llipt ic (Ca u er ) filt er design .
6-74
chirp
Purpose Syntax
6ch ir p
Description
opt ion s, wh er e method ca n be linear, wh ich specifies a n in st a n t a n eou s fr equ en cy sweep f i (t) given by f i (t ) = f 0 + = t wh er e = = (f 1 f 0 ) t 1 = en su r es t h a t t h e desir ed fr equ en cy br ea kpoin t f 1 a t t im e t 1 is m a in t a in ed. quadratic, wh ich specifies a n in st a n t a n eou s fr equ en cy sweep f i (t) given by f i (t ) = f 0 + = t 2 wh er e = = (f 1 f 0 ) t 1 logarithmic specifies a n in st a n t a n eou s fr equ en cy sweep f i (t) given by f i (t ) = f 0 + 10 = t wh er e = = [ log 10 (f 1 f 0 ) ] t 1 F or a log-sweep, f1 m u st be gr ea t er t h a n f0.
6-75
chirp
y = chirp(t,f0,t1,f1,'method',phi) a llows a n in it ia l ph a se phi t o be specified in degr ees. If u n specified, phi is 0. Defa u lt va lu es a r e su bst it u t ed for em pt y or om it t ed t r a ilin g in pu t a r gu m en t s.
Examples
6-76
chirp
6-77
chirp
See Also
cos diric gauspuls pulstran rectpuls sawtooth sin sinc square tripuls
Cosin e of vect or /m a t r ix elem en t s (see t h e on lin e M A T L AB Fu n ction R eferen ce). Dir ich let or per iodic sin c fu n ct ion . Ga u ssia n -m odu la t ed sin u soida l pu lse gen er a t or. P u lse t r a in gen er a t or. Sa m pled a per iodic r ect a n gle gen er a t or. Sawt oot h or t r ia n gle wave gen er a t or. Sin e of vect or /m a t r ix elem en t s (see t h e on lin e M A T L AB Fu n ction R eferen ce). Sin c fu n ct ion . Squ a r e wa ve gen er a t or. Sa m pled a per iodic t r ia n gle gen er a t or.
6-78
cohere
Purpose Syntax
6coh er e
Description
P x y (f ) 2 C x y (f ) = -----------------------------P x x (f ) P y y (f )
x a n d y m u st be t h e sa m e len gt h . Cxy = cohere(x,y) u ses t h e followin g defa u lt va lu es:
If x is r ea l, cohere est im a t es t h e coh er en ce fu n ct ion a t posit ive fr equ en cies on ly; in t h is ca se, t h e ou t pu t Cxy is a colu m n vect or of len gt h nfft/2 + 1 for nfft even a n d (nfft + 1)/2 for n odd. If x or y is com plex, cohere est im a t es t h e coh er en ce fu n ct ion a t bot h posit ive a n d n ega t ive fr equ en cies, a n d Cxy h a s len gt h nfft.
6-79
cohere
Cxy = cohere(x,y,nfft) u ses t h e F F T len gt h nfft in est im a t in g t h e power spect r u m for x. Specify nfft a s a power of 2 for fa st est execu t ion . [Cxy,f] = cohere(x,y,nfft,Fs) r et u r n s a vect or f of fr equ en cies a t wh ich t h e fu n ct ion eva lu a t es t h e coh er en ce. Fs is t h e sa m plin g fr equ en cy. f is t h e sa m e size a s Cxy, so plot(f,Cxy) plot s t h e coh er en ce fu n ct ion ver su s pr oper ly sca led fr equ en cy. Fs h a s n o effect on t h e ou t pu t Cxy; it is a fr equ en cy sca lin g m u lt iplier . Cxy = cohere(x,y,nfft,Fs,window) specifies a win dowin g fu n ct ion a n d t h e n u m ber of sa m ples per sect ion of t h e vect or s x a n d y. If you su pply a sca la r for window, cohere u ses a H a n n in g win dow of t h a t len gt h . Th e len gt h of t h e win dow m u st be less t h a n or equ a l t o nfft; cohere zer o pa ds t h e sect ion s if t h e win dow len gt h exceeds nfft. Cxy = cohere(x,y,nfft,Fs,window,noverlap) over la ps t h e sect ion s of x by noverlap sa m ples.
linear, t o r em ove t h e best st r a igh t -lin e fit fr om t h e pr ewin dowed sect ion s of x and y mean, t o r em ove t h e m ea n fr om t h e pr ewin dowed sect ion s of x a n d y none, for n o det r en din g (defa u lt ) Th e dflag pa r a m et er m u st a ppea r la st in t h e list of in pu t a r gu m en t s. cohere r ecogn izes a dflag st r in g n o m a t t er h ow m a n y in t er m edia t e a r gu m en t s a r e om it t ed.
cohere wit h n o ou t pu t a r gu m en t s plot s t h e coh er en ce est im a t e ver su s
6-80
cohere
Example
Com pu t e a n d plot t h e coh er en ce est im a t e bet ween t wo color ed n oise sequ en ces x a n d y:
h = fir1(30,0.2,boxcar(31)); h1 = ones(1,10)/sqrt(10); r = randn(16384,1); x = filter(h1,1,r); y = filter(h,1,x); cohere(x,y,1024,[],[],512)
Coherence Function Estimate 1 0.9 0.8
Coherence Function Estimate
0.1
0.2
0.3
0.4
0.7
0.8
0.9
Diagnostics
An a ppr opr ia t e dia gn ost ic m essa ge is displa yed wh en in cor r ect a r gu m en t s a r e u sed:
Requires Requires Requires Requires Requires window's length to be no greater than the FFT length. NOVERLAP to be strictly less than the window length. positive integer values for NFFT and NOVERLAP. vector (either row or column) input. inputs X and Y to have the same length.
Algorithm
m et h od of power spect r u m est im a t ion (see r efer en ces [2] a n d [3]), a s follows:
6-81
cohere
1 It divides t h e sign a ls x a n d y in t o over la ppin g sect ion s, det r en ds ea ch
t h e squ a r es of t h e spect r a of t h e y sect ion s t o for m Pyy, a n d a ver a ges t h e pr odu ct s of t h e spect r a of t h e x a n d y sect ion s t o for m Pxy. It ca lcu la t es Cxy by
Cxy = abs(Pxy).^2/(Pxx.*Pyy)
See Also
E st im a t e t h e cr oss spect r a l den sit y (CSD) of t wo sign a ls. E st im a t e t h e power spect r a l den sit y (P SD) of a sign a l u sin g Welch s m et h od. Tr a n sfer fu n ct ion est im a t e fr om in pu t a n d ou t pu t .
References
[1] Ka y, S.M. M od ern S pectral E stim ation . E n glewood Cliffs, NJ : P r en t ice-H a ll, 1988. P g. 454. [2] Ra bin er , L.R., a n d B. Gold. T h eory an d Application of Digital S ign al Processin g . E n glewood Cliffs, NJ : P r en t ice-H a ll, 1975. [3] Welch , P .D. Th e Use of F a st F ou r ier Tr a n sfor m for t h e E st im a t ion of P ower Spect r a : A Met h od Ba sed on Tim e Aver a gin g Over Sh or t , Modified P er iodogr a m s. IE E E T ran s. Au d io E lectroacou st . Vol. AU-15 (J u n e 1967). P gs. 70-73.
6-82
conv
Purpose Syntax Description
6con v
c(n + 1 ) =
+ a (k + 1 ) b (n k )
k =0
wh er e N is t h e m a xim u m sequ en ce len gt h . Th e ser ies is in dexed fr om n + 1 a n d k + 1 in st ea d of t h e u su a l n a n d k beca u se MATLAB vect or s r u n fr om 1 t o n in st ea d of fr om 0 t o n -1. Th e conv fu n ct ion is pa r t of t h e st a n da r d MATLAB la n gu a ge.
Example
Algorithm
Th e conv fu n ct ion is a n M-file t h a t u ses t h e filter pr im it ive. conv com pu t es t h e con volu t ion oper a t ion a s F IR filt er in g wit h a n a ppr opr ia t e n u m ber of zer os a ppen ded t o t h e in pu t .
conv2 convmtx convn deconv filter residuez xcorr
See Also
Two-dim en sion a l con volu t ion . Con volu t ion m a t r ix. N -dim en sion a l con volu t ion (see t h e on lin e M AT L A B Fu n ction R eferen ce). Decon volu t ion a n d polyn om ia l division . F ilt er da t a wit h a r ecu r sive (IIR) or n on r ecu r sive (F IR) filt er. z -t r a n sfor m pa r t ia l fr a ct ion expa n sion . Cr oss-cor r ela t ion fu n ct ion est im a t e.
6-83
conv2
Purpose Syntax Description
6con v2
m a t r ix is filt er ed in t wo dim en sion s. E a ch dim en sion of t h e ou t pu t m a t r ix C is equ a l in size t o t h e su m of t h e cor r espon din g dim en sion s of t h e in pu t m a t r ices m in u s 1. F or [ma,na] = size(A) a n d [mb,nb] = size(B), t h en
size(C) = [ma+mb1,na+nb1] C = conv2(A,B,'shape') r et u r n s a su bsect ion of t h e t wo-dim en sion a l con volu t ion wit h size specified by shape, wh er e:
full r et u r n s t h e fu ll t wo-dim en sion a l con volu t ion (defa u lt ) same r et u r n s t h e cen t r a l pa r t of t h e con volu t ion t h a t is t h e sa m e size a s A valid r et u r n s on ly t h ose pa r t s of t h e con volu t ion t h a t a r e com pu t ed wit h ou t t h e zer o-pa dded edges. Usin g t h is opt ion , size(C) = [mamb+1,nanb+1] wh en size(A) > size(B)
conv2 execu t es m ost qu ickly wh en size(A) > size(B).
Examples
In im a ge pr ocessin g, t h e Sobel edge-fin din g oper a t ion is a t wo-dim en sion a l con volu t ion of a n in pu t a r r a y wit h t h e specia l m a t r ix
s = [1 2 1; 0 0 0; 1 2 1];
Th e lin es below ext r a ct fir st t h e ver t ica l edges, t h en bot h h or izon t a l a n d ver t ica l edges com bin ed:
v = conv2(I,s'); v2 = (sqrt(h.^2 + v.^2))
6-84
conv2
See Also
Con volu t ion a n d polyn om ia l m u lt iplica t ion . N -dim en sion a l con volu t ion (see t h e on lin e M AT L A B Fu n ction R eferen ce). Decon volu t ion a n d polyn om ia l division . Two-dim en sion a l digit a l filt er in g. Cr oss-cor r ela t ion fu n ct ion est im a t e. Two-dim en sion a l cr oss-cor r ela t ion .
6-85
convmtx
Purpose Syntax Description
6con vm t x
A con volu tion m atrix is a m a t r ix, for m ed fr om a vect or , wh ose in n er pr odu ct wit h a n ot h er vect or is t h e con volu t ion of t h e t wo vect or s.
A = convmtx(c,n) wh er e c is a len gt h m colu m n vect or r et u r n s a m a t r ix A of size (m + n1)-by-n. Th e pr odu ct of A a n d a n ot h er colu m n vect or x of len gt h n is t h e con volu t ion of c wit h x. A = convmtx(r,n) wh er e r is a len gt h m r ow vect or r et u r n s a m a t r ix A of size n-by-(m + n1). Th e pr odu ct of A a n d a n ot h er r ow vect or x of len gt h n is t h e con volu t ion of r wit h x.
Example
Not e t h a t convmtx h a n dles edge con dit ion s by zer o pa ddin g. In pr a ct ice, it is m or e efficien t t o com pu t e con volu t ion u sin g
y = conv(c,x)
Algorithm
6-86
convmtx
See Also
Con volu t ion a n d polyn om ia l m u lt iplica t ion . N -dim en sion a l con volu t ion (see t h e on lin e M AT L A B Fu n ction R eferen ce). Two-dim en sion a l con volu t ion . Discr et e Fou r ier t r a n sfor m m a t r ix.
6-87
corrcoef
Purpose Syntax Description
6cor r coef
m a t r ix wh ose r ows a r e obser va t ion s a n d wh ose colu m n s a r e va r ia bles. If C = cov(X), t h en corrcoef(X) is t h e m a t r ix wh ose elem en t (i , j ) is C (i , j ) cor r coef(i , j ) = ---------------------------------C (i , i ) C (j , j )
C = corrcoef(X) is t h e zer ot h la g of t h e cova r ia n ce fu n ct ion , t h a t is, t h e zer ot h la g of xcov(x,'coeff') pa ck ed in t o a squ a r e a r r a y. C = corrcoef(X,Y) is t h e sa m e a s corrcoef([X Y]), t h a t is, it con ca t en a t es X a n d Y in t h e r ow dir ect ion befor e it s com pu t a t ion . corrcoef r em oves t h e m ea n fr om ea ch colu m n befor e ca lcu la t in g t h e r esu lt s. See t h e xcorr fu n ct ion for cr oss-cor r ela t ion opt ion s.
See Also
Cova r ia n ce m a t r ix. Aver a ge va lu e (see t h e on lin e M AT L AB Fu n ction R eferen ce). Media n va lu e (see t h e on lin e M AT L AB Fu n ction R eferen ce). St a n da r d devia t ion (see t h e on lin e M AT L AB Fu n ction R eferen ce). Cr oss-cor r ela t ion fu n ct ion est im a t e. Cr oss-cova r ia n ce fu n ct ion est im a t e (equ a l t o m ea n -r em oved cr oss-cor r ela t ion ).
6-88
cov
Purpose Syntax Description
6cov
Cova r ia n ce m a t r ix.
c = cov(x) c = cov(x,y) cov com pu t es t h e cova r ia n ce m a t r ix. If x is a vect or , c is a sca la r con t a in in g t h e
va r ia n ce. F or a n a r r a y wh er e ea ch r ow is a n obser va t ion a n d ea ch colu m n a va r ia ble, cov(X) is t h e cova r ia n ce m a t r ix. diag(cov(X)) is a vect or of va r ia n ces for ea ch colu m n , a n d sqrt(diag(cov(X))) is a vect or of st a n da r d devia t ion s.
cov(x) is t h e zer ot h la g of t h e cova r ia n ce fu n ct ion , t h a t is, t h e zer ot h la g of xcov(x)/(n1) pa ck ed in t o a squ a r e a r r a y. cov(x,y) wh er e x a n d y a r e colu m n vect or s of equ a l len gt h is equ iva len t t o cov([x y])), t h a t is, it con ca t en a t es x a n d y in t h e r ow dir ect ion befor e it s
com pu t a t ion .
cov r em oves t h e m ea n fr om ea ch colu m n befor e ca lcu la t in g t h e r esu lt s.
Algorithm
[n,p] = size(x); x = xones(n,1)*(sum(x)/n); y = x'*x/(n1); corrcoef mean median std xcorr xcov
See Also
Cor r ela t ion coefficien t m a t r ix. Aver a ge va lu e (see t h e on lin e M AT L AB Fu n ction R eferen ce). Media n va lu e (see t h e on lin e M AT L AB Fu n ction R eferen ce). St a n da r d devia t ion (see t h e on lin e M A T L AB Fu n ction R eferen ce). Cr oss-cor r ela t ion fu n ct ion est im a t e. Cr oss-cova r ia n ce fu n ct ion est im a t e (equ a l t o m ea n -r em oved cr oss-cor r ela t ion ).
6-89
cplxpair
Purpose Syntax Description
6cp lxpa ir
elem en t wit h n ega t ive im a gin a r y pa r t com es fir st . Th e fu n ct ion r et u r n s a ll pu r ely r ea l va lu es followin g a ll t h e com plex pa ir s.
y = cplxpair(x,tol) in clu des a t oler a n ce, tol, for det er m in in g wh ich n u m ber s a r e r ea l a n d wh ich a r e pa ir ed com plex con ju ga t es. By defa u lt , cplxpair u ses a t oler a n ce of 100*eps r ela t ive t o abs(x(i)). cplxpair for ces t h e com plex con ju ga t e pa ir s t o be exa ct com plex con ju ga t es.
Example
Or der five poles even ly spa ced a r ou n d t h e u n it cir cle in t o com plex pa ir s:
cplxpair(exp(2*pi*sqrt(1)*(0:4)/5)') ans = 0.8090 0.8090 0.3090 0.3090 1.0000 + + 0.5878i 0.5878i 0.9511i 0.9511i
Diagnostics
If t h er e is a n odd n u m ber of com plex n u m ber s, or if t h e com plex n u m ber s ca n n ot be gr ou ped in t o com plex con ju ga t e pa ir s wit h in t h e t oler a n ce, cplxpair gen er a t es t h e er r or m essa ge:
Complex numbers can't be paired.
6-90
cremez
Purpose Syntax
6cr em ez
Description
design of a possibly com plex F IR filt er . Th e Ch ebysh ev (or m in im a x) filt er er r or is opt im ized, pr odu cin g equ ir ipple F IR filt er design s.
b = cremez(n,f,'fresp') r et u r n s a len gt h n+1 F IR filt er wit h t h e best a ppr oxim a t ion t o t h e desir ed fr equ en cy r espon se a s r et u r n ed by fu n ct ion fresp. f is a vect or of fr equ en cy ba n d edge pa ir s, specified in t h e r a n ge -1 a n d 1, wh er e 1 cor r espon ds t o h a lf t h e sa m plin g fr equ en cy (t h e Nyqu ist fr equ en cy). Th e fr equ en cies m u st be in in cr ea sin g or der , a n d f m u st h a ve even len gt h . Th e fr equ en cy ba n ds spa n f(k) t o f(k+1) for k odd; t h e in t er va ls f(k+1) t o f(k+2) for k odd a r e t r a n sit ion ba n ds or don t ca r e r egion s du r in g opt im iza t ion . b = cremez(n,f,'fresp',w) u ses t h e r ea l, n on -n ega t ive weigh t s in vect or w t o weigh t t h e fit in ea ch fr equ en cy ba n d. Th e len gt h of w is h a lf t h e len gt h of f, so t h er e is exa ct ly on e weigh t per ba n d. b = cremez(n,f,{'fresp',p1,p2,...},...) su pplies opt ion a l pa r a m et er s p1, p2, ..., t o t h e fr equ en cy r espon se fu n ct ion fresp. P r edefin ed 'fresp'
fr equ en cy r espon se fu n ct ion s a r e in clu ded for a n u m ber of com m on filt er design s, a s descr ibed below. F or a ll of t h e pr edefin ed fr equ en cy r espon se fu n ct ion s, t h e sym m et r y opt ion 'sym' defa u lt s t o 'even' if n o n ega t ive fr equ en cies a r e con t a in ed in f a n d d = 0; ot h er wise 'sym' defa u lt s t o 'none'. (See t h e 'sym' opt ion below for det a ils.) F or a ll of t h e pr edefin ed fr equ en cy r espon se fu n ct ion s, d specifies a gr ou p-dela y offset su ch t h a t t h e filt er r espon se
6-91
cremez
h a s a gr ou p dela y of n/2+d in u n it s of t h e sa m ple in t er va l. Nega t ive va lu es cr ea t e less dela y; posit ive va lu es cr ea t e m or e dela y. By defa u lt , d = 0. lowpass, highpass, bandpass, bandstop Th ese fu n ct ion s sh a r e a com m on syn t a x, exem plified h er e by 'lowpass':
b = cremez(n,f,'lowpass',...) a n d b = cremez(n,f,{'lowpass',d},...) design a lin ea r -ph a se (n/2+d dela y)
filt er . multiband design s a lin ea r -ph a se fr equ en cy r espon se filt er wit h a r bit r a r y ba n d a m plit u des.
b = cremez(n,f,{'multiband',a},...) a n d b = cremez(n,f,{'multiband',a,d},...) specify vect or a con t a in in g t h e desir ed a m plit u des a t t h e ba n d edges in f. Th e desir ed a m plit u de a t fr equ en cies bet ween pa ir s of poin t s f(k) a n d f(k+1) for k odd is t h e lin e segm en t con n ect in g t h e poin t s (f(k),a(k)) a n d (f(k+1),a(k+1)).
differentiator design s a lin ea r -ph a se differ en t ia t or . F or t h ese design s, zer o-fr equ en cy m u st be in a t r a n sit ion ba n d, a n d ba n d weigh t in g is set t o be in ver sely pr opor t ion a l t o fr equ en cy.
b = cremez(n,f,{'differentiator',Fs},...) a n d b = cremez(n,f,{'differentiator',Fs,d},...) specify t h e sa m ple r a t e Fs u sed t o det er m in e t h e slope of t h e differ en t ia t or r espon se. If om it t ed, Fs
defa u lt s t o 1. hilbfilt design s a lin ea r -ph a se H ilber t t r a n sfor m filt er r espon se. F or H ilber t design s, zer o-fr equ en cy m u st be in a t r a n sit ion ba n d.
b = cremez(n,f,'hilbfilt',...) a n d b = cremez(N,F,{'hilbfilt',d},...) design a lin ea r -ph a se (n/2+d dela y)
6-92
cremez
'none' in dica t es n o sym m et r y con st r a in t Th is is t h e defa u lt if a n y n ega t ive ba n d edge fr equ en cies a r e pa ssed, or if
'fresp' does n ot su pply a defa u lt .
'even' in dica t es a r ea l a n d even im pu lse r espon se Th is is t h e defa u lt for h igh pa ss, lowpa ss, ba n dpa ss, ba n dst op, a n d m u lt iba n d design s. 'odd' in dica t es a r ea l a n d odd im pu lse r espon se Th is is t h e defa u lt for H ilber t a n d differ en t ia t or design s. 'real' in dica t es con ju ga t e sym m et r y for t h e fr equ en cy r espon se If a n y 'sym' opt ion ot h er t h a n 'none' is specified, t h e ba n d edges sh ou ld on ly be specified over posit ive fr equ en cies; t h e n ega t ive fr equ en cy r egion is filled in fr om sym m et r y. If a 'sym' opt ion is n ot specified, t h e 'fresp' fu n ct ion is qu er ied for a defa u lt set t in g.
b = cremez(...,'skip_stage2') disa bles t h e secon d-st a ge opt im iza t ion a lgor it h m , wh ich execu t es on ly wh en cremez det er m in es t h a t a n opt im a l solu t ion h a s n ot been r ea ch ed by t h e st a n da r d Rem ez er r or -exch a n ge. Disa blin g t h is a lgor it h m m a y in cr ea se t h e speed of com pu t a t ion , bu t m a y in cu r a r edu ct ion in a ccu r a cy. By defa u lt , t h e secon d-st a ge opt im iza t ion is en a bled. b = cremez(...,'debug') en a bles t h e displa y of in t er m edia t e r esu lt s du r in g t h e filt er design , wh er e 'debug' m a y be on e of 'trace', 'plots', 'both', or 'off'. By defa u lt , it is set t o 'off'. b = cremez(...,{lgrid}) u ses t h e in t eger lgrid t o con t r ol t h e den sit y of t h e fr equ en cy gr id, wh ich h a s r ou gh ly 2^nextpow2(lgrid*n) fr equ en cy poin t s. Th e defa u lt va lu e for lgrid is 25. Not e t h a t t h e {lgrid} a r gu m en t m u st be a 1-by-1 cell a r r a y.
An y com bin a t ion of t h e 'sym', 'skip_stage2', 'debug', a n d {lgrid} opt ion s m a y be specified.
[b,delta] = cremez(...) r et u r n s t h e m a xim u m r ipple h eigh t delta.
6-93
cremez
[b,delta,opt] = cremez(...) r et u r n s a st r u ct u r e opt of opt ion a l r esu lt s com pu t ed by cremez a n d con t a in s t h e followin g fields: opt.fgrid opt.des opt.wt opt.H opt.error opt.iextr opt.fextr
F r equ en cy gr id vect or u sed for t h e filt er design opt im iza t ion Desir ed fr equ en cy r espon se for ea ch poin t in opt.fgrid Weigh t in g for ea ch poin t in opt.fgrid Act u a l fr equ en cy r espon se for ea ch poin t in opt.fgrid E r r or a t ea ch poin t in opt.fgrid Vect or of in dices in t o opt.fgrid for ext r em a l fr equ en cies Vect or of ext r em a l fr equ en cies
Examples
Example 1
Design a 31-t a p, lin ea r -ph a se, lowpa ss filt er :
b = cremez(30,[1 0.5 0.4 0.7 0.8 1],'lowpass'); freqz(b,1,512,'whole');
50 Magnitude (dB)
!50
0.2
0.4 0.6 0.8 1 1.2 1.4 1.6 Normalized Angular Frequency (A$ rads/sample)
1.8
0.2
0.4 0.6 0.8 1 1.2 1.4 1.6 Normalized Angular Frequency (A$ rads/sample)
1.8
6-94
cremez
Example 2
Design a n on lin ea r -ph a se a llpa ss F IR filt er . F ir st select (or cr ea t e) t h e fu n ct ion fresp t h a t r et u r n s t h e desir ed fr equ en cy r espon se. F or t h is exa m ple, fresp is t h e allpass.m fu n ct ion in t h e signal/signal/private dir ect or y wh ich r et u r n s t h e fr equ en cy r espon se of a n on lin ea r -ph a se a llpa ss filt er . Copy allpass.m t o a n ot h er loca t ion on t h e MATLAB pa t h befor e t r yin g t h e exa m ple. Befor e u sin g cremez wit h allpass.m t o gen er a t e t h e filt er coefficien t s, ca ll allpass a lon e t o cr ea t e t h e d esired r espon se.
n = 22; f = [1 1]; w = [1 1]; gf = linspace(1,1,256); d = allpass(n,f,gf,w); % % % % % Filter order Frequency band edges Weights for optimization Grid of frequency points Desired frequency response
Vect or d n ow con t a in s t h e com plex fr equ en cy r espon se t h a t we desir e for t h e F IR filt er com pu t ed by cremez. Now com pu t e t h e F IR filt er t h a t best a ppr oxim a t es t h is r espon se:
b = cremez(n,f,'allpass',w,'real' ); % Approximation freqz(b,1,256,'whole');
0.2 Magnitude (dB) 0.1 0 !0.1 !0.2 0 0 Phase (degrees) 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 Normalized Angular Frequency (A$ rads/sample) 1.8 2
!1000
!2000
!3000 0
0.2
0.4 0.6 0.8 1 1.2 1.4 1.6 Normalized Angular Frequency (A$ rads/sample)
1.8
6-95
cremez
Th e freqz plot sh ows t h e fr equ en cy r espon se of t h e filt er com pu t ed by cremez t o a ppr oxim a t e t h e desir ed r espon se. Ch eck t h e a ccu r a cy of t h e a ppr oxim a t ion by over la yin g t h e d esired fr equ en cy r espon se on t h e plot .
subplot(2,1,1); hold on plot(pi*(gf+1),20*log10(abs(fftshift(d))),'r--') subplot(2,1,2); hold on plot(pi*(gf+1),unwrap(angle(fftshift(d)))*180/pi,'r--') legend('Approximation','Desired')
0.2 Magnitude (dB) 0.1 0 !0.1 !0.2 0 0 Phase (degrees) Approximation Desired !1000 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 Normalized Angular Frequency (A$ rads/sample) 1.8 2
!2000
!3000 0
0.2
0.4 0.6 0.8 1 1.2 1.4 1.6 Normalized Angular Frequency (A$ rads/sample)
1.8
Remarks
User -defin a ble fu n ct ion s m a y be u sed, in st ea d of t h e pr edefin ed fr equ en cy r espon se fu n ct ion s for 'fresp'. Th e fu n ct ion is ca lled fr om wit h in cremez u sin g t h e followin g syn t a x:
[dh,dw] = fresp(n,f,gf,w,p1,p2,...) wh er e
n is t h e filt er or der . f is t h e vect or of fr equ en cy ba n d edges t h a t a ppea r m on ot on ica lly bet ween -1 a n d 1, wh er e 1 is t h e Nyqu ist fr equ en cy. gf is a vect or of gr id poin t s t h a t h a ve been lin ea r ly in t er pola t ed over ea ch specified fr equ en cy ba n d by cremez. gf det er m in es t h e fr equ en cy gr id a t wh ich t h e r espon se fu n ct ion m u st be eva lu a t ed. Th is is t h e sa m e da t a r et u r n ed by cremez in t h e fgrid field of t h e opt st r u ct u r e.
6-96
cremez
w is a vect or of r ea l, posit ive weigh t s, on e per ba n d, u sed du r in g opt im iza t ion . w is opt ion a l in t h e ca ll t o cremez; if n ot specified, it is set t o u n it y weigh t in g befor e bein g pa ssed t o 'fresp'. dh a n d dw a r e t h e desir ed com plex fr equ en cy r espon se a n d ba n d weigh t vect or s, r espect ively, eva lu a t ed a t ea ch fr equ en cy in gr id gf. p1, p2, ..., a r e opt ion a l pa r a m et er s t h a t m a y be pa ssed t o 'fresp'. Addit ion a lly, a pr elim in a r y ca ll is m a de t o 'fresp' t o det er m in e t h e defa u lt sym m et r y pr oper t y 'sym'. Th is ca ll is m a de u sin g t h e syn t a x:
sym = fresp('defaults',{n,f,[],w,p1,p2,...})
Th e a r gu m en t s m a y be u sed in det er m in in g a n a ppr opr ia t e sym m et r y defa u lt a s n ecessa r y. Th e fu n ct ion private/lowpass.m m a y be u sefu l a s a t em pla t e for gen er a t in g n ew fr equ en cy r espon se fu n ct ion s.
Algorithm
An ext en ded ver sion of t h e Rem ez exch a n ge m et h od is im plem en t ed for t h e com plex ca se. Th is exch a n ge m et h od obt a in s t h e opt im a l filt er wh en t h e equ ir ipple n a t u r e of t h e filt er is r est r ict ed t o h a ve n+2 ext r em a ls. Wh en it does n ot con ver ge, t h e a lgor it h m swit ch es t o a n a scen t -descen t a lgor it h m t h a t t a kes over t o fin ish t h e con ver gen ce t o t h e opt im a l solu t ion . See t h e r efer en ces for fu r t h er det a ils.
6-97
cremez
Diagnostics
6-98
cremez
See Also
fir1 fir2 firls remez private/bandpass private/bandstop private/different iator private/highpass private/hilbfilt private/lowpass private/multiband
Win dow-ba sed fin it e im pu lse r espon se filt er design st a n da r d r espon se. Win dow-ba sed fin it e im pu lse r espon se filt er design a r bit r a r y r espon se. Lea st squ a r e lin ea r -ph a se F IR filt er design . P a r ks-McClella n opt im a l F IR filt er design . Ba n dpa ss filt er design fu n ct ion . Ba n dst op filt er design fu n ct ion . Differ en t ia t or filt er design fu n ct ion . H igh pa ss filt er design fu n ct ion . H ilber t filt er design fu n ct ion . Lowpa ss filt er design fu n ct ion . Mu lt iba n d filt er design fu n ct ion .
References
[1] Ka r a m , L.J ., a n d J .H . McClella n . Com plex Ch ebysh ev Appr oxim a t ion for F IR F ilt er Design . IE E E T ran s. on Circu its an d S ystem s II . Ma r ch 1995. P gs. 207-216. [2] Ka r a m , L.J . Design of Com plex Digital FIR Filters in th e Ch ebysh ev S en se . P h .D. Th esis, Geor gia In st it u t e of Tech n ology, Ma r ch 1995. [3] Dem ja n jov, V.F ., a n d V.N. Ma lozem ov. In trod u ction to M in im ax . New Yor k : J oh n Wiley & Son s, 1974.
6-99
csd
Purpose Syntax
6csd
Description
If x a n d y a r e r ea l, csd est im a t es t h e cr oss spect r a l den sit y a t posit ive fr equ en cies on ly; in t h is ca se, t h e ou t pu t Pxy is a colu m n vect or of len gt h nfft/2 + 1 for nfft even a n d (nfft + 1)/2 for nfft odd. If x or y is com plex, csd est im a t es t h e cr oss spect r a l den sit y a t bot h posit ive a n d n ega t ive fr equ en cies a n d Pxy h a s len gt h nfft.
Pxy = csd(x,y,nfft) u ses t h e F F T len gt h nfft in est im a t in g t h e cr oss spect r a l den sit y of x a n d y. Specify nfft a s a power of 2 for fa st est execu t ion . [Pxy,f] = csd(x,y,nfft,Fs) r et u r n s a vect or f of fr equ en cies a t wh ich t h e fu n ct ion eva lu a t es t h e CSD. f is t h e sa m e size a s Pxy, so plot(f,Pxy) plot s t h e
6-100
csd
spect r u m ver su s pr oper ly sca led fr equ en cy. Fs h a s n o effect on t h e ou t pu t Pxy; it is a fr equ en cy sca lin g m u lt iplier .
Pxy = csd(x,y,nfft,Fs,window) specifies a win dowin g fu n ct ion a n d t h e n u m ber of sa m ples per sect ion of t h e x vect or . If you su pply a sca la r for window, csd u ses a H a n n in g win dow of t h a t len gt h . Th e len gt h of t h e win dow m u st be less t h a n or equ a l t o nfft; csd zer o pa ds t h e sect ion s if t h e len gt h of t h e win dow is less t h a n nfft. csd r et u r n s a n er r or if t h e len gt h of t h e win dow is gr ea t er t h a n nfft. Pxy = csd(x,y,nfft,Fs,window,noverlap) over la ps t h e sect ion s of x a n d y by noverlap sa m ples.
linear, t o r em ove t h e best st r a igh t -lin e fit fr om t h e pr ewin dowed sect ion s of x and y mean, t o r em ove t h e m ea n fr om t h e pr ewin dowed sect ion s of x a n d y none, for n o det r en din g (defa u lt ) Th e dflag pa r a m et er m u st a ppea r la st in t h e list of in pu t a r gu m en t s. csd r ecogn izes a dflag st r in g n o m a t t er h ow m a n y in t er m edia t e a r gu m en t s a r e om it t ed.
[Pxy,Pxyc,f] = csd(x,y,nfft,Fs,window,noverlap,p) wh er e p is a posit ive sca la r bet ween 0 a n d 1 r et u r n s a vect or Pxyc t h a t con t a in s a n est im a t e of t h e p*100 per cen t con fiden ce in t er va l for Pxy. Pxyc is a t wo-colu m n m a t r ix t h e sa m e len gt h a s Pxy. Th e in t er va l [Pxyc(:,1), Pxyc(:,2)] cover s t h e t r u e CSD wit h pr oba bilit y p. plot(f,[Pxy Pxyc]) plot s t h e cr oss spect r u m in side t h e p*100 per cen t con fiden ce in t er va l. If u n specified, p defa u lt s t o 0.95.
6-101
csd
csd(x,y,...) plot s t h e CSD ver su s fr equ en cy in t h e cu r r en t figu r e win dow. If t h e p pa r a m et er is specified, t h e plot in clu des t h e con fiden ce in t er va l.
Example
Gen er a t e t wo color ed n oise sign a ls a n d plot t h eir CSD wit h a con fiden ce in t er va l of 95%. Specify a len gt h 1024 F F T, a 500 poin t t r ia n gu la r win dow wit h n o over la p, a n d a sa m plin g fr equ en cy of 10 H z:
h = fir1(30,0.2,boxcar(31)); h1 = ones(1,10)/sqrt(10); r = randn(16384,1); x = filter(h1,1,r); y = filter(h,1,x); csd(x,y,1024,10000,triang(500),0,[])
20 10 Cross Spectrum Magnitude (dB) 0 -10 -20 -30 -40 -50 -60 -70
1000
4000
5000
Algorithm
csd im plem en t s t h e Welch m et h od of spect r a l den sit y est im a t ion (see r efer en ces [1] a n d [2]):
1 It a pplies t h e win dow specified by t h e window vect or t o ea ch su ccessive
6-102
csd
4 It a ver a ges t h e per iodogr a m s of t h e su ccessive over la ppin g sect ion s t o for m
Diagnostics
An a ppr opr ia t e dia gn ost ic m essa ge is displa yed wh en in cor r ect a r gu m en t s t o csd a r e u sed:
Requires Requires Requires Requires Requires Requires window's length to be no greater than the FFT length. NOVERLAP to be strictly less than the window length. positive integer values for NFFT and NOVERLAP. vector (either row or column) input. inputs X and Y to have the same length. confidence parameter to be a scalar between 0 and 1.
See Also
E st im a t e m a gn it u de squ a r ed coh er en ce fu n ct ion bet ween t wo sign a ls. Power spect r u m est im a t e u sin g t h e Bu r g m et h od. Power spect r u m est im a t e u sin g t h e m u lt it a per m et h od (MTM). Power spect r u m est im a t e u sin g MUSIC eigen vect or m et h od. E st im a t e t h e power spect r a l den sit y (P SD) of a sign a l u sin g Welch s m et h od. Power spect r u m est im a t e u sin g Yu le-Wa lker AR m et h od. Tr a n sfer fu n ct ion est im a t e fr om in pu t a n d ou t pu t .
References
[1] Ra bin er , L.R., a n d B. Gold. T h eory an d Application of Digital S ign al Processin g. E n glewood Cliffs, NJ : P r en t ice-H a ll, 1975. P gs. 414-419. [2] Welch , P .D. Th e Use of F a st F ou r ier Tr a n sfor m for t h e E st im a t ion of P ower Spect r a : A Met h od Ba sed on Tim e Aver a gin g Over Sh or t , Modified P er iodogr a m s. IE E E T ran s. A u d io E lectroacou st . Vol. AU-15 (J u n e 1967). P gs. 70-73.
6-103
csd
[3] Oppen h eim , A.V., a n d R.W. Sch a fer . Discrete-T im e S ign al Processin g. E n glewood Cliffs, NJ : P r en t ice-H a ll, 1989. P g. 737.
6-104
czt
Purpose Syntax Description
6czt
Ch ir p z -t r a n sfor m .
y = czt(x,m,w,a) y = czt(x) y = czt(x,m,w,a) r et u r n s t h e ch ir p z -t r a n sfor m of sign a l x. Th e ch ir p z -t r a n sfor m is t h e z -t r a n sfor m of x a lon g a spir a l con t ou r defin ed by w a n d a. m is a sca la r t h a t specifies t h e len gt h of t h e t r a n sfor m , w is t h e r a t io bet ween poin t s a lon g t h e z -pla n e spir a l con t ou r of in t er est , a n d sca la r a is t h e com plex
m = length(x) w = exp(j*2*pi/m) a = 1 Wit h t h ese defa u lt s, czt r et u r n s t h e z -t r a n sfor m of x a t m equ a lly spa ced poin t s a r ou n d t h e u n it cir cle. Th is is equ iva len t t o t h e discr et e F ou r ier t r a n sfor m of x, or fft(x). Th e em pt y m a t r ix [] specifies t h e defa u lt va lu e for a pa r a m et er . If x is a m a t r ix, czt(x,m,w,a) t r a n sfor m s t h e colu m n s of x.
Examples
Cr ea t e a r a n dom vect or x of len gt h 1013 a n d com pu t e it s DF T u sin g czt. Th is is fa st er t h a n t h e fft fu n ct ion on t h e sa m e sequ en ce.
x = randn(1013,1); y = czt(x);
Use czt t o zoom in on a n a r r ow-ba n d sect ion (100 t o 150 H z) of a filt er s fr equ en cy r espon se. F ir st design t h e filt er :
h = fir1(30,125/500,boxcar(31)); % filter
6-105
czt
Algorithm
czt u ses t h e n ext power -of-2 len gt h F F T t o per for m a fa st con volu t ion wh en com pu t in g t h e z -t r a n sfor m on a specified ch ir p con t ou r [1]. czt ca n be sign ifica n t ly fa st er t h a n fft for la r ge, pr im e-len gt h sequ en ces.
Diagnostics
6-106
czt
See Also
fft freqz
References
[1] Ra bin er , L.R., a n d B. Gold. T h eory an d Application of Digital S ign al Processin g. E n glewood Cliffs, NJ : P r en t ice-H a ll, 1975. P gs. 393-399.
6-107
dct
Purpose Syntax Description
6dct
y (k ) = w (k ) wh er e
+
n =1
k = 1 , , N
k =1 25k 5N
N is t h e len gt h of x, a n d x a n d y a r e t h e sa m e size. If x is a m a t r ix, dct t r a n sfor m s it s colu m n s. Th e ser ies is in dexed fr om n = 1 a n d k = 1 in st ea d of t h e u su a l n = 0 a n d k = 0 beca u se MATLAB vect or s r u n fr om 1 t o N in st ea d of fr om 0 t o N - 1.
y = dct(x,n) pa ds or t r u n ca t es x t o len gt h n befor e t r a n sfor m in g.
Th e DCT is closely r ela t ed t o t h e discr et e F ou r ier t r a n sfor m . You ca n oft en r econ st r u ct a sequ en ce ver y a ccu r a t ely fr om on ly a few DCT coefficien t s, a u sefu l pr oper t y for a pplica t ion s r equ ir in g da t a r edu ct ion .
6-108
dct
Example
See Also
On e-dim en sion a l fa st Fou r ier t r a n sfor m . In ver se discr et e cosin e t r a n sfor m . Two-dim en sion a l DCT (see Im age Processin g T oolbox Users Gu id e). Two-dim en sion a l in ver se DCT (see Im age Processin g T oolbox Users Gu id e).
References
[1] J a in , A.K. Fu n d am en tals of Digital Im age Processin g . E n glewood Cliffs, NJ : P r en t ice-H a ll, 1989. [2] P en n eba ker , W.B., a n d J .L. Mit ch ell. J PE G S till Im age Data Com pression S tan d ard . New Yor k , NY: Va n Nost r a n d Rein h old, 1993. Ch a pt er 4.
6-109
decimate
Purpose Syntax
6decim a t e
Description
Decim a t ion r edu ces t h e or igin a l sa m plin g r a t e for a sequ en ce t o a lower r a t e. It is t h e opposit e of in t er pola t ion . Th e decim a t ion pr ocess filt er s t h e in pu t da t a wit h a lowpa ss filt er a n d t h en r esa m ples t h e r esu lt in g sm oot h ed sign a l a t a lower r a t e.
y = decimate(x,r) r edu ces t h e sa m ple r a t e of x by a fa ct or r. Th e decim a t ed vect or y is r t im es sh or t er in len gt h t h a n t h e in pu t vect or x. By defa u lt , decimate em ploys a n eigh t h -or der lowpa ss Ch ebysh ev t ype I filt er . It filt er s t h e in pu t sequ en ce in bot h t h e for wa r d a n d r ever se dir ect ion s t o r em ove a ll ph a se dist or t ion , effect ively dou blin g t h e filt er or der . y = decimate(x,r,n) u ses a n or der n Ch ebysh ev filt er . Or der s a bove 13 a r e n ot r ecom m en ded beca u se of n u m er ica l in st a bilit y. MATLAB displa ys a wa r n in g in t h is ca se. y = decimate(x,r,'fir') u ses a 30-poin t F IR filt er , in st ea d of t h e Ch ebysh ev IIR filt er . H er e decimate filt er s t h e in pu t sequ en ce in on ly on e dir ect ion . Th is t ech n iqu e con ser ves m em or y a n d is u sefu l for wor k in g wit h lon g sequ en ces. y = decimate(x,r,n,'fir') u ses a len gt h n F IR filt er .
Example
6-110
decimate
% original signal
% decimated signal
Decimated Signal
50
100
10
20
30
Algorithm
filt er wit h n or m a lized cu t off fr equ en cy 0.8/r a n d 0.05 dB of pa ssba n d r ipple. F or t h e fir opt ion , decimate design s a lowpa ss F IR filt er wit h cu t off fr equ en cy 1/r u sin g fir1.
2 F or t h e F IR filt er , decimate a pplies t h e filt er t o t h e in pu t vect or in on e
dir ect ion . In t h e IIR ca se, decimate a pplies t h e filt er in for wa r d a n d r ever se dir ect ion s wit h filtfilt.
3 decimate r esa m ples t h e filt er ed da t a by select in g ever y r-t h poin t .
Diagnostics
6-111
decimate
See Also
interp resample spline upfirdn
In cr ea se sa m plin g r a t e by a n in t eger fa ct or (in t er pola t ion ). Ch a n ge sa m plin g r a t e by a n y r a t ion a l fa ct or. Cu bic splin e in t er pola t ion (see t h e on lin e M A T L AB Fu n ction R eferen ce). Upsa m ple, a pply a n F IR filt er, a n d down sa m ple.
References
[1] IE E E . Program s for Digital S ign al Processin g. IE E E P r ess. New Yor k: J oh n Wiley & Son s, 1979. Ch a pt er 8.
6-112
deconv
Purpose Syntax Description
6decon v
If a a n d b a r e vect or s of polyn om ia l coefficien t s, con volvin g t h em is equ iva len t t o polyn om ia l m u lt iplica t ion , a n d decon volu t ion is equ iva len t t o polyn om ia l division . Th e r esu lt of dividin g b by a is qu ot ien t q a n d r em a in der r. Th e deconv fu n ct ion is pa r t of t h e st a n da r d MATLAB la n gu a ge.
Example
Th is fu n ct ion ca lls filter t o com pu t e t h e decon volu t ion a s t h e im pu lse r espon se of a n IIR filt er .
conv filter residuez
Con volu t ion a n d polyn om ia l m u lt iplica t ion . F ilt er da t a wit h a r ecu r sive (IIR) or n on r ecu r sive (F IR) filt er. z -t r a n sfor m pa r t ia l fr a ct ion expa n sion .
6-113
demod
Purpose Syntax
6dem od
Description
or
am amdsbtc
Am p litu d e d e m o d u la ti o n , d o u ble s id e b a n d , tra n s m i tte d c a rrie r. Mu lt iplies y by a sin u soid of fr equ en cy Fc, a n d a pplies a
Am p litu d e d e m o d u la ti o n , s i n g le s id e ba n d . Mu lt iplies y by a
sin u soid of fr equ en cy Fc a n d a pplies a fift h -or der Bu t t er wor t h lowpa ss filt er u sin g filtfilt:
x = y.*cos(2*pi*Fc*t); [b,a] = butter(5,Fc*2/Fs); x = filtfilt(b,a,x);
6-114
demod
fm
F re qu e n c y d e m o d u la tio n . Dem odu la t es t h e F M wavefor m by m odu la t in g t h e H ilber t t r a n sfor m of y by a com plex expon en t ia l of fr equ en cy Fc H z a n d obt a in s t h e in st a n t a n eou s fr equ en cy of t h e r esu lt . P h a s e d e m o d u la tio n . Dem odu la t es t h e P M wa vefor m by m odu la t in g t h e H ilber t t r a n sfor m of y by a com plex expon en t ia l of fr equ en cy Fc H z a n d obt a in s t h e in st a n t a n eou s ph a se of t h e r esu lt . P u ls e -tim e d e m o d u la tio n . F in ds t h e pu lse t im es of a pu lse-t im e m odu la t ed sign a l y. For cor r ect dem odu la t ion , t h e pu lses ca n n ot over la p. x is len gt h length(t)*Fc/Fs. P u ls e -w id th d e m o d u la tio n . Fin ds t h e pu lse widt h s of a pu lse-widt h m odu la t ed sign a l y. demod r et u r n s in x a vect or wh ose elem en t s specify t h e widt h of ea ch pu lse in fr a ct ion s of a per iod. Th e pu lses in y sh ou ld st a r t a t t h e begin n in g of ea ch ca r r ier per iod, t h a t is, t h ey sh ou ld be left ju st ified. Qu a d ra tu re a m p litu d e d e m o d u la tio n .
[x1,x2] = demod(y,Fc,Fs,'qam') m u lt iplies y by a cosin e a n d a sin e of fr equ en cy Fc a n d a pplies a fift h -or der Bu t t er wor t h lowpa ss filt er u sin g filtfilt: x1 = y.*cos(2*pi*Fc*t); x2 = y.*sin(2*pi*Fc*t); [b,a] = butter(5,Fc*2/Fs); x1 = filtfilt(b,a,x1); x2 = filtfilt(b,a,x2);
pm
ptm
pwm
qam
Th e defa u lt m et h od is 'am'. E xcept for t h e 'ptm' a n d 'pwm' ca ses, x is t h e sa m e size a s y. If y is a m a t r ix, demod dem odu la t es it s colu m n s.
x = demod(y,Fc,Fs,'pwm','centered') fin ds t h e pu lse widt h s a ssu m in g t h ey a r e cen t er ed a t t h e begin n in g of ea ch per iod. x is len gt h length(y)*Fc/Fs.
6-115
demod
See Also
modulate vco
Modu la t ion for com m u n ica t ion s sim u la t ion . Volt a ge con t r olled oscilla t or.
6-116
dftmtx
Purpose Syntax Description
6dft m t x
A d iscrete Fou rier tran sform m atrix is a com plex m a t r ix of va lu es a r ou n d t h e u n it cir cle, wh ose m a t r ix pr odu ct wit h a vect or com pu t es t h e discr et e F ou r ier t r a n sfor m of t h e vect or .
A = dftmtx(n) r et u r n s t h e n-by-n com plex m a t r ix A t h a t , wh en m u lt iplied in t o a len gt h n colu m n vect or x: y = A*x
Example
In pr a ct ice, t h e discr et e F ou r ier t r a n sfor m is com pu t ed m or e efficien t ly a n d u ses less m em or y wit h a n F F T a lgor it h m
x = 1:256; y1 = fft(x);
6-117
diric
Purpose Syntax Description
6dir ic
x = 0 , 2 $, 4 $, else
for a n y n on zer o in t eger n. Th is fu n ct ion h a s per iod 2 $ for n odd a n d per iod 4 $ for n even . It s pea k va lu e is 1, a n d it s m in im u m va lu e is -1 for n even . Th e m a gn it u de of t h is fu n ct ion is (1/n) t im es t h e m a gn it u de of t h e discr et e-t im e F ou r ier t r a n sfor m of t h e n-poin t r ect a n gu la r win dow.
Diagnostics
See Also
Cosin e of vect or /m a t r ix elem en t s (see t h e on lin e M A T L AB Fu n ction R eferen ce). Ga u ssia n -m odu la t ed sin u soida l pu lse gen er a t or. P u lse t r a in gen er a t or. Sa m pled a per iodic r ect a n gle gen er a t or. Sawt oot h or t r ia n gle wave gen er a t or. Sin e of vect or /m a t r ix elem en t s (see t h e on lin e M A T L AB Fu n ction R eferen ce). Sin c or sin ($t )/$t fu n ct ion . Squ a r e wa ve gen er a t or. Sa m pled a per iodic t r ia n gle gen er a t or.
6-118
dpss
Purpose Syntax
6dpss
Description
[e,v] = dpss(n,nw) gen er a t es t h e fir st 2*nw d iscrete prolate sph eroid al sequ en ces (DP SS) of len gt h n in t h e colu m n s of e, a n d t h eir cor r espon din g con cen t r a t ion s in vect or v. Th ey a r e a lso gen er a t ed in t h e DP SS MAT-file da t a ba se dpss.mat. nw m u st be less t h a n n/2. [e,v] = dpss(n,nw,k) r et u r n s t h e k m ost ba n d-lim it ed sequ en ces of t h e 2*nw discr et e pr ola t e sph er oida l sequ en ces ca lcu la t ed. k m u st be bet ween 0 a n d 2*nw. [e,v] = dpss(n,nw,[k1 k2]) r et u r n s t h e k1-t h t h r ou gh t h e k2-t h sequ en ces fr om t h e 2*nw discr et e pr ola t e sph er oida l sequ en ces ca lcu la t ed, wh er e 1 5 k1 5 k2 5 (2*nw).
F or a ll of t h e a bove for m s, Th e Slepia n sequ en ces a r e ca lcu la t ed dir ect ly. Th e sequ en ces a r e gen er a t ed in t h e fr equ en cy ba n d |#| 5 (2$W), wh er e W = nw/n is t h e h a lf-ba n dwidt h a n d # is in r a dia n s. e(:,1) is t h e len gt h n sign a l m ost con cen t r a t ed in t h e fr equ en cy ba n d |#| 5 (2$W) r a dia n s, e(:,2) is t h e sign a l or t h ogon a l t o e(:,1) t h a t is m ost con cen t r a t ed in t h is ba n d, e(:,3) is t h e sign a l or t h ogon a l t o bot h e(:,1) a n d e(:,2) t h a t is m ost con cen t r a t ed in t h is ba n d, et c. F or m u lt it a per spect r a l a n a lysis, t ypica l ch oices for nw a r e 2, 5/2, 3, 7/2, or 4.
[e,v] = dpss(n,nw,'spline') u ses splin e in t er pola t ion t o com pu t e e a n d v fr om t h e sequ en ces in dpss.mat wit h len gt h closest t o n.
6-119
dpss
[e,v] = dpss(n,nw,'spline',Ni) in t er pola t es fr om exist in g len gt h Ni
sequ en ces.
[e,v] = dpss(n,nw,'linear') a n d [e,v] = dpss(n,nw,'linear',Ni) u se lin ea r in t er pola t ion , wh ich is m u ch fa st er bu t less a ccu r a t e t h a n splin e in t er pola t ion . 'linear' r equ ir es Ni > n. [e,v] = dpss(...,'trace') a n d [e,v] = dpss(...,'int','trace') u se a t r a ilin g 'trace' a r gu m en t t o fin d ou t wh ich m et h od DP SS u ses, wh er e 'int' is eit h er 'spline' or 'linear'.
See Also
Rem ove discr et e pr ola t e sph er oida l sequ en ces fr om da t a ba se. Discr et e pr ola t e sph er oida l sequ en ces da t a ba se dir ect or y. Loa d discr et e pr ola t e sph er oida l sequ en ces fr om da t a ba se. Save discr et e pr ola t e sph er oida l sequ en ces in da t a ba se. Power spect r u m est im a t e u sin g t h e m u lt it a per m et h od (MTM).
References
[1] P er civa l, D.B., a n d A.T. Wa lden . S pectral A n alysis for Ph ysical Application s: M u ltitaper an d Con ven tion al Un ivariate T ech n iqu es . Ca m br idge: Ca m br idge Un iver sit y P r ess, 1993.
6-120
dpssclear
Purpose Syntax Description See Also
6dpssclea r
Discr et e pr ola t e sph er oida l sequ en ces (Slepia n sequ en ces). Discr et e pr ola t e sph er oida l sequ en ces da t a ba se dir ect or y. Loa d discr et e pr ola t e sph er oida l sequ en ces fr om da t a ba se. Save discr et e pr ola t e sph er oida l sequ en ces in da t a ba se.
6-121
dpssdir
Purpose Syntax
6dpssdir
Description
pr odu ct nw.
index = dpssdir is a st r u ct u r e a r r a y descr ibin g t h e DP SS da t a ba se. P a ss n a n d nw opt ion s a s for t h e n o ou t pu t ca se t o get a filt er ed index.
See Also
Discr et e pr ola t e sph er oida l sequ en ces (Slepia n sequ en ces). Rem ove discr et e pr ola t e sph er oida l sequ en ces fr om da t a ba se. Loa d discr et e pr ola t e sph er oida l sequ en ces fr om da t a ba se. Save discr et e pr ola t e sph er oida l sequ en ces in da t a ba se.
6-122
dpssload
Purpose Syntax Description
6dpssloa d
See Also
Discr et e pr ola t e sph er oida l sequ en ces (Slepia n sequ en ces). Rem ove discr et e pr ola t e sph er oida l sequ en ces fr om da t a ba se. Discr et e pr ola t e sph er oida l sequ en ces da t a ba se dir ect or y. Save discr et e pr ola t e sph er oida l sequ en ces in da t a ba se.
6-123
dpsssave
Purpose Syntax Description
6dpsssa ve
It is n ot n ecessa r y t o specify sequ en ce len gt h , beca u se t h e len gt h of t h e sequ en ce is det er m in ed by t h e n u m ber of r ows of e. nw is t h e tim e-ban d w id th prod u ct t h a t wa s specified wh en t h e sequ en ce wa s cr ea t ed u sin g dpss.
status = dpsssave(nw,e,v) r et u r n s 0 if t h e sa ve wa s su ccessfu l a n d 1 if t h er e
wa s a n er r or .
See Also
Discr et e pr ola t e sph er oida l sequ en ces (Slepia n sequ en ces). Rem ove discr et e pr ola t e sph er oida l sequ en ces fr om da t a ba se. Discr et e pr ola t e sph er oida l sequ en ces da t a ba se dir ect or y. Loa d discr et e pr ola t e sph er oida l sequ en ces fr om da t a ba se.
6-124
ellip
Purpose Syntax
6ellip
Description
ellipt ic filt er s. E llipt ic filt er s offer st eeper r olloff ch a r a ct er ist ics t h a n Bu t t er wor t h or Ch ebysh ev filt er s, bu t a r e equ ir ipple in bot h t h e pa ss- a n d st opba n ds. In gen er a l, ellipt ic filt er s m eet given per for m a n ce specifica t ion s wit h t h e lowest or der of a n y filt er t ype.
Digital Domain
[b,a] = ellip(n,Rp,Rs,Wn) design s a n or der n lowpa ss digit a l ellipt ic filt er wit h cu t off fr equ en cy Wn, Rp dB of r ipple in t h e pa ssba n d, a n d a st opba n d Rs dB down fr om t h e peak va lu e in t h e pa ssban d. It r et u r n s t h e filt er coefficien t s in t h e lengt h n + 1 r ow vect or s b an d a, with coefficien t s in descen din g power s of z :
B (z ) b (1 ) + b (2 ) z 1 + L + b (n + 1 ) z n H (z ) = ---------- = --------------------------------------------------------------------------------A (z ) + a (n + 1 ) z n 1 + a (2 ) z 1 + L Th e cu toff frequ en cy is t h e edge of t h e pa ssba n d, a t wh ich t h e m a gn it u de r espon se of t h e filt er is Rp dB. F or ellip, t h e cu t off fr equ en cy Wn is a n u m ber bet ween 0 a n d 1, wh er e 1 cor r espon ds t o h a lf t h e sa m ple fr equ en cy (Nyqu ist fr equ en cy). Sm a ller va lu es of pa ssba n d r ipple Rp a n d la r ger va lu es of st opba n d a t t en u a t ion Rs bot h lea d t o wider t r a n sit ion widt h s (sh a llower r olloff ch a r a ct er ist ics). If Wn is a t wo-elem en t vect or , Wn = [w1 w2], ellip r et u r n s a n or der 2*n ba n dpa ss filt er wit h pa ssba n d w1 < # < w2.
[b,a] = ellip(n,Rp,Rs,Wn,'ftype') design s a h igh pa ss or ba n dst op filt er ,
wh er e ftype is:
6-125
ellip
high for a h igh pa ss digit a l filt er wit h cu t off fr equ en cy Wn stop for a n or der 2*n ba n dst op digit a l filt er if Wn is a t wo-elem en t vect or ,
Wn = [w1 w2]
Th e st opba n d is w1 < # < w2. Wit h differ en t n u m ber s of ou t pu t a r gu m en t s, ellip dir ect ly obt a in s ot h er r ea liza t ion s of t h e filt er . To obt a in zer o-pole-ga in for m , u se t h r ee ou t pu t a r gu m en t s:
[z,p,k] = ellip(n,Rp,Rs,Wn) or [z,p,k] = ellip(n,Rp,Rs,Wn,'ftype') r et u r n s t h e zer os a n d poles in len gt h n colu m n vect or s z a n d p a n d t h e ga in in t h e sca la r k.
x [n + 1 ] = A x [n ] + B u [n ] y [n ] = C x [n ] + D u [n ] a n d u is t h e in pu t , x is t h e st a t e vect or , a n d y is t h e ou t pu t .
Analog Domain
[b,a] = ellip(n,Rp,Rs,Wn,'s') design s a n or der n lowpa ss a n a log ellipt ic filt er wit h cu t off fr equ en cy Wn a n d r et u r n s t h e filt er coefficien t s in t h e len gt h n + 1 r ow vect or s b a n d a, in descen din g power s of s :
B (s ) b (1 ) s n + b (2 ) s n 1 + L + b (n + 1 ) H (s ) = ---------- = --------------------------------------------------------------------------------A (s ) + a (n + 1 ) s n + a (2 ) s n 1 + L Th e cu toff frequ en cy is t h e edge of t h e pa ssba n d, a t wh ich t h e m a gn it u de r espon se of t h e filt er is Rp dB. F or ellip, t h e cu t off fr equ en cy Wn m u st be gr ea t er t h a n 0. If Wn is a t wo-elem en t vect or wit h w1 < w2, t h en ellip(n,Rp,Rs,Wn,'s') r et u r n s a n or der 2*n ba n dpa ss a n a log filt er wit h pa ssba n d w1 < # < w2.
6-126
ellip
filt er , wh er e ftype is: high for a h igh pa ss a n a log filt er wit h cu t off fr equ en cy Wn stop for a n or der 2*n ba n dst op a n a log filt er . Wn is a t wo-elem en t vect or , [w1 w2], specifyin g t h e st opba n d w1 < # < w2. Wit h differ en t n u m ber s of ou t pu t a r gu m en t s, ellip dir ect ly obt a in s ot h er r ea liza t ion s of t h e a n a log filt er . To obt a in zer o-pole-ga in for m , u se t h r ee ou t pu t a r gu m en t s:
[z,p,k] = ellip(n,Rp,Rs,Wn,'s') or [z,p,k] = ellip(n,Rp,Rs,Wn,'ftype','s') r et u r n s t h e zer os a n d poles in len gt h n or 2*n colu m n vect or s z a n d p a n d t h e ga in in t h e sca la r k.
x = Ax + Bu y = Cx + Du a n d u is t h e in pu t , x is t h e st a t e vect or , a n d y is t h e ou t pu t .
Examples
F or da t a sa m pled a t 1000 H z, design a sixt h -or der lowpa ss ellipt ic filt er wit h a cu t off fr equ en cy of 300 H z, 3 dB of r ipple in t h e pa ssba n d, a n d 50 dB of a t t en u a t ion in t h e st opba n d:
[b,a] = ellip(6,3,50,300/500);
6-127
ellip
0 -20 -40 -60 -80 -100 0 50 100 150 200 250 300 Frequency (Hertz) 350 400 450 500
200
Phase (degrees)
50
100
150
350
400
450
500
6-128
ellip
Design a 20t h -or der ba n dpa ss ellipt ic filt er wit h a pa ssba n d fr om 100 t o 200 H z a n d plot it s im pu lse r espon se:
n = 10; Rp = 0.5; Rs = 20; Wn = [100 200]/500; [b,a] = ellip(n,Rp,Rs,Wn); [y,t] = impz(b,a,101); stem(t,y) title('Impulse Response of n=10 Elliptic Filter')
Impulse Response of n = 10 Elliptic Filter 0.2
0.15
0.1
0.05
-0.05
-0.1
-0.15
-0.2 0
10
20
30
40
50
60
70
80
90
100
Limitations
F or h igh or der filt er s, t h e st a t e-spa ce for m is t h e m ost n u m er ica lly a ccu r a t e, followed by t h e zer o-pole-ga in for m . Th e t r a n sfer fu n ct ion for m is t h e lea st a ccu r a t e; n u m er ica l pr oblem s ca n a r ise for filt er or der s a s low a s 15. Th e design of ellipt ic filt er s is t h e m ost difficu lt a n d com pu t a t ion a lly in t en sive of t h e Bu t t er wor t h , Ch ebysh ev t ype I a n d II, a n d ellipt ic design s. ellip u ses a five-st ep a lgor it h m :
1 It fin ds t h e lowpa ss a n a log pr ot ot ype poles, zer os, a n d ga in u sin g t h e
Algorithm
ellipap fu n ct ion .
2 It con ver t s t h e poles, zer os, a n d ga in in t o st a t e-spa ce for m . 3 It t r a n sfor m s t h e lowpa ss filt er t o a ba n dpa ss, h igh pa ss, or ba n dst op filt er
6-129
ellip
4 F or digit a l filt er design , ellip u ses bilinear t o con ver t t h e a n a log filt er
in t o a digit a l filt er t h r ou gh a bilin ea r t r a n sfor m a t ion wit h fr equ en cy pr ewa r pin g. Ca r efu l fr equ en cy a dju st m en t gu a r a n t ees t h a t t h e a n a log filt er s a n d t h e digit a l filt er s will h a ve t h e sa m e fr equ en cy r espon se m a gn it u de a t Wn or w1 a n d w2.
5 It con ver t s t h e st a t e-spa ce filt er ba ck t o t r a n sfer fu n ct ion or zer o-pole-ga in
See Also
Bessel a n a log filt er design . Bu t t er wor t h a n a log a n d digit a l filt er design . Ch ebysh ev t ype I filt er design (pa ssba n d r ipple). Ch ebysh ev t ype II filt er design (st opba n d r ipple). E llipt ic a n a log lowpa ss filt er pr ot ot ype. E llipt ic filt er or der select ion .
6-130
ellipap
Purpose Syntax Description
6ellipa p
( s z (1 ) ) ( s z (2 ) ) L ( s z (n ) ) z (s ) H (s ) = --------- = k ---------------------------------------------------------------------------( s p (1 ) ) ( s p (2 ) ) L ( s p (n ) ) p (s ) E llipt ic filt er s a r e equ ir ipple in bot h t h e pa ssba n d a n d st opba n d. Th ey offer st eeper r olloff ch a r a ct er ist ics t h a n Bu t t er wor t h a n d Ch ebysh ev filt er s, bu t t h ey a r e equ ir ipple in bot h t h e pa ssba n d a n d t h e st opba n d. Of t h e fou r cla ssica l filt er t ypes, ellipt ic filt er s u su a lly m eet a given set of filt er per for m a n ce specifica t ion s wit h t h e lowest filt er or der .
ellip set s t h e cu t off fr equ en cy # 0 of t h e ellipt ic filt er t o 1 for a n or m a lized
Algorithm
ellipap u ses t h e a lgor it h m ou t lin ed in [1]. It em ploys t h e M-file ellipk t o ca lcu la t e t h e com plet e ellipt ic in t egr a l of t h e fir st kin d a n d t h e M-file ellipj t o ca lcu la t e J a cobi ellipt ic fu n ct ion s. besselap buttap cheb1ap cheb2ap ellip
See Also
Bessel a n a log lowpa ss filt er pr ot ot ype. Bu t t er wor t h a n a log lowpa ss filt er pr ot ot ype. Ch ebysh ev t ype I a n a log lowpa ss filt er pr ot ot ype. Ch ebysh ev t ype II a n a log lowpa ss filt er pr ot ot ype. E llipt ic (Ca u er ) filt er design .
References
[1] P a r ks, T.W., a n d C.S. Bu r r u s. Digital Filter Design . New Yor k: J oh n Wiley & Son s, 1987. Ch a pt er 7.
6-131
ellipord
Purpose Syntax Description
6ellipord
Pa ssba n d cor n er fr equ en cy. Wp, t h e cu t off fr equ en cy, h a s a va lu e bet ween 0 a n d 1, wh er e 1 cor r espon ds t o h a lf t h e sa m plin g fr equ en cy (t h e Nyqu ist fr equ en cy). St opba n d cor n er fr equ en cy. Ws is in t h e sa m e u n it s a s Wp; it h a s a va lu e bet ween 0 a n d 1, wh er e 1 cor r espon ds t o h a lf t h e sa m plin g fr equ en cy (t h e Nyqu ist fr equ en cy). Pa ssba n d r ipple, in decibels. Th is va lu e is t h e m a xim u m per m issible pa ssba n d loss in decibels. Th e pa ssba n d is 0 < w < Wp. St opba n d a t t en u a t ion , in decibels. Th is va lu e is t h e n u m ber of decibels t h e st opba n d is down fr om t h e pa ssba n d. Th e st opba n d is Ws < w < 1.
Ws
Rp Rs
Digital Domain
[n,Wn] = ellipord(Wp,Ws,Rp,Rs) r et u r n s t h e or der n of t h e lowest or der ellipt ic filt er t h a t loses n o m or e t h a n Rp dB in t h e pa ssba n d a n d h a s a t lea st Rs dB of a t t en u a t ion in t h e st opba n d. Th e pa ssba n d r u n s fr om 0 t o Wp a n d t h e st opba n d ext en ds fr om Ws t o 1, t h e Nyqu ist fr equ en cy. ellipord a lso r et u r n s Wn, t h e cu t off fr equ en cy t h a t a llows ellip t o a ch ieve t h e given specifica t ion s.
Use ellipord for lowpa ss, h igh pa ss, ba n dpa ss, a n d ba n dst op filt er s. F or h igh pa ss filt er s, Wp is gr ea t er t h a n Ws. F or ba n dpa ss a n d ba n dst op filt er s, Wp a n d Ws a r e t wo-elem en t vect or s t h a t specify t h e cor n er fr equ en cies a t bot h edges of t h e filt er , lower fr equ en cy edge fir st . F or t h e ba n d filt er s, ellipord r et u r n s Wn a s a t wo-elem en t r ow vect or for in pu t t o ellip. If filt er specifica t ion s ca ll for a ba n dpa ss or ba n dst op filt er wit h u n equ a l r ipple in ea ch of t h e pa ssba n ds or st opba n ds, design t h e filt er a s sepa r a t e lowpa ss a n d h igh pa ss sect ion s a n d ca sca de t h e t wo filt er s t oget h er .
6-132
ellipord
Analog Domain
[n,Wn] = ellipord(Wp,Ws,Rp,Rs,'s') fin ds t h e m in im u m or der n a n d cu t off fr equ en cies Wn for a n a n a log filt er . In t h is ca se t h e fr equ en cies in Wp a n d Ws a r e in r a dia n s per secon d a n d m a y be gr ea t er t h a n 1.
Use ellipord for lowpa ss, h igh pa ss, ba n dpa ss, a n d ba n dst op filt er s a s descr ibed u n der Digit a l Dom a in .
6-133
ellipord
Examples
F or 1000 H z da t a , design a lowpa ss filt er wit h less t h a n 3 dB of a t t en u a t ion fr om 0 t o 100 H z a n d a t lea st 15 dB of a t t en u a t ion fr om 150 H z t o t h e Nyqu ist fr equ en cy:
Wp = 100/500; Ws = 150/500; Rp = 3; Rs = 15; [n,Wn] = ellipord(Wp,Ws,Rp,Rs) n = 2 Wn = 0.2000 [b,a] = ellip(n,Rp,Rs,Wn); freqz(b,a,512,1000); title('n=2 Elliptic Lowpass Filter')
n = 2 Elliptic Lowpass Filter
Magnitude Response (dB)
50
100
150
350
400
450
500
50
Phase (degrees)
0 -50 -100 -150 -200 0 50 100 150 200 250 300 Frequency (Hertz) 350 400 450 500
6-134
ellipord
Now design a ba n dpa ss filt er wit h a pa ssba n d fr om 90 H z t o 200 H z, less t h a n 3 dB of r ipple t h r ou gh ou t t h e pa ssba n d, a n d 30 dB st opba n ds 50 H z ou t on bot h sides of t h e pa ssba n d:
Wp = [90 200]/500; Ws = [50 250]/500; Rp = 3; Rs = 30; [n,Wn] = ellipord(Wp,Ws,Rp,Rs) n = 3 Wn = 0.1800 0.4000 [b,a] = ellip(n,Rp,Rs,Wn); freqz(b,a,512,1000); title('n=3 Elliptic Bandpass Filter')
n = 3 Elliptic Bandpass Filter Magnitude Response (dB) 0
-100
-200
-300 0
50
100
150
350
400
450
500
50
100
150
350
400
450
500
Algorithm
ellipord u ses t h e ellipt ic lowpa ss filt er or der pr edict ion for m u la descr ibed in [1]. Th e fu n ct ion per for m s it s ca lcu la t ion s in t h e a n a log dom a in for bot h t h e a n a log a n d digit a l ca ses. F or t h e digit a l ca se, it con ver t s t h e fr equ en cy
6-135
ellipord
pa r a m et er s t o t h e s -dom a in befor e t h e or der a n d n a t u r a l fr equ en cy est im a t ion pr ocess, t h en con ver t s t h em ba ck t o t h e z -dom a in .
ellipord in it ia lly develops a lowpa ss filt er pr ot ot ype by t r a n sfor m in g t h e pa ssba n d fr equ en cies of t h e desir ed filt er t o 1 r a d/sec (for low- a n d h igh pa ss filt er s) a n d t o -1 a n d 1 r a d/sec (for ba n dpa ss a n d ba n dst op filt er s). It t h en com pu t es t h e m in im u m or der r equ ir ed for a lowpa ss filt er t o m eet t h e st opba n d specifica t ion .
See Also
Bu t t er wor t h filt er or der select ion . Ch ebysh ev t ype I filt er or der select ion . Ch ebysh ev t ype II filt er or der select ion . E llipt ic (Ca u er ) filt er design .
References
[1] Ra bin er , L.R., a n d B. Gold. T h eory an d Application of Digital S ign al Processin g . E n glewood Cliffs, NJ : P r en t ice-H a ll, 1975. P g. 241.
6-136
fft
Purpose Syntax Description
6fft
X (k + 1 ) =
+
n =0
kn x (n + 1 ) W n
wh er e W N = e -j(2 $/N ) a n d N = length(x). Not e t h a t t h e ser ies is in dexed a s n + 1 a n d k + 1 in st ea d of t h e u su a l n a n d k beca u se MATLAB vect or s r u n fr om 1 t o N in st ea d of fr om 0 t o N -1.
y = fft(x) is t h e discr et e F ou r ier t r a n sfor m of vect or x, com pu t ed wit h a fa st F ou r ier t r a n sfor m (F F T) a lgor it h m . If x is a m a t r ix, y is t h e F F T of ea ch colu m n of t h e m a t r ix. Th e fft fu n ct ion em ploys a r a dix-2 fa st F ou r ier t r a n sfor m a lgor it h m if t h e len gt h of t h e sequ en ce is a power of t wo, a n d a slower a lgor it h m if it is n ot ; see t h e Algor it h m sect ion for det a ils. y = fft(x,n) is t h e n-poin t F F T. If t h e len gt h of x is less t h a n n, fft pa ds x wit h t r a ilin g zer os t o len gt h n. If t h e len gt h of x is gr ea t er t h a n n, fft t r u n ca t es t h e sequ en ce x. If x is a n a r r a y, fft a dju st s t h e len gt h of t h e colu m n s in t h e
Example
A com m on u se of t h e F ou r ier t r a n sfor m is t o fin d t h e fr equ en cy com pon en t s of a t im e-dom a in sign a l bu r ied in n oise. Con sider da t a sa m pled a t 1000 H z. F or m
6-137
fft
a sign a l con sist in g of 50 H z a n d 120 H z sin u soids a n d cor r u pt t h e sign a l wit h zer o-m ea n r a n dom n oise:
t = 0:0.001:0.6; x = sin(2*pi*50*t) + sin(2*pi*120*t); y = x + 2*randn(1,length(t)); plot(y(1:50))
4 3 2 1 0 -1 -2 -3 -4 -5 -6 0
10
15
20
25
30
35
40
45
50
It is difficu lt t o iden t ify t h e fr equ en cy com pon en t s by st u dyin g t h e or igin a l sign a l. Con ver t t o t h e fr equ en cy dom a in by t a k in g t h e discr et e F ou r ier t r a n sfor m of t h e n oisy sign a l y u sin g a 512-poin t fa st F ou r ier t r a n sfor m (F F T):
Y = fft(y,512);
6-138
fft
Gr a ph t h e fir st 256 poin t s (t h e ot h er 256 poin t s a r e sym m et r ic) on a m ea n in gfu l fr equ en cy a xis:
f = 1000*(0:255)/512; plot(f,Pyy(1:256))
70
60
50
40
30
20
10
0 0
100
200
300
400
500
See t h e pwelch fu n ct ion for det a ils on ca lcu la t in g spect r a l den sit y. Som et im es it is u sefu l t o n or m a lize t h e ou t pu t of fft so t h a t a u n it sin u soid in t h e t im e dom a in cor r espon ds t o u n it a m plit u de in t h e fr equ en cy dom a in . To pr odu ce a n or m a lized discr et e-t im e F ou r ier t r a n sfor m in t h is m a n n er , u se
Pn = abs(fft(x))*2/length(x)
Algorithm
fft is a bu ilt -in MATLAB fu n ct ion . Wh en t h e sequ en ce len gt h is a power of t wo, fft u ses a h igh -speed r a dix-2 fa st F ou r ier t r a n sfor m a lgor it h m . Th e r a dix-2 F F T r ou t in e is opt im ized t o per for m a r ea l F F T if t h e in pu t sequ en ce is pu r ely r ea l; ot h er wise it com pu t es t h e com plex F F T. Th is ca u ses a r ea l power -of-t wo F F T t o be a bou t 40% fa st er t h a n a com plex F F T of t h e sa m e len gt h .
Wh en t h e sequ en ce len gt h is n ot a n exa ct power of t wo, a sepa r a t e a lgor it h m fin ds t h e pr im e fa ct or s of t h e sequ en ce len gt h a n d com pu t es t h e m ixed-r a dix discr et e F ou r ier t r a n sfor m s of t h e sh or t er sequ en ces.
6-139
fft
Th e execu t ion t im e for fft depen ds on t h e sequ en ce len gt h . If t h e len gt h of a sequ en ce h a s m a n y pr im e fa ct or s, t h e fu n ct ion com pu t es t h e F F T qu ick ly; if t h e len gt h h a s few pr im e fa ct or s, execu t ion is slower . F or sequ en ces wh ose len gt h s a r e pr im e n u m ber s, fft u ses t h e r a w (a n d slow) DF T a lgor it h m . F or t h is r ea son it is u su a lly bet t er t o u se power -of-t wo F F Ts, if t h is is su ppor t ed by you r a pplica t ion . F or exa m ple, on on e m a ch in e a 4096-poin t r ea l F F T t a kes 2.1 secon ds a n d a com plex F F T of t h e sa m e len gt h t a kes 3.7 secon ds. Th e F F Ts of n eigh bor in g sequ en ces of len gt h 4095 a n d 4097, h owever , t a ke 7 secon ds a n d 58 secon ds, r espect ively. Su ppose a sequ en ce x of N poin t s is obt a in ed a t a sa m ple fr equ en cy of f s . Th en , for u p t o t h e Nyqu ist fr equ en cy, or poin t n = N / 2 + 1, t h e r ela t ion sh ip bet ween t h e a ct u a l fr equ en cy a n d t h e in dex k in t o x (ou t of N possible in dices) is f = (k 1 ) ) f s N
See Also
Discr et e cosin e t r a n sfor m (DCT). Discr et e Fou r ier t r a n sfor m m a t r ix. Two-dim en sion a l fa st Fou r ier t r a n sfor m . Rea r r a n ge t h e ou t pu t s of fft a n d fft2. F ilt er da t a wit h a r ecu r sive (IIR) or n on r ecu r sive (F IR) filt er. F r equ en cy r espon se of digit a l filt er s. On e-dim en sion a l in ver se fa st Fou r ier t r a n sfor m . E st im a t e t h e power spect r a l den sit y (P SD) of a sign a l u sin g Welch s m et h od.
6-140
fft2
Purpose Syntax Description
6fft 2
Algorithm
Th is com pu t es t h e on e-dim en sion a l fft of ea ch colu m n of x, t h en of ea ch r ow of t h e r esu lt . Th e t im e r equ ir ed t o com pu t e fft2(x) depen ds on t h e n u m ber of pr im e fa ct or s in [m,n] = size(x). fft2 is fa st est wh en m a n d n a r e power s of 2.
See Also
On e-dim en sion a l fa st Fou r ier t r a n sfor m . Rea r r a n ge t h e ou t pu t s of fft a n d fft2. On e-dim en sion a l in ver se fa st Fou r ier t r a n sfor m . Two-dim en sion a l in ver se fa st Fou r ier t r a n sfor m .
6-141
fftfilt
Purpose Syntax Description
6fft filt
y (n ) = b (1 ) x (n ) + b (2 ) x (n 1 ) + L + b (n b + 1 ) x (n n b ) An equ iva len t r epr esen t at ion is t h e z -t r an sfor m or frequ en cy d om ain descr ipt ion + b (n b + 1 ) z n b ) X (z ) Y (z ) = ( b (1 ) + b (2 ) z 1 + L By defa u lt , fftfilt ch ooses a n F F T len gt h a n d da t a block len gt h t h a t gu a r a n t ee efficien t execu t ion t im e.
y = fftfilt(b,x,n) u ses a n F F T len gt h of nfft = 2^nextpow2(n) a n d a da t a block len gt h of nfft length(b) + 1. fftfilt wor k s for bot h r ea l a n d com plex in pu t s.
Example
Algorithm
fftfilt u ses fft t o im plem en t t h e overlap-ad d m eth od [1], a t ech n iqu e t h a t com bin es su ccessive fr equ en cy dom a in filt er ed blocks of a n in pu t sequ en ce. fftfilt br ea k s a n in pu t sequ en ce x in t o len gt h L da t a blocks:
x L 2L 3L . . . ceil(nx/L)*L
6-142
fftfilt
wh er e nfft is t h e F F T len gt h . fftfilt over la ps su ccessive ou t pu t sect ion s by nb1 poin t s, wh er e nb is t h e len gt h of t h e filt er , a n d su m s t h em :
L nb1 2L nb1 3L nb1 . . .
fftfilt ch ooses t h e key pa r a m et er s L a n d nfft in differ en t wa ys, depen din g on wh et h er you su pply a n F F T len gt h n a n d on t h e len gt h s of t h e filt er a n d sign a l. If you do n ot specify a va lu e for n (wh ich det er m in es F F T len gt h ), fftfilt ch ooses t h ese k ey pa r a m et er s a u t om a t ica lly:
If length(x) > length(b), fftfilt ch ooses va lu es t h a t m in im ize t h e n u m ber of blocks t im es t h e n u m ber of flops per F F T. If length(b) >= length(x), fftfilt u ses a sin gle F F T of len gt h
2^nextpow2(length(b) + length(x) 1)
If you su pply a va lu e for n, fftfilt ch ooses a n F F T len gt h , nfft, of 2^nextpow2(n)a n d a da t a block len gt h of nfft length(b) + 1. If n is less t h a n length(b), fftfilt set s n t o length(b).
See Also
Con volu t ion a n d polyn om ia l m u lt iplica t ion . F ilt er da t a wit h a r ecu r sive (IIR) or n on r ecu r sive (F IR) filt er. Zer o-ph a se digit a l filt er in g.
References
[1] Oppen h eim , A.V., a n d R.W. Sch a fer . Discrete-T im e S ign al Processin g. E n glewood Cliffs, NJ : P r en t ice H a ll, 1989.
6-143
fftshift
Purpose Syntax Description
6fft sh ift
Rea r r a n ge t h e ou t pu t s of t h e F F T fu n ct ion s.
y = fftshift(x) y = fftshift(x) r ea r r a n ges t h e ou t pu t s of fft a n d fft2 by m ovin g t h e zer o
fr equ en cy com pon en t t o t h e cen t er of t h e spect r u m , wh ich is som et im es a m or e con ven ien t for m . F or vect or s, fftshift(x) r et u r n s a vect or wit h t h e left a n d r igh t h a lves swa pped. F or a r r a ys, fftshift(x) swa ps qu a dr a n t s on e a n d t h r ee wit h qu a dr a n t s t wo a n d fou r . Th e fftshift fu n ct ion is pa r t of t h e st a n da r d MATLAB la n gu a ge.
Example
F or a n y a r r a y X,
Y = fft2(x)
h a s Y(1,1) = sum(sum(X)); t h e DC com pon en t of t h e sign a l is in t h e u pper -left cor n er of t h e t wo-dim en sion a l F F T. F or
Z = fftshift(Y)
See Also
fft fft2
On e-dim en sion a l fa st Fou r ier t r a n sfor m . Two-dim en sion a l fa st Fou r ier t r a n sfor m .
6-144
filter
Purpose Syntax
6filt er
Description
is t h e tran sposed d irect form II st r u ct u r e [1], wh ich ca n h a n dle bot h F IR a n d IIR filt er s. If a (1) - 1, filter n or m a lizes t h e filt er coefficien t s by a (1). If a (1) = 0, t h e in pu t is in er r or .
y = filter(b,a,x) filt er s t h e da t a in vect or x wit h t h e filt er descr ibed by coefficien t vect or s a a n d b t o cr ea t e t h e filt er ed da t a vect or y. Wh en x is a m a t r ix, filt er oper a t es on t h e colu m n s of x. Wh en x is a n N -dim en sion a l a r r a y, filt er oper a t es on t h e fir st n on -sin glet on dim en sion . [y,zf] = filter(b,a,x) r et u r n s t h e fin a l va lu es of t h e st a t es in t h e vect or zf. [...] = filter(b,a,x,zi) specifies in it ia l st a t e con dit ion s in t h e vect or zi.
Th e size of t h e in it ia l/fin a l con dit ion vect or is max(length(b),length(a))1. zi or zf ca n a lso be a n a r r a y of su ch vect or s, on e for ea ch colu m n of x if x is a m a t r ix. If x is a m u lt idim en sion a l a r r a y, filter wor ks a cr oss t h e fir st n on sin glet on dim en sion of x by defa u lt .
[...] = filter(b,a,x,zi,dim) wor ks a cr oss t h e dim en sion dim of x. Set zi
6-145
filter
Example
0.3
0.2
0.1
-0.1
-0.2 0
20
40
60
80
100
120
Algorithm
wh er e n -1 is t h e filt er or der .
6-146
filter
Th e oper a t ion of filter a t sa m ple m is given by t h e t im e dom a in differ en ce equ a t ion s for y a n d t h e st a t es z i: y (m ) = b (1 ) x (m ) + z 1 (m 1 ) a (1 ) y (m ) z 1 (m ) = b (2 ) x (m ) + z 2 (m 1 ) a (2 ) y (m ) M zn zn
1 (m )
M
1 (m
2 (m ) = b (n 1 ) x (m ) + z n
1 ) a (n 1 ) y (m )
= b (n ) x (m ) a (n ) y (m )
You ca n u se filtic t o gen er a t e t h e st a t e vect or z i(0) fr om pa st in pu t s a n d ou t pu t s. Th e in pu t -ou t pu t descr ipt ion of t h is filt er in g oper a t ion in t h e z -t r a n sfor m dom a in is a r a t ion a l t r a n sfer fu n ct ion : + b (n b + 1 ) z n b b (1 ) + b (2 ) z 1 + L - X (z ) Y (z ) = ---------------------------------------------------------------------------------------+ a (n a + 1 ) z n a a (1 ) + a (2 ) z 1 + L
Diagnostics
If t h e len gt h of t h e in it ia l con dit ion vect or is n ot t h e gr ea t er of n a a n d n b , filter gives t h e followin g er r or m essa ge:
Initial condition vector has incorrect dimensions.
See Also
F F T-ba sed F IR filt er in g u sin g t h e over la p-a dd m et h od. Two-dim en sion a l digit a l filt er in g. Zer o-ph a se digit a l filt er in g. Ma ke in it ia l con dit ion s for filter fu n ct ion .
References
[1] Oppen h eim , A.V., a n d R.W. Sch a fer . Discrete-T im e S ign al Processin g. E n glewood Cliffs, NJ : P r en t ice H a ll, 1989. P gs. 311-312.
6-147
filter2
Purpose Syntax Description
6filt er 2
same r et u r n s t h e cen t r a l pa r t of t h e con volu t ion t h a t is t h e sa m e size a s X (defa u lt ). full r et u r n s t h e fu ll t wo-dim en sion a l con volu t ion , size(Y) > size(X). valid r et u r n s on ly t h ose pa r t s of t h e con volu t ion t h a t a r e com pu t ed wit h ou t t h e zer o-pa dded edges, size(Y) < size(X). Th e filter2 fu n ct ion is pa r t of t h e st a n da r d MATLAB la n gu a ge.
Algorithm
Th e filter2 fu n ct ion u ses conv2 t o com pu t e t h e fu ll t wo-dim en sion a l con volu t ion of t h e F IR filt er wit h t h e in pu t m a t r ix. By defa u lt , filter2 ext r a ct s a n d r et u r n s t h e cen t r a l pa r t of t h e con volu t ion t h a t is t h e sa m e size a s t h e in pu t m a t r ix. Use t h e shape pa r a m et er t o specify a n a lt er n a t e pa r t of t h e con volu t ion for r et u r n .
conv2 filter
See Also
Two-dim en sion a l con volu t ion . F ilt er da t a wit h a r ecu r sive (IIR) or n on r ecu r sive (F IR) filt er.
6-148
filtfilt
Purpose Syntax Description
6filt filt
in pu t da t a in bot h t h e for wa r d a n d r ever se dir ect ion s (see pr oblem 5.39 in [1]). Aft er filt er in g in t h e for wa r d dir ect ion , it r ever ses t h e filt er ed sequ en ce a n d r u n s it ba ck t h r ou gh t h e filt er . Th e r esu lt in g sequ en ce h a s pr ecisely zer o-ph a se dist or t ion a n d dou ble t h e filt er or der . filtfilt m in im izes st a r t -u p a n d en din g t r a n sien t s by m a t ch in g in it ia l con dit ion s, a n d wor ks for bot h r ea l a n d com plex in pu t s. Not e t h a t filtfilt sh ou ld n ot be u sed wit h differ en t ia t or a n d H ilber t F IR filt er s, sin ce t h e oper a t ion of t h ese filt er s depen ds h ea vily on t h eir ph a se r espon se.
Algorithm
for wa r d-r ever se filt er in g, it a t t em pt s t o m in im ize st a r t u p t r a n sien t s by a dju st in g in it ia l con dit ion s t o m a t ch t h e DC com pon en t of t h e sign a l a n d by pr epen din g sever a l filt er len gt h s of a flipped, r eflect ed copy of t h e in pu t sign a l.
See Also
F F T-ba sed F IR filt er in g u sin g t h e over la p-a dd m et h od. F ilt er da t a wit h a r ecu r sive (IIR) or n on r ecu r sive (F IR) filt er. Two-dim en sion a l digit a l filt er in g.
References
[1] Oppen h eim , A.V., a n d R.W. Sch a fer . Discrete-T im e S ign al Processin g. E n glewood Cliffs, NJ : P r en t ice H a ll, 1989. P gs. 311-312.
6-149
filtic
Purpose Syntax Description
6filt ic
F in d in it ia l con dit ion s for a t r a n sposed dir ect for m II filt er im plem en t a t ion .
z = filtic(b,a,y,x) z = filtic(b,a,y) z = filtic(b,a,y,x) fin ds t h e in it ia l con dit ion s z for t h e dela ys in t h e tran sposed d irect form II filt er im plem en t a t ion given pa st ou t pu t s y a n d in pu t s x. Th e vect or s b a n d a r epr esen t t h e n u m er a t or a n d den om in a t or coefficien t s,
r espect ively, of t h e filt er s t r a n sfer fu n ct ion . Th e vect or s x a n d y con t a in t h e m ost r ecen t in pu t or ou t pu t fir st , a n d oldest in pu t or ou t pu t la st : x = { x ( 1 ), x ( 2 ), x ( 3 ), , x ( n b ), } y = { y ( 1 ), y ( 2 ), y ( 3 ), , y ( n a ), } wh er e nb is length(b)1 (t h e n u m er a t or or der ) a n d na is length(a)1 (t h e den om in a t or or der ). If length(x) is less t h a n nb, filtic pa ds it wit h zer os t o len gt h nb; if length(y) is less t h a n na, filtic pa ds it wit h zer os t o len gt h na. E lem en t s of x beyon d x(nb1) a n d elem en t s of y beyon d y(na1) a r e u n n ecessa r y so filtic ign or es t h em . Ou t pu t z is a colu m n vect or of len gt h equ a l t o t h e la r ger of n b a n d n a . z descr ibes t h e st a t e of t h e dela ys given pa st in pu t s x a n d pa st ou t pu t s y.
z = filtic(b,a,y) a ssu m es t h a t t h e in pu t x is 0 in t h e pa st .
wh er e n -1 is t h e filt er or der .
filtic wor k s for bot h r ea l a n d com plex in pu t s.
6-150
filtic
Algorithm Diagnostics
See Also
filter filtfilt
F ilt er da t a wit h a r ecu r sive (IIR) or n on r ecu r sive (F IR) filt er. Zer o-ph a se digit a l filt er in g.
References
[1] Oppen h eim , A.V., a n d R.W. Sch a fer . Discrete-T im e S ign al Processin g. E n glewood Cliffs, NJ : P r en t ice H a ll, 1989. P gs. 296, 301-302.
6-151
fir1
Purpose Syntax
6fir 1
Win dow-ba sed fin it e im pu lse r espon se filt er design st a n da r d r espon se.
b b b b b = = = = = fir1(n,Wn) fir1(n,Wn,'ftype') fir1(n,Wn,window) fir1(n,Wn,'ftype',window) fir1(...,'noscale')
Description
fir1 im plem en t s t h e cla ssica l m et h od of win dowed lin ea r -ph a se F IR digit a l filt er design [1]. It design s filt er s in st a n da r d lowpa ss, ba n dpa ss, h igh pa ss, a n d ba n dpa ss con figu r a t ion s. (F or win dowed filt er s wit h a r bit r a r y fr equ en cy r espon se, u se fir2.) b = fir1(n,Wn) r et u r n s r ow vect or b con t a in in g t h e n+1 coefficien t s of a n or der n lowpa ss F IR filt er . Th is is a H a m m in g-win dowed, lin ea r -ph a se filt er wit h cu t off fr equ en cy Wn. Th e ou t pu t filt er coefficien t s, b, a r e or der ed in descen din g power s of z :
B (z ) = b (1 ) + b (2 ) z 1 + L + b (n + 1 ) z n
Wn, t h e cu t off fr equ en cy, is a n u m ber bet ween 0 a n d 1, wh er e 1 cor r espon ds t o
h a lf t h e sa m plin g fr equ en cy (t h e Nyqu ist fr equ en cy). If Wn is a t wo-elem en t vect or , Wn = [w1 w2], fir1 r et u r n s a ba n dpa ss filt er wit h pa ssba n d w1 < # < w2. If Wn is a m u lt i-elem en t vect or , Wn = [w1 w2 w3 w4 w5 ... wn], fir1 r et u r n s a n or der n m u lt iba n d filt er wit h ba n ds 0 < # < w1, w1 < # < w2, ..., wn < # < 1. By defa u lt , t h e filt er is sca led so t h a t t h e cen t er of t h e fir st pa ssba n d h a s m a gn it u de exa ct ly 1 a ft er win dowin g.
b = fir1(n,Wn,'ftype') specifies a filt er t ype, wh er e ftype is
high for a h igh pa ss filt er wit h cu t off fr equ en cy Wn stop for a ba n dst op filt er , if Wn = [w1 w2] Th e st opba n d is w1 < # < w2. 'DC-1' t o m a ke t h e fir st ba n d of a m u lt iba n d filt er a pa ssba n d 'DC-0' t o m a ke t h e fir st ba n d of a m u lt iba n d filt er a st opba n d
6-152
fir1
fir1 a lwa ys u ses a n even filt er or der for t h e h igh pa ss a n d ba n dst op con figu r a t ion s. Th is is beca u se for odd or der s, t h e fr equ en cy r espon se a t t h e Nyqu ist fr equ en cy is 0, wh ich is in a ppr opr ia t e for h igh pa ss a n d ba n dst op filt er s. If you specify a n odd-va lu ed n, fir1 in cr em en t s it by 1. b = fir1(n,Wn,window) u ses t h e win dow specified in colu m n vect or window for t h e design . Th e vect or window m u st be n+1 elem en t s lon g. If n o win dow is specified, fir1 em ploys a H a m m in g win dow. b = fir1(n,Wn,'ftype',window) a ccept s bot h ftype a n d window pa r a m et er s. b = fir1(...,'noscale') t u r n s off t h e defa u lt sca lin g.
Algorithm
fir1 u ses t h e win dow m et h od of F IR filt er design [1]. If w (n ) den ot es a win dow, wh er e 1 5 n 5 N , a n d t h e im pu lse r espon se of t h e idea l filt er is h (n ), wh er e h (n ) is t h e in ver se F ou r ier t r a n sfor m of t h e idea l fr equ en cy r espon se, t h en t h e win dowed digit a l filt er coefficien t s a r e given by
b (n ) = w (n ) h (n ),
15n 5N
6-153
fir1
Examples Example 1
Design a 48t h -or der F IR ba n dpa ss filt er wit h pa ssba n d 0.35 5 w 5 0.65:
b = fir1(48,[0.35 0.65]); freqz(b,1,512)
50 Magnitude (dB)
!50
Example 2
Th e chirp.mat file con t a in s a sign a l, y, t h a t h a s m ost of it s power a bove Fs/4, or h a lf t h e Nyqu ist fr equ en cy. Design a 34t h -or der F IR h igh pa ss filt er t o a t t en u a t e t h e com pon en t s of t h e sign a l below Fs/4. Use a cu t off fr equ en cy of 0.48 a n d a Ch ebysh ev win dow wit h 30 dB of r ipple:
load chirp % loads y and Fs b = fir1(34,0.48,'high',chebwin(35,30)); yfilt = filter(b,1,y);
6-154
fir1
Diagnostics
If n is odd a n d you specify a ba n dst op or h igh pa ss filt er , fir1 gives t h e followin g wa r n in g m essa ge:
For highpass and bandstop filters, N must be even. Order is being increased by 1.
6-155
fir1
See Also
filter fir2 fircls fircls1 firls freqz kaiserord remez
F ilt er da t a wit h a r ecu r sive (IIR) or n on r ecu r sive (F IR) filt er. Win dow-ba sed fin it e im pu lse r espon se filt er design a r bit r a r y r espon se. Con st r a in ed lea st squ a r e F IR filt er design for m u lt iba n d filt er s. Con st r a in ed lea st squ a r e filt er design for lowpa ss a n d h igh pa ss lin ea r ph a se F IR filt er s. Lea st squ a r e lin ea r-ph a se F IR filt er design . F r equ en cy r espon se of digit a l filt er s. E st im a t e pa r a m et er s for fir1 wit h Ka iser win dow. Pa r ks-McClella n opt im a l F IR filt er design .
References
[1] IE E E . Program s for Digital S ign al Processin g. IE E E P r ess. New Yor k: J oh n Wiley & Son s, 1979. Algor it h m 5.2.
6-156
fir2
Purpose Syntax
6fir 2
Win dow-ba sed fin it e im pu lse r espon se filt er design a r bit r a r y r espon se.
b b b b b b = = = = = = fir2(n,f,m) fir2(n,f,m,window) fir2(n,f,m,npt) fir2(n,f,m,npt,window) fir2(n,f,m,npt,lap) fir2(n,f,m,npt,lap,window)
Description
fir2 design s win dowed digit a l F IR filt er s wit h a r bit r a r ily sh a ped fr equ en cy
r espon se. (F or st a n da r d lowpa ss, ba n dpa ss, h igh pa ss, a n d ba n dst op con figu r a t ion s, u se fir1.)
b = fir2(n,f,m) r et u r n s r ow vect or b con t a in in g t h e n+1 coefficien t s of a n or der n F IR filt er . Th e fr equ en cy-m a gn it u de ch a r a ct er ist ics of t h is filt er m a t ch t h ose given by vect or s f a n d m:
f is a vect or of fr equ en cy poin t s in t h e r a n ge fr om 0 t o 1, wh er e 1 cor r espon ds t o h a lf t h e sa m plin g fr equ en cy (t h e Nyqu ist fr equ en cy). Th e fir st poin t of f m u st be 0 a n d t h e la st poin t 1. Th e fr equ en cy poin t s m u st be in in cr ea sin g or der . m is a vect or con t a in in g t h e desir ed m a gn it u de r espon se a t t h e poin t s specified in f. f a n d m m u st be t h e sa m e len gt h . Du plica t e fr equ en cy poin t s a r e a llowed, cor r espon din g t o st eps in t h e fr equ en cy r espon se. Use plot(f,m) t o view t h e filt er sh a pe. Th e ou t pu t filt er coefficien t s, b, a r e or der ed in descen din g power s of z : b (z ) = b (1 ) + b (2 ) z 1 + L + b (n + 1 ) z n
b = fir2(n,f,m,window) u ses t h e win dow specified in colu m n vect or window for t h e filt er design . Th e vect or window m u st be n+1 elem en t s lon g. If n o win dow is specified, fir2 em ploys a H a m m in g win dow.
6-157
fir2
b = fir2(n,f,m,npt) a n d b = fir2(n,f,m,npt, window) specify t h e n u m ber of poin t s npt for t h e gr id on t o wh ich fir2 in t er pola t es t h e fr equ en cy r espon se, wit h or wit h ou t a window specifica t ion . b = fir2(n,f,m,npt,lap) a n d b = fir2(n,f,m,npt,lap,window) specify t h e size of t h e r egion , lap, t h a t fir2 in ser t s a r ou n d du plica t e fr equ en cy poin t s, wit h or wit h ou t a window
Algorithm
Th e desir ed fr equ en cy r espon se is in t er pola t ed on t o a den se, even ly spa ced gr id of len gt h npt. npt is 512 by defa u lt . If t wo su ccessive va lu es of f a r e t h e sa m e, a r egion of lap poin t s is set u p a r ou n d t h is fr equ en cy t o pr ovide a sm oot h bu t st eep t r a n sit ion in t h e r equ est ed fr equ en cy r espon se. By defa u lt , lap is 25. Th e filt er coefficien t s a r e obt a in ed by a pplyin g a n in ver se fa st F ou r ier t r a n sfor m t o t h e gr id a n d m u lt iplyin g by a win dow; by defa u lt , t h is is a H a m m in g win dow.
6-158
fir2
Example
Design a 30t h -or der lowpa ss filt er a n d over plot t h e desir ed fr equ en cy r espon se wit h t h e a ct u a l fr equ en cy r espon se:
f = [0 0.6 0.6 1]; m = [1 1 0 0]; b = fir2(30,f,m); [h,w] = freqz(b,1,128); plot(f,m,w/pi,abs(h))
1.2
0.8
0.6
0.4
0.2
0 0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
See Also
Bu t t er wor t h a n a log a n d digit a l filt er design . Ch ebysh ev t ype I filt er design (pa ssba n d r ipple). Ch ebysh ev t ype II filt er design (st opba n d r ipple). E llipt ic (Ca u er ) filt er design . Win dow-ba sed fin it e im pu lse r espon se filt er design st a n da r d r espon se. Gen er a lized digit a l Bu t t er wor t h filt er design . Pa r ks-McClella n opt im a l F IR filt er design . Recu r sive digit a l filt er design .
6-159
fircls
Purpose Syntax Description
6fir cls
Th e fr equ en cy-m a gn it u de ch a r a ct er ist ics of t h is filt er m a t ch t h ose given by vect or s f a n d amp: f is a vect or of t r a n sit ion fr equ en cies in t h e r a n ge fr om 0 t o 1, wh er e 1 cor r espon ds t o h a lf t h e sa m plin g fr equ en cy (t h e Nyqu ist fr equ en cy). Th e fir st poin t of f m u st be 0 a n d t h e la st poin t 1. Th e fr equ en cy poin t s m u st be in in cr ea sin g or der . amp is a vect or descr ibin g t h e piecewise con st a n t desir ed a m plit u de of t h e fr equ en cy r espon se. Th e len gt h of amp is equ a l t o t h e n u m ber of ba n ds in t h e r espon se a n d sh ou ld be equ a l t o length(f)1. up a n d lo a r e vect or s wit h t h e sa m e len gt h a s amp. Th ey defin e t h e u pper a n d lower bou n ds for t h e fr equ en cy r espon se in ea ch ba n d.
fircls(n,f,amp,up,lo,'design_flag') en a bles you t o m on it or t h e filt er
design , wh er e design_flag ca n be: trace, for a t ext u a l displa y of t h e design er r or a t ea ch it er a t ion st ep. plots, for a collect ion of plot s sh owin g t h e filt er s fu ll-ba n d m a gn it u de r espon se a n d a zoom ed view of t h e m a gn it u de r espon se in ea ch su b-ba n d. All plot s a r e u pda t ed a t ea ch it er a t ion st ep. both, for bot h t h e t ext u a l displa y a n d plot s.
6-160
fircls
Example
0.2
0.4
0.6
0.8
1.2
1.4
0.02 0 -0.02 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 1.02 1 0.98 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.01 0 -0.01 0.8 0.85 0.9 Frequency 0.95 1
NOTE Nor m a lly, t h e lower va lu e in t h e st opba n d will be specified a s n ega t ive. By set t in g lo equ a l t o 0 in t h e st opba n ds, a n on n ega t ive fr equ en cy r espon se a m plit u de ca n be obt a in ed. Su ch filt er s ca n be spect r a lly fa ct or ed t o obt a in m in im u m ph a se filt er s.
Algorithm
Th e a lgor it h m is a m u lt iple exch a n ge a lgor it h m t h a t u ses La gr a n ge m u lt iplier s a n d Ku h n -Tu ck er con dit ion s on ea ch it er a t ion .
Band #3
Band #2
6-161
fircls
See Also
fircls1 firls remez
Con st r a in ed lea st squ a r e filt er design for lowpa ss a n d h igh pa ss lin ea r ph a se F IR filt er s. Lea st squ a r e lin ea r-ph a se F IR filt er design . Pa r ks-McClella n opt im a l F IR filt er design .
References
[1] Selesn ick, I.W., M. La n g, a n d C.S. Bu r r u s. Con st r a in ed Lea st Squ a r e Design of F IR F ilt er s wit h ou t Specified Tr a n sit ion Ba n ds. Proceed in gs of th e IE E E In t. Con f. Acou st., S peech , S ign al Processin g. Vol. 2 (Ma y 1995). P gs. 1260-1263. [2] Selesn ick, I.W., M. La n g, a n d C.S. Bu r r u s. Con st r a in ed Lea st Squ a r e Design of F IR F ilt er s wit h ou t Specified Tr a n sit ion Ba n ds. IE E E T ran saction s on S ign al Processin g , Vol. 44, No. 8 (Au gu st 1996).
6-162
fircls1
Purpose Syntax
6fir cls1
Con st r a in ed lea st squ a r e filt er design for lowpa ss a n d h igh pa ss lin ea r ph a se F IR filt er s.
b b b b b b b = = = = = = = fircls1(n,wo,dp,ds) fircls1(n,wo,dp,ds,'high') fircls1(n,wo,dp,ds,wt) fircls1(n,wo,dp,ds,wt,'high') fircls1(n,wo,dp,ds,wp,ws,k) fircls1(n,wo,dp,ds,wp,ws,k,'high') fircls1(n,wo,dp,ds,,'design_flag')
Description
b = fircls1(n,wo,dp,ds) gen er a t es a lowpa ss F IR filt er b. n+1 is t h e filt er len gt h , wo is t h e n or m a lized cu t off fr equ en cy in t h e r a n ge bet ween 0 a n d 1 (wh er e 1 cor r espon ds t o h a lf t h e sa m plin g fr equ en cy, t h a t is, t h e Nyqu ist fr equ en cy), dp is t h e m a xim u m pa ssba n d devia t ion fr om 1 (pa ssba n d r ipple), a n d ds is t h e m a xim u m st opba n d devia t ion fr om 0 (st opba n d r ipple). b = fircls1(n,wo,dp,ds,'high') gen er a t es a h igh pa ss F IR filt er b. b = fircls1(n,wo,dp,ds,wt) a n d b = fircls1(n,wo,dp,ds,wt,'high') specify a fr equ en cy wt a bove wh ich (for wt>wo) or below wh ich (for wt<wo) t h e filt er is gu a r a n t eed t o m eet t h e given
ba n d cr it er ion . Th is will h elp you design a filt er t h a t m eet s a pa ssba n d or st opba n d edge r equ ir em en t . Th er e a r e fou r ca ses: Lowpa ss: - 0<wt<wo<1: t h e a m plit u de of t h e filt er is wit h in dp of 1 over t h e fr equ en cy r a n ge 0 < # < wt. - 0<wo<wt<1: t h e a m plit u de of t h e filt er is wit h in ds of 0 over t h e fr equ en cy r a n ge wt < # < 1. H igh pa ss: - 0<wt<wo<1: t h e a m plit u de of t h e filt er is wit h in ds of 0 over t h e fr equ en cy r a n ge 0 < # < wt. - 0<wo<wt<1: t h e a m plit u de of t h e filt er is wit h in dp of 1 over t h e fr equ en cy r a n ge wt < # < 1.
6-163
fircls1
b = fircls1(n,wo,dp,ds,wp,ws,k) gen er at es a lowpa ss FIR filter b wit h a weigh t ed fu n ct ion . n+1 is t h e filt er lengt h , wo is t h e n or m alized cu t off fr equ en cy, dp is t h e m a ximum passba n d devia t ion from 1 (passba n d r ipple), a nd ds is t h e ma ximum st opba nd deviat ion from 0 (stopband r ipple). wp is the pa ssband edge of t h e L2 weigh t fu n ct ion an d ws is t h e stopba n d edge of th e L2 weigh t fu n ction , wh er e wp < wo < ws. k is t h e r a t io (pa ssban d L2 er r or )/(st opban d L2 er r or ):
wp
60
----------------------------------------------------- = k $
6w
b = fircls1(n,wo,dp,ds,wp,ws,k,'high') gen er a t es a h igh pa ss F IR filt er b wit h a weigh t ed fu n ct ion , wh er e ws < wo < wp. b = fircls1(n,wo,dp,ds,,'design_flag') en a bles you t o m on it or t h e filt er design , wh er e design_flag ca n be
trace, for a t ext u a l displa y of t h e design t a ble u sed in t h e design plots, for plot s of t h e filt er s m a gn it u de, gr ou p dela y, a n d zer os a n d poles both, for bot h t h e t ext u a l displa y a n d plot s NOTE In t h e design of ver y n a r r ow ba n d filt er s wit h sm a ll dp a n d ds, t h er e m a y n ot exist a filt er of t h e given len gt h t h a t m eet s t h e specifica t ion s.
6-164
fircls1
Example
Th e a lgor it h m is a m u lt iple exch a n ge a lgor it h m t h a t u ses La gr a n ge m u lt iplier s a n d Ku h n -Tu ck er con dit ion s on ea ch it er a t ion .
fircls firls remez
Con st r a in ed lea st squ a r e F IR filt er design for m u lt iba n d filt er s. Lea st squ a r e lin ea r-ph a se F IR filt er design . Pa r ks-McClella n opt im a l F IR filt er design .
References
[1] Selesn ick, I.W., M. La n g, a n d C.S. Bu r r u s. Con st r a in ed Lea st Squ a r e Design of F IR F ilt er s wit h ou t Specified Tr a n sit ion Ba n ds. Proceed in gs of th e IE E E In t. Con f. Acou st., S peech , S ign al Processin g. Vol. 2 (Ma y 1995). P gs. 1260-1263. [2] Selesn ick, I.W., M. La n g, a n d C.S. Bu r r u s. Con st r a in ed Lea st Squ a r e Design of F IR F ilt er s wit h ou t Specified Tr a n sit ion Ba n ds. IE E E T ran saction s on S ign al Processin g , Vol. 44, No. 8 (Au gu st 1996).
6-165
firls
Purpose Syntax
6fir ls
Description
in t egr a t ed squ a r ed er r or bet ween a n idea l piecewise lin ea r fu n ct ion a n d t h e m a gn it u de r espon se of t h e filt er over a set of desir ed fr equ en cy ba n ds.
b = firls(n,f,a) r et u r n s r ow vect or b con t a in in g t h e n+1 coefficien t s of t h e or der n F IR filt er wh ose fr equ en cy-a m plit u de ch a r a ct er ist ics a ppr oxim a t ely m a t ch t h ose given by vect or s f a n d a. Th e ou t pu t filt er coefficien t s, or t a ps, in b obey t h e sym m et r y r ela t ion
b (k ) = b (n + 2 k ),
k = 1 , , n + 1
Th ese a r e t ype I (n odd) a n d t ype II (n even ) lin ea r -ph a se filt er s. Vect or s f a n d a specify t h e fr equ en cy-a m plit u de ch a r a ct er ist ics of t h e filt er : f is a vect or of pa ir s of fr equ en cy poin t s, specified in t h e r a n ge bet ween 0 a n d 1, wh er e 1 cor r espon ds t o h a lf t h e sa m plin g fr equ en cy (t h e Nyqu ist fr equ en cy). Th e fr equ en cies m u st be in in cr ea sin g or der . Du plica t e fr equ en cy poin t s a r e a llowed a n d, in fa ct , ca n be u sed t o design a filt er exa ct ly t h e sa m e a s t h ose r et u r n ed by t h e fir1 a n d fir2 fu n ct ion s wit h a r ect a n gu la r or boxcar win dow. a is a vect or con t a in in g t h e desir ed a m plit u de a t t h e poin t s specified in f. Th e desir ed a m plit u de fu n ct ion a t fr equ en cies bet ween pa ir s of poin t s (f (k ), f (k +1)) for k odd is t h e lin e segm en t con n ect in g t h e poin t s (f (k ), a (k )) a n d (f (k +1), a (k +1)). Th e desir ed a m plit u de fu n ct ion a t fr equ en cies bet ween pa ir s of poin t s (f (k ), f (k +1)) for k even is u n specified. Th ese a r e t r a n sit ion or don t ca r e r egion s. f a n d a a r e t h e sa m e len gt h . Th is len gt h m u st be a n even n u m ber .
6-166
firls
0.5
0.0 0.0
b = firls(n,f,a,w) u ses t h e weigh t s in vect or w t o weigh t t h e fit in ea ch fr equ en cy ba n d. Th e len gt h of w is h a lf t h e len gt h of f a n d a, so t h er e is exa ct ly on e weigh t per ba n d. b = firls(n,f,a,'ftype') a n d b = firls(n,f,a,w,'ftype') specify a filt er t ype, wh er e ftype is
hilbert for lin ea r -ph a se filt er s wit h odd sym m et r y (t ype III a n d t ype IV) Th e ou t pu t coefficien t s in b obey t h e r ela t ion b (k ) = -b (n + 2 - k ), k = 1, ..., n + 1. Th is cla ss of filt er s in clu des t h e H ilber t t r a n sfor m er , wh ich h a s a desir ed a m plit u de of 1 a cr oss t h e en t ir e ba n d. differentiator for t ype III a n d t ype IV filt er s, u sin g a specia l weigh t in g t ech n iqu e F or n on zer o a m plit u de ba n ds, t h e in t egr a t ed squ a r ed er r or h a s a weigh t of (1/f )2 so t h a t t h e er r or a t low fr equ en cies is m u ch sm a ller t h a n a t h igh fr equ en cies. F or F IR differ en t ia t or s, wh ich h a ve a n a m plit u de ch a r a ct er ist ic pr opor t ion a l t o fr equ en cy, t h e filt er s m in im ize t h e r ela t ive in t egr a t ed squ a r ed er r or (t h e in t egr a l of t h e squ a r e of t h e r a t io of t h e er r or t o t h e desir ed a m plit u de).
6-167
firls
Examples
Design a 24t h -or der a n t i-sym m et r ic filt er wit h piecewise lin ea r pa ssba n ds a n d plot t h e desir ed a n d a ct u a l fr equ en cy r espon se:
F = [0 0.3 0.4 0.6 0.7 0.9]; A = [0 1 0 0 0.5 0.5]; b = firls(24,F,A,'hilbert'); for i=1:2:6, plot([F(i) F(i+1)],[A(i) A(i+1)],' '), hold on end [H,f] = freqz(b,1,512,2); plot(f,abs(H)), grid on, hold off
1 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0 0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
Algorithm
Refer en ce [1] descr ibes t h e t h eor et ica l a ppr oa ch t h a t firls t a kes. Th e fu n ct ion solves a syst em of lin ea r equ a t ion s in volvin g a n in n er pr odu ct m a t r ix of size r ou gh ly n/2 u sin g MATLABs \ oper a t or .
6-168
firls
Th is fu n ct ion design s t ype I, II, III, a n d IV lin ea r -ph a se filt er s. Type I a n d II a r e t h e defa u lt s for n even a n d odd r espect ively, wh ile t h e 'hilbert' a n d 'differentiator' fla gs pr odu ce t ype III (n even ) a n d IV (n odd) filt er s. Th e va r iou s filt er t ypes h a ve differ en t sym m et r ies a n d con st r a in t s on t h eir fr equ en cy r espon ses (see [2] for det a ils).
Linear Phase Filter Type
Filter Order n
Symmetry of Coefficients
even : b ( k ) = b ( n + 2 k ) , k = 1 , , n + 1 odd: b (k ) = b (n + 2 k ), k = 1 , , n + 1
Diagnostics
An a ppr opr ia t e dia gn ost ic m essa ge is displa yed wh en in cor r ect a r gu m en t s a r e u sed:
F must be even length. F and A must be equal lengths. Requires symmetry to be 'hilbert' or 'differentiator'. Requires one weight per band. Frequencies in F must be nondecreasing. Frequencies in F must be in range [0,1].
Th is t en ds t o h a ppen wh en t h e filt er len gt h t im es t h e t r a n sit ion widt h gr ows la r ge. In t h is ca se, t h e filt er coefficien t s b m igh t n ot r epr esen t t h e desir ed filt er . You ca n ch eck t h e filt er by lookin g a t it s fr equ en cy r espon se.
6-169
firls
See Also
fir1 fir2 firrcos remez
Win dow-ba sed fin it e im pu lse r espon se filt er design st a n da r d r espon se. Win dow-ba sed fin it e im pu lse r espon se filt er design a r bit r a r y r espon se. Ra ised cosin e F IR filt er design . Pa r ks-McClella n opt im a l F IR filt er design .
References
[1] P a r ks, T.W., a n d C.S. Bu r r u s. Digital Filter Design . New Yor k: J oh n Wiley & Son s, 1987. P gs. 54-83. [2] Oppen h eim , A.V., a n d R.W. Sch a fer . Discrete-T im e S ign al Processin g. E n glewood Cliffs, NJ : P r en t ice H a ll, 1989. P gs. 256-266.
6-170
firrcos
Purpose
6fir r cos
Description
firrcos(n,F0,df,Fs) r et u r n s a n or der n lowpa ss lin ea r -ph a se F IR filt er wit h a r a ised cosin e t r a n sit ion ba n d. Th e filt er h a s cu t off fr equ en cy F0, t r a n sit ion ba n dwidt h df, a n d sa m plin g fr equ en cy Fs, a ll in H er t z. df m u st be sm a ll en ou gh so t h a t F0 df/2 is bet ween 0 a n d Fs/2. Th e coefficien t s in b a r e n or m a lized so t h a t t h e n om in a l pa ssba n d ga in is a lwa ys equ a l t o on e. firrcos(n,F0,df) u ses a defa u lt sa m plin g fr equ en cy of Fs = 2. b = firrcos(n,F0,r,Fs,'rolloff') in t er pr et s t h e t h ir d a r gu m en t , r, a s t h e r olloff fa ct or in st ea d of t h e t r a n sit ion ba n dwidt h , df. r m u st be in t h e r a n ge [0,1]. b = firrcos(...,'type') design s eit h er a n or m a l r a ised cosin e filt er or a squ a r e r oot r a ised cosin e filt er depen din g on t h e type specifica t ion , wh ich ca n be
normal, for a r egu la r r a ised cosin e filt er . Th is is t h e defa u lt , a n d is a lso in effect wh en t h e 'type' a r gu m en t is left em pt y, []. sqrt, for a squ a r e r oot r a ised cosin e filt er .
b = firrcos(...,'type',delay) specifies a n in t eger dela y in t h e r a n ge [0,n+1]. Th e defa u lt is n/2 for even n a n d (n+1)/2 for odd n. b = firrcos(...,'type',delay,window) a pplies a len gt h n+1 win dow t o t h e design ed filt er t o r edu ce t h e r ipple in t h e fr equ en cy r espon se. window m u st be a n+1 lon g colu m n vect or . If n o win dow is specified, a boxca r (r ect a n gu la r ) win dow is u sed. Ca r e m u st be exer cised wh en u sin g a win dow wit h a dela y ot h er t h a n t h e defa u lt . [b,a] = firrcos(...) a lwa ys r et u r n s a = 1.
6-171
firrcos
Example
Design a n or der 20 r a ised cosin e F IR filt er wit h cu t off fr equ en cy 0.25 of t h e Nyqu ist fr equ en cy a n d a t r a n sit ion ba n dwidt h of 0.25:
h = firrcos(20,0.25,0.25); freqz(h,1,'Fs',2,'phase','no')
20
!40
!60
!80
!100
!120 0
0.2
0.8
See Also
Win dow-ba sed fin it e im pu lse r espon se filt er design st a n da r d r espon se. Win dow-ba sed fin it e im pu lse r espon se filt er design a r bit r a r y r espon se. Lea st squ a r e lin ea r-ph a se F IR filt er design . Pa r ks-McClella n opt im a l F IR filt er design .
6-172
freqs
Purpose Syntax
6freqs
Description
r espon se h.
freqs wit h n o ou t pu t a r gu m en t s plot s t h e m a gn it u de a n d ph a se r espon se
6-173
freqs
Example
Magnitude
10
10 -1 10
-1
10 Frequency
10
0
Phase (degrees)
-50
-100
-150 -1 10
10 Frequency
10
6-174
freqs
Algorithm
See Also
Absolu t e va lu e (m a gn it u de). P h a se a n gle. F r equ en cy r espon se of digit a l filt er s. Con t in u ou s-t im e (a n a log) filt er iden t ifica t ion fr om fr equ en cy da t a . Gen er a t e loga r it h m ica lly spa ced vect or s (see t h e on lin e M AT L AB Fu n ction R eferen ce). Polyn om ia l eva lu a t ion (see t h e on lin e M A T L AB Fu n ction R eferen ce).
6-175
freqspace
Purpose Syntax
6fr eqspa ce
Description
See Also
freqz invfreqz
F r equ en cy r espon se of digit a l filt er s. Discr et e-t im e filt er iden t ifica t ion fr om fr equ en cy da t a .
6-176
freqz
Purpose Syntax
6freqz
Description
digit a l filt er B (z ) b (1 ) + b (2 ) z 1 + L + b (n b + 1 ) z n b H (z ) = ---------- = --------------------------------------------------------------------------------------- 1 A (z ) + a (n a + 1 ) z n a a (1 ) + a (2 ) z + L eva lu a t ed a t z = ej# given t h e coefficien t vect or s b a n d a. freqz r et u r n s bot h h, t h e com plex fr equ en cy r espon se, a n d w, a vect or con t a in in g t h e n fr equ en cy poin t s in u n it s of r a ds/sa m ple. freqz eva lu a t es t h e fr equ en cy r espon se a t n poin t s equ a lly spa ced a r ou n d t h e u pper h a lf of t h e u n it cir cle, so w con t a in s n poin t s bet ween 0 a n d $. It is best , a lt h ou gh n ot n ecessa r y, t o ch oose a va lu e for n t h a t is a n exa ct power of t wo, beca u se t h is a llows fa st com pu t a t ion u sin g a n F F T a lgor it h m . If you do n ot specify a va lu e for n, it defa u lt s t o 512.
[h,f] = freqz(b,a,n,Fs) specifies a posit ive sa m plin g fr equ en cy Fs, in H er t z. Th e defa u lt for Fs is 1. It r et u r n s a vect or f con t a in in g t h e a ct u a l fr equ en cy poin t s bet ween 0 a n d Fs/2 (t h e Nyqu ist fr equ en cy) a t wh ich it ca lcu la t ed t h e fr equ en cy r espon se. f is of len gt h n. [h,w] = freqz(b,a,n,'whole') u ses n poin t s a r ou n d t h e wh ole u n it cir cle, so w h a s r a n ge [0,2 $). [h,f] = freqz(b,a,n,'whole',Fs) u ses n poin t s a r ou n d t h e wh ole u n it
6-177
freqz
h = freqz(b,a,w) r et u r n s t h e fr equ en cy r espon se a t t h e fr equ en cies in vect or w (specified in r a ds/sa m ple). h = freqz(b,a,f,Fs) r et u r n s t h e fr equ en cy r espon se a t t h e fr equ en cies in vect or f (specified in H z). freqz(...) wit h n o ou t pu t a r gu m en t s plot s t h e m a gn it u de a n d ph a se r espon se ver su s fr equ en cy in t h e cu r r en t figu r e win dow.
Examples
Algorithm
freqz u ses a n F F T a lgor it h m wh en a r gu m en t n is pr esen t . It com pu t es t h e fr equ en cy r espon se a s t h e r a t io of t h e t r a n sfor m ed n u m er a t or a n d den om in a t or coefficien t s, pa dded wit h zer os t o t h e desir ed len gt h : h = fft(b,n)./fft(a,n)
If n is n ot a power of t wo, t h e F F T a lgor it h m is n ot a s efficien t a n d m a y ca u se lon g com pu t a t ion t im es. Wh en a fr equ en cy vect or w or f is pr esen t , or if n is less t h a n max(length(b),length(a)), freqz eva lu a t es t h e polyn om ia ls a t ea ch fr equ en cy poin t u sin g H or n er s m et h od of polyn om ia l eva lu a t ion a n d t h en divides t h e n u m er a t or r espon se by t h e den om in a t or r espon se.
6-178
freqz
See Also
Absolu t e va lu e (m a gn it u de). P h a se a n gle. On e-dim en sion a l fa st Fou r ier t r a n sfor m . F ilt er da t a wit h a r ecu r sive (IIR) or n on r ecu r sive (F IR) filt er. F r equ en cy r espon se of a n a log filt er s. Im pu lse r espon se of digit a l filt er s. Discr et e-t im e filt er iden t ifica t ion fr om fr equ en cy da t a . Gen er a t e loga r it h m ica lly spa ced vect or s (see t h e on lin e M AT L AB Fu n ction R eferen ce).
6-179
gauspuls
Purpose Syntax
6ga u spu ls
Description
Remarks
6-180
gauspuls
Example
P lot a 50 k H z Ga u ssia n RF pu lse wit h 60% ba n dwidt h , sa m pled a t a r a t e of 1 MH z. Tr u n ca t e t h e pu lse wh er e t h e en velope fa lls 40 dB below t h e pea k :
tc = gauspuls('cutoff',50e3,0.6,[],40); t = tc : 1e6 : tc; yi = gauspuls(t,50e3,0.6); plot(t,yi)
1 0.8 0.6 0.4 0.2 0 -0.2 -0.4 -0.6 -0.8 -4
-2
2 x 10
4
-5
See Also
chirp cos diric pulstran rectpuls sawtooth sin sinc square tripuls
Swept -fr equ en cy cosin e gen er a t or. Cosin e of vect or /m a t r ix elem en t s (see t h e on lin e M AT L AB Fu n ction R eferen ce). Dir ich let or per iodic sin c fu n ct ion . P u lse t r a in gen er a t or. Sa m pled a per iodic r ect a n gle gen er a t or. Sawt oot h or t r ia n gle wave gen er a t or. Sin e of vect or /m a t r ix elem en t s (see t h e on lin e M AT L AB Fu n ction R eferen ce). Sin c or sin ($t )/$t fu n ct ion . Squ a r e wa ve gen er a t or. Sa m pled a per iodic t r ia n gle gen er a t or.
6-181
grpdelay
Purpose Syntax
6grpd ela y
Description
Th e grou p d elay of a filt er is a m ea su r e of t h e a ver a ge dela y of t h e filt er a s a fu n ct ion of fr equ en cy. It is t h e n ega t ive fir st der iva t ive of t h e ph a se r espon se of t h e filt er . If t h e com plex fr equ en cy r espon se of a filt er is H (ej#), t h en t h e gr ou p dela y is d .(#) / g (#) = -------------d# wh er e # is fr equ en cy a n d . is t h e ph a se a n gle of H (ej#). digit a l filt er
[gd,w] = grpdelay(b,a,n) r et u r n s t h e n-poin t gr ou p dela y, / g ( # ) , of t h e
B (z ) b (1 ) + b (2 ) z 1 + L + b (n b + 1 ) z n b H (z ) = ---------- = --------------------------------------------------------------------------------------- 1 A (z ) + a (n a + 1 ) z n a a (1 ) + a (2 ) z + L given t h e n u m er a t or a n d den om in a t or coefficien t s in vect or s b a n d a. grpdelay r et u r n s bot h gd, t h e gr ou p dela y, a n d w, a vect or con t a in in g t h e n fr equ en cy poin t s in r a dia n s. grpdelay eva lu a t es t h e gr ou p dela y a t n poin t s equ a lly spa ced a r ou n d t h e u pper h a lf of t h e u n it cir cle, so w con t a in s n poin t s bet ween 0 a n d $. A va lu e for n t h a t is a n exa ct power of t wo a llows fa st com pu t a t ion u sin g a n F F T a lgor it h m .
[gd,f] = grpdelay(b,a,n,Fs) specifies a posit ive sa m plin g fr equ en cy Fs in H er t z. It r et u r n s a len gt h n vect or f con t a in in g t h e a ct u a l fr equ en cy poin t s a t wh ich t h e gr ou p dela y is ca lcu la t ed, a lso in H er t z. f con t a in s n poin t s bet ween 0 a n d Fs/2.
6-182
grpdelay
H er t z.
grpdelay wit h n o ou t pu t a r gu m en t s plot s t h e gr ou p dela y ver su s fr equ en cy in
Examples
10
0 0
0.1
0.2
0.8
0.9
6-183
grpdelay
grpdelay m u lt iplies t h e filt er coefficien t s by a u n it r a m p. Aft er F ou r ier t r a n sfor m a t ion , t h is pr ocess cor r espon ds t o differ en t ia t ion . cceps fft freqz hilbert icceps rceps
Com plex cepst r a l a n a lysis. On e-dim en sion a l fa st Fou r ier t r a n sfor m . F r equ en cy r espon se of digit a l filt er s. H ilber t t r a n sfor m . In ver se com plex cepst r u m . Rea l cepst r u m a n d m in im u m ph a se r econ st r u ct ion .
6-184
hamming
Purpose Syntax Description
6h a m m in g
H a m m in g win dow.
w = hamming(n) w = hamming(n,sflag) w = hamming(n) r et u r n s a n n-poin t sym m et r ica lly sa m pled H a m m in g win dow in t h e colu m n vect or w. n sh ou ld be a n on n ega t ive in t eger . Th e coefficien t s of a
w = hamming(n,sflag) r et u r n s a n n-poin t H a m m in g win dow u sin g t h e win dow sa m plin g specified by sflag, wh ich ca n be eit h er 'periodic' or 'symmetric' (t h e defa u lt ). Wh en 'periodic' is specified, hamming com pu t es a len gt h n+1 win dow a n d r et u r n s t h e fir st n poin t s.
Diagnostics
See Also
Ba r t let t win dow. Bla ck m a n win dow. Rect a n gu la r win dow. Ch ebysh ev win dow. H a n n in g win dow. Ka iser win dow. Tr ia n gu la r win dow.
References
[1] Oppen h eim , A.V., a n d R.W. Sch a fer , Discrete-T im e S ign al Processin g. E n glewood Cliffs, NJ : P r en t ice-H a ll, 1989.
6-185
hanning
Purpose Syntax Description
6h a n n in g
H a n n in g win dow.
w = hanning(n) w = hanning(n,sflag) w = hanning(n) r et u r n s a n n-poin t sym m et r ica lly sa m pled H a n n in g win dow in t h e colu m n vect or w. n sh ou ld be a n on n ega t ive in t eger . Th e coefficien t s of a
w = hanning(n,sflag) r et u r n s a n n-poin t H a n n in g win dow u sin g t h e win dow sa m plin g specified by sflag, wh ich ca n be eit h er 'periodic' or 'symmetric' (t h e defa u lt ). Wh en 'periodic' is specified, hanning com pu t es a len gt h n+1 win dow a n d r et u r n s t h e fir st n poin t s.
Diagnostics
See Also
Ba r t let t win dow. Bla ck m a n win dow. Rect a n gu la r win dow. Ch ebysh ev win dow. H a m m in g win dow. Ka iser win dow. Tr ia n gu la r win dow.
References
[1] Oppen h eim , A.V., a n d R.W. Sch a fer , Discrete-T im e S ign al Processin g. E n glewood Cliffs, NJ : P r en t ice-H a ll, 1989.
6-186
hilbert
Purpose Syntax Description
6h ilber t
H ilber t t r a n sfor m .
y = hilbert(x) y = hilbert(x) r et u r n s a com plex h elica l sequ en ce, som et im es ca lled t h e
an alytic sign al , fr om a r ea l da t a sequ en ce. Th e a n a lyt ic sign a l h a s a r ea l pa r t , wh ich is t h e or igin a l da t a , a n d a n im a gin a r y pa r t , wh ich con t a in s t h e H ilber t t r a n sfor m . Th e im a gin a r y pa r t is a ver sion of t h e or igin a l r ea l sequ en ce wit h a 90 ph a se sh ift . Sin es a r e t h er efor e t r a n sfor m ed t o cosin es a n d vice ver sa . Th e H ilber t t r a n sfor m ed ser ies h a s t h e sa m e a m plit u de a n d fr equ en cy con t en t a s t h e or igin a l r ea l da t a a n d in clu des ph a se in for m a t ion t h a t depen ds on t h e ph a se of t h e or igin a l da t a . If x is a m a t r ix, y = hilbert(x) oper a t es colu m n wise on t h e m a t r ix, fin din g t h e H ilber t t r a n sfor m of ea ch colu m n . Th e H ilber t t r a n sfor m is u sefu l in ca lcu la t in g in st a n t a n eou s a t t r ibu t es of a t im e ser ies, especia lly t h e a m plit u de a n d fr equ en cy. Th e in st a n t a n eou s a m plit u de is t h e a m plit u de of t h e com plex H ilber t t r a n sfor m ; t h e in st a n t a n eou s fr equ en cy is t h e t im e r a t e of ch a n ge of t h e in st a n t a n eou s ph a se a n gle. F or a pu r e sin u soid, t h e in st a n t a n eou s a m plit u de a n d fr equ en cy a r e con st a n t . Th e in st a n t a n eou s ph a se, h owever , is a sa wt oot h , r eflect in g t h e wa y in wh ich t h e loca l ph a se a n gle va r ies lin ea r ly over a sin gle cycle. F or m ixt u r es of sin u soids, t h e a t t r ibu t es a r e sh or t t er m , or loca l, a ver a ges spa n n in g n o m or e t h a n t wo or t h r ee poin t s. Refer en ce [1] descr ibes t h e Kolm ogor ov m et h od for m in im u m ph a se r econ st r u ct ion , wh ich in volves t a kin g t h e H ilber t t r a n sfor m of t h e loga r it h m of t h e spect r u m of a t im e ser ies. Th e t oolbox fu n ct ion rceps per for m s t h is r econ st r u ct ion .
Algorithm
Th e a n a lyt ic sign a l for a sequ en ce x h a s a on e-sid ed Fou rier tran sform , t h a t is, n ega t ive fr equ en cies a r e 0. To a ppr oxim a t e t h e a n a lyt ic sign a l, hilbert ca lcu la t es t h e F F T of t h e in pu t sequ en ce, r epla ces t h ose F F T coefficien t s t h a t cor r espon d t o n ega t ive fr equ en cies wit h zer os, a n d ca lcu la t es t h e in verse F F T of t h e r esu lt . In det a il, hilbert u ses a fou r -st ep a lgor it h m :
6-187
hilbert
1 It ca lcu la t es t h e F F T of t h e in pu t sequ en ce, st or in g t h e r esu lt in a vect or y.
Befor e t r a n sfor m in g, it zer o pa ds t h e in pu t sequ en ce so it s len gt h n is t h e closest power of t wo, if n ecessa r y. Th is en su r es t h e m ost efficien t F F T com pu t a t ion .
2 It cr ea t es a vect or h wh ose elem en t s h(i) h a ve t h e va lu es
t h e fir st n elem en t s of t h e r esu lt . If t h e in pu t da t a x is a m a t r ix, hilbert oper a t es in a sim ila r m a n n er , ext en din g ea ch st ep a bove t o h a n dle t h e m a t r ix ca se.
See Also
On e-dim en sion a l fa st Fou r ier t r a n sfor m . On e-dim en sion a l in ver se fa st Fou r ier t r a n sfor m . Rea l cepst r u m a n d m in im u m ph a se r econ st r u ct ion .
References
[1] Cla er bou t , J .F . Fu n d am en tals of Geoph ysical Data Processin g . New Yor k : McGr a w-H ill, 1976. P gs. 59-62.
6-188
icceps
Purpose Syntax Description
6icceps
See Also
Com plex cepst r a l a n a lysis. H ilber t t r a n sfor m . Rea l cepst r u m a n d m in im u m ph a se r econ st r u ct ion . Un wr a p ph a se a n gles.
References
[1] Oppen h eim , A.V., a n d R.W. Sch a fer . Digital S ign al Processin g . E n glewood Cliffs, NJ : P r en t ice H a ll, 1975.
6-189
idct
Purpose Syntax Description
6idct
Th e in ver se discr et e cosin e t r a n sfor m r econ st r u ct s a sequ en ce fr om it s discr et e cosin e t r a n sfor m (DCT) coefficien t s. Th e idct fu n ct ion is t h e in ver se of t h e dct fu n ct ion .
x = idct(y) r et u r n s t h e in ver se discr et e cosin e t r a n sfor m of y
N
x (n ) = wh er e
-, + w (k ) y (k ) cos -----------------------------------------2N
k =1
$(2 n 1 )(k 1 )
n = 1 , , N
k =1 25k 5N
a n d N = length(x), wh ich is t h e sa m e a s length(y). Th e ser ies is in dexed fr om n = 1 a n d k = 1 in st ea d of t h e u su a l n = 0 a n d k = 0 beca u se MATLAB vect or s r u n fr om 1 t o N in st ea d of fr om 0 t o N -1.
x = idct(y,n) a ppen ds zer os or t r u n ca t es t h e vect or y t o len gt h n befor e
See Also
Discr et e cosin e t r a n sfor m (DCT). Two-dim en sion a l DCT (see Im age Processin g T oolbox Users Gu id e). Two-dim en sion a l in ver se DCT (see Im age Processin g T oolbox Users Gu id e). On e-dim en sion a l in ver se fa st Fou r ier t r a n sfor m .
6-190
idct
References
[1] J a in , A.K. Fu n d am en tals of Digital Im age Processin g . E n glewood Cliffs, NJ : P r en t ice-H a ll, 1989. [2] P en n eba ker , W.B., a n d J .L. Mit ch ell. J PE G S till Im age Data Com pression S tan d ard . New Yor k , NY: Va n Nost r a n d Rein h old, 1993. Ch a pt er 4.
6-191
ifft
Purpose Syntax Description
6ifft
1 x (n + 1 ) = ---N
k n + X (k + 1 ) W n k =0
wh er e W N = e -j (2p/N ) a n d N = length(x). Not e t h a t t h e ser ies is in dexed a s n + 1 a n d k + 1 in st ea d of t h e u su a l n a n d k beca u se MATLAB vect or s r u n fr om 1 t o N in st ea d of fr om 0 t o N -1.
y = ifft(x) is t h e in ver se F ou r ier t r a n sfor m of vect or x. If x is a n a r r a y, y is t h e in ver se F F T of ea ch colu m n of t h e m a t r ix. y = ifft(x,n) is t h e n-poin t in ver se F F T. If t h e len gt h of x is less t h a n n, ifft pa ds x wit h t r a ilin g zer os t o len gt h n. If t h e len gt h of x is gr ea t er t h a n n, ifft t r u n ca t es t h e sequ en ce x. Wh en x is a n a r r a y, ifft a dju st s t h e len gt h of t h e
Algorithm
Th e ifft fu n ct ion is a n M-file. Th e a lgor it h m for ifft is t h e sa m e a s t h a t for fft, except for a sign ch a n ge a n d a sca le fa ct or of n = length(x). Th e execu t ion t im e is fa st est wh en n is a power of t wo a n d slowest wh en n is a la r ge pr im e.
fft fft2 fftshift ifft2
See Also
On e-dim en sion a l fa st Fou r ier t r a n sfor m . Two-dim en sion a l fa st Fou r ier t r a n sfor m . Rea r r a n ge t h e ou t pu t s of fft a n d fft2. Two-dim en sion a l in ver se fa st Fou r ier t r a n sfor m .
6-192
ifft2
Purpose Syntax Description
6ifft 2
F or a n y X, ifft2(fft2(X)) equ a ls X t o wit h in r ou n doff er r or . If X is r ea l, ifft2(fft2(X)) m a y h a ve sm a ll im a gin a r y pa r t s. Th e ifft2 fu n ct ion is pa r t of t h e st a n da r d MATLAB la n gu a ge.
Algorithm
Th e a lgor it h m for ifft2 is t h e sa m e a s t h a t for fft2, except for a sign ch a n ge a n d sca le fa ct or s of [m n]= size(X). Th e execu t ion t im e is fa st est wh en m a n d n a r e power s of t wo a n d slowest wh en t h ey a r e la r ge pr im es.
fft fft2 fftn fftshift ifft ifftn
See Also
On e-dim en sion a l fa st Fou r ier t r a n sfor m . Two-dim en sion a l fa st Fou r ier t r a n sfor m . N -dim en sion a l fa st Fou r ier t r a n sfor m (see t h e on lin e M AT L AB Fu n ction R eferen ce). Rea r r a n ge t h e ou t pu t s of fft a n d fft2. On e-dim en sion a l in ver se fa st Fou r ier t r a n sfor m . N -dim en sion a l in ver se fa st Fou r ier t r a n sfor m (see t h e on lin e M AT L AB Fu n ction R eferen ce).
6-193
impinvar
Purpose Syntax
6im pin va r
Description
Example
Con ver t a n a n a log lowpa ss filt er t o a digit a l filt er u sin g impinvar wit h a sa m plin g fr equ en cy of 10 H z:
[b,a] = butter(4,0.3,'s'); [bz,az] = impinvar(b,a,10) bz = 1.0e-006 * -0.0000 az = 1.0000 -3.9216 5.7679 -3.7709 0.9246 0.1324 0.5192 0.1273 0
Algorithm
6-194
impinvar
fr om st ep 1 a n d t h e poles fr om st ep 2.
See Also
Bilin ea r t r a n sfor m a t ion m et h od of a n a log-t o-digit a l filt er con ver sion . Lowpa ss t o ba n dpa ss a n a log filt er t r a n sfor m a t ion . Lowpa ss t o ba n dst op a n a log filt er t r a n sfor m a t ion . Lowpa ss t o h igh pa ss a n a log filt er t r a n sfor m a t ion . Lowpa ss t o lowpa ss a n a log filt er t r a n sfor m a t ion .
References
[1] P a r ks, T.W., a n d C.S. Bu r r u s. Digital Filter Design . New Yor k: J oh n Wiley & Son s, 1987. P gs. 206-209.
6-195
impz
Purpose Syntax
6im pz
Description
t h e n u m ber of sa m ples.
impz wit h n o ou t pu t a r gu m en t s plot s t h e im pu lse r espon se in t h e cu r r en t figu r e win dow u sin g stem(t,h). impz wor ks for bot h r ea l a n d com plex in pu t syst em s.
6-196
impz
Example
P lot t h e fir st 50 sa m ples of t h e im pu lse r espon se of a fou r t h -or der lowpa ss ellipt ic filt er wit h cu t off fr equ en cy of 0.4 t im es t h e Nyqu ist fr equ en cy:
[b,a] = ellip(4,0.5,20,0.4); impz(b,a,50)
0.5
0.4
0.3
0.2
0.1
-0.1
-0.2
10
15
20
25
30
35
40
45
Algorithm
To com pu t e n in t h e a u t o-len gt h ca se, impz eit h er u ses n = length(b) for t h e F IR ca se or fir st fin ds t h e poles u sin g p = roots(a), if length(a) is gr ea t er t h a n 1. If t h e filt er is u n st a ble, n is ch osen t o be t h e poin t a t wh ich t h e t er m fr om t h e la r gest pole r ea ch es 10^6 t im es it s or igin a l va lu e. If t h e filt er is st a ble, n is ch osen t o be t h e poin t a t wh ich t h e t er m du e t o t h e la r gest a m plit u de pole is 5*10^5 of it s or igin a l a m plit u de. If t h e filt er is oscilla t or y (poles on t h e u n it cir cle on ly), impz com pu t es five per iods of t h e slowest oscilla t ion . If t h e filt er h a s bot h oscilla t or y a n d da m ped t er m s, n is ch osen t o equ a l five per iods of t h e slowest oscilla t ion or t h e poin t a t wh ich t h e t er m du e t o t h e
6-197
impz
la r gest (n on u n it y) a m plit u de pole is 5*10^5 of it s or igin a l a m plit u de, wh ich ever is gr ea t er .
impz a lso a llows for dela y in t h e n u m er a t or polyn om ia l, wh ich it a dds t o t h e r esu lt in g n.
See Also
impulse stem
Un it im pu lse r espon se (see Con trol S ystem T oolbox Users Gu id e). P lot discr et e sequ en ce da t a (see t h e on lin e M AT L A B Fu n ction R eferen ce).
6-198
interp
Purpose Syntax
6in t er p
Description
In t er pola t ion in cr ea ses t h e or igin a l sa m plin g r a t e for a sequ en ce t o a h igh er r a t e. interp per for m s lowpa ss in t er pola t ion by in ser t in g zer os in t o t h e or igin a l sequ en ce a n d t h en a pplyin g a specia l lowpa ss filt er .
y = interp(x,r) in cr ea ses t h e sa m plin g r a t e of x by a fa ct or of r. Th e in t er pola t ed vect or y is r t im es lon ger t h a n t h e or igin a l in pu t x. y = interp(x,r,l,alpha) specifies l (filt er len gt h ) a n d alpha (cu t -off fr equ en cy). Th e defa u lt va lu e for l is 4 a n d t h e defa u lt va lu e for alpha is 0.5. [y,b] = interp(x,r,l,alpha) r et u r n s vect or b con t a in in g t h e filt er coefficien t s u sed for t h e in t er pola t ion .
Example
10
15
20
25
30
20
40
60
80
100
120
6-199
interp
Algorithm
interp u ses t h e lowpa ss in t er pola t ion Algor it h m 8.1 descr ibed in [1]:
1 It expa n ds t h e in pu t vect or t o t h e cor r ect len gt h by in ser t in g zer os bet ween
t h e or igin a l da t a va lu es.
2 It design s a specia l sym m et r ic F IR filt er t h a t a llows t h e or igin a l da t a t o pa ss
t h r ou gh u n ch a n ged a n d in t er pola t es bet ween so t h a t t h e m ea n -squ a r e er r or s bet ween t h e in t er pola t ed poin t s a n d t h eir idea l va lu es a r e m in im ized.
3 It a pplies t h e filt er t o t h e in pu t vect or t o pr odu ce t h e in t er pola t ed ou t pu t
vect or . Th e len gt h of t h e F IR lowpa ss in t er pola t in g filt er is 2 *l*r+1. Th e n u m ber of or igin a l sa m ple va lu es u sed for in t er pola t ion is 2 *l. Or din a r ily, l sh ou ld be less t h a n or equ a l t o 10. Th e or igin a l sign a l is a ssu m ed t o be ba n d lim it ed wit h n or m a lized cu t off fr equ en cy 0 5 alpha 5 1, wh er e 1 is h a lf t h e or igin a l sa m plin g fr equ en cy (t h e Nyqu ist fr equ en cy). Th e defa u lt va lu e for l is 4 a n d t h e defa u lt va lu e for alpha is 0.5.
Diagnostics
See Also
Decr ea se t h e sa m plin g r a t e for a sequ en ce (decim a t ion ). On e-dim en sion a l da t a in t er pola t ion (t a ble looku p) (see t h e on lin e M AT L AB Fu n ction R eferen ce). Ch a n ge sa m plin g r a t e by a n y r a t ion a l fa ct or. Cu bic splin e in t er pola t ion (see t h e on lin e M AT L AB Fu n ction R eferen ce). Upsa m ple, a pply a n F IR filt er, a n d down sa m ple.
References
[1] IE E E . Program s for Digital S ign al Processin g. IE E E P r ess. New Yor k: J oh n Wiley & Son s, 1979. Algor it h m 8.1.
6-200
intfilt
Purpose Syntax Description
6in t filt
Bot h t ypes of filt er s a r e ba sica lly lowpa ss a n d a r e in t en ded for in t er pola t ion a n d decim a t ion .
Examples
Design a digit a l in t er pola t ion filt er t o u psa m ple a sign a l by fou r , u sin g t h e ba n dlim it ed m et h od:
alpha = 0.5; % "bandlimitedness" factor h1 = intfilt(4,2,alpha); % bandlimited interpolation
Th e filt er h1 wor k s best wh en t h e or igin a l sign a l is ba n dlim it ed t o alpha t im es t h e Nyqu ist fr equ en cy. Cr ea t e a ba n dlim it ed n oise sign a l:
randn('seed',0) x = filter(fir1(40,0.5),1,randn(200,1)); % bandlimit
Now zer o pa d t h e sign a l wit h t h r ee zer os bet ween ever y sa m ple. Th e r esu lt in g sequ en ce is fou r t im es t h e len gt h of x:
xr = reshape([x zeros(length(x),3)]',4*length(x),1);
6-201
intfilt
y is a n in t er pola t ed ver sion of x, dela yed by seven sa m ples (t h e gr ou p-dela y of t h e filt er ). Zoom in on a sect ion t o see t h is: plot(100:200,y(100:200),7+(101:4:196),x(26:49),'o')
Solid = interpolated, o = original 1.5 1 0.5 0 -0.5 -1 -1.5 100 110 120 130 140 150 160 Sample Number 170 180 190 200
t h e or igin a l sign a l. F or exa m ple, fir st -or der polyn om ia l in t er pola t ion is ju st lin ea r in t er pola t ion , wh ich is a ccom plish ed wit h a t r ia n gu la r filt er :
h2 = intfilt(4,1,'l') h2 = 0.2500 0.5000 % Lagrange interpolation 1.0000 0.7500 0.5000 0.2500
0.7500
Algorithm
Th e ba n dlim it ed m et h od u ses firls t o design a n in t er pola t ion F IR equ iva len t t o t h a t pr esen t ed in [1]. Th e polyn om ia l m et h od u ses La gr a n ges polyn om ia l in t er pola t ion for m u la on equ a lly spa ced sa m ples t o con st r u ct t h e a ppr opr ia t e filt er .
decimate interp resample
See Also
Decr ea se t h e sa m plin g r a t e for a sequ en ce (decim a t ion ). In cr ea se sa m plin g r a t e by a n in t eger fa ct or (in t er pola t ion ). Ch a n ge sa m plin g r a t e by a n y r a t ion a l fa ct or.
References
[1] Oet ken , P a r ks, a n d Sch ler . New Resu lt s in t h e Design of Digit a l In t er pola t or s. IE E E T ran s. Acou st., S peech , S ign al Processin g . Vol. ASSP -23 (J u n e 1975). P gs. 301-309.
6-202
invfreqs
Purpose Syntax
Description
invfreqs is t h e in ver se oper a t ion of freqs; it fin ds a con t in u ou s-t im e t r a n sfer fu n ct ion t h a t cor r espon ds t o a given com plex fr equ en cy r espon se. F r om a la bor a t or y a n a lysis st a n dpoin t , invfreqs is u sefu l in con ver t in g m a gn it u de a n d ph a se da t a in t o t r a n sfer fu n ct ion s. [b,a] = invfreqs(h,w,nb,na) r et u r n s t h e r ea l n u m er a t or a n d den om in a t or coefficien t vect or s b a n d a of t h e t r a n sfer fu n ct ion
B (s ) b (1 ) s n b + b (2 ) s n b 1 + L + b (n b + 1 ) H (s ) = ---------- = --------------------------------------------------------------------------------------------n a n a 1 A (s ) +L + a (n a + 1 ) a (1 ) s + a (2 ) s wh ose com plex fr equ en cy r espon se is given in vect or h a t t h e fr equ en cy poin t s specified in vect or w. Sca la r s nb a n d na specify t h e desir ed or der s of t h e n u m er a t or a n d den om in a t or polyn om ia ls. F r equ en cy is specified in r a dia n s bet ween 0 a n d $, a n d t h e len gt h of h m u st be t h e sa m e a s t h e len gt h of w. invfreqs u ses conj(h) a t w t o en su r e t h e pr oper fr equ en cy dom a in sym m et r y for a r ea l filt er .
[b,a] = invfreqs(h,w,nb,na,wt) weigh t s t h e fit -er r or s ver su s fr equ en cy. wt is a vect or of weigh t in g fa ct or s t h e sa m e len gt h a s w. invfreqs(h,w,nb,na,wt,iter) a n d invfreqs(h,w,nb,na,wt,iter,tol) pr ovide a su per ior a lgor it h m t h a t gu a r a n t ees st a bilit y of t h e r esu lt in g lin ea r syst em a n d sea r ch es for t h e best fit u sin g a n u m er ica l, it er a t ive sch em e. Th e iter pa r a m et er t ells invfreqs t o en d t h e it er a t ion wh en t h e solu t ion h a s con ver ged, or a ft er iter it er a t ion s, wh ich ever com es fir st . invfreqs defin es con ver gen ce a s occu r r in g wh en t h e
6-203
invfreqs
n or m of t h e (m odified) gr a dien t vect or is less t h a n tol. tol is a n opt ion a l pa r a m et er t h a t defa u lt s t o 0.01. To obt a in a weigh t vect or of a ll on es, u se
invfreqs(h,w,nb,na,[],iter,tol) invfreqs(h,w,nb,na,wt,iter,tol,'trace') displa ys a t ext u a l pr ogr ess
r epor t of t h e it er a t ion .
invfreqs(h,w,'complex',nb,na,...) cr ea t es a com plex filt er . In t h is ca se n o sym m et r y is en for ced, a n d t h e fr equ en cy is specified in r a dia n s bet ween -$ a n d $.
Remarks
Wh en bu ildin g h igh er or der m odels u sin g h igh fr equ en cies, it is im por t a n t t o sca le t h e fr equ en cies, dividin g by a fa ct or su ch a s h a lf t h e h igh est fr equ en cy pr esen t in w, so a s t o obt a in well con dit ion ed va lu es of a a n d b. Th is cor r espon ds t o a r esca lin g of t im e. Con ver t a sim ple t r a n sfer fu n ct ion t o fr equ en cy r espon se da t a a n d t h en ba ck t o t h e or igin a l filt er coefficien t s:
a = [1 2 3 2 1 4]; b = [1 2 3 2 3]; [h,w] = freqs(b,a,64); [bb,aa] = invfreqs(h,w,4,5) bb = 1.0000 aa = 1.0000 2.0000 3.0000 2.0000 1.0000 4.0000 2.0000 3.0000 2.0000 3.0000
Examples
6-204
invfreqs
Not ice t h a t bb a n d aa a r e equ iva len t t o b a n d a, r espect ively. H owever , aa h a s poles in t h e left h a lf-pla n e a n d t h u s t h e syst em is u n st a ble. Use invfreqss it er a t ive a lgor it h m t o fin d a st a ble a ppr oxim a t ion t o t h e syst em :
[bbb,aaa] = invfreqs(h,w,4,5,[],30) bbb = 0.6816 aaa = 1.0000 3.4676 7.4060 6.2102 2.5413 0.0001 2.1015 2.6694 0.9113 -0.1218
Su ppose you h a ve t wo vect or s, mag a n d phase, t h a t con t a in m a gn it u de a n d ph a se da t a ga t h er ed in a la bor a t or y, a n d a t h ir d vect or w of fr equ en cies. You ca n con ver t t h e da t a in t o a con t in u ou s-t im e t r a n sfer fu n ct ion u sin g invfreqs:
[b,a] = invfreqs(mag.*exp(j*phase),w,2,3);
Algorithm
By defa u lt , invfreqs u ses a n equ a t ion er r or m et h od t o iden t ify t h e best m odel fr om t h e da t a . Th is fin ds b a n d a in
n
m in
b, a
+ w t (k ) h (k ) A (w (k )) B (w (k )) 2
k =1
by cr ea t in g a syst em of lin ea r equ a t ion s a n d solvin g t h em wit h MATLABs \ oper a t or . H er e A (w (k )) a n d B (w (k )) a r e t h e F ou r ier t r a n sfor m s of t h e polyn om ia ls a a n d b, r espect ively, a t t h e fr equ en cy w (k ), a n d n is t h e n u m ber of fr equ en cy poin t s (t h e len gt h of h a n d w). Th is a lgor it h m is ba sed on Levi [1]. Sever a l va r ia n t s h a ve been su ggest ed in t h e lit er a t u r e, wh er e t h e weigh t in g fu n ct ion wt gives less a t t en t ion t o h igh fr equ en cies. Th e su per ior (ou t pu t -er r or ) a lgor it h m u ses th e da m ped Ga u ss-Newton m eth od for iter a tive sea r ch [2], with th e ou t pu t of th e fir st algor ith m as t h e in it ial estim a t e. Th is solves t h e dir ect pr oblem of m in im izin g t h e weigh t ed su m of t h e squ a r ed er r or between t h e actu a l a n d t h e desir ed fr equ en cy r espon se poin ts:
n
m in
b, a
+ w t (k ) h (k ) ------------------A (w (k ))
k =1
B ( w ( k ))
6-205
invfreqs
See Also
freqs freqz invfreqz prony
F r equ en cy r espon se of a n a log filt er s. F r equ en cy r espon se of digit a l filt er s. Discr et e-t im e filt er iden t ifica t ion fr om fr equ en cy da t a . P r on ys m et h od for t im e dom a in IIR filt er design .
References
[1] Levi, E .C. Com plex-Cu r ve F it t in g. IR E T ran s. on A u tom atic Con trol . Vol. AC-4 (1959). P gs. 37-44. [2] Den n is, J .E ., J r ., a n d R.B. Sch n a bel. N u m erical M eth od s for Un con strain ed Optim ization an d N on lin ear E qu ation s . E n glewood Cliffs, NJ : P r en t ice H a ll, 1983.
6-206
invfreqz
Purpose Syntax
Description
fu n ct ion t h a t cor r espon ds t o a given com plex fr equ en cy r espon se. F r om a la bor a t or y a n a lysis st a n dpoin t , invfreqz ca n be u sed t o con ver t m a gn it u de a n d ph a se da t a in t o t r a n sfer fu n ct ion s.
[b,a] = invfreqz(h,w,nb,na) r et u r n s t h e r ea l n u m er a t or a n d den om in a t or coefficien t s in vect or s b a n d a of t h e t r a n sfer fu n ct ion
B (z ) b (1 ) + b (2 ) z 1 + L + b (n b + 1 ) z n b H (z ) = ---------- = --------------------------------------------------------------------------------------- 1 A (z ) + a (n a + 1 ) z n a a (1 ) + a (2 ) z + L wh ose com plex fr equ en cy r espon se is given in vect or h a t t h e fr equ en cy poin t s specified in vect or w. Sca la r s nb a n d na specify t h e desir ed or der s of t h e n u m er a t or a n d den om in a t or polyn om ia ls. F r equ en cy is specified in r a dia n s bet ween 0 a n d $, a n d t h e len gt h of h m u st be t h e sa m e a s t h e len gt h of w. invfreqz u ses conj(h) a t w t o en su r e t h e pr oper fr equ en cy dom a in sym m et r y for a r ea l filt er .
[b,a] = invfreqz(h,w,nb,na,wt) weigh t s t h e fit -er r or s ver su s fr equ en cy. wt is a vect or of weigh t in g fa ct or s t h e sa m e len gt h a s w. invfreqz(h,w,nb,na,wt,iter) a n d invfreqz(h,w,nb,na,wt,iter,tol) pr ovide a su per ior a lgor it h m t h a t gu a r a n t ees st a bilit y of t h e r esu lt in g lin ea r syst em a n d sea r ch es for t h e best fit u sin g a n u m er ica l, it er a t ive sch em e. Th e iter pa r a m et er t ells invfreqz t o en d t h e it er a t ion wh en t h e solu t ion h a s con ver ged, or a ft er iter it er a t ion s, wh ich ever com es fir st . invfreqz defin es con ver gen ce a s occu r r in g wh en t h e
6-207
invfreqz
n or m of t h e (m odified) gr a dien t vect or is less t h a n tol. tol is a n opt ion a l pa r a m et er t h a t defa u lt s t o 0.01. To obt a in a weigh t vect or of a ll on es, u se
invfreqz(h,w,nb,na,[],iter,tol) invfreqz(h,w,nb,na,wt,iter,tol,'trace') displa ys a t ext u a l pr ogr ess
r epor t of t h e it er a t ion .
invfreqz(h,w,'complex',nb,na,...) cr ea t es a com plex filt er . In t h is ca se n o sym m et r y is en for ced, a n d t h e fr equ en cy is specified in r a dia n s bet ween -$ a n d $.
Example
Con ver t a sim ple t r a n sfer fu n ct ion t o fr equ en cy r espon se da t a a n d t h en ba ck t o t h e or igin a l filt er coefficien t s:
a = [1 2 3 2 1 4]; b = [1 2 3 2 3]; [h,w] = freqz(b,a,64); [bb,aa] = invfreqz(h,w,4,5) bb = 1.0000 aa = 1.0000 2.0000 3.0000 2.0000 1.0000 4.0000 2.0000 3.0000 2.0000 3.0000
Not ice t h a t bb a n d aa a r e equ iva len t t o b a n d a, r espect ively. H owever , aa h a s poles ou t side t h e u n it cir cle a n d t h u s t h e syst em is u n st a ble. Use invfreqzs it er a t ive a lgor it h m t o fin d a st a ble a ppr oxim a t ion t o t h e syst em :
[bbb,aaa] = invfreqz(h,w,4,5,[],30) bbb = 0.2427 aaa = 1.0000 0.8944 0.6954 0.9997 0.8933 0.6949 0.2788 0.0069 0.0971 0.1980
Algorithm
By defa u lt , invfreqz u ses a n equ a t ion er r or m et h od t o iden t ify t h e best m odel fr om t h e da t a . Th is fin ds b a n d a in
6-208
invfreqz
m in
b, a
+ w t (k ) h (k ) A (w (k )) B (w (k )) 2
k =1
by cr ea t in g a syst em of lin ea r equ a t ion s a n d solvin g t h em wit h MATLABs \ oper a t or . H er e A (w (k )) a n d B (w (k )) a r e t h e F ou r ier t r a n sfor m s of t h e polyn om ia ls a a n d b, r espect ively, a t t h e fr equ en cy w (k ), a n d n is t h e n u m ber of fr equ en cy poin t s (t h e len gt h of h a n d w). Th is a lgor it h m is a ba sed on Levi [1]. Th e su per ior (ou t pu t -er r or ) a lgor it h m u ses t h e da m ped Ga u ss-Newt on m et h od for it er a t ive sea r ch [2], wit h t h e ou t pu t of t h e fir st a lgor it h m a s t h e in it ia l est im a t e. Th is solves t h e dir ect pr oblem of m in im izin g t h e weigh t ed su m of t h e squ a r ed er r or bet ween t h e a ct u a l a n d t h e desir ed fr equ en cy r espon se poin t s:
n
m in
b, a
+ w t (k ) h (k ) ------------------A (w (k ))
k =1
B ( w ( k ))
See Also
F r equ en cy r espon se of a n a log filt er s. F r equ en cy r espon se of digit a l filt er s. Con t in u ou s-t im e (a n a log) filt er iden t ifica t ion fr om fr equ en cy da t a . P r on ys m et h od for t im e dom a in IIR filt er design .
References
[1] Levi, E .C. Com plex-Cu r ve F it t in g. IR E T ran s. on Au tom atic Con trol . Vol. AC-4 (1959). P gs. 37-44. [2] Den n is, J .E ., J r ., a n d R.B. Sch n a bel. N u m erical M eth od s for Un con strain ed Optim ization an d N on lin ear E qu ation s . E n glewood Cliffs, NJ : P r en t ice H a ll, 1983.
6-209
kaiser
Purpose Syntax Description
6ka iser
sidelobe a t t en u a t ion of t h e F ou r ier t r a n sfor m of t h e win dow. To obt a in a Ka iser win dow t h a t design s a n F IR filt er wit h sidelobe h eigh t -? dB, u se t h e followin g =: ( 0.1102 ( ? 8.7 ) , ? > 50 & = = ' 0.5842 ( ? 21 ) 0.4 + 0.07886 ( ? 21 ) , 50 8 ? 8 21 & ? < 21 % 0, In cr ea sin g beta widen s t h e m a in lobe a n d decr ea ses t h e a m plit u de of t h e sidelobes (in cr ea ses t h e a t t en u a t ion ).
See Also
Ba r t let t win dow. Bla ck m a n win dow. Rect a n gu la r win dow. Ch ebysh ev win dow. H a m m in g win dow. H a n n in g win dow. E st im a t e pa r a m et er s for fir1 wit h Ka iser win dow. Tr ia n gu la r win dow.
References
[1] Ka iser , J .F . Non r ecu r sive Digit a l F ilt er Design Usin g t h e I 0 - sin h Win dow F u n ct ion . Proc. 1974 IE E E S ym p. Circu its an d S yst . (Apr il 1974). P gs. 20-23. [2] IE E E . Digital S ign al Processin g II . IE E E P r ess. New Yor k: J oh n Wiley & Son s, 1975.
6-210
kaiserord
Purpose Syntax
6ka iser or d
Description
NOTE If t h e ba n d r ipples a r e specified a s u n equ a l, t h e sm a llest on e is u sed, sin ce t h e Ka iser win dow m et h od is con st r a in ed t o give filt er s wit h equ a l r ipple h eigh t s in a ll t h e pa ssba n ds a n d st opba n ds.
[n,Wn,beta,ftype] = kaiserord(f,a,dev) fin ds t h e a ppr oxim a t e or der n, n or m a lized fr equ en cy ba n d edges Wn, a n d weigh t s t h a t m eet in pu t specifica t ion s f, a, a n d dev. f is a vect or of ba n d edges a n d a is a vect or specifyin g t h e desir ed a m plit u de on t h e ba n ds defin ed by f. Th e len gt h of f is t wice t h e len gt h of a, m in u s 2. Toget h er , f a n d a defin e a desir ed piecewise con st a n t r espon se fu n ct ion . dev is a vect or t h e sa m e size a s a t h a t specifies t h e m a xim u m a llowa ble er r or or devia t ion bet ween t h e fr equ en cy r espon se of t h e ou t pu t filt er a n d it s desir ed a m plit u de, for ea ch ba n d. fir1 ca n u se t h e r esu lt in g or der n, fr equ en cy vect or Wn, m u lt iba n d m a gn it u de t ype ftype, a n d t h e Ka iser win dow pa r a m et er beta. Th e ftype st r in g is in t en ded for u se wit h fir1; it is equ a l t o 'high' for a h igh pa ss filt er a n d 'stop' for a ba n dst op filt er . F or m u lt iba n d filt er s, it ca n be equ a l t o 'dc0' wh en t h e fir st ba n d is a st opba n d (st a r t in g a t f = 0) or 'dc1' wh en t h e fir st ba n d is a pa ssba n d.
To design a filt er b t h a t a ppr oxim a t ely m eet s t h e specifica t ion s given by kaiser pa r a m et er s f, a, a n d dev:
b = fir1(n,Wn,kaiser(n+1,beta),ftype,'noscale')
6-211
kaiserord
[n,Wn,beta,ftype] = kaiserord(f,a,dev,Fs) specifies a sa m plin g fr equ en cy Fs. If n ot pr esen t , Fs defa u lt s t o 2 H z, im plyin g a Nyqu ist fr equ en cy of 1 H z. You ca n t h er efor e specify ba n d edges sca led t o a pa r t icu la r a pplica t ion s sa m plin g fr equ en cy. c = kaiserord(f,a,dev,Fs,'cell') is a cell-a r r a y wh ose elem en t s a r e t h e
pa r a m et er s t o fir1. NOTE In som e ca ses, kaiserord u n der est im a t es or over est im a t es t h e or der n. If t h e filt er does n ot m eet t h e specifica t ion s, t r y a h igh er or der su ch a s n+1, n+2, a n d so on , or a lower or der . Resu lt s a r e in a ccu r a t e if t h e cu t off fr equ en cies a r e n ea r 0 or t h e Nyqu ist fr equ en cy, or if dev is la r ge (gr ea t er t h a n 10%).
Algorithm
kaiserord u ses em pir ica lly der ived for m u la s for est im a t in g t h e or der s of lowpa ss filt er s, a s well a s differ en t ia t or s a n d H ilber t t r a n sfor m er s. E st im a t es for m u lt iba n d filt er s (su ch a s ba n dpa ss filt er s) a r e der ived fr om t h e lowpa ss design for m u la s.
Th e design for m u la s t h a t u n der lie t h e Ka iser win dow a n d it s a pplica t ion t o F IR filt er design a r e ( 0.1102 ( ? 8.7 ) , ? > 50 & = = ' 0.5842 ( ? 21 ) 0.4 + 0.07886 ( ? 21 ) , 50 8 ? 8 21 & ? < 21 % 0, wh er e ? = -20log 10 B is t h e st opba n d a t t en u a t ion expr essed in decibels (r eca ll t h a t Bp = Bs is r equ ir ed). Th e design for m u la is: ? 7.95 n = --------------------------2.285 ( @# ) wh er e n is t h e filt er or der a n d @# is t h e widt h of t h e sm a llest t r a n sit ion r egion .
6-212
kaiserord
Examples
Design a lowpa ss filt er wit h pa ssba n d fr om 0 t o 1 kH z a n d st opba n d fr om 1500 H z t o 4 kH z. Specify pa ssba n d r ipple of 5% a n d st opba n d a t t en u a t ion of 40 dB:
fsamp = 8000; fcuts = [1000 1500]; mags = [1 0]; devs = [0.05 0.01]; [n,Wn,beta,ftype] = kaiserord(fcuts,mags,devs,fsamp); hh = fir1(n,Wn,ftype,kaiser(n+1,beta),'noscale'); freqz(hh)
50 Magnitude (dB) 0 !50 !100 !150 0 0 Phase (degrees) 0.2 0.4 0.6 0.8 Normalized Angular Frequency (A$ rads/sample) 1
!500
!1000
!1500 0
6-213
kaiserord
Design a n odd-len gt h ba n dpa ss filt er (n ot e t h a t odd len gt h m ea n s even or der , so t h e in pu t t o fir1 m u st be a n even in t eger ):
fsamp = 8000; fcuts = [1000 1300 2210 2410]; mags = [0 1 0]; devs = [0.01 0.05 0.01]; [n,Wn,beta,ftype] = kaiserord(fcuts,mags,devs,fsamp); n = n + rem(n,2); hh = fir1(n,Wn,ftype,kaiser(n+1,beta),'noscale'); [H,f] = freqz(hh,1,1024,fsamp); plot(f,abs(H)), grid on
1.4
1.2
0.8
0.6
0.4
0.2
0 0
500
1000
1500
2000
2500
3000
3500
4000
Design a lowpa ss filt er wit h a pa ssba n d cu t off of 1500 H z, a st opba n d cu t off of 2000 H z, pa ssba n d r ipple of 0.01, st opba n d r ipple of 0.1, a n d a sa m plin g fr equ en cy of 8000 H z:
[n,Wn,beta,ftype] = kaiserord([1500 2000],[1 0],[0.01 0.1],8000); b = fir1(n,Wn,ftype,kaiser(n+1,beta),'noscale');
6-214
kaiserord
Remarks
Be ca r efu l t o dist in gu ish bet ween t h e m ea n in gs of filt er len gt h a n d filt er or der . Th e filt er len gth is t h e n u m ber of im pu lse r espon se sa m ples in t h e F IR filt er . Gen er a lly, t h e im pu lse r espon se is in dexed fr om n = 0 t o n = L -1, wh er e L is t h e filt er len gt h . Th e filt er ord er is t h e h igh est power in a z -t r a n sfor m r epr esen t a t ion of t h e filt er . F or a n F IR t r a n sfer fu n ct ion , t h is r epr esen t a t ion is a polyn om ia l in z , wh er e t h e h igh est power is z L-1 a n d t h e lowest power is z 0 . Th e filt er or der is 1 less t h a n t h e len gt h (L -1) a n d is a lso equ a l t o t h e n u m ber of zer os of t h e z polyn om ia l. Th e len gt h s of t h e fr equ en cy, m a gn it u de, a n d devia t ion vect or s m u st m a t ch ; ot h er wise, kaiserord gives t h e followin g er r or m essa ge:
Requires M and DEV to be the same length. Length of F must be 2*length(M)2.
Diagnostics
Wh en m a gn it u des a r e n ot specified cor r ect ly, kaiserord gives t h e followin g er r or m essa ges:
Stopbands must be zero. All passbands must have the same height.
See Also
Win dow-ba sed fin it e im pu lse r espon se filt er design st a n da r d r espon se. Ka iser win dow. Pa r ks-McClella n opt im a l F IR filt er or der est im a t ion .
References
[1] Ka iser , J .F . Non r ecu r sive Digit a l F ilt er Design Usin g t h e I 0 - sin h Win dow F u n ct ion . P roc. 1974 IE E E S ym p. Circu its an d S yst . (Apr il 1974). P gs. 20-23. [2] IE E E . Digital S ign al Processin g II . IE E E P r ess. New Yor k: J oh n Wiley & Son s, 1975. P gs. 123-126.
6-215
latc2tf
Purpose Syntax
6la t c2t f
Description
See Also
latcfilt tf2latc
La t t ice a n d la t t ice-la dder filt er im plem en t a t ion . Con ver sion of t r a n sfer fu n ct ion t o la t t ice filt er.
6-216
latcfilt
Purpose Syntax
6la t cfilt
Description
If k a n d x a r e vect or s, t h e r esu lt is a (sign a l) vect or . Ma t r ix a r gu m en t s a r e per m it t ed u n der t h e followin g r u les: If x is a m a t r ix a n d k is a vect or , ea ch colu m n of x is pr ocessed t h r ou gh t h e la t t ice filt er specified by k. If x is a vect or a n d k is a m a t r ix, ea ch colu m n of k is u sed t o filt er x, a n d a sign a l m a t r ix is r et u r n ed. If x a n d k a r e bot h m a t r ices wit h t h e sa m e n u m ber of colu m n s, t h en t h e i -t h colu m n of k is u sed t o filt er t h e i -t h colu m n of x. A sign a l m a t r ix is r et u r n ed.
[f,g] = latcfilt(k,v,x) filt er s x wit h t h e IIR la t t ice coefficien t s k a n d la dder coefficien t s v. k a n d v m u st be vect or s, wh ile x m a y be a sign a l m a t r ix. [f,g] = latcfilt(k,1,x) filt er s x wit h t h e IIR a ll-pole la t t ice specified by k. k a n d x m a y be vect or s or m a t r ices a ccor din g t o t h e r u les given for t h e F IR
la t t ice.
[f,g,zf] = latcfilt(...,'ic',zi) a ccept s a len gt h -k vect or zi specifyin g t h e in it ia l con dit ion of t h e la t t ice st a t es. Ou t pu t zf is a len gt h -k vect or specifyin g t h e fin a l con dit ion of t h e la t t ice st a t es.
See Also
F ilt er da t a wit h a r ecu r sive (IIR) or n on r ecu r sive (F IR) filt er. La t t ice filt er t o t r a n sfer fu n ct ion con ver sion . Con ver sion of t r a n sfer fu n ct ion t o la t t ice filt er.
6-217
levinson
Purpose Syntax Description
6levin son
Th e Levin son -Du r bin r ecu r sion is a n a lgor it h m for fin din g a n a ll-pole IIR filt er wit h a pr escr ibed det er m in ist ic a u t ocor r ela t ion sequ en ce. It h a s a pplica t ion s in filt er design , codin g, a n d spect r a l est im a t ion . Th e filt er t h a t levinson pr odu ces is m in im u m ph a se.
a = levinson(r,p) fin ds t h e coefficien t s of a n pt h -or der a u t or egr essive lin ea r pr ocess wh ich h a s r a s it s a u t ocor r ela t ion sequ en ce. r is a r ea l or com plex det er m in ist ic a u t ocor r ela t ion sequ en ce (a vect or ), a n d p is t h e or der of den om in a t or polyn om ia l A (z ); t h a t is, a = [1 a(2) ... a(p+1)]. Th e filt er
Algorithm
r (1 ) r (2 )
r (p )
) )
r (2 ) r (1 ) L r (p 1 ) M O O M r (p ) L r (2 ) r (1 )
a (2 ) r (2 ) a (3 ) r (3 ) = M M a (p + 1 ) r (p + 1 )
wh er e r = [r (1) ... r (p+1)] is t h e in pu t a u t ocor r ela t ion vect or , a n d r (i )* den ot es t h e com plex con ju ga t e of r (i ). Th e a lgor it h m r equ ir es O (p 2 ) flops a n d is t h u s m u ch m or e efficien t t h a n t h e MATLAB \ com m a n d for la r ge p. H owever , t h e levinson fu n ct ion u ses \ for low or der s t o pr ovide t h e fa st est possible execu t ion .
See Also
Lin ea r pr edict ion coefficien t s. P r on ys m et h od for t im e dom a in IIR filt er design . Rever se Levin son -Du r bin r ecu r sion . Lin ea r m odel u sin g St eiglit z-McBr ide it er a t ion .
6-218
levinson
References
[1] Lju n g, L. S ystem Id en tification : T h eory for th e User . E n glewood Cliffs, NJ : P r en t ice H a ll, 1987. P gs. 278-280.
6-219
lp2bp
Purpose Syntax Description
6lp2bp
1 r a d/sec in t o ba n dpa ss filt er s wit h desir ed ba n dwidt h a n d cen t er fr equ en cy. Th e t r a n sfor m a t ion is on e st ep in t h e digit a l filt er design pr ocess for t h e butter, cheby1, cheby2, a n d ellip fu n ct ion s.
lp2bp ca n per for m t h e t r a n sfor m a t ion on t wo differ en t lin ea r syst em
r epr esen t a t ion s: t r a n sfer fu n ct ion for m a n d st a t e-spa ce for m . In bot h ca ses, t h e in pu t syst em m u st be a n a n a log filt er pr ot ot ype.
b (s ) b (1 ) s n b + L + b (n b ) s + b (n b + 1 ) --------- = -----------------------------------------------------------------------------------a (s ) + a (n a ) s + a (n a + 1 ) a (1 ) s n a + L Sca la r s Wo a n d Bw specify t h e cen t er fr equ en cy a n d ba n dwidt h in u n it s of r a dia n s/secon d. F or a filt er wit h lower ba n d edge w1 a n d u pper ba n d edge w2, u se Wo = sqrt(w1*w2) a n d Bw = w2w1.
lp2bp r et u r n s t h e fr equ en cy t r a n sfor m ed filt er in r ow vect or s bt a n d at.
State-Space Form
[At,Bt,Ct,Dt] = lp2bp(A,B,C,D,Wo,Bw) con ver t s t h e con t in u ou s-t im e st a t e-spa ce lowpa ss filt er pr ot ot ype in m a t r ices A, B, C, D:
x = Ax + Bu y = Cx + Du
6-220
lp2bp
in t o a ba n dpa ss filt er wit h cen t er fr equ en cy Wo a n d ba n dwidt h Bw. F or a filt er wit h lower ba n d edge w1 a n d u pper ba n d edge w2, u se Wo = sqrt(w1*w2) a n d Bw = w2w1. Th e ba n dpa ss filt er is r et u r n ed in m a t r ices At, Bt, Ct, Dt.
Algorithm
lp2bp is a h igh ly a ccu r a t e st a t e-spa ce for m u la t ion of t h e cla ssic a n a log filt er
fr equ en cy t r a n sfor m a t ion . Con sider t h e st a t e-spa ce syst em : x = Ax + Bu y = Cx + Du wh er e u is t h e in pu t , x is t h e st a t e vect or , a n d y is t h e ou t pu t . Th e La pla ce t r a n sfor m of t h e fir st equ a t ion (a ssu m in g zer o in it ia l con dit ion s) is s X (s ) = A X (s ) + B U (s ) Now if a ba n dpa ss filt er is t o h a ve cen t er fr equ en cy #0 a n d ba n dwidt h B w, t h e st a n da r d s -dom a in t r a n sfor m a t ion is s = Q (p 2 + 1 ) p wh er e Q = #0/B w a n d p = s /#0. Su bst it u t in g t h is for s in t h e La pla ce t r a n sfor m ed st a t e-spa ce equ a t ion , a n d con sider in g t h e oper a t or p a s d /d t : Qx + Qx = A x + B u or Q x A x B u = Q x Now defin e Q # = Q x wh ich , wh en su bst it u t ed, lea ds t o Qx = A x + Q# + B u
6-221
lp2bp
Th e la st t wo equ a t ion s give equ a t ion s of st a t e. Wr it e t h em in st a n da r d for m a n d m u lt iply t h e differ en t ia l equ a t ion s by #0 t o r ecover t h e t im e/fr equ en cy sca lin g r epr esen t ed by p a n d fin d st a t e m a t r ices for t h e ba n dpa ss filt er :
Q = Wo/Bw; [ma,na] = size(A); At = Wo*[A/Q eye(ma,na);eye(ma,na) zeros(ma,na)]; Bt = Wo*[B/Q; zeros(ma,nb)]; Ct = [C zeros(mc,ma)]; Dt = d;
If t h e in pu t t o lp2bp is in t r a n sfer fu n ct ion for m , t h e fu n ct ion t r a n sfor m s it in t o st a t e-spa ce for m befor e a pplyin g t h is a lgor it h m .
See Also
Bilin ea r t r a n sfor m a t ion m et h od of a n a log-t o-digit a l filt er con ver sion . Im pu lse in va r ia n ce m et h od of a n a log-t o-digit a l filt er con ver sion . Lowpa ss t o ba n dst op a n a log filt er t r a n sfor m a t ion . Lowpa ss t o h igh pa ss a n a log filt er t r a n sfor m a t ion . Lowpa ss t o lowpa ss a n a log filt er t r a n sfor m a t ion .
6-222
lp2bs
Purpose Syntax Description
6lp2bs
1 r a d/sec in t o ba n dst op filt er s wit h desir ed ba n dwidt h a n d cen t er fr equ en cy. Th e t r a n sfor m a t ion is on e st ep in t h e digit a l filt er design pr ocess for t h e butter, cheby1, cheby2, a n d ellip fu n ct ion s.
lp2bs ca n per for m t h e t r a n sfor m a t ion on t wo differ en t lin ea r syst em
r epr esen t a t ion s: t r a n sfer fu n ct ion for m a n d st a t e-spa ce for m . In bot h ca ses, t h e in pu t syst em m u st be a n a n a log filt er pr ot ot ype.
b (s ) b (1 ) s n b + L + b (n b ) s + b (n b + 1 ) --------- = -----------------------------------------------------------------------------------a (s ) + a (n a ) s + a (n a + 1 ) a (1 ) s n a + L Sca la r s Wo a n d Bw specify t h e cen t er fr equ en cy a n d ba n dwidt h in u n it s of r a dia n s/secon d. F or a filt er wit h lower ba n d edge w1 a n d u pper ba n d edge w2, u se Wo = sqrt(w1*w2) a n d Bw = w2w1.
lp2bs r et u r n s t h e fr equ en cy t r a n sfor m ed filt er in r ow vect or s bt a n d at.
State-Space Form
[At,Bt,Ct,Dt] = lp2bs(A,B,C,D,Wo,Bw) con ver t s t h e con t in u ou s-t im e st a t e-spa ce lowpa ss filt er pr ot ot ype in m a t r ices A, B, C, D:
x = Ax + Bu y = Cx + Du
6-223
lp2bs
in t o a ba n dst op filt er wit h cen t er fr equ en cy Wo a n d ba n dwidt h Bw. F or a filt er wit h lower ba n d edge w1 a n d u pper ba n d edge w2, u se Wo = sqrt(w1*w2) a n d Bw = w2w1. Th e ba n dst op filt er is r et u r n ed in m a t r ices At, Bt, Ct, Dt.
Algorithm
lp2bs is a h igh ly a ccu r a t e st a t e-spa ce for m u la t ion of t h e cla ssic a n a log filt er
fr equ en cy t r a n sfor m a t ion . If a ba n dst op filt er is t o h a ve cen t er fr equ en cy #0 a n d ba n dwidt h B w, t h e st a n da r d s -dom a in t r a n sfor m a t ion is p s = -----------------------2 Q (p + 1 ) wh er e Q = #0/B w a n d p = s /#0. Th e st a t e-spa ce ver sion of t h is t r a n sfor m a t ion is
Q = Wo/Bw; At = [Wo/Q*inv(A) Wo*eye(ma);Wo*eye(ma) zeros(ma)]; Bt = [Wo/Q*(A B); zeros(ma,nb)]; Ct = [C/A zeros(mc,ma)]; Dt = D C/A*B;
See lp2bp for a der iva t ion of t h e ba n dpa ss ver sion of t h is t r a n sfor m a t ion .
See Also
Bilin ea r t r a n sfor m a t ion m et h od of a n a log-t o-digit a l filt er con ver sion . Im pu lse in va r ia n ce m et h od of a n a log-t o-digit a l filt er con ver sion . Lowpa ss t o ba n dpa ss a n a log filt er t r a n sfor m a t ion . Lowpa ss t o h igh pa ss a n a log filt er t r a n sfor m a t ion . Lowpa ss t o lowpa ss a n a log filt er t r a n sfor m a t ion .
6-224
lp2hp
Purpose Syntax Description
6lp2h p
1 r a d/sec in t o h igh pa ss filt er s wit h desir ed cu t off fr equ en cy. Th e t r a n sfor m a t ion is on e st ep in t h e digit a l filt er design pr ocess for t h e butter, cheby1, cheby2, a n d ellip fu n ct ion s. Th e lp2hp fu n ct ion ca n per for m t h e t r a n sfor m a t ion on t wo differ en t lin ea r syst em r epr esen t a t ion s: t r a n sfer fu n ct ion for m a n d st a t e-spa ce for m . In bot h ca ses, t h e in pu t syst em m u st be a n a n a log filt er pr ot ot ype.
b (s ) b (1 ) s n b + L + b (n b ) s + b (n b + 1 ) --------- = -----------------------------------------------------------------------------------a (s ) + a (n a ) s + a (n a + 1 ) a (1 ) s n a + L Sca la r Wo specifies t h e cu t off fr equ en cy in u n it s of r a dia n s/secon d. Th e fr equ en cy t r a n sfor m ed filt er is r et u r n ed in r ow vect or s bt a n d at.
State-Space Form
[At,Bt,Ct,Dt] = lp2hp(A,B,C,D,Wo) con ver t s t h e con t in u ou s-t im e st a t e-spa ce lowpa ss filt er pr ot ot ype in m a t r ices A, B, C, D:
x = Ax + Bu y = Cx + Du in t o a h igh pa ss filt er wit h cu t off fr equ en cy Wo. Th e h igh pa ss filt er is r et u r n ed in m a t r ices At, Bt, Ct, Dt.
6-225
lp2hp
Algorithm
lp2hp is a h igh ly a ccu r a t e st a t e-spa ce for m u la t ion of t h e cla ssic a n a log filt er
fr equ en cy t r a n sfor m a t ion . If a h igh pa ss filt er is t o h a ve cu t off fr equ en cy #0, t h e st a n da r d s -dom a in t r a n sfor m a t ion is #0 s = -----p Th e st a t e-spa ce ver sion of t h is t r a n sfor m a t ion is
At Bt Ct Dt = = = = Wo*inv(A); Wo*(A\B); C/A; D C/A*B;
See lp2bp for a der iva t ion of t h e ba n dpa ss ver sion of t h is t r a n sfor m a t ion .
See Also
Bilin ea r t r a n sfor m a t ion m et h od of a n a log-t o-digit a l filt er con ver sion . Im pu lse in va r ia n ce m et h od of a n a log-t o-digit a l filt er con ver sion . Lowpa ss t o ba n dpa ss a n a log filt er t r a n sfor m a t ion . Lowpa ss t o ba n dst op a n a log filt er t r a n sfor m a t ion . Lowpa ss t o lowpa ss a n a log filt er t r a n sfor m a t ion .
6-226
lp2lp
Purpose Syntax Description
6lp2lp
1 r a d/sec in t o a lowpa ss filt er wit h a n y specified cu t off fr equ en cy. Th e t r a n sfor m a t ion is on e st ep in t h e digit a l filt er design pr ocess for t h e butter, cheby1, cheby2, a n d ellip fu n ct ion s. Th e lp2lp fu n ct ion ca n per for m t h e t r a n sfor m a t ion on t wo differ en t lin ea r syst em r epr esen t a t ion s: t r a n sfer fu n ct ion for m a n d st a t e-spa ce for m . In bot h ca ses, t h e in pu t syst em m u st be a n a n a log filt er pr ot ot ype.
b (s ) b (1 ) s n b + L + b (n b ) s + b (n b + 1 ) --------- = -----------------------------------------------------------------------------------a (s ) + a (n a ) s + a (n a + 1 ) a (1 ) s n a + L Sca la r Wo specifies t h e cu t off fr equ en cy in u n it s of r a dia n s/secon d. lp2lp r et u r n s t h e fr equ en cy t r a n sfor m ed filt er in r ow vect or s bt a n d at.
State-Space Form
[At,Bt,Ct,Dt] = lp2lp(A,B,C,D,Wo) con ver t s t h e con t in u ou s-t im e st a t e-spa ce lowpa ss filt er pr ot ot ype in m a t r ices A, B, C, D:
x = Ax + Bu y = Cx + Du in t o a lowpa ss filt er wit h cu t off fr equ en cy Wo. lp2lp r et u r n s t h e lowpa ss filt er in m a t r ices At, Bt, Ct, Dt.
6-227
lp2lp
Algorithm
lp2lp is a h igh ly a ccu r a t e st a t e-spa ce for m u la t ion of t h e cla ssic a n a log filt er
fr equ en cy t r a n sfor m a t ion . If a lowpa ss filt er is t o h a ve cu t off fr equ en cy #0, t h e st a n da r d s -dom a in t r a n sfor m a t ion is s = p #0 Th e st a t e-spa ce ver sion of t h is t r a n sfor m a t ion is
At Bt Ct Dt = = = = Wo*A; Wo*B; C; D;
See lp2bp for a der iva t ion of t h e ba n dpa ss ver sion of t h is t r a n sfor m a t ion .
See Also
Bilin ea r t r a n sfor m a t ion m et h od of a n a log-t o-digit a l filt er con ver sion . Im pu lse in va r ia n ce m et h od of a n a log-t o-digit a l filt er con ver sion . Lowpa ss t o ba n dpa ss a n a log filt er t r a n sfor m a t ion . Lowpa ss t o ba n dst op a n a log filt er t r a n sfor m a t ion . Lowpa ss t o h igh pa ss a n a log filt er t r a n sfor m a t ion .
6-228
lpc
Purpose Syntax Description
6lpc
pr edict ion er r or in t h e lea st -squ a r es sen se. It h a s a pplica t ion s in filt er design a n d speech codin g.
a = lpc(x,p) fin ds t h e coefficien t s of a pt h -or der lin ea r pr edict or (F IR filt er ) t h a t pr edict s t h e cu r r en t va lu e of t h e r ea l t im e ser ies x ba sed on pa st sa m ples:
(n ) = a (2 ) x (n 1 ) a (3 ) x (n 2 ) L x a (p + 1 ) x (n p )
p is t h e or der of t h e pr edict ion polyn om ia l, a = [1 a(2) ... a(p+1)].
If p is u n specified, lpc u ses a s a defa u lt p = length(x)1. If x is a m a t r ix con t a in in g a sepa r a t e sign a l in ea ch colu m n , lpc r et u r n s a m odel est im a t e for ea ch colu m n in t h e r ows of m a t r ix a.
Example
E st im a t e a da t a ser ies u sin g a 3r d-or der for wa r d pr edict or , a n d com pa r e t o t h e or igin a l sign a l. F ir st , cr ea t e t h e sign a l da t a a s t h e ou t pu t of a n a u t or egr essive pr ocess dr iven by wh it e n oise. Use t h e la st 4096 sa m ples of t h e AR pr ocess ou t pu t t o a void st a r t -u p t r a n sien t s.
noise = randn(50000,1); % Normalized white Gaussian noise x = filter(1,[1 1/2 1/3 1/4],noise); x = x(45904:50000);
Com pu t e t h e pr edict or coefficien t s, est im a t ed sign a l, pr edict ion er r or , a n d a u t ocor r ela t ion sequ en ce of t h e pr edict ion er r or .
a = lpc(x,3); est_x = filter([0 a(2:end)],1,x); e = x est_x; [acs,lags] = xcorr(e,'coeff'); % Estimated signal % Prediction error % ACS of prediction error
6-229
lpc
Th e pr edict ion er r or , e(n ), ca n be viewed a s t h e ou t pu t of t h e pr edict ion er r or filt er A (z ) sh own below, wh er e H (z ) is t h e opt im a l lin ea r pr edict or , x (n ) is t h e ( n ) is t h e pr edict ed sign a l. in pu t sign a l, a n d x
Prediction Error Filter
x (n )
H (z ) =
a ( 2 ) z
a ( 3 ) z
L a ( n
+ 1 )z
(n ) x
e(n )
+
Amplitude
!1
!2
6-230
lpc
Th e pr edict ion er r or is a ppr oxim a t ely wh it e Ga u ssia n n oise, a s expect ed for a 3r d-or der AR in pu t pr ocess.
Autocorrelation of the Prediction Error 1.2
0.6
0.4
0.2
!0.2 !5000
0 Lags
5000
Algorithm
lpc u ses t h e a u t ocor r ela t ion m et h od of a u t or egr essive (AR) m odelin g t o fin d t h e filt er coefficien t s. Th e gen er a t ed filt er m igh t n ot m odel t h e pr ocess exa ct ly even if t h e da t a sequ en ce is t r u ly a n AR pr ocess of t h e cor r ect or der . Th is is beca u se t h e a u t ocor r ela t ion m et h od im plicit ly win dows t h e da t a , t h a t is, it a ssu m es t h a t sign a l sa m ples beyon d t h e len gt h of x a r e 0. lpc com pu t es t h e lea st -squ a r es solu t ion t o
Xa C b wh er e x (1 ) 0 L 0 x (2 ) x (1 ) O M M x (2 ) O 0 X = x (m ) M O x (1 ) , 0 x (m ) O x (2 ) M O O M 0 L 0 x (m )
1 a (2 ) a = , M a (p + 1 )
1 0 b= M 0
6-231
lpc
a n d m is t h e len gt h of x. Solvin g t h e lea st -squ a r es pr oblem via t h e n or m a l equ a t ion s XHXa = XHb lea ds t o t h e Yu le-Wa lker equ a t ion s r (1 ) r (2 ) * r (2 ) r (1 ) M O r (p ) L L r (p ) * a (2 ) r (2 ) O M a (3 ) r (3 ) = O r (2 ) * M M r (2 ) r (1 ) a (p + 1 ) r (p + 1 )
wh er e r = [r (1) r (2) ... r (p+1)] is a n a u t ocor r ela t ion est im a t e for x com pu t ed u sin g xcorr. Th e Yu le-Wa lker equ a t ion s a r e solved in O (p 2 ) flops by t h e Levin son -Du r bin a lgor it h m (see levinson).
See Also
Com pu t e a n est im a t e of AR m odel pa r a m et er s u sin g t h e Yu le-Wa lker m et h od. Levin son -Du r bin r ecu r sion . P r on ys m et h od for t im e dom a in IIR filt er design . Power spect r u m est im a t e u sin g Yu le-Wa lker AR m et h od. Lin ea r m odel u sin g St eiglit z-McBr ide it er a t ion .
References
[1] J a ckson , L.B. Digital Filters an d S ign al Processin g . Secon d E d. Bost on : Klu wer Aca dem ic P u blish er s, 1989. P gs. 255-257.
6-232
maxflat
Purpose Syntax
6m a xfla t
Description
design , wh er e design_flag is trace, for a t ext u a l displa y of t h e design t a ble u sed in t h e design plots, for plot s of t h e filt er s m a gn it u de, gr ou p dela y, a n d zer os a n d poles both, for bot h t h e t ext u a l displa y a n d plot s
6-233
maxflat
Examples
0.5
0.4 w/p 5
0.6
Th e m et h od con sist s of t h e u se of for m u la e, polyn om ia l r oot fin din g, a n d a t r a n sfor m a t ion of polyn om ia l r oot s.
butter filter freqz
Bu t t er wor t h a n a log a n d digit a l filt er design . F ilt er da t a wit h a r ecu r sive (IIR) or n on r ecu r sive (F IR) filt er. F r equ en cy r espon se of digit a l filt er s.
References
[1] Selesn ick, I.W., a n d C.S. Bu r r u s. Gen er a lized Digit a l Bu t t er wor t h F ilt er Design . Proceed in gs of th e IE E E In t. Con f. Acou st., S peech , S ign al Processin g . Vol. 3 (Ma y 1996).
6-234
medfilt1
Purpose Syntax Description
6m edfilt 1
t h e en d poin t s. F or n odd, y(k) is t h e m edia n of x(k(n1)/2:k+(n1)/2). F or n even , y(k) is t h e m edia n of x(kn/2), x(k(n/2)+1), ..., x(k+(n/2)1). In t h is ca se, medfilt1 sor t s t h e n u m ber s, t h en t a kes t h e a ver a ge of t h e (n 1)/2 a n d ((n1)/2)+1 elem en t s. Th e defa u lt for n is 3.
y = medfilt1(x,n,blksz) u ses a for-loop t o com pu t e blksz (block size) ou t pu t sa m ples a t a t im e. Use blksz << length(x) if you a r e low on m em or y, sin ce medfilt1 u ses a wor kin g m a t r ix of size n-by-blksz. By defa u lt , blksz = length(x); t h is is t h e fa st est execu t ion if you h a ve su fficien t m em or y.
See Also
F ilt er da t a wit h a r ecu r sive (IIR) or n on r ecu r sive (F IR) filt er. Two-dim en sion a l m edia n filt er in g (see Im age Processin g T oolbox Users Gu id e). Media n va lu e (see t h e on lin e M AT L AB Fu n ction R eferen ce).
References
[1] P r a t t , W.K. Digital Im age Processin g . New Yor k: J oh n Wiley & Son s, 1978. P gs. 330-333.
6-235
modulate
Purpose Syntax
6m odu la t e
Description
If t h e opt pa r a m et er is n ot pr esen t , modulate u ses a defa u lt of min(min(x)) so t h a t t h e m essa ge sign a l (xopt) is en t ir ely n on -n ega t ive a n d h a s a m in im u m va lu e of 0.
amssb
Am p litu d e m o d u la ti o n , s i n g le s id e ba n d . Mu lt iplies x by a sin u soid of frequen cy Fc and adds the result to the Hilbert transform of x mult iplied by a ph ase shifted sinusoid of frequency Fc:
y = x.*cos(2*pi*Fc*t)+imag(hilbert(x)).*sin(2*pi*Fc*t)
6-236
modulate
fm
F re qu e n c y m o d u la tio n . Cr ea t es a sin u soid wit h in st a n t a n eou s fr equ en cy t h a t va r ies wit h t h e m essa ge sign a l x:
y = cos(2*pi*Fc*t + opt*cumsum(x)) cumsum is a r ect a n gu la r a ppr oxim a t ion t o t h e in t egr a l of x. modulate u ses opt a s t h e con st a n t of fr equ en cy m odu la t ion . If opt is n ot pr esen t , modulate u ses a defa u lt of opt = (Fc/Fs)*2*pi/(max(max(x)))
sign a l fr om t h e pu lse widt h s in x. Th e elem en t s of x m u st be bet ween 0 a n d 1, specifyin g t h e widt h of ea ch pu lse in fr a ct ion s of a per iod. Th e pu lses st a r t a t t h e begin n in g of ea ch per iod, t h a t is, t h ey a r e left ju st ified.
modulate(x,Fc,Fs,'pwm','centered')
fr om t h e pu lse t im es in x. Th e elem en t s of x m u st be bet ween 0 a n d 1, specifyin g t h e left edge of ea ch pu lse in fr a ct ion s of a per iod. opt is a sca la r bet ween 0 a n d 1 t h a t specifies t h e len gt h of ea ch pu lse in fr a ct ion s of a per iod. Th e defa u lt for opt is 0.1. y is len gt h length(x)*Fs/Fc.
qam
6-237
modulate
If you do n ot specify method, t h en modulate a ssu m es am. E xcept for t h e pwm a n d ptm ca ses, y is t h e sa m e size a s x. If x is a n a r r a y, modulate m odu la t es it s colu m n s.
[y,t] = modulate(x,Fc,Fs) r et u r n s t h e in t er n a l t im e vect or t t h a t modulate
See Also
demod vco
Dem odu la t ion for com m u n ica t ion s sim u la t ion . Volt a ge con t r olled oscilla t or.
6-238
pburg
Purpose Syntax
6pbu rg
Description
u sin g t h e Bu r g m et h od. Th is m et h od fit s a n a u t or egr essive (AR) m odel t o t h e sign a l by m in im izin g (lea st squ a r es) t h e for wa r d a n d ba ckwa r d pr edict ion er r or s wh ile con st r a in in g t h e AR pa r a m et er s t o sa t isfy t h e Levin son -Du r bin r ecu r sion . Th e spect r a l est im a t e r et u r n ed by pburg is t h e m a gn it u de squ a r ed fr equ en cy r espon se of t h is AR m odel. Th e cor r ect ch oice of t h e m odel or der p is im por t a n t .
Pxx = pburg(x,p,nfft) r et u r n s Pxx, t h e power spect r u m est im a t e. x is t h e in pu t sign a l, p is t h e m odel or der for t h e a ll-pole filt er , a n d nfft is t h e F F T len gt h (defa u lt s t o 256 if n ot specified). Pxx h a s len gt h (nfft/2+1) for nfft even , (nfft+1)/2 for nfft odd, a n d nfft if x is com plex. [Pxx,freq] = pburg(x,p,nfft) r et u r n s Pxx, t h e power spect r u m est im a t e, a n d freq, a vect or of fr equ en cies a t wh ich t h e P SD wa s est im a t ed. If t h e in pu t sign a l is r ea l-va lu ed, t h e r a n ge of freq is [0,$). If t h e in pu t sign a l is com plex, t h e r a n ge of freq is [0,2 $). [Pxx,freq] = pburg(x,p,nfft,Fs) u ses t h e sign a ls sa m plin g fr equ en cy, Fs, t o sca le bot h t h e P SD vect or (Pxx) a n d t h e fr equ en cy vect or (freq). Pxx is sca led by 1/Fs. If t h e in pu t sign a l is r ea l-va lu ed, t h e r a n ge of freq is [0,Fs/2). If t h e in pu t sign a l is com plex, t h e r a n ge of freq is [0,Fs). Fs defa u lt s t o 1 if left em pt y, []. [Pxx,freq] = pburg(x,p,nfft,Fs,'range') specifies t h e r a n ge of fr equ en cy
va lu es t o in clu de in freq. range ca n be: half, t o com pu t e t h e P SD over t h e r a n ge [0,Fs/2) for r ea l x, a n d [0,Fs) for com plex x. If Fs is left bla n k, [], t h e r a n ge is [0,1/2) for r ea l x, a n d [0,1)
6-239
pburg
for com plex x. If Fs is om it t ed en t ir ely, t h e r a n ge is [0,pi) for r ea l x, a n d [0,2*pi) for com plex x. half is t h e defa u lt r a n ge. whole, t o com pu t e t h e P SD over t h e r a n ge [0,Fs) for a ll x. If Fs is left bla n k , [], t h e r a n ge is [0,1) for a ll x. If Fs is om it t ed en t ir ely, t h e r a n ge is [0,2*pi) for a ll x.
pburg(...) plot s t h e power spect r a l den sit y in t h e cu r r en t figu r e win dow. Th e fr equ en cy r a n ge on t h e plot is t h e sa m e a s t h e r a n ge of ou t pu t freq for a given set of pa r a m et er s. pburg(...,'squared') plot s t h e m a gn it u de of Pxx dir ect ly, r a t h er t h a n con ver t in g t h e va lu es t o dB.
Example
Beca u se t h e m et h od est im a t es t h e spect r u m by fit t in g a n AR m odel t o t h e sign a l, fir st defin e t h e AR syst em (a ll-pole filt er ) t h a t gen er a t es t h e in pu t . Ch eck t h e m a gn it u de r espon se of t h e pr ocess wit h freqz.
a = [1 2.2137 2.9403 2.1697 0.9606]; % AR system coefficients freqz(1,a,'phase','no') % AR system magnitude response title('AR System Magnitude Response')
AR System Magnitude Response 40
30
20 Magnitude (dB)
10
!10
!20 0
6-240
pburg
Now gen er a t e t h e in pu t sign a l x by filt er in g wh it e n oise t h r ou gh t h e AR syst em . E st im a t e t h e P SD of x ba sed on a fou r t h -or der AR m odel (sin ce we kn ow t h a t t h e or igin a l AR syst em , a, h a s or der 4).
x = filter(1,a,randn(150,1)); pburg(x,4)
Burg Spectral Estimate Pxx(#) 40
20
10
!10
!20 0
Diagnostics
6-241
pburg
See Also
arburg lpc pcov pmcov pmtm pmusic prony pwelch pyulear
Com pu t e a n est im a t e of AR m odel pa r a m et er s u sin g t h e Bu r g m et h od. Lin ea r pr edict ion coefficien t s. Power spect r u m est im a t e u sin g t h e cova r ia n ce m et h od. Power spect r u m est im a t e u sin g t h e m odified cova r ia n ce m et h od. Power spect r u m est im a t e u sin g t h e m u lt it a per m et h od (MTM). Power spect r u m est im a t e u sin g MUSIC eigen vect or m et h od. P r on ys m et h od for t im e dom a in IIR filt er design . E st im a t e t h e power spect r a l den sit y (P SD) of a sign a l u sin g Welch s m et h od. Power spect r u m est im a t e u sin g Yu le-Wa lker AR m et h od.
References
[1] Ma r ple, S.L. Digital S pectral A n alysis . E n glewood Cliffs, NJ : P r en t ice H a ll, 1987. Ch a pt er 7.
6-242
pcov
Purpose Syntax
6pcov
Description
t h e cova r ia n ce m et h od. Th is m et h od fit s a n a u t or egr essive (AR) m odel t o t h e sign a l by m in im izin g t h e for wa r d pr edict ion er r or in t h e lea st -squ a r es sen se. Th e spect r a l est im a t e r et u r n ed by pcov is t h e m a gn it u de squ a r ed fr equ en cy r espon se of t h is AR m odel. Th e cor r ect ch oice of t h e m odel or der p is im por t a n t .
Pxx = pcov(x,p,nfft) r et u r n s Pxx, t h e power spect r u m est im a t e. x is t h e in pu t sign a l, p is t h e m odel or der for t h e a ll-pole filt er , a n d nfft is t h e F F T len gt h (defa u lt s t o 256 if n ot specified). Pxx h a s len gt h (nfft/2+1) for nfft even , (nfft+1)/2 for nfft odd, a n d nfft if x is com plex. [Pxx,freq] = pcov(x,p,nfft) r et u r n s Pxx, t h e power spect r u m est im a t e, a n d freq, a vect or of fr equ en cies a t wh ich t h e P SD wa s est im a t ed. If t h e in pu t sign a l is r ea l-va lu ed, t h e r a n ge of freq is [0,$). If t h e in pu t sign a l is com plex, t h e r a n ge of freq is [0,2 $). [Pxx,freq] = pcov(x,p,nfft,Fs) u ses t h e sign a ls sa m plin g fr equ en cy, Fs, t o sca le bot h t h e P SD vect or (Pxx) a n d t h e fr equ en cy vect or (freq). Pxx is sca led by 1/Fs. If t h e in pu t sign a l is r ea l-va lu ed, t h e r a n ge of freq is [0,Fs/2). If t h e in pu t sign a l is com plex, t h e r a n ge of freq is [0,Fs). Fs defa u lt s t o 1 if left em pt y, []. [Pxx,freq] = pcov(x,p,nfft,Fs,'range') specifies t h e r a n ge of fr equ en cy
va lu es t o in clu de in freq. range ca n be: half, t o com pu t e t h e P SD over t h e r a n ge [0,Fs/2) for r ea l x, a n d [0,Fs) for com plex x. If Fs is left bla n k, [], t h e r a n ge is [0,1/2) for r ea l x, a n d [0,1)
6-243
pcov
for com plex x. If Fs is om it t ed en t ir ely, t h e r a n ge is [0,pi) for r ea l x, a n d [0,2*pi) for com plex x. half is t h e defa u lt r a n ge. whole, t o com pu t e t h e P SD over t h e r a n ge [0,Fs) for a ll x. If Fs is left bla n k , [], t h e r a n ge is [0,1) for a ll x. If Fs is om it t ed en t ir ely, t h e r a n ge is [0,2*pi) for a ll x.
pcov(...) plot s t h e power spect r a l den sit y in t h e fir st a va ila ble figu r e win dow. Th e fr equ en cy r a n ge on t h e plot is t h e sa m e a s t h e r a n ge of ou t pu t freq for a given set of pa r a m et er s. pcov(...,'squared') plot s t h e m a gn it u de of Pxx dir ect ly, r a t h er t h a n con ver t in g t h e va lu es t o dB.
Example
Beca u se t h e m et h od est im a t es t h e spect r u m by fit t in g a n AR m odel t o t h e sign a l, fir st defin e t h e AR syst em (a ll-pole filt er ) t h a t gen er a t es t h e in pu t . Ch eck t h e m a gn it u de r espon se of t h e pr ocess wit h freqz.
a = [1 2.2137 2.9403 2.1697 0.9606]; % AR system coefficients freqz(1,a,'phase','no') % AR system magnitude response title('AR System Magnitude Response')
AR System Magnitude Response 40
30
20 Magnitude (dB)
10
!10
!20 0
6-244
pcov
Now gen er a t e t h e in pu t sign a l x by filt er in g wh it e n oise t h r ou gh t h e AR syst em . E st im a t e t h e P SD of x ba sed on a fou r t h -or der AR m odel (sin ce we kn ow t h a t t h e or igin a l AR syst em , a, h a s or der 4).
x = filter(1,a,randn(150,1)); pcov(x,4)
Covariance Spectral Estimate P (#)
xx
40
30
20
10
!10
!20 0
Diagnostics
6-245
pcov
See Also
arcov lpc pburg pmcov pmtm pmusic prony pwelch pyulear
Com pu t e a n est im a t e of AR m odel pa r a m et er s u sin g t h e cova r ia n ce m et h od. Lin ea r pr edict ion coefficien t s. Power spect r u m est im a t e u sin g t h e Bu r g m et h od. Power spect r u m est im a t e u sin g t h e m odified cova r ia n ce m et h od. Power spect r u m est im a t e u sin g t h e m u lt it a per m et h od (MTM). Power spect r u m est im a t e u sin g MUSIC eigen vect or m et h od. P r on ys m et h od for t im e dom a in IIR filt er design . E st im a t e t h e power spect r a l den sit y (P SD) of a sign a l u sin g Welch s m et h od. Power spect r u m est im a t e u sin g Yu le-Wa lker AR m et h od.
References
[1] Ma r ple, S.L. Digital S pectral A n alysis . E n glewood Cliffs, NJ : P r en t ice H a ll, 1987. Ch a pt er 7.
6-246
pmcov
Purpose Syntax
6pm cov
Description
u sin g t h e m odified cova r ia n ce m et h od. Th is m et h od fit s a n a u t or egr essive (AR) m odel t o t h e sign a l by m in im izin g t h e for wa r d a n d ba ckwa r d pr edict ion er r or s in t h e lea st -squ a r es sen se. Th e spect r a l est im a t e r et u r n ed by pmcov is t h e m a gn it u de squ a r ed fr equ en cy r espon se of t h is AR m odel. Th e cor r ect ch oice of t h e m odel or der p is im por t a n t .
Pxx = pmcov(x,p,nfft) r et u r n s Pxx, t h e power spect r u m est im a t e. x is t h e in pu t sign a l, p is t h e m odel or der for t h e a ll-pole filt er , a n d nfft is t h e F F T len gt h (defa u lt s t o 256 if n ot specified). Pxx h a s len gt h (nfft/2+1) for nfft even , (nfft+1)/2 for nfft odd, a n d nfft if x is com plex. [Pxx,freq] = pmcov(x,p,nfft) r et u r n s Pxx, t h e power spect r u m est im a t e, a n d freq, a vect or of fr equ en cies a t wh ich t h e P SD wa s est im a t ed. If t h e in pu t sign a l is r ea l-va lu ed, t h e r a n ge of freq is [0,$). If t h e in pu t sign a l is com plex, t h e r a n ge of freq is [0,2 $). [Pxx,freq] = pmcov(x,p,nfft,Fs) u ses t h e sign a ls sa m plin g fr equ en cy, Fs, t o sca le bot h t h e P SD vect or (Pxx) a n d t h e fr equ en cy vect or (freq). Pxx is sca led by 1/Fs. If t h e in pu t sign a l is r ea l-va lu ed, t h e r a n ge of freq is [0,Fs/2). If t h e in pu t sign a l is com plex, t h e r a n ge of freq is [0,Fs). Fs defa u lt s t o 1 if left em pt y, []. [Pxx,freq] = pmcov(x,p,nfft,Fs,'range') specifies t h e r a n ge of fr equ en cy
va lu es t o in clu de in freq. range ca n be: half, t o com pu t e t h e P SD over t h e r a n ge [0,Fs/2) for r ea l x, a n d [0,Fs) for com plex x. If Fs is left bla n k, [], t h e r a n ge is [0,1/2) for r ea l x, a n d [0,1)
6-247
pmcov
for com plex x. If Fs is om it t ed en t ir ely, t h e r a n ge is [0,pi) for r ea l x, a n d [0,2*pi) for com plex x. half is t h e defa u lt r a n ge. whole, t o com pu t e t h e P SD over t h e r a n ge [0,Fs) for a ll x. If Fs is left bla n k , [], t h e r a n ge is [0,1) for a ll x. If Fs is om it t ed en t ir ely, t h e r a n ge is [0,2*pi) for a ll x.
pmcov(...) plot s t h e power spect r a l den sit y in t h e fir st a va ila ble figu r e win dow. Th e fr equ en cy r a n ge on t h e plot is t h e sa m e a s t h e r a n ge of ou t pu t freq for a given set of pa r a m et er s. pmcov(...,'squared') plot s t h e m a gn it u de of Pxx dir ect ly, r a t h er t h a n con ver t in g t h e va lu es t o dB.
Example
Beca u se t h e m et h od est im a t es t h e spect r u m by fit t in g a n AR m odel t o t h e sign a l, fir st cr ea t e t h e AR syst em (a ll-pole filt er ) t h a t gen er a t es t h e in pu t . Ch eck t h e m a gn it u de r espon se of t h e pr ocess wit h freqz.
a = [1 2.2137 2.9403 2.1697 0.9606]; % AR system coefficients freqz(1,a,'phase','no') % AR system magnitude response title('AR System Magnitude Response')
AR System Magnitude Response 40
30
20 Magnitude (dB)
10
!10
!20 0
6-248
pmcov
Now gen er a t e t h e in pu t sign a l x by filt er in g wh it e n oise t h r ou gh t h e AR syst em . E st im a t e t h e P SD of x ba sed on a fou r t h -or der AR m odel (sin ce we kn ow t h a t t h e or igin a l AR syst em , a, h a s or der 4).
x = filter(1,a,randn(150,1)); pmcov(x,4)
Modified Covariance Spectral Estimate P (#)
xx
40
20
10
!10
!20
!30 0
Diagnostics
6-249
pmcov
See Also
armcov lpc pburg pcov pmtm pmusic prony pwelch pyulear
Com pu t e a n est im a t e of AR m odel pa r a m et er s u sin g t h e m odified cova r ia n ce m et h od. Lin ea r pr edict ion coefficien t s. Power spect r u m est im a t e u sin g t h e Bu r g m et h od. Power spect r u m est im a t e u sin g t h e cova r ia n ce m et h od. Power spect r u m est im a t e u sin g t h e m u lt it a per m et h od (MTM). Power spect r u m est im a t e u sin g MUSIC eigen vect or m et h od. P r on ys m et h od for t im e dom a in IIR filt er design . E st im a t e t h e power spect r a l den sit y (P SD) of a sign a l u sin g Welch s m et h od. Power spect r u m est im a t e u sin g Yu le-Wa lker AR m et h od.
References
[1] Ma r ple, S.L. Digital S pectral A n alysis . E n glewood Cliffs, NJ : P r en t ice H a ll, 1987. Ch a pt er 7.
6-250
pmtm
Purpose Syntax
6pm t m
Description
adapt, t o specify Th om son s a da pt ive n on lin ea r com bin a t ion (defa u lt ) unity, t o specify a lin ea r com bin a t ion wit h u n it y weigh t s eigen, t o specify a lin ea r com bin a t ion wit h eigen va lu e weigh t s
[Pxx,Pxxc,f] = pmtm(x,nw,nfft,Fs,'method') r et u r n s Pxxc, t h e 95%
6-251
pmtm
in t er va ls a r e com pu t ed u sin g a ch i-squ a r ed a ppr oa ch , wh er e Pxxc(:,1) is t h e lower bou n d a n d Pxxc(:,2) is t h e u pper bou n d of t h e con fiden ce in t er va l.
[Pxx,Pxxc,f] = pmtm(x,e,v,nfft,Fs,'method',p) r et u r n s t h e P SD est im a t e Pxx, t h e con fiden ce in t er va l Pxxc, a n d t h e fr equ en cy vect or f fr om t h e da t a t a per s in e a n d t h eir con cen t r a t ion s v. [Pxx,Pxxc,f] = pmtm(x,dpss_params,nfft,Fs,'method',p) r et u r n s t h e P SD est im a t e Pxx, t h e con fiden ce in t er va l Pxxc, a n d t h e fr equ en cy vect or f fr om t h e da t a t a per s com pu t ed u sin g dpss wit h pa r a m et er s fr om t h e cell a r r a y dpss_params, wh ose fir st elem en t is t h e secon d in pu t t o dpss. Th e fir st dpss pa r a m et er (n) is det er m in ed by t h e len gt h of x. F or exa m ple, pmtm(x,{3.5,'trace'},512,Fs) ca lcu la t es t h e Slepia n sequ en ces for nw = 3.5, a n d displa ys t h e m et h od t h a t dpss u ses. See dpss for ot h er opt ion s.
Remarks
pmtm wit h n o ou t pu t a r gu m en t s plot s t h e P SD in t h e cu r r en t or n ext a va ila ble figu r e, wit h con fiden ce in t er va ls.
To u se defa u lt pa r a m et er s for a n y a r gu m en t in a n expr ession , in ser t a n em pt y m a t r ix []. F or exa m ple, pmtm(x,[],[],1000) u ses defa u lt s for t h e secon d a n d t h ir d elem en t s, in t h is ca se, nw a n d nfft.
6-252
pmtm
Example
15
10
-5
-10
100
200
300
400
500
See Also
Discr et e pr ola t e sph er oida l sequ en ces (Slepia n sequ en ces). Power spect r u m est im a t e u sin g t h e Bu r g m et h od. Power spect r u m est im a t e u sin g t h e cova r ia n ce m et h od. Power spect r u m est im a t e u sin g t h e m odified cova r ia n ce m et h od. Power spect r u m est im a t e u sin g MUSIC eigen vect or m et h od. E st im a t e t h e power spect r a l den sit y (P SD) of a sign a l u sin g Welch s m et h od. Power spect r u m est im a t e u sin g Yu le-Wa lker AR m et h od.
6-253
pmtm
References
[1] P er civa l, D.B., a n d A.T. Wa lden . S pectral A n alysis for Ph ysical Application s: M u ltitaper an d Con ven tion al Un ivariate T ech n iqu es . Ca m br idge: Ca m br idge Un iver sit y P r ess, 1993. [2] Th om son , D.J . Spect r u m est im a t ion a n d h a r m on ic a n a lysis. In Proceed in gs of th e IE E E . Vol. 70 (1982). P gs. 1055-1096.
6-254
pmusic
Purpose Syntax
6pm u sic
Description
m a t r ix u sin g Sch m idt s eigen -a n a lysis m et h od [1]. Th e n a m e MUSIC is a n a cr on ym for MUlt iple SIgn a l Cla ssifica t ion . Th e eigen vector m eth od , wh ich u ses eigen va lu e weigh t in g, is a lso su ppor t ed [2]. Th e ca llin g syn t a x is sim ila r t o t h a t of pwelch, wh ich a lso per for m s spect r u m est im a t ion . pwelch u ses t h e cla ssica l F F T-ba sed a ppr oa ch wh ile pmusic per for m s eigen -a n a lysis of t h e sign a ls cor r ela t ion m a t r ix.
[Pxx,f] = pmusic(x,p) a n d [Pxx,f] = pmusic(x,[p thresh]) r et u r n Pxx, t h e power spect r u m est im a t e, a n d f, a vect or of fr equ en cies a t wh ich t h e P SD is est im a t ed. x is t h e in pu t sign a l, wh er e:
A r ow or colu m n vect or r epr esen t s on e obser va t ion of t h e pr ocess ou t pu t (for exa m ple, on e sign a l) A r ect a n gu la r (possibly squ a r e) a r r a y a ssu m es t h a t ea ch colu m n of x is a sepa r a t e obser va t ion of t h e pr ocess ou t pu t (for exa m ple, ea ch colu m n is on e ou t pu t of a n a r r a y of sen sor s, a s in a r r a y pr ocessin g) A squ a r e m a t r ix, given t h e t r a ilin g a r gu m en t 'corr', r epr esen t s a cor r ela t ion m a t r ix Th e secon d a r gu m en t is a on e- or t wo-elem en t vect or , eit h er p or [p thresh]. If on ly p is specified, t h e sign a l su bspa ce dim en sion is p. If [p thresh] is specified, thresh is m u lt iplied by <m in , t h e sm a llest eigen va lu e; eigen va lu es below t h e t h r esh old <m in *thresh a r e a ssign ed t o t h e n oise su bspa ce. In t h is ca se, p is t h e m a xim u m dim en sion of t h e sign a l su bspa ce.
6-255
pmusic
NOTE pmusic m u st a ssign eigen vect or s t o t h e n oise a n d sign a l su bspa ces, bu t t h is is ver y difficu lt t o do in pr a ct ice. Th e t wo pa r a m et er s p a n d thresh a r e pr ovided for flexibilit y a n d con t r ol.
[Pxx,f] = pmusic(x,[p thresh],nfft,Fs,window,noverlap) specifies t h e F F T len gt h nfft (defa u lt is 256) a n d t h e sa m plin g fr equ en cy for t h e sign a l Fs (defa u lt is 1). If Fs is specified, t h e ou t pu t fr equ en cy vect or f is sca led by t h is va lu e. If t h e in pu t sign a l is r ea l-va lu ed, t h e fr equ en cy r a n ge is 0 t o Fs/2; for t h e com plex ca se, it is 0 t o Fs. window is a sca la r specifyin g t h e r ect a n gu la r win dow len gt h , or a vect or givin g t h e a ct u a l win dow coefficien t s. noverlap, u sed in con ju n ct ion wit h window, is a sca la r t h a t gives t h e n u m ber of poin t s by wh ich t o over la p su ccessive win dows. [Pxx,f] = pmusic(x,...,'corr') for ces x t o be t a ken a s a cor r ela t ion m a t r ix. In t h is ca se, t h e a r gu m en t s window a n d noverlap a r e ign or ed. [Pxx,f] = pmusic(x,...,'ev') select s t h e eigen vect or va r ia n t of t h e MUSIC est im a t or . See t h e Algor it h m sect ion below for a n expla n a t ion of h ow t h is is differ en t fr om t h e MUSIC m et h od. [Pxx,f,evects,svals] = pmusic(x,...) r et u r n s t wo a ddit ion a l a r gu m en t s. evects is a m a t r ix of eigen vect or s spa n n in g t h e n oise su bspa ce (on e per colu m n ). svals is eit h er a vect or of sin gu la r va lu es (squ a r ed) fr om svd or a vect or of eigen va lu es of t h e cor r ela t ion m a t r ix wh en t h e 'corr' opt ion is
pr esen t .
Remarks
Th e in pu t x ca n be a vect or or a m a t r ix. x ca n be in t er pr et ed a s sign a l da t a or a s a cor r ela t ion m a t r ix, in on e of t h r ee wa ys: x is a vect or of sign a l va lu es (r ow or colu m n ). In t h is ca se, t h e dim en sion of t h e eigen vect or s m u st be given . Th is is don e eit h er by t a kin g t h e defa u lt va lu e of 2*p or by specifyin g a win dow len gt h u sin g window. x is a r ect a n gu la r (m-by-n, possibly squ a r e) m a t r ix. In t h is ca se, ea ch colu m n of x is a sepa r a t e obser va t ion sign a l t h a t en t er s in t o t h e SVD a n a lysis, n is
6-256
pmusic
t h e n u m ber of obser va t ion s, a n d t h e dim en sion of t h e eigen vect or s is equ a l t o m, t h e len gt h of a colu m n . x is a squ a r e m a t r ix a n d t h e t r a ilin g 'corr' is pr esen t . x is t r ea t ed a s a cor r ela t ion m a t r ix. In t h is ca se, t h e m a t r ix m u st h a ve on ly r ea l, n on n ega t ive eigen va lu es. Th e in pu t s p a n d thresh ca n det er m in e t h e n u m ber of n oise eigen vect or s in on e of fou r wa ys: If thresh < 1, or if it is u n specified, t h e n u m ber of eigen vect or s spa n n in g t h e sign a l su bspa ce will be equ a l t o p. p m u st be a n in t eger sa t isfyin g 0 5 p < n, wh er e n is t h e dim en sion of t h e eigen vect or s. Th is dim en sion n is t h e colu m n len gt h in t h e da t a m a t r ix ca se, t h e m a t r ix size in t h e cor r ela t ion m a t r ix ca se, or t h e win dow len gt h for sign a l vect or s. Th e va lu e of thresh is u n u sed. If p 8 n, thresh m u st be a t lea st 1. thresh is u sed a s t h e m u lt iplier t o det er m in e a n a bsolu t e t h r esh old for split t in g t h e eigen va lu es bet ween t h e sign a l a n d n oise su bspa ces: < k 5 ( thresh ) m in (< k ) D {< k, v k} belon g t o n oise su bspa ce
If thresh < 1, t h er e will be n o n oise eigen vect or s. Th is ca se is n ot a llowed a n d gives t h e followin g er r or m essa ge:
Noise subspace dimension cannot be zero.
Wh en p < n a n d thresh 8 1, p specifies t h e m a xim u m n u m ber of sign a l eigen vect or s. H owever , t h e t h r esh old t est specified by thresh ca n a lso t a ke eigen vect or s fr om t h e sign a l su bspa ce a n d a ssign t h em t o t h e n oise su bspa ce.
Examples
Th is exa m ple a n a lyzes a sign a l vect or xx, a ssu m in g t h a t t wo r ea l sign a ls a r e pr esen t in t h e sign a l su bspa ce. In t h is ca se, t h e dim en sion of t h e sign a l su bspa ce is 4 beca u se ea ch r ea l sin u soid is t h e su m of t wo com plex expon en t ia ls:
nn = 0:199; xx = cos(0.257*pi*nn) + sin(0.2*pi*nn) + 0.01*randn(size(nn)); [PP,ff] = pmusic(xx,4);
Th is exa m ple a n a lyzes t h e sa m e sign a l vect or xx wit h a n eigen va lu e cu t off of 10% a bove t h e m in im u m . Set t in g p = Inf for ces t h e sign a l/n oise su bspa ce
6-257
pmusic
decision t o be ba sed on thresh. Use eigen vect or s of dim en sion 7 a n d a sa m plin g fr equ en cy Fs of 8 k H z:
[PP,ff] = pmusic(xx,[Inf,1.1],[],8000,7); % window length = 7
Wit h t h e t h ir d a n d fou r t h ou t pu t s, by plot t in g t h e zer os of t h e n oise-eigen vect or polyn om ia ls, it is possible t o cr ea t e a Root -MUSIC a lgor it h m , a s t h e followin g zplane plot illu st r a t es:
[PP,ff,v_noise] = pmusic(xx,4); for kk = 1:size(v_noise,2) rr(:,kk) = roots(v_noise(:,kk)); end zplane(rr)
Use t h e sa m e sign a l, bu t let pmusic for m t h e 100-by-7 da t a m a t r ix u sin g it s win dow a n d over la p in pu t s. In a ddit ion , u se a lon ger F F T:
yy = xx(:); [PP,ff] = pmusic(yy,4,512,[],7,0);
If we set p = 0, a ll t h e eigen vect or s a r e a ssign ed t o t h e n oise su bspa ce. 'ev' specifies t h e eigen vect or weigh t in g. Th is t u r n s ou t t o be equ iva len t t o MVDL (Ca pon s MLM):
[PP,ff] = pmusic(RR,0,'ev','corr');
Algorithm
6-258
pmusic
wh er e N is t h e dim en sion of t h e eigen vect or s a n d v k is t h e k -t h eigen vect or of t h e cor r ela t ion m a t r ix of t h e in pu t sign a l. Th e in t eger p is t h e dim en sion of t h e sign a l su bspa ce, so t h e eigen vect or s v k u sed in t h e su m cor r espon d t o t h e sm a llest eigen va lu es a n d a lso spa n t h e n oise su bspa ce. Th e vect or e (f ) con sist s of com plex expon en t ia ls, so t h e in n er pr odu ct
H e (f ) vk
a m ou n t s t o a F ou r ier t r a n sfor m . Th e secon d for m is pr efer r ed for com pu t a t ion beca u se t h e F F T is com pu t ed for ea ch v k a n d t h en t h e squ a r ed m a gn it u des a r e su m m ed. In t h e eigen vect or m et h od, t h e su m m a t ion is weigh t ed by t h e eigen va lu es <k of t h e cor r ela t ion m a t r ix: 1 P ev (f ) = ---------------------------------------------------------N 3 4 9 H e (f ) 2 : < vk 9 : k 1k = p + 1 2
Th e fu n ct ion r elies on t h e svd m a t r ix decom posit ion in t h e sign a l ca se, a n d it u ses t h e eig fu n ct ion for a n a lyzin g t h e cor r ela t ion m a t r ix. If SVD is u sed, t h e cor r ela t ion m a t r ix is n ever explicit ly com pu t ed, bu t t h e sin gu la r va lu es a r e t h e <k .
Diagnostics
6-259
pmusic
If t h e secon d a r gu m en t wa s en t er ed a s a n em pt y m a t r ix, or if it h a s m or e t h a n t wo elem en t s, or if it h a s n ega t ive or n on -in t eger elem en t s, pmusic gives on e of t h e followin g er r or m essa ges:
P cannot be empty. Second input must have only 1 or 2 elements. P must be an integer. Second input must contain non-negative entries.
If t h e va lu e of p is t oo la r ge wit h r espect t o t h e eigen vect or dim en sion , a n d thresh is less t h a n 1, n o eigen vect or s ca n be a ssign ed t o t h e n oise su bspa ce a n d t h e a lgor it h m fa ils. In t h is ca se, pmusic gives t h e followin g er r or m essa ge:
Noise subspace dimension cannot be zero.
If t h e 'corr' pa r a m et er is u sed, t h en t h e fir st in pu t m u st be a squ a r e cor r ela t ion m a t r ix. If it is n ot , pmusic gives t h e followin g er r or m essa ge:
Correlation matrix (R) is not square.
Th e cor r ela t ion m a t r ix is t h en ch ecked for va lidit y; if it fa ils, pmusic gives t h e followin g er r or m essa ge:
Correlation matrix (R) has negative or complex eigenvalue.
See Also
Lin ea r pr edict ion coefficien t s. Power spect r u m est im a t e u sin g t h e Bu r g m et h od. Power spect r u m est im a t e u sin g t h e cova r ia n ce m et h od. Power spect r u m est im a t e u sin g t h e m odified cova r ia n ce m et h od. Power spect r u m est im a t e u sin g t h e m u lt it a per m et h od (MTM). P r on ys m et h od for t im e dom a in IIR filt er design . E st im a t e t h e power spect r a l den sit y (P SD) of a sign a l u sin g Welch s m et h od. Power spect r u m est im a t e u sin g Yu le-Wa lk er AR m et h od.
6-260
pmusic
References
[1] Sch m idt , R.O. Mu lt iple E m it t er Loca t ion a n d Sign a l P a r a m et er E st im a t ion . IE E E T ran s. An ten n as Propagation . Vol. AP -34 (Ma r ch 1986). P gs. 276-280. [2] Ma r ple, S.L. Digital S pectral A n alysis . E n glewood Cliffs, NJ : P r en t ice H a ll, 1987. P gs. 373-378.
6-261
poly2ac
Purpose Syntax Description
6poly2a c
Con ver sion of pr edict ion polyn om ia l t o a u t ocor r ela t ion sequ en ce.
r = poly2ac(a,efinal) r = poly2ac(a,efinal) fin ds t h e a u t ocor r ela t ion sequ en ce cor r espon din g t o pr edict ion polyn om ia l a a n d fin a l pr edict ion er r or efinal. If a(1) is n ot equ a l t o 1, poly2ac n or m a lizes t h e pr edict ion polyn om ia l by a(1). a(1) ca n n ot be 0. ac2poly poly2rc rc2ac
See Also
Con ver sion of a u t ocor r ela t ion sequ en ce t o pr edict ion polyn om ia l. Con ver sion of pr edict ion polyn om ia l t o r eflect ion coefficien t s. Con ver sion of r eflect ion coefficien t s t o a u t ocor r ela t ion sequ en ce.
References
[1] Ka y, S.M. M od ern S pectral E stim ation . E n glewood Cliffs, NJ : P r en t ice-H a ll, 1988.
6-262
poly2rc
Purpose Syntax Description
6poly2r c
A sim ple, fa st wa y t o ch eck if a h a s a ll of it s r oot s in side t h e u n it cir cle is t o ch eck if ea ch of t h e elem en t s of k h a s m a gn it u de less t h a n 1:
stable = all(abs(poly2rc(a))<1)
Example
Limitations
If abs(k(i)) == 1 for a n y i, fin din g t h e r eflect ion coefficien t s is a n ill-con dit ion ed pr oblem . poly2rc will r et u r n som e NaNs a n d pr ovide a wa r n in g m essa ge in t h is ca se.
poly2rc im plem en t s t h e r ecu r sive r ela t ion sh ip:
Algorithm
6-263
poly2rc
k (n ) = a n (n ) a n (m ) k (n ) a n (n m ) , a n 1 (m ) = ---------------------------------------------------------1 k (n ) 2 m = 1 , 2 , , n 1
Th is r ela t ion sh ip is ba sed on Levin son s r ecu r sion [1]. To im plem en t it , poly2rc loops t h r ou gh a in r ever se or der a ft er disca r din g it s fir st elem en t . F or ea ch loop it er a t ion i, t h e fu n ct ion
1 set s k(i) equ a l t o a(i) 2 a pplies t h e secon d r ela t ion sh ip a bove t o elem en t s 1 t h r ou gh i of t h e vect or a: a = (ak(i)*fliplr(a))/(1k(i)^2);
See Also
Con ver sion of a u t ocor r ela t ion sequ en ce t o r eflect ion coefficien t s. La t t ice filt er t o t r a n sfer fu n ct ion con ver sion . La t t ice a n d la t t ice-la dder filt er im plem en t a t ion . Con ver sion of pr edict ion polyn om ia l t o a u t ocor r ela t ion sequ en ce. Con ver sion of r eflect ion coefficien t s t o pr edict ion polyn om ia l. Con ver sion of t r a n sfer fu n ct ion t o la t t ice filt er.
References
[1] Ka y, S.M. M od ern S pectral E stim ation : T h eory an d Application . E n glewood Cliffs, NJ : P r en t ice H a ll, 1988.
6-264
polystab
Purpose Syntax Description
6polyst a b
St a bilize polyn om ia l.
b = polystab(a) polystab st a bilizes a polyn om ia l wit h r espect t o t h e u n it cir cle; it r eflect s r oot s
Example
polystab ca n con ver t a lin ea r -ph a se filt er in t o a m in im u m -ph a se filt er wit h t h e sa m e m a gn it u de r espon se: h = fir1(25,0.4); hmin = polystab(h)*norm(h)/norm(polystab(h));
Algorithm
polystab fin ds t h e r oot s of t h e polyn om ia l a n d m a ps t h ose r oot s fou n d ou t side t h e u n it cir cle t o t h e in side of t h e u n it cir cle: v = roots(a); vs = 0.5*(sign(abs(v)1)+1); v = (1vs).*v + vs./conj(v); b = a(1)*poly(v);
See Also
roots
6-265
prony
Purpose Syntax Description
6pr on y
P r on ys m et h od is a n a lgor it h m for fin din g a n IIR filt er wit h a pr escr ibed t im e dom a in im pu lse r espon se. It h a s a pplica t ion s in filt er design , expon en t ia l sign a l m odelin g, a n d syst em iden t ifica t ion (pa r a m et r ic m odelin g).
[b,a] = prony(h,nb,na) fin ds a filt er wit h n u m er a t or or der nb, den om in a t or or der na, a n d t h e t im e dom a in im pu lse r espon se in h. prony r et u r n s t h e filt er coefficien t s in r ow vect or s b a n d a, of len gt h nb + 1 a n d na + 1, r espect ively. Th e filt er coefficien t s a r e in descen din g power s of z :
B (z ) b (1 ) + b (2 ) z 1 + L + b (n b + 1 ) z n b H (z ) = ---------- = --------------------------------------------------------------------------------------- 1 A (z ) + a (n a + 1 ) z n a a (1 ) + a (2 ) z + L
Example
Algorithm
va r ia t ion of t h e cova r ia n ce m et h od of AR m odelin g t o fin d t h e den om in a t or coefficien t s a a n d t h en fin ds t h e n u m er a t or coefficien t s b for wh ich t h e im pu lse r espon se of t h e ou t pu t filt er m a t ch es exa ct ly t h e fir st nb + 1 sa m ples of x. Th e filt er is n ot n ecessa r ily st a ble, bu t pot en t ia lly ca n r ecover t h e coefficien t s
6-266
prony
exa ct ly if t h e da t a sequ en ce is t r u ly a n a u t or egr essive m ovin g a ver a ge (ARMA) pr ocess of t h e cor r ect or der .
See Also
Bu t t er wor t h a n a log a n d digit a l filt er design . Ch ebysh ev t ype I filt er design (pa ssba n d r ipple). Ch ebysh ev t ype II filt er design (st opba n d r ipple). E llipt ic (Ca u er ) filt er design . Discr et e-t im e filt er iden t ifica t ion fr om fr equ en cy da t a . Levin son -Du r bin r ecu r sion . Lin ea r pr edict ion coefficien t s. Lin ea r m odel u sin g St eiglit z-McBr ide it er a t ion .
References
[1] P a r ks, T.W., a n d C.S. Bu r r u s. Digital Filter Design . New Yor k: J oh n Wiley & Son s, 1987. P gs. 226-228.
6-267
psd
Superseded
Th e psd fu n ct ion for spect r a l est im a t ion by Welch s m et h od h a s been su per seded by pwelch.
6psd
Th e pwelch fu n ct ion im pr oves u pon psd in t h r ee wa ys: Th e m a gn it u de of t h e spect r u m is sca led by 1/Fs Th e defa u lt va lu e of Fs is 1 No det r en din g is per for m ed Th e psd fu n ct ion will con t in u e t o be in clu ded in t h e Sign a l P r ocessin g Toolbox for ba ck wa r ds com pa t ibilit y.
6-268
pulstran
Purpose Syntax
6pu lst r a n
P u lse t r a in gen er a t or .
y y y y = = = = pulstran(t,d,'func') pulstran(t,d,'func',p1,p2,...) pulstran(t,d,p,Fs) pulstran(t,d,p)
Description
pulstran gen er a t es pu lse t r a in s fr om con t in u ou s fu n ct ion s or sa m pled pr ot ot ype pu lses. y = pulstran(t,d,'func') gen er a t es a pu lse t r a in ba sed on sa m ples of a con t in u ou s fu n ct ion , 'func', wh er e func is:
gauspuls, for Ga u ssia n -m odu la t ed sin u soida l pu lse gen er a t or rectpuls, for sa m pled a per iodic r ect a n gle gen er a t or tripuls, for sa m pled a per iodic t r ia n gle gen er a t or
pulstran is eva lu a t ed length(d) t im es a n d r et u r n s t h e su m of t h e eva lu a t ion s y = func(td(1)) + func(td(2)) + ...
Th e fu n ct ion is eva lu a t ed over t h e r a n ge of a r gu m en t va lu es specified in a r r a y t, a ft er r em ovin g a sca la r a r gu m en t offset t a k en fr om t h e vect or d. Not e t h a t func m u st be a vect or ized fu n ct ion t h a t ca n t a k e a n a r r a y t a s a n a r gu m en t . An opt ion a l ga in fa ct or m a y be a pplied t o ea ch dela yed eva lu a t ion by specifyin g d a s a t wo-colu m n m a t r ix, wit h t h e offset defin ed in colu m n 1 a n d a ssocia t ed ga in in colu m n 2 of d. Not e t h a t a r ow vect or will be in t er pr et ed a s specifyin g dela ys on ly.
pulstran(t,d,'func',p1,p2,...) a llows a ddit ion a l pa r a m et er s t o be pa ssed
6-269
pulstran
pulstran(t,d,p) a ssu m es t h a t t h e sa m plin g r a t e Fs is equ a l t o 1 H z. pulstran(...,'func') specifies a lt er n a t ive in t er pola t ion m et h ods. See interp1 for a list of a va ila ble m et h ods.
Examples
Th is exa m ple gen er a t es a n a sym m et r ic sa wt oot h wa vefor m wit h a r epet it ion fr equ en cy of 3 H z a n d a sa wt oot h widt h of 0.1 sec. It h a s a sign a l len gt h of 1 sec a n d a 1 k H z sa m ple r a t e:
t = 0 : 1/1e3 : 1; % 1 kHz sample freq for 1 sec d = 0 : 1/3 : 1; % 3 Hz repetition freq y = pulstran(t,d,'tripuls',0.1,1); plot(t,y)
1 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0 0 0.2 0.4 0.6 0.8 1
Th is exa m ple gen er a t es a per iodic Ga u ssia n pu lse sign a l a t 10 k H z, wit h 50% ba n dwidt h . Th e pu lse r epet it ion fr equ en cy is 1 k H z, sa m ple r a t e is 50 k H z, a n d
6-270
pulstran
0.002
0.004
0.006
0.008
0.01
6-271
pulstran
See Also
chirp cos diric gauspuls rectpuls sawtooth sin sinc square tripuls
Swept -fr equ en cy cosin e gen er a t or. Cosin e of vect or /m a t r ix elem en t s (see t h e on lin e M A T L AB Fu n ction R eferen ce). Dir ich let or per iodic sin c fu n ct ion . Ga u ssia n -m odu la t ed sin u soida l pu lse gen er a t or. Sa m pled a per iodic r ect a n gle gen er a t or. Sawt oot h or t r ia n gle wave gen er a t or. Sin e of vect or /m a t r ix elem en t s (see t h e on lin e M A T L AB Fu n ction R eferen ce). Sin c or sin ($t )/$t fu n ct ion . Squ a r e wa ve gen er a t or. Sa m pled a per iodic t r ia n gle gen er a t or.
6-272
pwelch
Purpose Syntax
6pwelch
Description
6-273
pwelch
[Pxx,f] = pwelch(x,nfft,Fs,window) specifies a win dowin g fu n ct ion a n d t h e n u m ber of sa m ples per win dowed sect ion of t h e x vect or (e.g., kaiser(64)). Th e len gt h of t h e win dow m u st be less t h a n or equ a l t o nfft; pwelch zer o pa ds t h e sect ion s if t h e len gt h of t h e win dow is less t h a n nfft. Specify a sca la r for window t o u se a H a n n in g win dow of t h a t len gt h ; specify a n em pt y m a t r ix, [], t o u se t h e defa u lt va lu e of hanning(nfft). [Pxx,f] = pwelch(x,nfft,Fs,window,noverlap) over la ps t h e win dowed sect ion s of x by noverlap sa m ples. Specify a n em pt y m a t r ix for noverlap, [], t o u se t h e defa u lt va lu e of 0. [Pxx,Pxxc,f] = pwelch(x,nfft,Fs,window,noverlap,p) wh er e p is a posit ive sca la r bet ween 0 a n d 1 r et u r n s a vect or Pxxc t h a t con t a in s a n est im a t e of t h e p*100 per cen t con fiden ce in t er va l for Pxx. Pxxc is a t wo-colu m n m a t r ix t h a t is t h e sa m e len gt h a s Pxx. Th e in t er va l [Pxxc(:,1),Pxxc(:,2)] cover s t h e t r u e P SD wit h pr oba bilit y p. plot(f,[Pxx Pxxc]) plot s t h e power spect r u m in side t h e p*100 per cen t con fiden ce in t er va l. Specify a n em pt y m a t r ix for p, [],
t o u se t h e defa u lt va lu e of 0.95.
[Pxx,Pxxc,f] = pwelch(...,'range') specifies t h e r a n ge of fr equ en cy
va lu es t o in clu de in f. range ca n be: half, t o com pu t e t h e P SD over t h e r a n ge [0,$) for r ea l or com plex x. If Fs is specified, t h e r a n ge is [0,Fs/2) for r ea l or com plex x. If Fs is specified by a n em pt y m a t r ix, [], t h e defa u lt va lu e of 1 is u sed, a n d t h e r a n ge is [0,1/2) for r ea l or com plex x. whole, t o com pu t e t h e P SD over t h e r a n ge [0,2 $) for r ea l or com plex x. If Fs is specified, t h e r a n ge is [0,Fs) for r ea l or com plex x. If Fs is specified by a n em pt y m a t r ix, [], t h e defa u lt va lu e of 1 is u sed, a n d t h e r a n ge is [0,1) for r ea l or com plex x.
pwelch(x,...) wit h n o ou t pu t a r gu m en t s plot s t h e P SD a ga in st fr equ en cy in t h e cu r r en t figu r e win dow. If p is specified, t h e plot in clu des t h e con fiden ce in t er va l. pwelch(...,'magunits') specifies t h e u n it s in wh ich t o expr ess t o t h e
6-274
pwelch
'db', t o expr ess t h e P SD da t a in decibels (dB). Th is is t h e defa u lt . 'squared', t o expr ess t h e P SD in lin ea r u n it s (m a gn it u de squ a r ed).
Example
Gen er a t e a color ed n oise sign a l a n d plot it s P SD wit h a con fiden ce in t er va l of 95%. Specify a len gt h 1024 F F T, a 512-poin t Ka iser win dow wit h n o over la p, a n d a sa m plin g fr equ en cy of 10 kH z:
h = fir1(30,0.2,boxcar(31)); % design a lowpass filter r = randn(16384,1); % white noise x = filter(h,1,r); % color the noise pwelch(x,1024,10000,kaiser(512,5),0,0.95)
Welchs Spectral Estimate Pxx(f) / fs !30 !40 !50 !60 !70 !80 !90 !100 !110 0
1000
4000
5000
Algorithm
sect ion of in pu t x.
2 It t r a n sfor m s ea ch sect ion wit h a n nfft-poin t F F T. 3 It for m s t h e per iodogr a m of ea ch sect ion by sca lin g t h e m a gn it u de squ a r ed
6-275
pwelch
4 It a ver a ges t h e per iodogr a m s of t h e over la ppin g sect ion s t o for m Pxx(f). 5 It sca les Pxx(f) by 1/Fs t o for m Pxx(f)/Fs, t h e power spect r u m of x.
Diagnostics
An a ppr opr ia t e dia gn ost ic m essa ge is displa yed wh en in cor r ect a r gu m en t s t o pwelch a r e u sed:
Requires Requires Requires Requires Requires windows length to be no greater than FFT length. NOVERLAP to be strictly less than the window length. positive integer values for NFFT and NOVERLAP. confidence parameter to be a scalar between 0 and 1. vector input.
See Also
cohere csd pburg pcov pmcov pmtm pmusic pyulear specgram tfe
E st im a t e m a gn it u de squ a r ed coh er en ce fu n ct ion bet ween t wo sign a ls. E st im a t e t h e cr oss spect r a l den sit y (CSD) of t wo sign a ls. Power spect r u m est im a t e u sin g t h e Bu r g m et h od. Power spect r u m est im a t e u sin g t h e cova r ia n ce m et h od. Power spect r u m est im a t e u sin g t h e m odified cova r ia n ce m et h od. Power spect r u m est im a t e u sin g t h e m u lt it a per m et h od (MTM). Power spect r u m est im a t e u sin g MUSIC eigen vect or m et h od. Power spect r u m est im a t e u sin g Yu le-Wa lker AR m et h od. Tim e-depen den t fr equ en cy a n a lysis (spect r ogr a m ). Tr a n sfer fu n ct ion est im a t e fr om in pu t a n d ou t pu t .
6-276
pwelch
References
[1] Ra bin er , L.R., a n d B. Gold. T h eory an d Application of Digital S ign al Processin g. E n glewood Cliffs, NJ : P r en t ice H a ll, 1975. P gs. 399-419. [2] Welch , P .D. Th e Use of F a st F ou r ier Tr a n sfor m for t h e E st im a t ion of P ower Spect r a : A Met h od Ba sed on Tim e Aver a gin g Over Sh or t , Modified P er iodogr a m s. IE E E T ran s. A u d io E lectroacou st . Vol. AU-15 (J u n e 1967). P gs. 70-73. [3] Oppen h eim , A.V., a n d R.W. Sch a fer . Discrete-T im e S ign al Processin g. E n glewood Cliffs, NJ : P r en t ice H a ll, 1989. P gs. 311-312.
6-277
pyulear
Purpose Syntax
6pyu lea r
Description
u sin g t h e Yu le-Wa lk er AR m et h od. Th is m et h od, a lso ca lled t h e a u t ocor r ela t ion m et h od, fit s a n a u t or egr essive (AR) m odel t o t h e sign a l by m in im izin g t h e for wa r d pr edict ion er r or in t h e lea st -squ a r es sen se. Th is for m u la t ion lea ds t o t h e Yu le-Wa lker equ a t ion s, wh ich a r e solved by t h e Levin son -Du r bin r ecu r sion . Th e spect r a l est im a t e r et u r n ed by pyulear is t h e m a gn it u de squ a r ed fr equ en cy r espon se of t h is AR m odel. Th e cor r ect ch oice of t h e m odel or der p is im por t a n t .
Pxx = pyulear(x,p,nfft) r et u r n s Pxx, t h e power spect r u m est im a t e. x is t h e in pu t sign a l, p is t h e m odel or der for t h e a ll-pole filt er , a n d nfft is t h e F F T len gt h (defa u lt s t o 256 if n ot specified). Pxx h a s len gt h (nfft/2+1) for nfft even , (nfft+1)/2 for nfft odd, a n d nfft if x is com plex. [Pxx,freq] = pyulear(x,p,nfft) r et u r n s Pxx, t h e power spect r u m est im a t e, a n d freq, a vect or of fr equ en cies a t wh ich t h e P SD wa s est im a t ed. If t h e in pu t sign a l is r ea l-va lu ed, t h e r a n ge of freq is [0,$). If t h e in pu t sign a l is com plex, t h e r a n ge of freq is [0,2 $). [Pxx,freq] = pyulear(x,p,nfft,Fs) u ses t h e sign a ls sa m plin g fr equ en cy, Fs, t o sca le bot h t h e P SD vect or (Pxx) a n d t h e fr equ en cy vect or (freq). Pxx is sca led by 1/Fs. If t h e in pu t sign a l is r ea l-va lu ed, t h e r a n ge of freq is [0,Fs/2). If t h e in pu t sign a l is com plex, t h e r a n ge of freq is [0,Fs). Fs defa u lt s t o 1 if left em pt y, []. [Pxx,freq] = pyulear(x,p,nfft,Fs,'range') specifies t h e r a n ge of fr equ en cy va lu es t o in clu de in freq. range ca n be:
half, t o com pu t e t h e P SD over t h e r a n ge [0,Fs/2) for r ea l x, a n d [0,Fs) for com plex x. If Fs is left bla n k , [], t h e r a n ge is [0,1/2) for r ea l x, a n d [0,1)
6-278
pyulear
for com plex x. If Fs is om it t ed en t ir ely, t h e r a n ge is [0,pi) for r ea l x, a n d [0,2*pi) for com plex x. half is t h e defa u lt r a n ge. whole, t o com pu t e t h e P SD over t h e r a n ge [0,Fs) for a ll x. If Fs is left bla n k , [], t h e r a n ge is [0,1) for a ll x. If Fs is om it t ed en t ir ely, t h e r a n ge is [0,2*pi) for a ll x.
pyulear(...) plot s t h e power spect r a l den sit y in t h e fir st a va ila ble figu r e win dow. Th e fr equ en cy r a n ge on t h e plot is t h e sa m e a s t h e r a n ge of ou t pu t freq for a given set of pa r a m et er s. pyulear(...,'squared') plot s t h e m a gn it u de of Pxx dir ect ly, r a t h er t h a n com n ver t in g t h e va lu es t o dB.
Example
Sin ce t h e m et h od est im a t es t h e spect r u m by fit t in g a n AR m odel t o t h e sign a l, fir st defin e t h e AR syst em (a ll-pole filt er ) t h a t gen er a t es t h e in pu t . Ch eck t h e m a gn it u de r espon se of t h e pr ocess wit h freqz.
a = [1 2.2137 2.9403 2.1697 0.9606]; % AR system coefficients freqz(1,a,'phase','no') % AR system magnitude response title('AR System Magnitude Response')
AR System Magnitude Response 40
30
20 Magnitude (dB)
10
!10
!20 0
6-279
pyulear
Now gen er a t e t h e in pu t sign a l x by filt er in g wh it e n oise t h r ou gh t h e AR syst em . E st im a t e t h e P SD of x ba sed on a fou r t h -or der AR m odel (sin ce we k n ow t h a t t h e or igin a l AR syst em , a, h a s or der 4).
x = filter(1,a,randn(150,1)); pyulear(x,4)
Yule!Walker Spectral Estimate P (#)
xx
25
20
15
10
!5
!10 0
Diagnostics
6-280
pyulear
See Also
Com pu t e a n est im a t e of AR m odel pa r a m et er s u sin g t h e Yu le-Wa lker m et h od. Lin ea r pr edict ion coefficien t s. Power spect r u m est im a t e u sin g t h e Bu r g m et h od. Power spect r u m est im a t e u sin g t h e cova r ia n ce m et h od. Power spect r u m est im a t e u sin g t h e m odified cova r ia n ce m et h od. Power spect r u m est im a t e u sin g t h e m u lt it a per m et h od (MTM). Power spect r u m est im a t e u sin g MUSIC eigen vect or m et h od. P r on ys m et h od for t im e dom a in IIR filt er design . E st im a t e t h e power spect r a l den sit y (P SD) of a sign a l u sin g Welch s m et h od.
References
[1] Ma r ple, S.L. Digital S pectral A n alysis . E n glewood Cliffs, NJ : P r en t ice H a ll, 1987. Ch a pt er 7.
6-281
rc2ac
Purpose Syntax Description See Also
6rc2a c
Con ver sion of r eflect ion coefficien t s t o a u t ocor r ela t ion sequ en ce.
r = rc2ac(k,r0) r = rc2ac(k,r0) fin ds t h e a u t ocor r ela t ion coefficien t s, r, of t h e discr et e filt er wit h r eflect ion coefficien t s k a n d zer o-la g a u t ocor r ela t ion r0. ac2rc poly2ac rc2poly
Con ver sion of a u t ocor r ela t ion sequ en ce t o r eflect ion coefficien t s. Con ver sion of pr edict ion polyn om ia l t o a u t ocor r ela t ion sequ en ce. Con ver sion of r eflect ion coefficien t s t o pr edict ion polyn om ia l.
References
[1] Ka y, S.M. M od ern S pectral E stim ation . E n glewood Cliffs, NJ : P r en t ice-H a ll, 1988.
6-282
rc2poly
Purpose Syntax Description
6rc2poly
Example
Algorithm
6-283
rc2poly
See Also
ac2poly latc2tf latcfilt poly2rc rc2ac tf2latc
Con ver sion of a u t ocor r ela t ion sequ en ce t o pr edict ion polyn om ia l. La t t ice filt er t o t r a n sfer fu n ct ion con ver sion . La t t ice a n d la t t ice-la dder filt er im plem en t a t ion . Con ver sion of pr edict ion polyn om ia l t o r eflect ion coefficien t s. Con ver sion of r eflect ion coefficien t s t o a u t ocor r ela t ion sequ en ce. Con ver sion of t r a n sfer fu n ct ion t o la t t ice filt er.
References
[1] Ka y, S.M. M od ern S pectral E stim ation . E n glewood Cliffs, NJ : P r en t ice-H a ll, 1988.
6-284
rceps
Purpose Syntax Description
6rceps
Th e real cepstru m is t h e in ver se F ou r ier t r a n sfor m of t h e r ea l loga r it h m of t h e m a gn it u de of t h e F ou r ier t r a n sfor m of a sequ en ce.
rceps(x) r et u r n s t h e r ea l cepst r u m of t h e r ea l sequ en ce x. Th e r ea l cepst r u m is a r ea l-va lu ed fu n ct ion . [y,ym] = rceps(x) r et u r n s bot h t h e r ea l cepst r u m y a n d a m in im u m ph a se r econ st r u ct ed ver sion ym of t h e in pu t sequ en ce.
Algorithm
See Also
Com plex cepst r a l a n a lysis. On e-dim en sion a l fa st Fou r ier t r a n sfor m . H ilber t t r a n sfor m . In ver se com plex cepst r u m . Un wr a p ph a se a n gles.
References
[1] Oppen h eim , A.V., a n d R.W. Sch a fer . Digital S ign al Processin g . E n glewood Cliffs, NJ : P r en t ice H a ll, 1975. [2] IE E E . Program s for Digital S ign al Processin g . IE E E P r ess. New Yor k: J oh n Wiley & Son s, 1979.
6-285
rectpuls
Purpose Syntax Description
6rect pu ls
a defa u lt widt h of 1. Not e t h a t t h e in t er va l of n on -zer o a m plit u de is defin ed t o be open on t h e r igh t , t h a t is, rectpuls(0.5) = 1 wh ile rectpuls(0.5) = 0.
y = rectpuls(t,w) gen er a t es a r ect a n gle of widt h w. rectpuls is t ypica lly u sed in con ju n ct ion wit h t h e pu lse t r a in gen er a t in g fu n ct ion , pulstran.
See Also
chirp cos diric gauspuls pulstran sawtooth sin sinc square tripuls
Swept -fr equ en cy cosin e gen er a t or. Cosin e of vect or /m a t r ix elem en t s (see t h e on lin e M A T L AB Fu n ction R eferen ce). Dir ich let or per iodic sin c fu n ct ion . Ga u ssia n -m odu la t ed sin u soida l pu lse gen er a t or. P u lse t r a in gen er a t or. Sawt oot h or t r ia n gle wave gen er a t or. Sin e of vect or /m a t r ix elem en t s (see t h e on lin e M A T L AB Fu n ction R eferen ce). Sin c or sin ($t )/$t fu n ct ion . Squ a r e wa ve gen er a t or. Sa m pled a per iodic t r ia n gle gen er a t or.
6-286
remez
Purpose Syntax
6rem ez
Description
a lgor it h m [1]. Th e P a r ks-McClella n a lgor it h m u ses t h e Rem ez exch a n ge a lgor it h m a n d Ch ebysh ev a ppr oxim a t ion t h eor y t o design filt er s wit h a n opt im a l fit bet ween t h e desir ed a n d a ct u a l fr equ en cy r espon ses. Th e filt er s a r e opt im a l in t h e sen se t h a t t h e m a xim u m er r or bet ween t h e desir ed fr equ en cy r espon se a n d t h e a ct u a l fr equ en cy r espon se is m in im ized. F ilt er s design ed t h is wa y exh ibit a n equ ir ipple beh a vior in t h eir fr equ en cy r espon ses a n d h en ce a r e som et im es ca lled equ iripple filt er s.
b = remez(n,f,a) r et u r n s r ow vect or b con t a in in g t h e n+1 coefficien t s of t h e or der n F IR filt er wh ose fr equ en cy-a m plit u de ch a r a ct er ist ics m a t ch t h ose given by vect or s f a n d a.
6-287
remez
f is a vect or of pa ir s of fr equ en cy poin t s, specified in t h e r a n ge bet ween 0 a n d 1, wh er e 1 cor r espon ds t o h a lf t h e sa m plin g fr equ en cy (t h e Nyqu ist fr equ en cy). Th e fr equ en cies m u st be in in cr ea sin g or der . a is a vect or con t a in in g t h e desir ed a m plit u des a t t h e poin t s specified in f. Th e desir ed a m plit u de a t fr equ en cies bet ween pa ir s of poin t s (f (k ), f (k +1)) for k odd is t h e lin e segm en t con n ect in g t h e poin t s (f (k ), a (k )) a n d (f (k +1), a (k +1)). Th e desir ed a m plit u de a t fr equ en cies bet ween pa ir s of poin t s (f (k ), f (k +1)) for k even is u n specified. Th e a r ea s bet ween su ch poin t s a r e t r a n sit ion or don t ca r e r egion s. f a n d a m u st be t h e sa m e len gt h . Th e len gt h m u st be a n even n u m ber . Th e r ela t ion sh ip bet ween t h e f a n d a vect or s in defin in g a desir ed fr equ en cy r espon se is sh own below:
f = [0 .3 .4 .6 .7 .9] a = [0 1 0 0 .5 .5]
0.5
0.0 0.0
remez(n,f,a,w) u ses t h e weigh t s in vect or w t o weigh t t h e fit in ea ch fr equ en cy ba n d. Th e len gt h of w is h a lf t h e len gt h of f a n d a, so t h er e is exa ct ly on e weigh t per ba n d. b = remez(n,f,a,'ftype') a n d b = remez(n,f,a,w,'ftype') specify a filt er t ype, wh er e ftype is
6-288
remez
hilbert, for lin ea r -ph a se filt er s wit h odd sym m et r y (t ype III a n d t ype IV) Th e ou t pu t coefficien t s in b obey t h e r ela t ion b (k ) = -b (n + 2 -k ), k = 1,...,n + 1. Th is cla ss of filt er s in clu des t h e H ilber t t r a n sfor m er , wh ich h a s a desir ed a m plit u de of 1 a cr oss t h e en t ir e ba n d. F or exa m ple,
h = remez(30,[0.1 0.9],[1 1],'hilbert');
design s a n a ppr oxim a t e F IR H ilber t t r a n sfor m er of len gt h 31. differentiator, for t ype III a n d IV filt er s, u sin g a specia l weigh t in g t ech n iqu e F or n on zer o a m plit u de ba n ds, it weigh t s t h e er r or by a fa ct or of 1/f so t h a t t h e er r or a t low fr equ en cies is m u ch sm a ller t h a n a t h igh fr equ en cies. F or F IR differ en t ia t or s, wh ich h a ve a n a m plit u de ch a r a ct er ist ic pr opor t ion a l t o fr equ en cy, t h ese filt er s m in im ize t h e m a xim u m r ela t ive er r or (t h e m a xim u m of t h e r a t io of t h e er r or t o t h e desir ed a m plit u de).
b = remez(...,{lgrid}) u ses t h e in t eger lgrid t o con t r ol t h e den sit y of t h e fr equ en cy gr id, wh ich h a s r ou gh ly (lgrid*n)/(2*bw) fr equ en cy poin t s, wh er e bw is t h e fr a ct ion of t h e t ot a l fr equ en cy ba n d in t er va l [0,1] cover ed by f. In cr ea sin g lgrid oft en r esu lt s in filt er s t h a t a r e m or e exa ct ly equ ir ipple, bu t wh ich t a ke lon ger t o com pu t e. Th e defa u lt va lu e of 16 is t h e m in im u m va lu e t h a t sh ou ld be specified for lgrid. Not e t h a t t h e {lgrid} a r gu m en t m u st be a 1-by-1 cell a r r a y. b = remez(n,f,'fresp',w) r et u r n s r ow vect or b con t a in in g t h e n+1 coefficien t s of t h e or der n F IR filt er wh ose fr equ en cy-a m plit u de ch a r a ct er ist ics best a ppr oxim a t e t h e r espon se specified by fu n ct ion fresp. Th e fu n ct ion is ca lled fr om wit h in remez wit h t h e followin g syn t a x: [dh,dw] = fresp(n,f,gf,w)
Th e a r gu m en t s a r e sim ila r t o t h ose for remez: n is t h e filt er or der . f is t h e vect or of fr equ en cy ba n d edges t h a t a ppea r m on ot on ica lly bet ween 0 a n d 1, wh er e 1 is t h e Nyqu ist fr equ en cy. gf is a vect or of gr id poin t s t h a t h a ve been lin ea r ly in t er pola t ed over ea ch specified fr equ en cy ba n d by remez. gf det er m in es t h e fr equ en cy gr id a t
6-289
remez
wh ich t h e r espon se fu n ct ion m u st be eva lu a t ed, a n d con t a in s t h e sa m e da t a r et u r n ed by cremez in t h e fgrid field of t h e opt st r u ct u r e. w is a vect or of r ea l, posit ive weigh t s, on e per ba n d, u sed du r in g opt im iza t ion . w is opt ion a l in t h e ca ll t o remez; if n ot specified, it is set t o u n it y weigh t in g befor e bein g pa ssed t o 'fresp'. dh a n d dw a r e t h e desir ed com plex fr equ en cy r espon se a n d ba n d weigh t vect or s, r espect ively, eva lu a t ed a t ea ch fr equ en cy in gr id gf. Th e pr edefin ed fr equ en cy r espon se fu n ct ion (fresp) t h a t remez ca lls is remezfrf in t h e signal/private dir ect or y.
b = remez(n,f,{'fresp',p1,p2,...},w) a llows you t o specify a ddit ion a l pa r a m et er s (p1, p2, et c.) t o pa ss t o fresp. Not e t h a t b = remez(n,f,a,w) is a syn on ym for b = remez(n,f,{'remezfrf',a},w), wh er e a is a vect or con t a in in g t h e desir ed a m plit u des a t t h e poin t s specified in f. b = remez(n,f,'fresp',w,'ftype') a n d b = remez(n,f,{'fresp',p1,p2,...},w,'ftype') design a n t isym m et r ic (odd) r a t h er t h a n sym m et r ic (even ) filt er s, wh er e 'ftype' is eit h er 'd' for a differ en t ia t or or 'h' for a H ilber t t r a n sfor m er .
In t h e a bsen ce of a specifica t ion for ftype, a pr elim in a r y ca ll is m a de t o fresp t o det er m in e t h e defa u lt sym m et r y pr oper t y sym. Th is ca ll is m a de u sin g t h e syn t a x:
sym = fresp('defaults',{n,f,[],w,p1,p2,...})
Th e a r gu m en t s n, f, w, et c., m a y be u sed a s n ecessa r y in det er m in in g a n a ppr opr ia t e va lu e for sym, wh ich remez expect s t o be eit h er 'even' or 'odd'. If t h e fresp fu n ct ion does n ot su ppor t t h is ca llin g syn t a x, remez defa u lt s t o even sym m et r y.
[b,delta] = remez(...) r et u r n s t h e m a xim u m r ipple h eigh t in delta.
6-290
remez
F r equ en cy gr id vect or u sed for t h e filt er design opt im iza t ion Desir ed fr equ en cy r espon se for ea ch poin t in opt.fgrid Weigh t in g for ea ch poin t in opt.fgrid Act u a l fr equ en cy r espon se for ea ch poin t in opt.fgrid E r r or a t ea ch poin t in opt.fgrid (opt.desopt.H) Vect or of in dices in t o opt.fgrid for ext r em a l fr equ en cies Vect or of ext r em a l fr equ en cies
Example
Gr a ph t h e desir ed a n d a ct u a l fr equ en cy r espon ses of a 17t h -or der P a r ks-McClella n ba n dpa ss filt er :
f = [0 0.3 0.4 0.6 0.7 1]; a = [0 0 1 1 0 0]; b = remez(17,f,a); [h,w] = freqz(b,1,512); plot(f,a,w/pi,abs(h))
1.2
0.8
0.6
0.4
0.2
0 0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
6-291
remez
Algorithm
design a r bit r a r ily lon g filt er s wit h a r bit r a r ily m a n y lin ea r ba n ds.
remez design s t ype I, II, III, a n d IV lin ea r -ph a se filt er s. Type I a n d Type II a r e t h e defa u lt s for n even a n d n odd, r espect ively, wh ile Type III (n even ) a n d Type IV (n odd) a r e obt a in ed wit h t h e 'hilbert' a n d 'differentiator' fla gs.
Th e differ en t t ypes of filt er s h a ve differ en t sym m et r ies a n d cer t a in con st r a in t s on t h eir fr equ en cy r espon ses (see [5] for m or e det a ils).
Linear Phase Filter Type
Filter Order n
Symmetry of Coefficients
even : b (k ) = b (n + 2 k ), k = 1 , , n + 1 odd: b (k ) = b (n + 2 k ), k = 1 , , n + 1
Diagnostics
An a ppr opr ia t e dia gn ost ic m essa ge is displa yed if in cor r ect a r gu m en t s a r e u sed:
Filter order must be 3 or more. There should be one weight per band. Frequency and amplitude vectors must be the same length. The number of frequency points must be even. Frequencies must lie between 0 and 1. Frequencies must be specified in bands. Frequencies must be nondecreasing. Adjacent bands not allowed.
In t h e r a r e even t t h a t you see t h is m essa ge, it is possible t h a t t h e filt er design m a y st ill be cor r ect . Ver ify t h e design by ch eckin g it s fr equ en cy r espon se.
6-292
remez
See Also
butter cheby1 cheby2 cremez ellip fir1 fir2 fircls fircls1 firls firrcos remezord yulewalk
Bu t t er wor t h a n a log a n d digit a l filt er design . Ch ebysh ev t ype I filt er design (pa ssba n d r ipple). Ch ebysh ev t ype II filt er design (st opba n d r ipple). Com plex a n d n on lin ea r-ph a se equ ir ipple F IR filt er design . E llipt ic (Ca u er ) filt er design . Win dow-ba sed fin it e im pu lse r espon se filt er design st a n da r d r espon se. Win dow-ba sed fin it e im pu lse r espon se filt er design a r bit r a r y r espon se. Con st r a in ed lea st squ a r e F IR filt er design for m u lt iba n d filt er s. Con st r a in ed lea st squ a r e filt er design for lowpa ss a n d h igh pa ss lin ea r ph a se F IR filt er s. Lea st squ a r e lin ea r-ph a se F IR filt er design . Ra ised cosin e F IR filt er design . Pa r ks-McClella n opt im a l F IR filt er or der est im a t ion . Recu r sive digit a l filt er design .
References
[1] IE E E . Program s for Digital S ign al Processin g . IE E E P r ess. New Yor k: J oh n Wiley & Son s, 1979. Algor it h m 5.1. [2] IE E E . S elected Papers in Digital S ign al Processin g, II . IE E E P r ess. New Yor k : J oh n Wiley & Son s, 1979. [3] P a r ks, T.W., a n d C.S. Bu r r u s. Digital Filter Design . New Yor k: J oh n Wiley & Son s, 1987. P g. 83. [4] Ra bin er , L.R., J .H . McClella n , a n d T.W. P a r ks. F IR Digit a l F ilt er Design Tech n iqu es Usin g Weigh t ed Ch ebysh ev Appr oxim a t ion s. Proc. IE E E 63 (1975). [5] Oppen h eim , A.V., a n d R.W. Sch a fer . Discrete-T im e S ign al Processin g. E n glewood Cliffs, NJ : P r en t ice H a ll, 1989. P gs. 256-266.
6-293
remezord
Purpose Syntax
6rem ezor d
Description
f is a vect or of fr equ en cy ba n d edges (bet ween 0 a n d F s/2, wh er e F s is t h e sa m plin g fr equ en cy), a n d a is a vect or specifyin g t h e desir ed a m plit u de on t h e ba n ds defin ed by f. Th e len gt h of f is t wice t h e len gt h of a, m in u s 2. Th e desir ed fu n ct ion is piecewise con st a n t . dev is a vect or t h e sa m e size a s a t h a t specifies t h e m a xim u m a llowa ble devia t ion or r ipples bet ween t h e fr equ en cy r espon se a n d t h e desir ed a m plit u de of t h e ou t pu t filt er , for ea ch ba n d. Use remez wit h t h e r esu lt in g or der n, fr equ en cy vect or fo, a m plit u de r espon se vect or ao, a n d weigh t s w t o design t h e filt er b wh ich a ppr oxim a t ely m eet s t h e specifica t ion s given by remezord in pu t pa r a m et er s f, a, a n d dev:
b = remez(n,fo,ao,w) [n,fo,ao,w] = remezord(f,a,dev,Fs) specifies a sa m plin g fr equ en cy Fs. Fs defa u lt s t o 2 H z, im plyin g a Nyqu ist fr equ en cy of 1 H z. You ca n t h er efor e
specify ba n d edges sca led t o a pa r t icu la r a pplica t ion s sa m plin g fr equ en cy. In som e ca ses remezord u n der est im a t es t h e or der n. If t h e filt er does n ot m eet t h e specifica t ion s, t r y a h igh er or der su ch a s n+1 or n+2.
c = remezord(f,a,dev,Fs,'cell') specifies a cell-a r r a y wh ose elem en t s a r e
t h e pa r a m et er s t o remez.
Examples
Design a m in im u m -or der lowpa ss filt er wit h a 500 H z pa ssba n d cu t off fr equ en cy a n d 600 H z st opba n d cu t off fr equ en cy, wit h a sa m plin g fr equ en cy of
6-294
remezord
% compute deviations dev = [(10^(rp/20)1)/(10^(rp/20)+1) [n,fo,ao,w] = remezord(f,a,dev,Fs); b = remez(n,fo,ao,w); [h,f] = freqz(b,1,1024,Fs); plot(f,20*log10(abs(h)));
-10
Magnitude (dB)
-20
-30
-40
-50
-60 0
100
200
300
700
800
900
1000
Not e t h a t t h e filt er fa lls sligh t ly sh or t of m eet in g t h e st opba n d a t t en u a t ion a n d pa ssba n d r ipple specifica t ion s. Usin g n+1 in t h e ca ll t o remez in st ea d of n a ch ieves t h e desir ed a m plit u de ch a r a ct er ist ics.
6-295
remezord
Design a lowpa ss filt er wit h a 1500 H z pa ssba n d cu t off fr equ en cy a n d 2000 H z st opba n d cu t off fr equ en cy, wit h a sa m plin g fr equ en cy of 8000 H z, a m a xim u m st opba n d a m plit u de of 0.1, a n d a m a xim u m pa ssba n d er r or (r ipple) of 0.01:
[n,fo,ao,w] = remezord( [1500 2000], [1 0], [0.01 0.1], 8000 ); b = remez(n,fo,ao,w);
NOTE In som e ca ses, remezord u n der est im a t es or over est im a t es t h e or der n. If t h e filt er does n ot m eet t h e specifica t ion s, t r y a h igh er or der su ch a s n+1 or n+2. Resu lt s a r e in a ccu r a t e if t h e cu t off fr equ en cies a r e n ea r 0 or t h e Nyqu ist fr equ en cy.
Algorithm Diagnostics
remezord u ses t h e a lgor it h m su ggest ed in [1]. Th is m et h od is in a ccu r a t e for ba n d edges close t o eit h er 0 or t h e Nyqu ist fr equ en cy (Fs/2).
See Also
Bu t t er wor t h filt er or der select ion . Ch ebysh ev t ype I filt er or der select ion . Ch ebysh ev t ype II filt er or der select ion . E llipt ic filt er or der select ion . E st im a t e pa r a m et er s for a n F IR filt er design wit h Ka iser win dow. Pa r ks-McClella n opt im a l F IR filt er design .
6-296
remezord
References
[1] Ra bin er , L.R., a n d O. H er r m a n n . Th e P r edict a bilit y of Cer t a in Opt im u m F in it e Im pu lse Respon se Digit a l F ilt er s. IE E E T ran s. on Circu it T h eory . Vol. CT-20, No. 4 (J u ly 1973). P gs. 401-408. [2] Ra bin er , L.R., a n d B. Gold. T h eory an d Application of Digital S ign al Processin g. E n glewood Cliffs, NJ : P r en t ice H a ll, 1975. P gs. 156-157.
6-297
resample
Purpose Syntax
6resa m ple
Ch a n ge sa m plin g r a t e by a n y r a t ion a l fa ct or .
y = resample(x,p,q) y = resample(x,p,q,n) y = resample(x,p,q,n,beta) y = resample(x,p,q,b) [y,b] = resample(x,p,q) y = resample(x,p,q) r esa m ples t h e sequ en ce in vect or x a t p/q t im es t h e or igin a l sa m plin g r a t e, u sin g a polyph a se filt er im plem en t a t ion . Th e len gt h of y is equ a l t o ceil(length(x)*p/q). p a n d q m u st be posit ive in t eger s. If x is a m a t r ix, resample wor k s down t h e colu m n s of x. resample a pplies a n a n t i-a lia sin g (lowpa ss) F IR filt er t o x du r in g t h e r esa m plin g pr ocess. It design s t h e filt er u sin g firls wit h a Ka iser win dow. y = resample(x,p,q,n) u ses n t er m s on eit h er side of t h e cu r r en t sa m ple, x(k), t o per for m t h e r esa m plin g. Th e len gt h of t h e F IR filt er resample u ses is pr opor t ion a l t o n; la r ger va lu es of n pr ovide bet t er a ccu r a cy a t t h e expen se of m or e com pu t a t ion t im e. Th e defa u lt for n is 10. If you let n = 0, resample
Description
6-298
resample
Examples
0.5
!0.5 !0.5
0.5 Time
1.5
Not ice t h a t t h e la st few poin t s of t h e ou t pu t y a r e in a ccu r a t e. In it s filt er in g pr ocess, resample a ssu m es t h e sa m ples a t t im es befor e a n d a ft er t h e given sa m ples in x a r e equ a l t o zer o. Th u s la r ge devia t ion s fr om zer o a t t h e en d
6-299
resample
poin t s of t h e sequ en ce x ca n ca u se in a ccu r a cies in y a t it s en d poin t s. Th e followin g t wo plot s illu st r a t e t h is side effect of resample:
x = [1:10 9:1:1]; y = resample(x,3,2); subplot(2,1,1); plot(1:19,x,'*',(0:28)*2/3 + 1,y,'o'); title('Edge Effects Not Noticeable'); legend('original','resampled'); x = [10:1:1 2:10]; y = resample(x,3,2); subplot(2,1,2); plot(1:19,x,'*',(0:28)*2/3 + 1,y,'o') title('Edge Effects Very Noticeable'); legend('original','resampled');
Edge Effects Not Noticeable 10 8 6 4 2 0 0 15 5 10 Edge Effects Very Noticeable 15 20 original resampled
10
5 original resampled 0 0 5 10 15 20
Diagnostics
6-300
resample
See Also
Decr ea se t h e sa m plin g r a t e for a sequ en ce (decim a t ion ). Lea st squ a r e lin ea r-ph a se F IR filt er design . In cr ea se sa m plin g r a t e by a n in t eger fa ct or (in t er pola t ion ). On e-dim en sion a l da t a in t er pola t ion (t a ble looku p) (see t h e on lin e M AT L AB Fu n ction R eferen ce). In t er pola t ion F IR filt er design . Ka iser win dow. Cu bic splin e in t er pola t ion (see t h e on lin e M AT L A B Fu n ction R eferen ce). Upsa m ple, a pply a n F IR filt er, a n d down sa m ple.
6-301
residuez
Purpose Syntax Description
6residu ez
polyn om ia ls, t o pa r t ia l fr a ct ion expa n sion , or r esidu e, for m . It a lso con ver t s t h e pa r t ia l fr a ct ion expa n sion ba ck t o t h e or igin a l polyn om ia l coefficien t s.
[r,p,k] = residuez(b,a) fin ds t h e r esidu es, poles, a n d dir ect t er m s of a
pa r t ia l fr a ct ion expa n sion of t h e r a t io of t wo polyn om ia ls, b (z ) a n d a (z ). Vect or s b a n d a specify t h e coefficien t s of t h e polyn om ia ls of t h e discr et e-t im e syst em b (z )/ a (z ) in descen din g power s of z : b (z ) = b 0 + b 1 z 1 + b 2 z 2 + L + b m z m + a n z n a (z ) = a 0 + a 1 z 1 + a 2 z 2 + L If t h er e a r e n o m u lt iple r oot s a n d a > n1, b (z ) r (1 ) r (n ) - + k (1 ) + k (2 ) z 1 + L +L + ---------------------------+ k (m n + 1 ) z ( m --------- = --------------------------- 1 a (z ) 1 p (1 ) z 1 p (n ) z 1
n)
Th e r et u r n ed colu m n vect or r con t a in s t h e r esidu es, colu m n vect or p con t a in s t h e pole loca t ion s, a n d r ow vect or k con t a in s t h e dir ect t er m s. Th e n u m ber of poles is
n = length(a)1 = length(r) = length(p)
If p(j) = ... = p(j+s1) is a pole of m u lt iplicit y s, t h en t h e expa n sion in clu des t er m s of t h e for m r (j + s r 1 ) r (j + 1 ) r (j ) -------------------------- + ----------------------------------+L + ---------------------------------- 1 2 1 1 p (j ) z ( 1 p (j ) z ) ( 1 p (j ) z 1 ) s r
6-302
residuez
[b,a] = residuez(r,p,k) wit h t h r ee in pu t a r gu m en t s a n d t wo ou t pu t a r gu m en t s, con ver t s t h e pa r t ia l fr a ct ion expa n sion ba ck t o polyn om ia ls wit h coefficien t s in r ow vect or s b a n d a.
Th e residue fu n ct ion in t h e st a n da r d MATLAB la n gu a ge is ver y sim ila r t o residuez. It com pu t es t h e pa r t ia l fr a ct ion expa n sion of con t in u ou s-t im e syst em s in t h e La pla ce dom a in (see r efer en ce [1]), r a t h er t h a n discr et e-t im e syst em s in t h e z -dom a in a s does residuez.
Algorithm
residuez a pplies st a n da r d MATLAB fu n ct ion s a n d pa r t ia l fr a ct ion t ech n iqu es t o fin d r, p, a n d k fr om b a n d a. It fin ds:
1 Th e dir ect t er m s a u sin g deconv (polyn om ia l lon g division ) wh en
length(b)>length(a)1.
2 Th e poles u sin g p = roots(a). mpoles fin ds r epea t ed poles a n d r eor der s t h e
for r2 u sin g \. h is t h e im pu lse r espon se of t h e r edu ced b (z )/ a (z ), S1 is a m a t r ix wh ose colu m n s a r e im pu lse r espon ses of t h e fir st -or der syst em s m a de u p of t h e n on r epea t in g r oot s, a n d r1 is a colu m n con t a in in g t h e r esidu es for t h e n on r epea t in g r oot s. E a ch colu m n of m a t r ix S2 is a n im pu lse r espon se. F or ea ch r oot p j of m u lt iplicit y s j, S2 con t a in s s j colu m n s r epr esen t in g t h e im pu lse r espon ses of ea ch of t h e followin g syst em s: 1 1 1 -, L ----------------------, -----------------------------, ------------------------------1 p jz 1 ( 1 p jz 1 ) 2 ( 1 p jz 1 ) s j Th e vect or h a n d m a t r ices S1 a n d S2 h a ve n + xtra r ows, wh er e n is t h e t ot a l n u m ber of r oot s a n d t h e in t er n a l pa r a m et er xtra, set t o 1 by defa u lt , det er m in es t h e degr ee of over det er m in a t ion of t h e syst em of equ a t ion s.
Diagnostics
If a(1) == 0 wh ile com pu t in g t h e pa r t ia l fr a ct ion decom posit ion u sin g [r,p,k] = residuez(b,a), residuez gives t h e followin g er r or m essa ge:
First coefficient in A vector must be nonzero.
6-303
residuez
If t h e n u m ber of r esidu es r a n d poles p is n ot t h e sa m e, residuez gives t h e followin g er r or m essa ge:
R and P vectors must be the same size.
See Also
convmtx deconv poly prony residue roots ss2tf tf2ss tf2zp zp2ss
Con volu t ion m a t r ix. Decon volu t ion a n d polyn om ia l division (see t h e on lin e M AT L AB Fu n ction R eferen ce). Polyn om ia l wit h specified r oot s (see t h e on lin e M A T L AB Fu n ction R eferen ce). P r on ys m et h od for t im e dom a in IIR filt er design . Pa r t ia l fr a ct ion expa n sion (see t h e on lin e M AT L A B Fu n ction R eferen ce). Polyn om ia l r oot s (see t h e on lin e M AT L AB Fu n ction R eferen ce). Con ver sion of st a t e-spa ce t o zer o-pole-ga in . Con ver sion of t r a n sfer fu n ct ion t o st a t e-spa ce. Con ver sion of t r a n sfer fu n ct ion t o zer o-pole-ga in . Con ver sion of zer o-pole-ga in t o st a t e-spa ce.
References
[1] Oppen h eim , A.V., a n d R.W. Sch a fer . Digital S ign al Processin g . E n glewood Cliffs, NJ : P r en t ice H a ll, 1975. P gs. 166-170.
6-304
rlevinson
Purpose Syntax
6rlevin son
Description
Th e r ever se Levin son -Du r bin r ecu r sion im plem en t s t h e st ep-down a lgor it h m for solvin g t h e followin g sym m et r ic Toeplit z syst em of lin ea r equ a t ion s for r , wh er e r = [r (1) ... r (p+1)] a n d r (i )* den ot es t h e com plex con ju ga t e of r (i ). r (1 ) r (2 )
)
r (p )
) )
r (2 ) r (1 ) L r (p 1 ) M O O M r (p ) L r (2 ) r (1 )
a (2 ) r (2 ) a (3 ) r (3 ) = M M a (p + 1 ) r (p + 1 )
r = rlevinson(a,efinal) solves t h e a bove syst em of equ a t ion s for r given vect or a, wh er e a = [1 a (2) ... a (p +1)]. In lin ea r pr edict ion a pplica t ion s, r r epr esen t s t h e a u t ocor r ela t ion sequ en ce of t h e in pu t t o t h e pr edict ion er r or filt er , wh er e r(1) is t h e zer o-la g elem en t . Th e figu r e below sh ows t h e t ypica l filt er of t h is t ype, wh er e H (z ) is t h e opt im a l lin ea r pr edict or , x (n ) is t h e in pu t ( n ) is t h e pr edict ed sign a l, a n d e(n ) is t h e pr edict ion er r or . sign a l, x Prediction Error Filter
x (n )
H (z ) =
a ( 2 ) z
a ( 3 ) z
L a ( n + 1 ) z
(n ) x
e(n )
+
A (z ) In pu t vect or a r epr esen t s t h e polyn om ia l coefficien t s of t h is pr edict ion er r or filt er in descen din g power s of z + a (n + 1 ) z p A (z ) = 1 + a (2 ) z 1 + L
6-305
rlevinson
Th e filt er m u st be m in im u m ph a se t o gen er a t e a va lid a u t ocor r ela t ion sequ en ce. efinal is t h e sca la r pr edict ion er r or power , wh ich is equ a l t o t h e va r ia n ce of t h e pr edict ion er r or sign a l, E2 (e).
[r,u] = rlevinson(a,efinal) r et u r n s u pper t r ia n gu la r m a t r ix U fr om t h e
= UE
wh er e r (1 ) r (2 )
)
r (p )
) )
R = r (2 ) r (1 ) L r (p 1 ) M O O M r (p ) L r (2 ) r (1 )
a n d E is a dia gon a l m a t r ix wit h elem en t s r et u r n ed in ou t pu t e (see below). Th is decom posit ion per m it s t h e efficien t eva lu a t ion of t h e in ver se of t h e a u t ocor r ela t ion m a t r ix, R -1 . Ou t pu t m a t r ix u con t a in s t h e pr edict ion polyn om ia l, a, fr om ea ch it er a t ion of t h e r ever se Levin son -Du r bin r ecu r sion a 1 ( 1 ) a 2 ( 2 ) La p + 1 ( p + 1 ) 0 U = 0 M 0 a 2 (1 ) O a p + 1 (p ) 0 O L O 0 M a p + 1 (1 )
) ) ) ) ) ) )
Oa p + 1 ( p 1 )
wh er e a i (j ) is t h e j t h coefficien t of t h e i t h or der pr edict ion polyn om ia l (i.e., st ep i in t h e r ecu r sion ). F or exa m ple, t h e 5t h or der pr edict ion polyn om ia l is
a5 = u(5:-1:1,5)'
6-306
rlevinson
[r,u,k] = rlevinson(a,efinal) r et u r n s a vect or k of len gt h (p +1) con t a in in g t h e r eflect ion coefficien t s. Th e r eflect ion coefficien t s a r e t h e con ju ga t es of t h e va lu es in t h e fir st r ow of u k = conj(u(1,2:end)) [r,u,k,e] = rlevinson(a,efinal) r et u r n s a vect or of len gt h (p +1) con t a in in g t h e pr edict ion er r or s fr om ea ch it er a t ion of t h e r ever se Levin son -Du r bin r ecu r sion : e(1) is t h e pr edict ion er r or fr om t h e fir st -or der m odel, e(2) is t h e pr edict ion er r or fr om t h e secon d-or der m odel, a n d so on .
Th ese pr edict ion er r or va lu es for m t h e dia gon a l of t h e m a t r ix E in t h e UDU * decom posit ion of R -1 , R
1
= UE
U . Levin son -Du r bin r ecu r sion . Lin ea r pr edict ion coefficien t s. P r on ys m et h od for t im e dom a in IIR filt er design . Lin ea r m odel u sin g St eiglit z-McBr ide it er a t ion .
See Also
References
[1] Ka y, S.M. M od ern S pectral E stim ation : T h eory an d Application . E n glewood Cliffs, NJ : P r en t ice H a ll, 1988.
6-307
sawtooth
Purpose Syntax Description
6sa wt oot h
wit h pea k s of -1 a n d 1 in st ea d of a sin e wa ve. Th e sa wt oot h wa ve is defin ed t o be -1 a t m u lt iples of 2 $ a n d t o in cr ea se lin ea r ly wit h t im e wit h a slope of 1/$ a t a ll ot h er t im es.
sawtooth(t,width) gen er a t es a m odified t r ia n gle wa ve wh er e width, a sca la r pa r a m et er bet ween 0 a n d 1, det er m in es t h e fr a ct ion bet ween 0 a n d 2 $ a t wh ich t h e m a xim u m occu r s. Th e fu n ct ion in cr ea ses fr om -1 t o 1 on t h e in t er va l 0 t o 2 $*width, t h en decr ea ses lin ea r ly fr om 1 t o -1 on t h e in t er va l 2 $*width t o 2 $. Th u s a pa r a m et er of 0.5 specifies a st a n da r d t r ia n gle wa ve, sym m et r ic a bou t t im e in st a n t $ wit h pea k -t o-pea k a m plit u de of 1. sawtooth(t,1) is equ iva len t t o sawtooth(t).
Diagnostics
See Also
chirp cos diric gauspuls pulstran rectpuls sin sinc square tripuls
Swept -fr equ en cy cosin e gen er a t or. Cosin e of vect or /m a t r ix elem en t s (see t h e on lin e M A T L AB Fu n ction R eferen ce). Dir ich let or per iodic sin c fu n ct ion . Ga u ssia n -m odu la t ed sin u soida l pu lse gen er a t or. P u lse t r a in gen er a t or. Sa m pled a per iodic r ect a n gle gen er a t or. Sin e of vect or /m a t r ix elem en t s (see t h e on lin e M A T L AB Fu n ction R eferen ce). Sin c or sin ($t )/$t fu n ct ion . Squ a r e wa ve gen er a t or. Sa m pled a per iodic t r ia n gle gen er a t or.
6-308
sgolay
Purpose Syntax Description
6sgola y
m a t r ix wh ose r ows r epr esen t t h e t im e-va r yin g F IR filt er coefficien t s. In a sm oot h in g filt er im plem en t a t ion (for exa m ple, sgolayfilt), t h e la st (f1)/2 r ows (ea ch a n F IR filt er ) a r e a pplied t o t h e sign a l du r in g t h e st a r t u p t r a n sien t , a n d t h e fir st (f1)/2 r ows a r e a pplied t o t h e sign a l du r in g t h e t er m in a l t r a n sien t . Th e cen t er r ow is a pplied t o t h e sign a l in t h e st ea dy st a t e.
b = sgolay(k,f,w) specifies a weigh t in g vect or w wit h len gt h f, wh ich con t a in s t h e r ea l, posit ive-va lu ed weigh t s t o be u sed du r in g t h e lea st -squ a r es m in im iza t ion .
Remarks
Sa vit zk y-Gola y sm oot h in g filt er s (a lso ca lled digit a l sm oot h in g polyn om ia l filt er s or lea st squ a r es sm oot h in g filt er s) a r e t ypica lly u sed t o sm oot h ou t a n oisy sign a l wh ose fr equ en cy spa n (wit h ou t n oise) is la r ge. In t h is t ype of a pplica t ion , Sa vit zk y-Gola y sm oot h in g filt er s per for m m u ch bet t er t h a n st a n da r d a ver a gin g F IR filt er s, wh ich t en d t o filt er ou t a sign ifica n t por t ion of t h e sign a ls h igh fr equ en cy con t en t a lon g wit h t h e n oise. Alt h ou gh Sa vit zk y-Gola y filt er s a r e m or e effect ive a t pr eser vin g t h e per t in en t h igh fr equ en cy com pon en t s of t h e sign a l, t h ey a r e less su ccessfu l t h a n st a n da r d a ver a gin g F IR filt er s a t r eject in g n oise. Sa vit zk y-Gola y filt er s a r e opt im a l in t h e sen se t h a t t h ey m in im ize t h e lea st -squ a r es er r or in fit t in g a polyn om ia l t o ea ch fr a m e of n oisy da t a .
See Also
Win dow-ba sed fin it e im pu lse r espon se filt er design st a n da r d r espon se. Lea st squ a r e lin ea r-ph a se F IR filt er design . F ilt er da t a wit h a r ecu r sive (IIR) or n on r ecu r sive (F IR) filt er. Savit zky-Gola y filt er in g.
6-309
sgolay
References
[1] Or fa n idis, S.J . In trod u ction to S ign al Processin g . E n glewood Cliffs, NJ : P r en t ice H a ll, 1996.
6-310
sgolayfilt
Purpose Syntax Description
6sgola yfilt
Remarks
Sa vit zk y-Gola y sm oot h in g filt er s (a lso ca lled digit a l sm oot h in g polyn om ia l filt er s or lea st -squ a r es sm oot h in g filt er s) a r e t ypica lly u sed t o sm oot h ou t a n oisy sign a l wh ose fr equ en cy spa n (wit h ou t n oise) is la r ge. In t h is t ype of a pplica t ion , Sa vit zk y-Gola y sm oot h in g filt er s per for m m u ch bet t er t h a n st a n da r d a ver a gin g F IR filt er s, wh ich t en d t o filt er ou t a sign ifica n t por t ion of t h e sign a ls h igh fr equ en cy con t en t a lon g wit h t h e n oise. Alt h ou gh Sa vit zk y-Gola y filt er s a r e m or e effect ive a t pr eser vin g t h e per t in en t h igh fr equ en cy com pon en t s of t h e sign a l, t h ey a r e less su ccessfu l t h a n st a n da r d a ver a gin g F IR filt er s a t r eject in g n oise. Sa vit zk y-Gola y filt er s a r e opt im a l in t h e sen se t h a t t h ey m in im ize t h e lea st -squ a r es er r or in fit t in g a polyn om ia l t o fr a m es of n oisy da t a .
6-311
sgolayfilt
Example
Sm oot h t h e mtlb sign a l by a pplyin g a cu bic Sa vit zk y-Gola y filt er t o da t a fr a m es of len gt h 41.
load mtlb % load the data smtlb = sgolayfilt(mtlb,3,41); % apply the 3rd-order filter subplot(2,1,1) plot([1:2000],mtlb(1:2000)); axis([0 2000 4 4]); title('mtlb'); grid; subplot(2,1,2) plot([1:2000],smtlb(1:2000)); axis([0 2000 4 4]); title('smtlb'); grid;
mtlb 4 2 0 !2 !4 0 4 2 0 !2 !4 0 500 1000 1500 2000 500 1000 smtlb 1500 2000
See Also
On e-dim en sion a l m edia n filt er in g. F ilt er da t a wit h a r ecu r sive (IIR) or n on r ecu r sive (F IR) filt er. Savit zky-Gola y filt er design . Secon d-or der (biqu a dr a t ic) IIR filt er in g.
References
[1] Or fa n idis, S.J . In trod u ction to S ign al Processin g . E n glewood Cliffs, NJ : P r en t ice H a ll, 1996.
6-312
sinc
Purpose Syntax Description
6sin c
Sin c fu n ct ion .
y = sinc(x) sinc com pu t es t h e sin c fu n ct ion of a n in pu t vect or or a r r a y, wh er e t h e sin c
Th is fu n ct ion is t h e con t in u ou s in ver se F ou r ier t r a n sfor m of t h e r ect a n gu la r pu lse of widt h 2 $ a n d h eigh t 1: 1 sin c(t ) = -----2$
6 $ e j # t d #
Th e spa ce of fu n ct ion s ba n dlim it ed in t h e fr equ en cy ba n d # F [ $,$] is spa n n ed by t h e in fin it e (yet cou n t a ble) set of sin c fu n ct ion s sh ift ed by in t eger s. Th u s a n y su ch ba n dlim it ed fu n ct ion g (t ) ca n be r econ st r u ct ed fr om it s sa m ples a t in t eger spa cin gs:
*
g (t ) =
+
n = *
6-313
sinc
Example
P er for m idea l ba n dlim it ed in t er pola t ion by a ssu m in g t h a t t h e sign a l t o be in t er pola t ed is 0 ou t side of t h e given t im e in t er va l a n d t h a t it h a s been sa m pled a t exa ct ly t h e Nyqu ist fr equ en cy:
t = (1:10)'; % a column vector of time samples randn('seed',0); x = randn(size(t)); % a column vector of data % ts is times at which to interpolate data ts = linspace(5,15,600)'; y = sinc(ts(:,ones(size(t))) t(:,ones(size(ts)))')*x; plot(t,x,'o',ts,y)
2
1.5
0.5
-0.5
-1 -5
10
15
6-314
sinc
See Also
chirp cos diric gauspuls pulstran rectpuls sawtooth sin square tripuls
Swept -fr equ en cy cosin e gen er a t or. Cosin e of vect or /m a t r ix elem en t s (see t h e on lin e M AT L AB Fu n ction R eferen ce). Dir ich let or per iodic sin c fu n ct ion . Ga u ssia n -m odu la t ed sin u soida l pu lse gen er a t or. P u lse t r a in gen er a t or. Sa m pled a per iodic r ect a n gle gen er a t or. Sawt oot h or t r ia n gle wave gen er a t or. Sin e of vect or /m a t r ix elem en t s (see t h e on lin e M AT L AB Fu n ction R eferen ce). Squ a r e wa ve gen er a t or. Sa m pled a per iodic t r ia n gle gen er a t or.
6-315
sos2ss
Purpose Syntax Description
6sos2ss
Con ver sion of secon d-or der sect ion s t o st a t e-spa ce.
[A,B,C,D] = sos2ss(sos) [A,B,C,D] = sos2ss(sos,g) sos2ss con ver t s a secon d-or der sect ion r epr esen t a t ion of a given syst em t o a n
x [n + 1 ] = A x [n ] + B u [n ] y [n ] = C x [n ] + D u [n ] Th e discr et e t r a n sfer fu n ct ion in secon d-or der sect ion for m is given by
L L
H (z ) =
0 H k (z )
k =1
0 --------------------------------------------------------1 + a z 1 + a z 2
k =1 1k 2k
b 0 k + b 1 k z 1 + b 2 k z 2
Th e en t r ies of sos m u st be r ea l for pr oper con ver sion t o st a t e spa ce. Th e r et u r n ed m a t r ix A is size N -by-N , wh er e N = 2 L -1, B is a len gt h N -1 colu m n vect or , C is a len gt h N -1 r ow vect or , a n d D is a sca la r .
[A,B,C,D] = sos2ss(sos,g) con ver t s t h e syst em sos in secon d-or der sect ion
for m wit h ga in g:
L
H (z ) = g
0 H k (z )
k =1
6-316
sos2ss
Example
Com pu t e t h e st a t e-spa ce r epr esen t a t ion of a sim ple secon d-or der sect ion syst em wit h a ga in of 2:
sos = [1 1 1 1 0 1; 2 [A,B,C,D] = sos2ss(sos) A = 10 1 0 0 B = 1 0 0 0 C = 21 D = 2 2 16 1 0 0 1 0 10 0 0 1 1 0 0 0 3 1 1 10 1];
sos2ss fir st con ver t s fr om secon d-or der sect ion s t o t r a n sfer fu n ct ion u sin g sos2tf, a n d t h en fr om t r a n sfer fu n ct ion t o st a t e-spa ce u sin g tf2ss. sos2tf sos2zp ss2sos tf2ss zp2ss
Con ver sion of secon d-or der sect ion s t o t r a n sfer fu n ct ion . Con ver sion of secon d-or der sect ion s t o zer o-pole-ga in . Con ver sion of st a t e-spa ce t o secon d-or der sect ion s. Con ver sion of t r a n sfer fu n ct ion t o st a t e-spa ce. Con ver sion of zer o-pole-ga in t o st a t e-spa ce.
6-317
sos2tf
Purpose Syntax Description
6sos2t f
Con ver sion of secon d-or der sect ion s t o t r a n sfer fu n ct ion .
[b,a] = sos2tf(sos) [b,a] = sos2tf(sos,g) sos2tf con ver t s a secon d-or der sect ion r epr esen t a t ion of a given syst em t o a n
H (z ) =
0
k =1
H k (z ) =
0
k =1
b 0 k + b 1 k z 1 + b 2 k z 2 --------------------------------------------------------1 + a 1 k z 1 + a 2 k z 2
sos is a n L -by-6 m a t r ix t h a t con t a in s t h e coefficien t s of ea ch secon d-or der sect ion st or ed in it s r ows:
Row vect or s b a n d a con t a in t h e n u m er a t or a n d den om in a t or coefficien t s of H (z ) st or ed in descen din g power s of z : b 1 + b 2 z 1 + L + b n + 1 z n B (z ) H (z ) = ---------- = -------------------------------------------------------------------A (z ) + a m + 1 z m a 1 + a 2 z 1 + L
[b,a] = sos2tf(sos,g) r et u r n s t h e t r a n sfer fu n ct ion t h a t descr ibes a discr et e-t im e syst em given by sos in secon d-or der sect ion for m wit h ga in g:
L
H (z ) = g
0 H k (z )
k =1
6-318
sos2tf
Algorithm Example
sos2tf u ses t h e conv fu n ct ion t o m u lt iply a ll of t h e n u m er a t or a n d den om in a t or secon d-or der polyn om ia ls t oget h er .
Com pu t e t h e t r a n sfer fu n ct ion r epr esen t a t ion of a sim ple secon d-or der sect ion syst em :
sos = [1 1 1 1 0 1; 2 [b,a] = sos2tf(sos) b = 2 a = 1 10 0 10 1 1 2 4 3 1 1 10 1];
See Also
La t t ice filt er t o t r a n sfer fu n ct ion con ver sion . Con ver sion of secon d-or der sect ion s t o st a t e-spa ce. Con ver sion of secon d-or der sect ion s t o zer o-pole-ga in . Con ver sion of st a t e-spa ce t o t r a n sfer fu n ct ion . Con ver sion of t r a n sfer fu n ct ion t o secon d-or der sect ion s. Con ver sion of zer o-pole-ga in t o t r a n sfer fu n ct ion .
6-319
sos2zp
Purpose Syntax Description
6sos2zp
Con ver sion of secon d-or der sect ion s t o zer o-pole-ga in .
[z,p,k] = sos2zp(sos) [z,p,k] = sos2zp(sos,g) sos2zp con ver t s a secon d-or der sect ion r epr esen t a t ion of a given syst em t o a n
H (z ) =
0
k =1
H k (z ) =
0
k =1
b 0 k + b 1 k z 1 + b 2 k z 2 --------------------------------------------------------1 + a 1 k z 1 + a 2 k z 2
sos is a n L -by-6 m a t r ix t h a t con t a in s t h e coefficien t s of ea ch secon d-or der sect ion st or ed in it s r ows:
Colu m n vect or s z a n d p con t a in t h e zer os a n d poles of t h e t r a n sfer fu n ct ion H (z ): (z z 1 )(z z 2 )L (z z n ) H (z ) = k -----------------------------------------------------------------(p p 1 )(p p 2 )L (p p m ) wh er e t h e or der s n a n d m a r e det er m in ed by t h e m a t r ix sos.
[z,p,k] = sos2zp(sos,g) r et u r n s t h e zer os z, poles p, a n d ga in k of t h e syst em given by sos in secon d-or der sect ion for m wit h ga in g:
L
H (z ) = g
0 H k (z )
k =1
6-320
sos2zp
Example
Com pu t e t h e poles, zer os, a n d ga in of a sim ple syst em in secon d-or der sect ion for m :
sos = [1 1 1 1 0 1; 2 [z,p,k] = sos2zp(sos) z = 0.5000 + 0.8660i 0.5000 0.8660i 1.7808 0.2808 p = 1.0000 1.0000 9.8990 0.1010 k 2 3 1 1 10 1];
sos2zp fin ds t h e poles a n d zer os of ea ch secon d-or der sect ion by r epea t edly ca llin g tf2zp. sos2ss sos2tf ss2zp tf2zp zp2sos
Con ver sion of secon d-or der sect ion s t o st a t e-spa ce. Con ver sion of secon d-or der sect ion s t o t r a n sfer fu n ct ion . Con ver sion of st a t e-spa ce t o zer o-pole-ga in . Con ver sion of t r a n sfer fu n ct ion t o zer o-pole-ga in . Con ver sion of zer o-pole-ga in t o secon d-or der sect ion s.
6-321
sosfilt
Purpose Syntax Description
6sosfilt
H (z ) =
0 H k (z )
k =1
0
k =1
b 0 k + b 1 k z 1 + b 2 k z 2 --------------------------------------------------------1 + a 1 k z 1 + a 2 k z 2
by a n L -by-6 m a t r ix con t a in in g t h e coefficien t s of ea ch secon d-or der sect ion in it s r ows b 01 b 11 b 21 1 a 11 a 21 s os = b 02 b 12 b 22 1 a 12 a 22 M M M M M M b0L b1 L b2L 1 a1L a2L
If x is a m a t r ix, sosfilt a pplies t h e filt er t o ea ch colu m n of x in depen den t ly. Ou t pu t y is a m a t r ix of t h e sa m e size, con t a in in g t h e filt er ed da t a cor r espon din g t o ea ch colu m n of x.
See Also
F ilt er da t a wit h a r ecu r sive (IIR) or n on r ecu r sive (F IR) filt er. On e-dim en sion a l m edia n filt er in g. Savit zky-Gola y filt er in g.
References
[1] Or fa n idis, S.J . In trod u ction to S ign al Processin g . E n glewood Cliffs, NJ : P r en t ice H a ll, 1996.
6-322
specgram
Purpose Syntax
6specgr a m
Description
a r gu m en t s t h a t you om it fr om t h e en d of t h e in pu t pa r a m et er list u se t h e defa u lt va lu es sh own a bove. If a is r ea l, specgram com pu t es t h e discr et e-t im e F ou r ier t r a n sfor m a t posit ive fr equ en cies on ly. If n is even , specgram r et u r n s nfft/2+1 r ows (in clu din g t h e zer o a n d Nyqu ist fr equ en cy t er m s). If n is odd, specgram r et u r n s nfft/2 r ows. Th e n u m ber of colu m n s in B is
k = fix((nnoverlap)/(length(window)noverlap))
If a is com plex, specgram com pu t es t h e discr et e-t im e F ou r ier t r a n sfor m a t bot h posit ive a n d n ega t ive fr equ en cies. In t h is ca se, B is a com plex m a t r ix wit h nfft
6-323
specgram
r ows. Tim e in cr ea ses lin ea r ly a cr oss t h e colu m n s of B, st a r t in g wit h sa m ple 1 in colu m n 1. F r equ en cy in cr ea ses lin ea r ly down t h e r ows, st a r t in g a t 0.
B = specgram(a,nfft) u ses t h e specified F F T len gt h nfft in it s ca lcu la t ion s. Specify nfft a s a power of 2 for fa st est execu t ion . [B,f] = specgram(a,nfft,Fs) r et u r n s a vect or f of fr equ en cies a t wh ich t h e fu n ct ion com pu t es t h e discr et e-t im e F ou r ier t r a n sfor m . Fs h a s n o effect on t h e ou t pu t B; it is a fr equ en cy sca lin g m u lt iplier . [B,f,t] = specgram(a,nfft,Fs) r et u r n s fr equ en cy a n d t im e vect or s f a n d t r espect ively. t is a colu m n vect or of sca led t im es, wit h len gt h equ a l t o t h e n u m ber of colu m n s of B. t(j) is t h e ea r liest t im e a t wh ich t h e j -t h win dow in t er sect s a. t(1) is a lwa ys equ a l t o 0. B = specgram(a,nfft,Fs,window) specifies a win dowin g fu n ct ion a n d t h e n u m ber of sa m ples per sect ion of t h e x vect or . If you su pply a sca la r for window, specgram u ses a H a n n in g win dow of t h a t len gt h . Th e len gt h of t h e win dow m u st be less t h a n or equ a l t o nfft; specgram zer o pa ds t h e sect ion s if t h e len gt h of t h e win dow exceeds nfft. B = specgram(a,nfft,Fs,window,noverlap) over la ps t h e sect ion s of x by noverlap sa m ples.
6-324
specgram
Th e axis xy m ode displa ys t h e low-fr equ en cy con t en t of t h e fir st por t ion of t h e sign a l in t h e lower -left cor n er of t h e a xes. specgram u ses Fs t o la bel t h e a xes a ccor din g t o t r u e t im e a n d fr equ en cy.
B = specgram(a,f,Fs,window,noverlap) com pu t es t h e spect r ogr a m a t t h e fr equ en cies specified in f, u sin g eit h er t h e ch ir p z -t r a n sfor m (for m or e t h a n 20 even ly spa ced fr equ en cies) or a polyph a se decim a t ion filt er ba n k. f is a vect or of fr equ en cies in H er t z; it m u st h a ve a t lea st t wo elem en t s.
Algorithm
len gt h nfft F F T t o pr odu ce a n est im a t e of t h e sh or t -t er m fr equ en cy con t en t of t h e sign a l; t h ese t r a n sfor m s m a k e u p t h e colu m n s of B. specgram zer o pa ds t h e win dowed sect ion s if nfft > length(window), so t h e qu a n t it y (length(window) noverlap) specifies by h ow m a n y sa m ples specgram sh ift s t h e win dow.
3 F or r ea l in pu t , specgram t r u n ca t es t h e spect r ogr a m t o t h e fir st nfft/2 + 1
6-325
specgram
Example
3000
2500
Frequency
2000
1500
1000
500
0 0
0.05
0.1
0.15
0.2
0.25 Time
0.3
0.35
0.4
0.45
Diagnostics
An a ppr opr ia t e dia gn ost ic m essa ge is displa yed wh en in cor r ect a r gu m en t s a r e u sed:
Requires Requires Requires Requires window's length to be no greater than the FFT length. NOVERLAP to be strictly less than the window length. positive integer values for NFFT and NOVERLAP. vector input.
See Also
E st im a t e m a gn it u de squ a r ed coh er en ce fu n ct ion bet ween t wo sign a ls. E st im a t e t h e cr oss spect r a l den sit y (CSD) of t wo sign a ls. E st im a t e t h e power spect r a l den sit y (P SD) of a sign a l u sin g Welch s m et h od. Tr a n sfer fu n ct ion est im a t e fr om in pu t a n d ou t pu t .
6-326
specgram
References
[1] Oppen h eim , A.V., a n d R.W. Sch a fer . Discrete-T im e S ign al Processin g. E n glewood Cliffs, NJ : P r en t ice H a ll, 1989. P gs. 713-718. [2] Ra bin er , L.R., a n d R.W. Sch a fer . Digital Processin g of S peech S ign als . E n glewood Cliffs, NJ : P r en t ice H a ll, 1978.
6-327
sptool
Purpose Syntax Description
6spt ool
Th e sptool com m a n d in vok es a su it e of gr a ph ica l u ser in t er fa ce (GUI) t ools t h a t pr ovides a ccess t o m a n y of t h e sign a l, filt er , a n d spect r a l a n a lysis fu n ct ion s in t h e t oolbox in a power fu l, ea sy-t o-u se in t er a ct ive sign a l displa y a n d explor a t ion en vir on m en t . Usin g SP Tool, you ca n im por t , expor t , a n d m a n a ge sign a ls, filt er s, a n d spect r a . F r om SP Tool, you ca n a ct iva t e it s fou r in t egr a t ed sign a l pr ocessin g t ools: Th e S ign al B row ser , for viewin g, m ea su r in g, a n d a n a lyzin g t h e t im e-dom a in in for m a t ion of on e or m or e sign a ls.
6-328
sptool
Th e Filter Design er , for design in g a n d edit in g F IR a n d IIR filt er s of va r iou s len gt h s a n d t ypes, wit h st a n da r d (lowpa ss, h igh pa ss, ba n dpa ss, ba n dst op, a n d m u lt iba n d) con figu r a t ion s.
6-329
sptool
Th e Filter View er , for viewin g t h e ch a r a ct er ist ics of a design ed or im por t ed filt er , in clu din g it s m a gn it u de r espon se, ph a se r espon se, gr ou p dela y, pole-zer o plot , im pu lse r espon se, a n d st ep r espon se.
6-330
sptool
Th e S pectru m V iew er , for gr a ph ica l a n a lysis of fr equ en cy-dom a in da t a u sin g a va r iet y of m et h ods of spect r a l den sit y est im a t ion , in clu din g t h e Bu r g m et h od, t h e F F T m et h od, t h e m u lt it a per m et h od (MTM), t h e MUSIC eigen vect or m et h od, Welch s m et h od, a n d t h e Yu le-Wa lk er AR m et h od.
6-331
square
Purpose Syntax Description
6squ a re
Squ a r e wa ve gen er a t or .
x = square(t) x = square(t,duty) x = square(t) gen er a t es a squ a r e wa ve wit h per iod 2 $ for t h e elem en t s of t im e vect or t. square(t) is sim ila r t o sin(t), bu t it cr ea t es a squ a r e wa ve wit h
See Also
chirp cos diric gauspuls pulstran rectpuls sawtooth sin sinc tripuls
Swept -fr equ en cy cosin e gen er a t or. Cosin e of vect or /m a t r ix elem en t s (see t h e on lin e M A T L AB Fu n ction R eferen ce). Dir ich let or per iodic sin c fu n ct ion . Ga u ssia n -m odu la t ed sin u soida l pu lse gen er a t or. P u lse t r a in gen er a t or. Sa m pled a per iodic r ect a n gle gen er a t or. Sawt oot h or t r ia n gle wave gen er a t or. Sin e of vect or /m a t r ix elem en t s (see t h e on lin e M A T L AB Fu n ction R eferen ce). Sin c or sin ($t )/$t fu n ct ion . Sa m pled a per iodic t r ia n gle gen er a t or.
6-332
ss2sos
Purpose Syntax
6ss2sos
Description
equ iva len t secon d-or der sect ion r epr esen t a t ion .
[sos,g] = ss2sos(A,B,C,D) fin ds a m a t r ix sos in secon d-or der sect ion for m wit h ga in g t h a t is equ iva len t t o t h e st a t e-spa ce syst em r epr esen t ed by in pu t a r gu m en t s A, B, C a n d D. Th e in pu t syst em m u st be sin gle ou t pu t a n d r ea l. sos is a n L -by-6 m a t r ix
wh ose r ows con t a in t h e n u m er a t or a n d den om in a t or coefficien t s b ik a n d a ik of t h e secon d-or der sect ion s of H (z ):
L L
H (z ) = g
0
k =1
H k (z ) = g
0
k =1
b 0 k + b 1 k z 1 + b 2 k z 2 --------------------------------------------------------1 + a 1 k z 1 + a 2 k z 2
[sos,g] = ss2sos(A,B,C,D,iu) specifies a sca la r iu t h a t det er m in es wh ich in pu t of t h e st a t e-spa ce syst em A, B, C, D is u sed in t h e con ver sion . Th e defa u lt for iu is 1. [sos,g] = ss2sos(A,B,C,D,'order') a n d [sos,g] = ss2sos(A,B,C,D,iu,'order') specify t h e or der of t h e r ows in sos,
wh er e order is:
6-333
ss2sos
down, t o or der t h e sect ion s so t h e fir st r ow of sos con t a in s t h e poles closest t o t h e u n it cir cle up, t o or der t h e sect ion s so t h e fir st r ow of sos con t a in s t h e poles fa r t h est fr om t h e u n it cir cle (defa u lt ) Th e zer os a r e a lwa ys pa ir ed wit h t h e poles closest t o t h em .
[sos,g] = ss2sos(A,B,C,D,iu,'order','scale') specifies t h e desir ed sca lin g of t h e ga in a n d t h e n u m er a t or coefficien t s of a ll secon d-or der sect ion s, wh er e scale is:
none, t o a pply n o sca lin g (defa u lt ) inf, t o a pply in fin it y-n or m sca lin g two, t o a pply 2-n or m sca lin g Usin g in fin it y-n or m sca lin g in con ju n ct ion wit h up-or der in g m in im izes t h e pr oba bilit y of over flow in t h e r ea liza t ion . Usin g 2-n or m sca lin g in con ju n ct ion wit h down-or der in g m in im izes t h e pea k r ou n d-off n oise.
sos = ss2sos(...) em beds t h e over a ll syst em ga in , g, in t h e fir st sect ion ,
H 1 (z ), so t h a t :
L
H (z ) =
0 H k (z )
k =1
Example
Algorithm
ss2sos u ses a fou r -st ep a lgor it h m t o det er m in e t h e secon d-or der sect ion
6-334
ss2sos
1 It fin ds t h e poles a n d zer os of t h e syst em given by A, B, C a n d D. 2 It u ses t h e fu n ct ion zp2sos, wh ich fir st gr ou ps t h e zer os a n d poles in t o
com plex con ju ga t e pa ir s u sin g t h e cplxpair fu n ct ion . zp2sos t h en for m s t h e secon d-or der sect ion s by m a t ch in g t h e pole a n d zer o pa ir s a ccor din g t o t h e followin g r u les:
a Ma t ch t h e poles closest t o t h e u n it cir cle wit h t h e zer os closest t o t h ose
poles.
b Ma t ch t h e poles n ext closest t o t h e u n it cir cle wit h t h e zer os closest t o
t h ose poles.
c
cir cle. ss2sos n or m a lly or der s t h e sect ion s wit h poles closest t o t h e u n it cir cle la st in t h e ca sca de. You ca n t ell ss2sos t o or der t h e sect ion s in t h e r ever se or der by specifyin g t h e 'down' fla g.
4 ss2sos sca les t h e sect ion s by t h e n or m specified in t h e 'scale' a r gu m en t .
1 = -----2$
6
0
H (#) d #
1 -p
wh er e p ca n be eit h er * or 2. See t h e r efer en ces for det a ils on t h e sca lin g. Th is sca lin g is a n a t t em pt t o m in im ize over flow or pea k r ou n d-off n oise in fixed poin t filt er im plem en t a t ion s.
Diagnostics
6-335
ss2sos
See Also
cplxpair sos2ss ss2tf ss2zp tf2sos zp2sos
Gr ou p com plex n u m ber s in t o com plex con ju ga t e pa ir s. Con ver sion of secon d-or der sect ion s t o st a t e-spa ce. Con ver sion of st a t e-spa ce t o t r a n sfer fu n ct ion . Con ver sion of st a t e-spa ce t o zer o-pole-ga in . Con ver sion of t r a n sfer fu n ct ion t o secon d-or der sect ion s. Con ver sion of zer o-pole-ga in t o secon d-or der sect ion s.
References
[1] J a ckson , L.B. Digital Filters an d S ign al Processin g . 3r d ed. Bost on : Klu wer Aca dem ic P u blish er s, 1996. Ch a pt er 11. [2] Mit r a , S.K. Digital S ign al Processin g: A Com pu ter-B ased Approach . New Yor k : McGr a w-H ill, 1998. Ch a pt er 9. [3] Va idya n a t h a n , P .P . Robu st Digit a l F ilt er St r u ct u r es. H an d book for Digital S ign al Processin g . S.K. Mit r a a n d J .F . Ka iser , ed. Ch a pt er 7. New Yor k: J oh n Wiley & Son s, 1993.
6-336
ss2tf
Purpose Syntax Description
6ss2t f
B (s ) H (s ) = ---------- = C ( s I A ) 1 B + D A (s ) of t h e syst em x = Ax + Bu y = Cx + Du fr om t h e iu-t h in pu t . Vect or a con t a in s t h e coefficien t s of t h e den om in a t or in descen din g power s of s . Th e n u m er a t or coefficien t s a r e r et u r n ed in a r r a y b wit h a s m a n y r ows a s t h er e a r e ou t pu t s y . ss2tf a lso wor ks wit h syst em s in discr et e t im e, in wh ich ca se it r et u r n s t h e z -t r a n sfor m r epr esen t a t ion . Th e ss2tf fu n ct ion is pa r t of t h e st a n da r d MATLAB la n gu a ge.
Algorithm
Th e ss2tf fu n ct ion u ses poly t o fin d t h e ch a r a ct er ist ic polyn om ia l det (sI-A ) a n d t h e equ a lit y det (s I A + B C ) det (s I A ) H (s ) = C ( s I A ) 1 B = ----------------------------------------------------------------------------det (s I A )
See Also
La t t ice filt er t o t r a n sfer fu n ct ion con ver sion . Con ver sion of secon d-or der sect ion s t o t r a n sfer fu n ct ion . Con ver sion of st a t e-spa ce t o secon d-or der sect ion s. Con ver sion of st a t e-spa ce t o zer o-pole-ga in . Con ver sion of t r a n sfer fu n ct ion t o st a t e-spa ce. Con ver sion of zer o-pole-ga in t o t r a n sfer fu n ct ion .
6-337
ss2zp
Purpose Syntax Description
6ss2zp
zer o-pole-ga in r epr esen t a t ion . Th e zer os, poles, a n d ga in s of st a t e-spa ce syst em s r epr esen t t h e t r a n sfer fu n ct ion in fa ct or ed for m .
[z,p,k] = ss2zp(A,B,C,D,iu) ca lcu la t es t h e t r a n sfer fu n ct ion in fa ct or ed
for m ( s z 1 )( s z 2 )L (s z n ) Z (s ) H (s ) = --------- = k --------------------------------------------------------------s p ( ) ( s p ) L P (s ) 1 2 (s p n ) of t h e syst em x = Ax + Bu y = Cx + Du fr om t h e iu-t h in pu t . Ret u r n ed colu m n vect or p con t a in s t h e pole loca t ion s of t h e den om in a t or coefficien t s of t h e t r a n sfer fu n ct ion . Ma t r ix z con t a in s t h e n u m er a t or zer os in it s colu m n s, wit h a s m a n y colu m n s a s t h er e a r e ou t pu t s y . Colu m n vect or k con t a in s t h e ga in s for ea ch n u m er a t or t r a n sfer fu n ct ion .
ss2zp a lso wor ks wit h syst em s in discr et e t im e, in wh ich ca se it r et u r n s t h e
z -t r a n sfor m r epr esen t a t ion . Th e in pu t st a t e-spa ce syst em m u st be r ea l. Th e ss2zp fu n ct ion is pa r t of t h e st a n da r d MATLAB la n gu a ge.
6-338
ss2zp
Example
Algorithm
In m a n y sit u a t ion s t h is a lgor it h m pr odu ces spu r iou s la r ge, bu t fin it e, zer os. ss2zp in t er pr et s t h ese la r ge zer os a s in fin it e.
ss2zp fin ds t h e ga in s by solvin g for t h e fir st n on zer o Ma r kov pa r a m et er s.
6-339
ss2zp
See Also
pzmap sos2zp ss2sos ss2tf tf2zp zp2ss
Pole-zer o m a p of LTI syst em (Con trol S ystem T oolbox Users Gu id e). Con ver sion of secon d-or der sect ion s t o zer o-pole-ga in . Con ver sion of st a t e-spa ce t o secon d-or der sect ion s. Con ver sion of st a t e-spa ce t o t r a n sfer fu n ct ion . Con ver sion of t r a n sfer fu n ct ion t o zer o-pole-ga in . Con ver sion of zer o-pole-ga in t o st a t e-spa ce.
References
[1] La u b, A.J ., a n d B.C. Moor e. Ca lcu la t ion of Tr a n sm ission Zer os Usin g QZ Tech n iqu es. A u tom atica 14 (1978). P g. 557.
6-340
stmcb
Purpose Syntax
6st m cb
Description
St eiglit z-McBr ide it er a t ion is a n a lgor it h m for fin din g a n IIR filt er wit h a pr escr ibed t im e dom a in im pu lse r espon se. It h a s a pplica t ion s in bot h filt er design a n d syst em iden t ifica t ion (pa r a m et r ic m odelin g).
[b,a] = stmcb(x,nb,na) fin ds t h e coefficien t s b a n d a of t h e syst em b (z )/ a (z ) wit h a ppr oxim a t e im pu lse r espon se x, exa ct ly nb zer os, a n d exa ct ly na poles. [b,a] = stmcb(x,u,nb,na) fin ds t h e syst em coefficien t s b a n d a of t h e syst em t h a t , given u a s in pu t , h a s x a s ou t pu t . x a n d u m u st be t h e sa m e len gt h . [b,a] = stmcb(x,nb,na,niter) a n d [b,a] = stmcb(x,u,nb,na,niter) u se niter it er a t ion s. Th e defa u lt for niter
is 5.
[b,a] = stmcb(x,nb,na,niter,ai) a n d [b,a] = stmcb(x,u,nb,na,niter,ai) u se t h e vect or ai a s t h e in it ia l est im a t e of t h e den om in a t or coefficien t s. If ai is n ot specified, stmcb u ses t h e ou t pu t a r gu m en t fr om [b,ai] = prony(x,0,na) a s t h e vect or ai. stmcb r et u r n s t h e IIR filt er coefficien t s in len gt h nb+1 a n d na+1 r ow vect or s b a n d a. Th e filt er coefficien t s a r e or der ed in descen din g power s of z :
B (z ) b (1 ) + b (2 ) z 1 + L + b (n b + 1 ) z n b H (z ) = ---------- = ---------------------------------------------------------------------------------------A (z ) + a (n a + 1 ) z n a a (1 ) + a (2 ) z 1 + L
6-341
stmcb
Example
Appr oxim a t e t h e im pu lse r espon se of a Bu t t er wor t h filt er wit h a syst em of lower or der :
[b,a] = butter(6,0.2); h = filter(b,a,[1 zeros(1,100)]); freqz(b,a,128)
0 Magnitude (dB)
!100
!200
!200
!400
!600 0
6-342
stmcb
Algorithm
m in
a, b
+
i =0
x (i ) x '(i )
stmcb r epea t s t h is pr ocess niter t im es. No ch eckin g is don e t o see if t h e b a n d a coefficien t s h a ve con ver ged in fewer t h a n niter it er a t ion s.
Diagnostics
See Also
Levin son -Du r bin r ecu r sion . Lin ea r pr edict ion coefficien t s. Com pu t e a n est im a t e of AR m odel pa r a m et er s u sin g t h e Yu le-Wa lker m et h od. P r on ys m et h od for t im e dom a in IIR filt er design .
References
[1] St eiglit z, K., a n d L.E . McBr ide. A Tech n iqu e for t h e Iden t ifica t ion of Lin ea r Syst em s. IE E E T ran s. Au tom atic Con trol . Vol. AC-10 (1965). P gs. 461-464. [2] Lju n g, L. S ystem Id en tification : T h eory for th e User . E n glewood Cliffs, NJ : P r en t ice H a ll, 1987. P g. 297.
6-343
strips
Purpose Syntax
6st r ips
St r ip plot .
strips(x) strips(x,n) strips(x,sd,Fs) strips(x,sd,Fs,scale) strips(x) plot s vect or x in h or izon t a l st r ips of len gt h 250. If x is a m a t r ix, strips(x) plot s ea ch colu m n of x. Th e left -m ost colu m n (colu m n 1) is t h e t op
Description
h or izon t a l st r ip.
strips(x,n) plot s vect or x in st r ips t h a t a r e ea ch n sa m ples lon g. strips(x,sd,Fs) plot s vect or x in st r ips of du r a t ion sd secon ds, given a sa m plin g fr equ en cy of Fs sa m ples per secon d. strips(x,sd,Fs,scale) sca les t h e ver t ica l a xes.
6-344
strips
Example
0.25
0.5
0.75
1.25
1.5
See Also
plot stem
Lin ea r t wo-dim en sion a l plot (see t h e on lin e M AT L A B Fu n ction R eferen ce). P lot discr et e sequ en ce da t a (see t h e on lin e M A T L AB Fu n ction R eferen ce).
6-345
tf2latc
Purpose Syntax
6t f2la t c
Description
filt er .
[k,v] = tf2latc(1,a) r et u r n s t h e sca la r la dder coefficien t a t t h e cor r ect posit ion in vect or v. All ot h er elem en t s of v a r e zer o. k = tf2latc(b) fin ds t h e la t t ice pa r a m et er s k for a n F IR (MA) la t t ice filt er , n or m a lized by b(1).
See Also
La t t ice filt er t o t r a n sfer fu n ct ion con ver sion . La t t ice a n d la t t ice-la dder filt er im plem en t a t ion . Con ver sion of t r a n sfer fu n ct ion t o secon d-or der sect ion s. Con ver sion of t r a n sfer fu n ct ion t o st a t e-spa ce. Con ver sion of t r a n sfer fu n ct ion t o zer o-pole-ga in .
6-346
tf2sos
Purpose Syntax
6tf2sos
Con ver sion of t r a n sfer fu n ct ion t o secon d-or der sect ion s.
[sos,g] = tf2sos(b,a) [sos,g] = tf2sos(b,a,'order') [sos,g] = tf2sos(b,a,'order','scale') sos = tf2sos(...) tf2sos con ver t s a t r a n sfer fu n ct ion r epr esen t a t ion of a given syst em t o a n
Description
equ iva len t secon d-or der sect ion r epr esen t a t ion .
[sos,g] = tf2sos(b,a) fin ds a m a t r ix sos in secon d-or der sect ion for m wit h ga in g t h a t is equ iva len t t o t h e syst em r epr esen t ed by t r a n sfer fu n ct ion coefficien t vect or s a a n d b.
b 1 + b 2 z 1 + L + b n b + 1 z n b B (z ) H (z ) = ---------- = -----------------------------------------------------------------------A (z ) + a n a + 1 z n a a 1 + a 2 z 1 + L
sos is a n L -by-6 m a t r ix
wh ose r ows con t a in t h e n u m er a t or a n d den om in a t or coefficien t s b ik a n d a ik of t h e secon d-or der sect ion s of H (z ):
L L
H (z ) = g
0 H k (z )
k =1
= g
0 --------------------------------------------------------1 + a z 1 + a z 2
k =1 1k 2k
b 0 k + b 1 k z 1 + b 2 k z 2
6-347
tf2sos
down, t o or der t h e sect ion s so t h e fir st r ow of sos con t a in s t h e poles closest t o t h e u n it cir cle up, t o or der t h e sect ion s so t h e fir st r ow of sos con t a in s t h e poles fa r t h est fr om t h e u n it cir cle (defa u lt )
[sos,g] = tf2sos(b,a,'order','scale') specifies t h e desir ed sca lin g of t h e ga in a n d n u m er a t or coefficien t s of a ll secon d-or der sect ion s, wh er e scale is:
none, t o a pply n o sca lin g (defa u lt ) inf, t o a pply in fin it y-n or m sca lin g two, t o a pply 2-n or m sca lin g Usin g in fin it y-n or m sca lin g in con ju n ct ion wit h up-or der in g m in im izes t h e pr oba bilit y of over flow in t h e r ea liza t ion . Usin g 2-n or m sca lin g in con ju n ct ion wit h down-or der in g m in im izes t h e pea k r ou n d-off n oise.
sos = tf2sos(...) em beds t h e over a ll syst em ga in , g, in t h e fir st sect ion ,
H 1 (z ), so t h a t
L
H (z ) =
0 H k (z )
k =1
See Also
Gr ou p com plex n u m ber s in t o com plex con ju ga t e pa ir s. Con ver sion of secon d-or der sect ion s t o t r a n sfer fu n ct ion . Con ver sion of st a t e-spa ce t o secon d-or der sect ion s. Con ver sion of t r a n sfer fu n ct ion t o st a t e-spa ce. Con ver sion of t r a n sfer fu n ct ion t o zer o-pole-ga in . Con ver sion of zer o-pole-ga in t o secon d-or der sect ion s.
6-348
tf2sos
References
[1] J a ckson , L.B. Digital Filters an d S ign al Processin g . 3r d ed. Bost on : Klu wer Aca dem ic P u blish er s, 1996. Ch a pt er 11. [2] Mit r a , S.K. Digital S ign al Processin g: A Com pu ter-B ased Approach . New Yor k : McGr a w-H ill, 1998. Ch a pt er 9. [3] Va idya n a t h a n , P .P . Robu st Digit a l F ilt er St r u ct u r es. H an d book for Digital S ign al Processin g . S.K. Mit r a a n d J .F . Ka iser , ed. Ch a pt er 7. New Yor k : J oh n Wiley & Son s, 1993.
6-349
tf2ss
Purpose Syntax Description
6t f2ss
x = Ax + Bu y = Cx + Du given a syst em in t r a n sfer fu n ct ion for m : B (s ) H (s ) = ---------- = C ( s I A ) 1 B + D A (s ) fr om a sin gle in pu t . In pu t vect or a con t a in s t h e den om in a t or coefficien t s in descen din g power s of s . Ma t r ix b con t a in s t h e n u m er a t or coefficien t s wit h a s m a n y r ows a s t h er e a r e ou t pu t s y . tf2ss r et u r n s t h e A, B, C, a n d D m a t r ices in con t r oller ca n on ica l for m .
tf2ss a lso wor ks for discr et e syst em s, bu t you m u st pa d t h e n u m er a t or wit h
Example
6-350
tf2ss
Th er e is disa gr eem en t in t h e lit er a t u r e on n a m in g con ven t ion s for t h e ca n on ica l for m s. It is ea sy, h owever , t o gen er a t e sim ila r it y t r a n sfor m a t ion s t h a t con ver t t o ot h er for m s. F or exa m ple:
T = fliplr(eye(n)); A = T\A*T;
tf2ss wr it es t h e ou t pu t in con t r oller ca n on ica l for m by in spect ion . sos2ss ss2tf tf2sos tf2zp zp2ss
Con ver sion of secon d-or der sect ion s t o st a t e-spa ce. Con ver sion of st a t e-spa ce t o t r a n sfer fu n ct ion . Con ver sion of t r a n sfer fu n ct ion t o secon d-or der sect ion s. Con ver sion of t r a n sfer fu n ct ion t o zer o-pole-ga in . Con ver sion of zer o-pole-ga in t o st a t e-spa ce.
6-351
tf2zp
Purpose Syntax Description
6t f2zp
fu n ct ion for m .
[z,p,k] = tf2zp(b,a) fin ds t h e sin gle-in pu t , m u lt i-ou t pu t (SIMO) fa ct or ed
t r a n sfer fu n ct ion for m : (s Z 1 )(s Z 2 )L (s Z m ) Z (s ) H (s ) = --------- = k -----------------------------------------------------------------( s p 1 )(s p 2 )L (s p n ) P (s ) given a SIMO syst em in polyn om ia l t r a n sfer fu n ct ion for m : + b (n b 1 )s + b (n b ) b 1 s (n b 1 ) + L B (s ) ---------- = -------------------------------------------------------------------------------------( n a 1 ) A (s ) +L + a (n a 1 )s + a (n a ) a1s Vect or a specifies t h e coefficien t s of t h e den om in a t or in descen din g power s of s . Ma t r ix b in dica t es t h e n u m er a t or coefficien t s wit h a s m a n y r ows a s t h er e a r e ou t pu t s. Th e zer o loca t ion s a r e r et u r n ed in t h e colu m n s of m a t r ix z, wit h a s m a n y colu m n s a s t h er e a r e r ows in b. Th e pole loca t ion s a r e r et u r n ed in colu m n vect or p a n d t h e ga in s for ea ch n u m er a t or t r a n sfer fu n ct ion in vect or k. Th e tf2zp fu n ct ion a lso wor ks for discr et e syst em s, a n d is pa r t of t h e st a n da r d MATLAB la n gu a ge.
6-352
tf2zp
Example
Th e syst em is con ver t ed t o st a t e-spa ce u sin g tf2ss a n d t h en t o zer os, poles, a n d ga in s u sin g ss2zp.
sos2zp ss2zp tf2sos tf2ss zp2tf
Con ver sion of secon d-or der sect ion s t o zer o-pole-ga in . Con ver sion of st a t e-spa ce t o zer o-pole-ga in . Con ver sion of t r a n sfer fu n ct ion t o secon d-or der sect ion s. Con ver sion of t r a n sfer fu n ct ion t o st a t e-spa ce. Con ver sion of zer o-pole-ga in t o t r a n sfer fu n ct ion .
6-353
tfe
Purpose Syntax
6t fe
Description
P x y (f ) T x y (f ) = -------------P x x (f ) Th e r ela t ion sh ip bet ween t h e in pu t x a n d ou t pu t y is m odeled by t h e lin ea r , t im e-in va r ia n t t r a n sfer fu n ct ion Txy. Vect or s x a n d y m u st be t h e sa m e len gt h . Txy = tfe(x,y) u ses t h e followin g defa u lt va lu es: nfft = min(256,(length(x)) Fs = 2 window = hanning(nfft) noverlap = 0
nfft specifies t h e F F T len gt h t h a t tfe u ses. Th is va lu e det er m in es t h e fr equ en cies a t wh ich t h e power spect r u m is est im a t ed. Fs is a sca la r t h a t specifies t h e sa m plin g fr equ en cy. window specifies a win dowin g fu n ct ion a n d t h e n u m ber of sa m ples tfe u ses in it s sect ion in g of t h e x a n d y vect or s. noverlap is t h e n u m ber of sa m ples by wh ich t h e sect ion s over la p. An y
a r gu m en t s t h a t a r e om it t ed fr om t h e en d of t h e pa r a m et er list u se t h e defa u lt va lu es sh own a bove. If x is r ea l, tfe est im a t es t h e t r a n sfer fu n ct ion a t posit ive fr equ en cies on ly; in t h is ca se, t h e ou t pu t Txy is a colu m n vect or of len gt h nfft/2+1 for nfft even a n d (nfft+1)/2 for nfft odd. If x or y is com plex, tfe est im a t es t h e t r a n sfer fu n ct ion for bot h posit ive a n d n ega t ive fr equ en cies a n d Txy h a s len gt h nfft.
6-354
tfe
Txy = tfe(x,y,nfft) u ses t h e specified F F T len gt h nfft in est im a t in g t h e t r a n sfer fu n ct ion . Specify nfft a s a power of 2 for fa st est execu t ion . [Txy,f] = tfe(x,y,nfft,Fs) r et u r n s a vect or f of fr equ en cies a t wh ich tfe est im a t es t h e t r a n sfer fu n ct ion . Fs is t h e sa m plin g fr equ en cy. f is t h e sa m e size a s Txy, so plot(f,Txy) plot s t h e t r a n sfer fu n ct ion est im a t e ver su s pr oper ly sca led fr equ en cy. Fs h a s n o effect on t h e ou t pu t Txy; it is a fr equ en cy sca lin g
m u lt iplier .
Txy = tfe(x,y,nfft,Fs,window) specifies a win dowin g fu n ct ion a n d t h e n u m ber of sa m ples per sect ion of t h e x vect or . If you su pply a sca la r for window, Txy u ses a H a n n in g win dow of t h a t len gt h . Th e len gt h of t h e win dow m u st be less t h a n or equ a l t o nfft; tfe zer o pa ds t h e sect ion s if t h e len gt h of t h e win dow exceeds nfft. Txy = tfe(x,y,nfft,Fs,window,noverlap) over la ps t h e sect ion s of x by noverlap sa m ples.
linear, t o r em ove t h e best st r a igh t -lin e fit fr om t h e pr ewin dowed sect ion s of x and y mean, t o r em ove t h e m ea n fr om t h e pr ewin dowed sect ion s of x a n d y none, for n o det r en din g (defa u lt ) Th e dflag pa r a m et er m u st a ppea r la st in t h e list of in pu t a r gu m en t s. tfe r ecogn izes a dflag st r in g n o m a t t er h ow m a n y in t er m edia t e a r gu m en t s a r e om it t ed.
tfe(...) wit h n o ou t pu t a r gu m en t s plot s t h e m a gn it u de of t h e t r a n sfer fu n ct ion est im a t e in decibels ver su s fr equ en cy in t h e cu r r en t figu r e win dow.
6-355
tfe
Example
Com pu t e a n d plot t h e t r a n sfer fu n ct ion est im a t e bet ween t wo color ed n oise sequ en ces x a n d y:
h = fir1(30,0.2,boxcar(31)); x = randn(16384,1); y = filter(h,1,x); tfe(x,y,1024,[],[],512) title('Transfer Function Estimate')
Transfer Function Estimate 5 0 -5
0.1
0.2
0.3
0.4
0.7
0.8
0.9
Algorithm
Txy = Pxy./Pxx
6-356
tfe
Diagnostics
An a ppr opr ia t e dia gn ost ic m essa ge is displa yed wh en in cor r ect a r gu m en t s a r e u sed:
Requires Requires Requires Requires Requires window's length to be no greater than the FFT length. NOVERLAP to be strictly less than the window length. positive integer values for NFFT and NOVERLAP. vector (either row or column) input. inputs X and Y to have the same length.
See Also
etfe
Com pu t e em pir ica l t r a n sfer fu n ct ion est im a t e a n d per iodogr a m (see S ystem Id en tification T oolbox Users Gu id e). E st im a t e m a gn it u de squ a r ed coh er en ce fu n ct ion bet ween t wo sign a ls. E st im a t e t h e cr oss spect r a l den sit y (CSD) of t wo sign a ls. E st im a t e t h e power spect r a l den sit y (P SD) of a sign a l u sin g Welch s m et h od. Per for m spect r a l a n a lysis for in pu t -ou t pu t da t a (see S ystem Id en tification T oolbox Users Gu id e ).
6-357
triang
Purpose Syntax Description
6t ria n g
Tr ia n gu la r win dow.
w = triang(n) triang(n) r et u r n s a n n-poin t t r ia n gu la r win dow in t h e colu m n vect or w. Th e
coefficien t s of a t r ia n gu la r win dow a r e F or n odd: 2k ( ------------, &n + 1 w [k ] = ' (n k + 1 ) &2 ------------------------------, % n +1 F or n even : k 1 (2 ---------------, & n w [k ] = ' (n k + 1 ) &2 ------------------------------, % n n 1 5 k 5 -2 n --+15k 5n 2 n +1 1 5 k 5 -----------2 n +1 ------------5k 5n 2
Th e t r ia n gu la r win dow is ver y sim ila r t o a Ba r t let t win dow. Th e Ba r t let t win dow a lwa ys en ds wit h zer os a t sa m ples 1 a n d n, wh ile t h e t r ia n gu la r win dow is n on zer o a t t h ose poin t s. F or n odd, t h e cen t er n2 poin t s of triang(n2) a r e equ iva len t t o bartlett(n).
See Also
Ba r t let t win dow. Bla ck m a n win dow. Rect a n gu la r win dow. Ch ebysh ev win dow. H a m m in g win dow. H a n n in g win dow. Ka iser win dow.
References
[1] Oppen h eim , A.V., a n d R.W. Sch a fer , Discrete-T im e S ign al Processin g. E n glewood Cliffs, NJ : P r en t ice-H a ll, 1989.
6-358
tripuls
Purpose Syntax
6tr ipu ls
Description
See Also
chirp cos diric gauspuls pulstran rectpuls sawtooth sin sinc square
Swept -fr equ en cy cosin e gen er a t or. Cosin e of vect or /m a t r ix elem en t s (see t h e on lin e M AT L AB Fu n ction R eferen ce). Dir ich let or per iodic sin c fu n ct ion . Ga u ssia n -m odu la t ed sin u soida l pu lse gen er a t or. P u lse t r a in gen er a t or. Sa m pled a per iodic r ect a n gle gen er a t or. Sawt oot h or t r ia n gle wave gen er a t or. Sin e of vect or /m a t r ix elem en t s (see t h e on lin e M AT L AB Fu n ction R eferen ce). Sin c or sin ($t )/$t fu n ct ion . Squ a r e wa ve gen er a t or.
6-359
unwrap
Purpose Syntax Description
6u n wr a p
Un wr a p ph a se a n gles.
p = unwrap(p) p = unwrap(p) cor r ect s t h e ph a se a n gles in vect or p by a ddin g m u lt iples of 2 $ , wh er e n eeded, t o sm oot h t h e t r a n sit ion s a cr oss br a n ch cu t s. Wh en p is a m a t r ix, unwrap cor r ect s t h e ph a se a n gles down ea ch colu m n . Th e ph a se m u st
6-360
upfirdn
Purpose Syntax
6u pfird n
Description
ou t pu t s a ct u a lly n eeded a r e com pu t ed. Th e F IR filt er is u su a lly a lowpa ss filt er , wh ich you m u st design u sin g a n ot h er fu n ct ion su ch a s remez or fir1. NOTE Th e fu n ct ion resample per for m s a n F IR design u sin g firls, followed by r a t e ch a n gin g im plem en t ed wit h upfirdn.
yout = upfirdn(xin,h) r et u r n s t h e ou t pu t sign a l yout. If yout is a r ow or colu m n vect or , t h en it r epr esen t s on e sign a l; if yout is a n a r r a y, t h en ea ch colu m n is a sepa r a t e ou t pu t . xin is t h e in pu t sign a l. If xin is a r ow or colu m n vect or , t h en it r epr esen t s on e sign a l; if xin is a n a r r a y, t h en ea ch colu m n is filt er ed. h is t h e im pu lse r espon se of t h e F IR filt er . If h is a r ow or colu m n vect or , t h en it r epr esen t s on e filt er ; if h is a n a r r a y, t h en ea ch colu m n is a sepa r a t e im pu lse r espon se. yout = upfirdn(xin,h,p) specifies t h e u psa m plin g fa ct or p. p is a n in t eger
wit h a defa u lt of 1.
yout = upfirdn(xin,h,p,q) specifies t h e down sa m plin g fa ct or q. q is a n
6-361
upfirdn
NOTE Sin ce upfirdn per for m s con volu t ion a n d r a t e ch a n gin g, t h e yout sign a ls h ave a differ en t len gt h t h a n xin. Th e len gt h of y [n ] is a ppr oxim a t ely p/q t im es t h e len gt h of x [n ].
Remarks
Usu a lly t h e in pu t s xin a n d t h e filt er h a r e vect or s, in wh ich ca se on ly on e ou t pu t sign a l is pr odu ced. H owever , wh en t h ese a r gu m en t s a r e a r r a ys, ea ch colu m n is t r ea t ed a s a sepa r a t e sign a l or filt er . Va lid com bin a t ion s a r e
1 xin is a vect or a n d h is a vect or .
Th er e is on e filt er a n d on e sign a l, so t h e fu n ct ion con volves xin wit h h. Th e ou t pu t sign a l yout is a r ow vect or if xin is a r ow; ot h er wise, it is a colu m n vect or .
2 xin is a n a r r a y a n d h is a vect or .
Th er e is on e filt er a n d m a n y sign a ls, so t h e fu n ct ion con volves h wit h ea ch colu m n of xin. Th e r esu lt in g yout will be a n a r r a y wit h t h e sa m e n u m ber of colu m n s a s xin.
3 xin is a vect or a n d h is a n a r r a y.
Th er e a r e m a n y filt er s a n d on e sign a l, so t h e fu n ct ion con volves ea ch colu m n of h wit h xin. Th e r esu lt in g yout will be a n a r r a y wit h t h e sa m e n u m ber of colu m n s a s h.
4 xin is a n a r r a y a n d h is a n a r r a y, bot h wit h t h e sa m e n u m ber of colu m n s.
Th er e a r e m a n y filt er s a n d m a n y sign a ls, so t h e fu n ct ion con volves cor r espon din g colu m n s of xin a n d h. Th e r esu lt in g yout is a n a r r a y wit h t h e sa m e n u m ber of colu m n s a s xin a n d h.
Examples
If bot h p a n d q a r e equ a l t o 1 (t h a t is, t h er e is n o r a t e ch a n gin g), t h e r esu lt is or din a r y con volu t ion of t wo sign a ls (equ iva len t t o conv):
yy = upfirdn(xx,hh);
Th is exa m ple im plem en t s a seven -ch a n n el filt er ba n k by con volvin g seven differ en t filt er s wit h on e in pu t sign a l, t h en down sa m ples by five:
% Assume that hh is an L-by-7 array of filters. yy = upfirdn(xx,hh,1,5);
6-362
upfirdn
Im plem en t a r a t e ch a n ge fr om 44.1 k H z (CD sa m plin g r a t e) t o 48 k H z (DAT r a t e), a r a t io of 160/147. Th is r equ ir es a lowpa ss filt er wit h cu t off fr equ en cy a t #c = 2 $/160:
% Design lowpass filter with cutoff at 1/160th of Fs. hh = fir1(300,2/160); % need a very long lowpass filter yy = upfirdn(xx,hh,160,147);
In t h is exa m ple, t h e filt er design a n d r esa m plin g a r e sepa r a t e st eps. Not e t h a t resample wou ld do bot h st eps a s on e.
Algorithm
oper a t ion s in t h e polyph a se st r u ct u r e is a ppr oxim a t ely (L h L x -pL x )/q wh er e L h a n d L x a r e t h e len gt h s of h [n ] a n d x [n ], r espect ively. A m or e a ccu r a t e flops cou n t is com pu t ed in t h e pr ogr a m , bu t t h e a ct u a l cou n t is st ill a ppr oxim a t e. F or lon g sign a ls x [n ], t h e for m u la is qu it e oft en exa ct .
Diagnostics
Th er e m u st be on e ou t pu t a r gu m en t a n d a t lea st t wo in pu t a r gu m en t s. If eit h er of t h ese con dit ion s a r e viola t ed, upfirdn gives t h e a ppr opr ia t e er r or m essa ge:
UPFIRDN needs at least two input arguments. UPFIRDN should have exactly one output argument.
Wh en t h e in pu t sign a ls a r e in t h e colu m n s of a m a t r ix a n d t h er e a r e m u lt iple filt er s a lso in t h e colu m n s of a m a t r ix, t h e n u m ber of sign a ls a n d filt er s m u st be t h e sa m e. If t h ey a r e n ot , upfirdn gives t h e er r or m essa ge
X and H must have the same number of columns, if more than one.
6-363
upfirdn
See Also
conv decimate filter interp intfilt resample
Con volu t ion a n d polyn om ia l m u lt iplica t ion . Decr ea se t h e sa m plin g r a t e for a sequ en ce (decim a t ion ). F ilt er da t a wit h a r ecu r sive (IIR) or n on r ecu r sive (F IR) filt er. In cr ea se sa m plin g r a t e by a n in t eger fa ct or (in t er pola t ion ). In t er pola t ion F IR filt er design . Ch a n ge sa m plin g r a t e by a n y r a t ion a l fa ct or.
References
[1] Cr och ier e, R.E ., a n d L.R. Ra bin er . M u lti-R ate S ign al Processin g . E n glewood Cliffs, NJ : P r en t ice H a ll, 1983. P gs. 88-91. [2] Cr och ier e, R.E . A Gen er a l P r ogr a m t o P er for m Sa m plin g Ra t e Con ver sion of Da t a by Ra t ion a l Ra t ios. In Program s for Digital S ign al Processin g . IE E E P r ess. New Yor k: J oh n Wiley & Son s, 1979. P gs. 8.2-1 t o 8.2-7.
6-364
vco
Purpose Syntax Description
6vco
By defa u lt , Fs is 1 a n d Fc is Fs/4. If x is a m a t r ix, vco pr odu ces a m a t r ix wh ose colu m n s oscilla t e a ccor din g t o t h e colu m n s of x.
Example
Gen er a t e t wo secon ds of a sign a l sa m pled a t 10,000 sa m ples/secon d wh ose in st a n t a n eou s fr equ en cy is a t r ia n gle fu n ct ion of t im e:
Fs = 10000; t = 0:1/Fs:2; x = vco(sawtooth(2*pi*t,0.75),[.1 0.4]*Fs,Fs);
6-365
vco
Frequency
0.2
0.4
0.6
0.8
1 Time
1.2
1.4
1.6
1.8
Algorithm Diagnostics
See Also
demod modulate
Dem odu la t ion for com m u n ica t ion s sim u la t ion . Modu la t ion for com m u n ica t ion s sim u la t ion .
6-366
xcorr
Purpose Syntax
6xcor r
Description
Au t ocor r ela t ion is h a n dled a s a specia l ca se. Th e t r u e cr oss-cor r ela t ion sequ en ce is 7 x y (m ) = E {x n y * n + m } wh er e x n a n d y n a r e st a t ion a r y r a n dom pr ocesses, * < n < * , a n d E {} is t h e expect ed va lu e oper a t or . xcorr m u st est im a t e t h e sequ en ce beca u se, in pr a ct ice, on ly a fin it e segm en t of t h e in fin it e-len gt h r a n dom pr ocess is a va ila ble.
c = xcorr(x,y) r et u r n s t h e cr oss-cor r ela t ion sequ en ce in a len gt h 2 N -1 vect or , wh er e x a n d y a r e len gt h N vect or s (N >1). If x a n d y a r e n ot t h e sa m e len gt h , t h e sh or t er vect or is zer o-pa dded t o t h e len gt h of t h e lon ger vect or .
By defa u lt , xcorr com pu t es r a w cor r ela t ion s wit h n o n or m a liza t ion : ( N m 1 & * xn yn +m & c x y (m ) = ' n =0 & & * % c y x ( m )
m 80
m <0
Th e ou t pu t vect or c h a s elem en t s given by c(m ) = cxy (m -N ), m =1, ..., 2 N -1. In gen er a l, t h e cor r ela t ion fu n ct ion r equ ir es n or m a liza t ion t o pr odu ce a n a ccu r a t e est im a t e (see below).
6-367
xcorr
c = xcorr(x) is t h e a u t ocor r ela t ion sequ en ce for t h e vect or x. If x is a n N -by-P m a t r ix, c is a m a t r ix wit h 2 N -1 r ows wh ose P 2 colu m n s con t a in t h e cr oss-cor r ela t ion sequ en ces for a ll com bin a t ion s of t h e colu m n s of x. c = xcorr(x,y,'option') specifies a n or m a liza t ion opt ion for t h e cr oss-cor r ela t ion , wh er e 'option' is:
biased, for bia sed est im a t es of t h e cr oss-cor r ela t ion fu n ct ion 1 c x y , biased (m ) = ---- c x y (m ) N unbiased, for u n bia sed est im a t es of t h e cr oss-cor r ela t ion fu n ct ion 1 - c (m ) c x y , u n biased (m ) = -----------------N m xy coeff, t o n or m a lize t h e sequ en ce so t h e a u t ocor r ela t ion s a t zer o la g a r e iden t ica lly 1.0 none, t o u se t h e r a w, u n sca led cr oss-cor r ela t ion s (defa u lt ) See r efer en ce [1] for m or e in for m a t ion on t h e pr oper t ies of bia sed a n d u n bia sed cor r ela t ion est im a t es.
c = xcorr(x,'option') specifies on e of t h e a bove n or m a liza t ion opt ion s for
6-368
xcorr
[c,lags] = xcorr(...) r et u r n s a vect or of t h e la g in dices a t wh ich c wa s est im a t ed, wit h t h e r a n ge [maxlags:maxlags]. Wh en maxlags is n ot specified, t h e r a n ge of lags is [N+1:N1].
In a ll ca ses, t h e cr oss-cor r ela t ion or a u t ocor r ela t ion com pu t ed by xcorr h a s t h e 0-t h la g in t h e m iddle of t h e sequ en ce, a t elem en t or r ow maxlags+1 (elem en t or r ow N if maxlags is n ot specified).
Examples
Th e secon d ou t pu t , lags, is u sefu l for plot t in g t h e cr oss-cor r ela t ion or a u t ocor r ela t ion . F or exa m ple, t h e est im a t ed a u t ocor r ela t ion of zer o-m ea n Ga u ssia n wh it e n oise cw w (m ) ca n be displa yed for -10 5 m 5 10 u sin g
ww = randn(1000,1); [c_ww,lags] = xcorr(ww,10,'coeff'); stem(lags,c_ww)
Swa ppin g t h e x a n d y in pu t a r gu m en t s r ever ses (a n d con ju ga t es) t h e ou t pu t cor r ela t ion sequ en ce. F or r ow vect or s, t h e r esu lt in g sequ en ces a r e r ever sed left t o r igh t ; for colu m n vect or s, u p a n d down . Th e followin g exa m ple illu st r a t es t h is pr oper t y (mat2str is u sed for a com pa ct displa y of com plex n u m ber s).
x = [1,2i,3]; y = [4,5,6]; [c1,lags] = xcorr(x,y); c1 = mat2str(c1,2), lags c1 = [12i*8.9e016 15i*8 22i*10 5i*12 6+i*8.9e016] lags = 2 1 0 1 2
6-369
xcorr
pr odu ces t h e cr oss-cor r ela t ion m a t r ix cor r espon din g t o t h e la g of t h e ch osen r ow. F or exa m ple, t h e cr oss-cor r ela t ion a t zer o la g ca n be r et r ieved by
randn('seed',0) X = randn(2,2); [M,P] = size(X); c = xcorr(X); c0 = zeros(P); c0(:) = c(M,:) c0 = 1.7500 0.3079 0.3079 0.1293
You ca n ca lcu la t e t h e m a t r ix of cor r ela t ion coefficien t s t h a t t h e MATLAB fu n ct ion corrcoef gen er a t es by su bst it u t in g
c = xcov(X,'coef')
in t h e la st exa m ple. Th e fu n ct ion xcov su bt r a ct s t h e m ea n a n d t h en ca lls xcorr. Use fftshift t o m ove t h e secon d h a lf of t h e sequ en ce st a r t in g a t t h e zer ot h la g t o t h e fr on t of t h e sequ en ce. fftshift swa ps t h e fir st a n d secon d h a lves of a sequ en ce.
Algorithm Diagnostics
F or m or e in for m a t ion on est im a t in g cova r ia n ce a n d cor r ela t ion fu n ct ion s, see [1] a n d [2]. Th er e m u st be a t lea st on e vect or in pu t a r gu m en t ; ot h er wise, xcorr gives t h e followin g er r or m essa ge:
1st arg must be a vector or matrix.
If t h e secon d a r gu m en t wa s en t er ed a s a sca la r , it is t a k en t o be maxlags a n d n o su cceedin g in pu t ca n be a sca la r . Wh en t h e secon d a r gu m en t is a vect or , t h e fir st m u st a lso be a sign a l vect or . Th e t h ir d a r gu m en t , wh en pr esen t , m u st be
6-370
xcorr
Nor m a lly t h e len gt h s of t h e vect or in pu t s sh ou ld be t h e sa m e; if t h ey a r e n ot , t h en t h e on ly a llowa ble sca lin g opt ion is 'none'. If it is n ot , xcorr gives t h e followin g er r or m essa ge:
OPTION must be 'none' for different length vectors A and B.
See Also
Con volu t ion a n d polyn om ia l m u lt iplica t ion . Cor r ela t ion coefficien t m a t r ix. Cova r ia n ce m a t r ix. Two-dim en sion a l cr oss-cor r ela t ion . Cr oss-cova r ia n ce fu n ct ion est im a t e (equ a l t o m ea n -r em oved cr oss-cor r ela t ion ).
References
[1] Ben da t , J .S., a n d A.G. P ier sol. R an d om Data: An alysis an d M easu rem en t Proced u res . New Yor k: J oh n Wiley & Son s, 1971. P g. 332. [2] Oppen h eim , A.V., a n d R.W. Sch a fer . Digital S ign al Processin g . E n glewood Cliffs, NJ : P r en t ice H a ll, 1975. P gs. 63-67, 746-747, 839-842.
6-371
xcorr2
Purpose Syntax Description
6xcor r 2
See Also
Two-dim en sion a l con volu t ion . Two-dim en sion a l digit a l filt er in g. Cr oss-cor r ela t ion fu n ct ion est im a t e.
6-372
xcov
Purpose Syntax
6xcov
Description
Au t ocova r ia n ce is h a n dled a s a specia l ca se. Th e t r u e cr oss-cova r ia n ce sequ en ce is t h e m ea n -r em oved cr oss-cor r ela t ion sequ en ce G x y (m ) = E { ( x n m x ) ( y n + m m y ) * } wh er e m x a n d m y a r e t h e m ea n va lu es of t h e t wo st a t ion a r y r a n dom pr ocesses, a n d E {}is t h e expect ed va lu e oper a t or . xcov est im a t es t h e sequ en ce beca u se, in pr a ct ice, a ccess is a va ila ble t o on ly a fin it e segm en t of t h e in fin it e-len gt h r a n dom pr ocess.
v = xcov(x,y) r et u r n s t h e cr oss-cova r ia n ce sequ en ce in a len gt h 2 N -1 vect or , wh er e x a n d y a r e len gt h N vect or s. v = xcov(x) is t h e a u t ocova r ia n ce sequ en ce for t h e vect or x. Wh er e x is a n N -by-P a r r a y, v = xcov(X) r et u r n s a m a r r a y wit h 2 N -1 r ows wh ose P 2 colu m n s con t a in t h e cr oss-cova r ia n ce sequ en ces for a ll com bin a t ion s of t h e colu m n s of X.
By defa u lt , xcov com pu t es r a w cova r ia n ces wit h n o n or m a liza t ion . F or a len gt h N vect or :
N 1 ( N m 13 43 1 1 & 9 x (n ) ---:9 * x i: 9 y n + m ---& 9 N N c x y (m ) = ' 1 i = 0 21 & n =0 & * ( m ) % cy x
+
=
4 y i*: : 2
m 80
m <0
6-373
xcov
biased, for bia sed est im a t es of t h e cr oss-cova r ia n ce fu n ct ion unbiased, for u n bia sed est im a t es of t h e cr oss-cova r ia n ce fu n ct ion coeff, t o n or m a lize t h e sequ en ce so t h e a u t o-cova r ia n ces a t zer o la g a r e iden t ica lly 1.0 none, t o u se t h e r a w, u n sca led cr oss-cova r ia n ces (defa u lt ) See [1] for m or e in for m a t ion on t h e pr oper t ies of bia sed a n d u n bia sed cor r ela t ion a n d cova r ia n ce est im a t es.
[c,lags] = xcov(x,y,maxlags) wh er e x a n d y a r e len gt h m vect or s, r et u r n s t h e cr oss-cova r ia n ce sequ en ce in a len gt h 2*maxlags+1 vect or c. lags is a vect or of t h e la g in dices wh er e c wa s est im a t ed, t h a t is, [maxlags:maxlags]. [c,lags] = xcov(x,maxlags) is t h e a u t ocova r ia n ce sequ en ce over t h e r a n ge
of la gs [maxlags:maxlags].
[c,lags] = xcov(x,maxlags) wh er e x is a n m-by-p a r r a y, r et u r n s a r r a y c wit h 2*maxlags+1 r ows wh ose P 2 colu m n s con t a in t h e cr oss-cova r ia n ce sequ en ces for a ll com bin a t ion s of t h e colu m n s of x. [c,lags] = xcov(x,y,maxlags,'option') specifies a sca lin g opt ion , wh er e option is t h e la st in pu t a r gu m en t .
In a ll ca ses, xcov gives a n ou t pu t su ch t h a t t h e zer ot h la g of t h e cova r ia n ce vect or is in t h e m iddle of t h e sequ en ce, a t elem en t or r ow maxlag+1 or a t m.
Examples
Th e secon d ou t pu t lags is u sefu l wh en plot t in g. F or exa m ple, t h e est im a t ed a u t ocova r ia n ce of u n ifor m wh it e n oise cw w (m ) ca n be displa yed for -10 5 m 5 10 u sin g
ww = randn(1000,1); % generate uniform noise with mean = 1/2 [cov_ww,lags] = xcov(ww,10,'coeff'); stem(lags,cov_ww)
6-374
xcov
Algorithm
xcov com pu t es t h e m ea n of it s in pu t s, su bt r a ct s t h e m ea n , a n d t h en ca lls xcorr. F or m or e in for m a t ion on est im a t in g cova r ia n ce a n d cor r ela t ion
xcov does n ot ch eck for a n y er r or s ot h er t h a n t h e cor r ect n u m ber of in pu t a r gu m en t s. In st ea d, it r elies on t h e er r or ch eckin g in xcorr, wh ich it ca lls. conv corrcoef cov xcorr xcorr2
Con volu t ion a n d polyn om ia l m u lt iplica t ion . Cor r ela t ion coefficien t m a t r ix. Cova r ia n ce m a t r ix. Cr oss-cor r ela t ion fu n ct ion est im a t e. Two-dim en sion a l cr oss-cor r ela t ion .
References
[1] Ben da t , J .S., a n d A.G. P ier sol. R an d om Data: An alysis an d M easu rem en t Proced u res . New Yor k: J oh n Wiley & Son s, 1971. P g. 332. [2] Oppen h eim , A.V., a n d R.W. Sch a fer . Digital S ign al Processin g . E n glewood Cliffs, NJ : P r en t ice H a ll, 1975. P gs. 63-67, 746-747, 839-842.
6-375
yulewalk
Purpose Syntax Description
6yu lewa lk
f is a vect or of fr equ en cy poin t s, specified in t h e r a n ge bet ween 0 a n d 1, wh er e 1 cor r espon ds t o h a lf t h e sa m ple fr equ en cy (t h e Nyqu ist fr equ en cy). Th e fir st poin t of f m u st be 0 a n d t h e la st poin t 1, wit h a ll in t er m edia t e poin t s in in cr ea sin g or der . Du plica t e fr equ en cy poin t s a r e a llowed, cor r espon din g t o st eps in t h e fr equ en cy r espon se. m is a vect or con t a in in g t h e desir ed m a gn it u de r espon se a t t h e poin t s specified in f. f a n d m m u st be t h e sa m e len gt h . plot(f,m) displa ys t h e filt er sh a pe. Th e ou t pu t filt er coefficien t s a r e or der ed in descen din g power s of z , B (z ) b (1 ) + b (2 ) z 1 + L + b (n + 1 ) z n ---------- = -------------------------------------------------------------------------------- 1 A (z ) + a (n + 1 ) z n a (1 ) + a (2 ) z + L Wh en specifyin g t h e fr equ en cy r espon se, a void excessively sh a r p t r a n sit ion s fr om pa ssba n d t o st opba n d. You m a y n eed t o exper im en t wit h t h e slope of t h e t r a n sit ion r egion t o get t h e best filt er design .
Example
Design a n 8t h -or der lowpa ss filt er a n d over plot t h e desir ed fr equ en cy r espon se wit h t h e a ct u a l fr equ en cy r espon se:
f = [0 0.6 0.6 1]; m = [1 1 0 0];
6-376
yulewalk
[b,a] = yulewalk(8,f,m);
0.8
0.6
0.4
0.2
0 0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
Algorithm
yulewalk per for m s a lea st -squ a r es fit in t h e t im e dom a in . It com pu t es t h e den om in a t or coefficien t s u sin g m odified Yu le-Wa lker equ a t ion s, wit h cor r ela t ion coefficien t s com pu t ed by in ver se F ou r ier t r a n sfor m a t ion of t h e specified fr equ en cy r espon se. To com pu t e t h e n u m er a t or , yulewalk t a kes t h e followin g st eps:
1 Com pu t es a n u m er a t or polyn om ia l cor r espon din g t o a n a ddit ive
filt er .
4 Obt a in s t h e n u m er a t or polyn om ia l by a lea st -squ a r es fit t o t h is im pu lse
r espon se.
6-377
yulewalk
See Also
butter cheby1 cheby2 ellip fir2 firls maxflat remez
Bu t t er wor t h a n a log a n d digit a l filt er design . Ch ebysh ev t ype I filt er design (pa ssba n d r ipple). Ch ebysh ev t ype II filt er design (st opba n d r ipple). E llipt ic (Ca u er ) filt er design . Win dow-ba sed fin it e im pu lse r espon se filt er design a r bit r a r y r espon se. Lea st squ a r e lin ea r-ph a se F IR filt er design . Gen er a lized digit a l Bu t t er wor t h filt er design . Pa r ks-McClella n opt im a l F IR filt er design .
References
[1] F r iedla n der , B., a n d B. P or a t . Th e Modified Yu le-Wa lker Met h od of ARMA Spect r a l E st im a t ion . IE E E T ran saction s on Aerospace E lectron ic S ystem s . AE S-20, No. 2 (Ma r ch 1984). P gs. 158-173.
6-378
zp2sos
Purpose Syntax
6zp2sos
Con ver sion of zer o-pole-ga in t o secon d-or der sect ion s.
[sos,g] = zp2sos(z,p,k) [sos,g] = zp2sos(z,p,k,'order') [sos,g] = zp2sos(z,p,k,'order','scale') sos = zp2sos(...) zp2sos con ver t s a zer o-pole-ga in r epr esen t a t ion of a given syst em t o a n
Description
equ iva len t secon d-or der sect ion r epr esen t a t ion .
[sos,g] = zp2sos(z,p,k) fin ds a m a t r ix sos in secon d-or der sect ion for m wit h ga in g equ iva len t t o t h e zer o-pole-ga in syst em r epr esen t ed by in pu t a r gu m en t s z, p, a n d k. Vect or s z a n d p con t a in t h e zer os a n d poles of t h e syst em H (z ), n ot n ecessa r ily in a n y or der :
(z z 1 )(z z 2 )L (z z n ) H (z ) = k ---------------------------------------------------------------( z p 1 )( z p 2 )L (z p m ) wh er e n a n d m a r e t h e len gt h s of z a n d p, r espect ively, a n d k is a sca la r ga in . Th e zer os a n d poles m u st be r ea l or com plex con ju ga t e pa ir s. sos is a n L -by-6 m a t r ix: b 01 b 11 b 21 1 a 11 a 21 s os = b 02 b 12 b 22 1 a 12 a 22 M M M b0L b1L b2L M M M 1 a1L a2L
wh ose r ows con t a in t h e n u m er a t or a n d den om in a t or coefficien t s b ik a n d a ik of t h e secon d-or der sect ion s of H (z ):
L L
H (z ) = g
0
k =1
H k (z ) = g
0
k =1
b 0 k + b 1 k z 1 + b 2 k z 2 --------------------------------------------------------1 + a 1 k z 1 + a 2 k z 2
6-379
zp2sos
[sos,g] = zp2sos(z,p,k,'order') specifies t h e or der of t h e r ows in sos,
wh er e order is: down, t o or der t h e sect ion s so t h e fir st r ow of sos con t a in s t h e poles closest t o t h e u n it cir cle up, t o or der t h e sect ion s so t h e fir st r ow of sos con t a in s t h e poles fa r t h est fr om t h e u n it cir cle (defa u lt )
[sos,g] = zp2sos(z,p,k,'order','scale') specifies t h e desir ed sca lin g of t h e ga in a n d t h e n u m er a t or coefficien t s of a ll secon d-or der sect ion s, wh er e scale is:
none, t o a pply n o sca lin g (defa u lt ) inf, t o a pply in fin it y-n or m sca lin g two, t o a pply 2-n or m sca lin g Usin g in fin it y-n or m sca lin g in con ju n ct ion wit h up-or der in g m in im izes t h e pr oba bilit y of over flow in t h e r ea liza t ion . Usin g 2-n or m sca lin g in con ju n ct ion wit h down-or der in g m in im izes t h e pea k r ou n d-off n oise.
sos = zp2sos(...) em beds t h e over a ll syst em ga in , g, in t h e fir st sect ion ,
H 1 (z ), so t h a t
L
H (z ) =
0 H k (z )
k =1
Example
Algorithm
zp2sos u ses a fou r -st ep a lgor it h m t o det er m in e t h e secon d-or der sect ion
cplxpair fu n ct ion .
2 It for m s t h e secon d-or der sect ion by m a t ch in g t h e pole a n d zer o pa ir s
6-380
zp2sos
poles.
b Ma t ch t h e poles n ext closest t o t h e u n it cir cle wit h t h e zer os closest t o
t h ose poles.
c
cir cle. zp2sos n or m a lly or der s t h e sect ion s wit h poles closest t o t h e u n it cir cle la st in t h e ca sca de. You ca n t ell zp2sos t o or der t h e sect ion s in t h e r ever se or der by specifyin g t h e down fla g.
4 zp2sos sca les t h e sect ion s by t h e n or m specified in t h e 'scale' a r gu m en t .
1 = -----2$
6
0
H (#) d #
1 -p
wh er e p ca n be eit h er * or 2. See t h e r efer en ces for det a ils on t h e sca lin g. Th is sca lin g is a n a t t em pt t o m in im ize over flow or pea k r ou n d-off n oise in fixed poin t filt er im plem en t a t ion s.
See Also
Gr ou p com plex n u m ber s in t o com plex con ju ga t e pa ir s. Con ver sion of secon d-or der sect ion s t o zer o-pole-ga in . Con ver sion of st a t e-spa ce t o secon d-or der sect ion s. Con ver sion of t r a n sfer fu n ct ion t o secon d-or der sect ion s. Con ver sion of zer o-pole-ga in t o st a t e-spa ce. Con ver sion of zer o-pole-ga in t o t r a n sfer fu n ct ion .
6-381
zp2sos
References
[1] J a ckson , L.B. Digital Filters an d S ign al Processin g . 3r d ed. Bost on : Klu wer Aca dem ic P u blish er s, 1996. Ch a pt er 11. [2] Mit r a , S.K. Digital S ign al Processin g: A Com pu ter-B ased Approach . New Yor k : McGr a w-H ill, 1998. Ch a pt er 9. [3] Va idya n a t h a n , P .P . Robu st Digit a l F ilt er St r u ct u r es. H an d book for Digital S ign al Processin g . S.K. Mit r a a n d J .F . Ka iser , ed. Ch a pt er 7. New Yor k: J oh n Wiley & Son s, 1993.
6-382
zp2ss
Purpose Syntax Description
6zp2ss
r epr esen t a t ion x = Ax + Bu y = Cx + Du given a syst em in fa ct or ed t r a n sfer fu n ct ion for m ( s z 1 )( s z 2 )L (s z n ) Z (s ) H (s ) = --------- = k --------------------------------------------------------------( s p 1 )(s p 2 )L (s p n ) P (s ) Colu m n vect or p specifies t h e pole loca t ion s, a n d m a t r ix z t h e zer o loca t ion s wit h a s m a n y colu m n s a s t h er e a r e ou t pu t s. Th e ga in s for ea ch n u m er a t or t r a n sfer fu n ct ion a r e in vect or k. Th e A, B, C, a n d D m a t r ices a r e r et u r n ed in con t r oller ca n on ica l for m .
Inf va lu es m a y be u sed a s pla ce h older s in z if som e colu m n s h a ve fewer zer os t h a n ot h er s.
Algorithm
zp2ss, for sin gle-in pu t syst em s, gr ou ps com plex pa ir s t oget h er in t o t wo-by-t wo blocks down t h e dia gon a l of t h e A m a t r ix. Th is r equ ir es t h e zer os a n d poles t o be r ea l or com plex con ju ga t e pa ir s. sos2ss ss2zp tf2ss zp2sos zp2tf
See Also
Con ver sion of secon d-or der sect ion s t o st a t e-spa ce. Con ver sion of st a t e-spa ce t o zer o-pole-ga in . Con ver sion of t r a n sfer fu n ct ion t o st a t e-spa ce. Con ver sion of zer o-pole-ga in t o secon d-or der sect ion s. Con ver sion of zer o-pole-ga in t o t r a n sfer fu n ct ion .
6-383
zp2tf
Purpose Syntax Description
6zp2t f
syst em in fa ct or ed for m .
[b,a] = zp2tf(z,p,k) fin ds a r a t ion a l t r a n sfer fu n ct ion :
+ b (n b 1 )s + b n b b 1 s (n b 1 ) + L B (s ) ---------- = ---------------------------------------------------------------------------------( n a 1 ) A (s ) +L + a (n a 1 )s + a n a a1s given a syst em in fa ct or ed t r a n sfer fu n ct ion for m : ( s z 1 )( s z 2 )L (s z m ) Z (s ) H (s ) = --------- = k --------------------------------------------------------------( s p 1 )(s p 2 )L (s p n ) P (s ) Colu m n vect or p specifies t h e pole loca t ion s, a n d m a t r ix z t h e zer o loca t ion s, wit h a s m a n y colu m n s a s t h er e a r e ou t pu t s. Th e ga in s for ea ch n u m er a t or t r a n sfer fu n ct ion a r e in vect or k. Th e zer os a n d poles m u st be r ea l or com e in com plex con ju ga t e pa ir s. Th e polyn om ia l coefficien t s a r e r et u r n ed in vect or s: t h e den om in a t or coefficien t s in r ow vect or a a n d t h e n u m er a t or coefficien t s in m a t r ix b, wit h a s m a n y r ows a s t h er e a r e colu m n s of z.
Inf va lu es ca n be u sed a s pla ce h older s in z if som e colu m n s h a ve fewer zer os t h a n ot h er s.
Th e syst em is con ver t ed t o t r a n sfer fu n ct ion for m u sin g poly wit h p a n d t h e colu m n s of Z.
sos2tf ss2tf tf2zp zp2sos zp2ss
Con ver sion of secon d-or der sect ion s t o t r a n sfer fu n ct ion . Con ver sion of st a t e-spa ce t o t r a n sfer fu n ct ion . Con ver sion of t r a n sfer fu n ct ion t o zer o-pole-ga in . Con ver sion of zer o-pole-ga in t o secon d-or der sect ion s. Con ver sion of zer o-pole-ga in t o st a t e-spa ce.
6-384
zplane
Purpose Syntax
6zpla n e
Description
or
set(gca,'ylim',[ymin ymax])
or
set(gca,'xlim',[xmin xmax])
a ft er ca llin g zplane. Th is is u sefu l in t h e ca se wh er e on e or a few of t h e zer os or poles h a ve su ch a la r ge m a gn it u de t h a t t h e ot h er s a r e gr ou ped t igh t ly a r ou n d t h e or igin a n d a r e h a r d t o dist in gu ish .
zplane(b,a) wh er e b a n d a a r e r ow vect or s, fir st u ses roots t o fin d t h e zer os a n d poles of t h e t r a n sfer fu n ct ion r epr esen t ed by n u m er a t or coefficien t s b a n d den om in a t or coefficien t s a. [hz,hp,ht] = zplane(z,p) r et u r n s vect or s of h a n dles t o t h e zer o lin es, hz, a n d t h e pole lin es, hp. ht is a vect or of h a n dles t o t h e a xes/u n it cir cle lin e a n d t o t ext object s, wh ich a r e pr esen t wh en t h er e a r e m u lt iple zer os or poles. If t h er e a r e n o zer os or n o poles, hz or hp is set t o t h e em pt y m a t r ix [].
6-385
zplane
Examples
P lot t h e poles a n d zer os of a 5t h -or der Bu t t er wor t h lowpa ss digit a l filt er wit h cu t off fr equ en cy of 0.2:
[z,p,k] = butter(5,0.2); zplane(z,p); title('5th-Order Butterworth Lowpass Digital Filter');
5th!Order Butterworth Lowpass Digital Filter 1 0.8 0.6 0.4 Imaginary Part 0.2 0 !0.2 !0.4 !0.6 !0.8 !1 !1 !0.5 0 Real Part 0.5 1 5
See Also
freqz
6-386
Index
A
abs 6-2, 6-12 ac2poly 6-3, 6-13 ac2rc 6-3, 6-14
a lgor it h m , filt er in g in SP Tool 5-18 a lia sed sin c fu n ct ion . S ee Dir ich let fu n ct ion a lia sin g a n d im pu lse in va r ia n ce 2-42 pr even t in g du r in g r esa m plin g 4-21 r edu cin g wit h a n a lyt ic sign a l 4-38 a ll-pole filt er . S ee IIR filt er a ll-zer o filt er . S ee F IR filt er am 4-29 AM. S ee a m plit u de m odu la t ion amdsbsc 4-29, 6-236 amdsbtc 4-29, 6-236 a m plit u de dem odu la t ion dou ble side-ba n d, su ppr essed ca r r ier 6-114 dou ble side-ba n d, t r a n sm it t ed ca r r ier 6-114 sin gle side-ba n d 6-114 a m plit u de m odu la t ion 4-29 dou ble side-ba n d, su ppr essed ca r r ier 6-236 dou ble side-ba n d, t r a n sm it t ed ca r r ier 6-236 sin gle side-ba n d 6-236 amssb 4-30, 6-236 a n a log filt er Bessel 6-22 Bu t t er wor t h 6-44 Ch ebysh ev t ype I 6-66 Ch ebysh ev t ype II 6-71 con ver t in g t o digit a l 2-41, 6-194
design 2-7 Bessel 2-11, 6-22 Bu t t er wor t h 6-43 Ch ebysh ev t ype I 6-65 Ch ebysh ev t ype II 6-71 ellipt ic 6-125, 6-126 in ver se 6-203 fr equ en cy r espon se 1-26, 6-173 or der est im a t ion Bu t t er wor t h 6-49 Ch ebysh ev t ype I 6-56 Ch ebysh ev t ype II 6-61 ellipt ic 6-133 r epr esen t a t ion a l m odels 1-40 a n a log fr equ en cy xvii a n a log pr ot ot ype 2-38 Bessel filt er 2-11, 6-21 Bu t t er wor t h filt er 2-8, 6-42 Ch ebysh ev t ype I filt er 2-9, 6-54 Ch ebysh ev t ype II filt er 2-10, 6-59 con ver sion t o ba n dpa ss 6-220 con ver sion t o ba n dst op 6-223 con ver sion t o h igh pa ss 6-225 con ver sion t o lowpa ss 6-227 ellipt ic filt er 6-131 fr equ en cy r espon se 2-12 plot t in g 2-12 a n a log pr ot ot ype design Bessel 2-38 bilin ea r t r a n sfor m a t ion 2-43 Bu t t er wor t h 2-38 Ch ebysh ev 2-38 ellipt ic 2-38 filt er discr et iza t ion 2-41 fr equ en cy t r a n sfor m a t ion 2-38 im pu lse in va r ia n ce 2-42
I-1
Index
S ee also IIR filt er design a n a log sign a l. S ee sign a l a n a lyt ic sign a l 2-26, 6-187 a pplica t ion s 4-38 pr oper t ies 4-38 angle 6-2, 6-15 a n t i-sym m et r ic filt er 2-25 Apply bu t t on , Spect r u m Viewer 5-97 Apply F ilt er bu t t on 5-18 a pplyin g pa r a m et er s wit h Apply bu t t on 5-100 arburg 4-11, 6-16 arcov 4-11, 6-17 ARMA filt er 1-15 S ee also IIR filt er ARMA m odel 4-13, 4-15 P r on ys m et h od 4-13 St eiglit z-McBr ide m et h od 4-15 armcov 4-11, 6-18 array displa y in Sign a l Br owser 5-47, 5-51 in SP Tool 5-14 Ar r a y Sign a ls bu t t on , Sign a l Br owser 5-47, 5-51 ARX m odel 4-13 aryule 4-11, 6-19 ASCII file, im por t in g 1-13 a t t en u a t ion , st opba n d 5-70 a t t r ibu t es, in st a n t a n eou s 6-187 a u t ocor r ela t ion 6-368 m u lt iple ch a n n els 3-4 t wo-dim en sion a l 6-372 a u t ocor r ela t ion sequ en ce con ver t in g fr om filt er coefficien t s 6-262 con ver t in g fr om r eflect ion coefficien t s 6-282 con ver t in g t o filt er coefficien t s 6-13 con ver t in g t o r eflect ion coefficien t s 6-14 a u t ocova r ia n ce 6-373 m u lt iple ch a n n els 3-4
a u t or egr essive (AR) filt er 1-15 S ee also IIR filt er a u t or egr essive (AR) m odel via Bu r g m et h od 6-16, 6-239 via cova r ia n ce m et h od 6-17, 6-243 via m odified cova r ia n ce m et h od 6-18, 6-247 via Yu le-Wa lker AR m et h od 6-19, 6-278 a u t or egr essive m ovin g a ver a ge (ARMA) filt er 1-15 S ee also IIR filt er a u t o-spect r u m , in SP Tool 5-15 a ver a gin g filt er 1-14 a xis la bels, in Sign a l Br owser 5-20, 5-23 a xis pa r a m et er s in F ilt er Viewer 5-20 in Spect r u m Viewer 5-20 a xis sca lin g r an ge in F ilt er Viewer 5-25, 5-87 in Spect r u m Viewer 5-24, 5-100, 5-102 a xis sca lin g u n it s in F ilt er Viewer 5-25, 5-87 in Spect r u m Viewer 5-24, 5-100, 5-102
B
ba n d edges, pr ewa r pin g 2-44 ba n dlim it ed in t er pola t ion 6-314 ba n dpa ss filt er a n a log pr ot ot ype design 2-6 a n d im pu lse in va r ia n ce 2-42 Bessel 6-22 Bu t t er wor t h 6-43, 6-44 Ch ebysh ev t ype I 6-65, 6-66 Ch ebysh ev t ype II 6-70, 6-71 ellipt ic 6-125, 6-126 exa m ple, Ch ebysh ev t ype I 2-40 F IR design , wit h win dow m et h od 2-21, 6-154 t r a n sfor m a t ion fr om lowpa ss t o 6-220
I-2
Index
ba n dst op filt er a n a log pr ot ot ype design 2-6 Bessel 6-22 Bu t t er wor t h 6-44, 6-45 Ch ebysh ev t ype I 6-66, 6-67 Ch ebysh ev t ype II 6-71, 6-72 ellipt ic 6-126, 6-127 F IR design , wit h win dow m et h od 2-21, 6-153 t r a n sfor m a t ion fr om lowpa ss t o 6-223 ba n dwidt h 2-40 bartlett 4-2, 6-8, 6-20 com pa r ed t o triang 6-20 exa m ple 4-2 Ba r t let t win dow 4-2 coefficien t s 6-20 Bessel filt er a n a log 6-22 a n a log pr ot ot ype 2-11, 2-38, 6-21 ba n dpa ss con figu r a t ion , a n a log 6-22 ba n dst op con figu r a t ion , a n a log 6-22 ch a r a ct er ist ics 2-11 h igh pa ss con figu r a t ion , a n a log 6-22 lim it a t ion s 6-24 lowpa ss con figu r a t ion , a n a log 6-22 besselap 2-5, 6-10, 6-21 exa m ple 2-11 besself 2-5, 2-6, 6-5, 6-22 bet a pa r a m et er , of Ka iser win dow 5-75 bia s cor r ela t ion 3-3, 4-12 power spect r a l den sit y 3-12 spect r a l den sit y 3-12 va r ia n ce t r ade-off 3-4 bilinear 2-5, 2-42, 2-43, 6-11, 6-25 bilin ea r t r a n sfor m a t ion 2-43, 6-25 defin ed 2-43 ou t pu t r epr esen t a t ion 6-26
pr ewa r pin g 2-44, 6-25 blackman 4-2, 6-8, 6-30 Bla ckm a n win dow 4-4, 6-30 defin ed 4-4 boxcar 4-2, 6-8, 6-32 exa m ple 4-2 boxca r win dow. S ee r ect a n gu la r win dow br a cket s, in dica t in g closed in t er va l xvii bu ffer in g 6-33 Bu r g m et h od 3-5, 3-6, 3-20 com pa r ed t o Welch s m et h od 3-22 defin ed 3-20 exa m ple 3-21 in Spect r u m Viewer 5-104 buttap 2-5, 6-10, 6-42 exa m ple 2-8 butter 2-5, 2-6, 6-5, 6-43 Bu t t er wor t h filt er a n a log 6-44 a n a log pr ot ot ype 2-8, 2-38, 6-42 ba n dpa ss con figu r a t ion a n a log 6-44 digit a l 6-43 ba n dst op con figu r a t ion a n a log 6-45 digit a l 6-44 ch a r a ct er ist ics 2-8 design 6-43 digit a l 6-43 gen er a lized 2-14 h igh pa ss con figu r a t ion a n a log 6-45 digit a l 6-44 lim it a t ion s 6-47 lowpa ss con figu r a t ion a n a log 6-44 digit a l 6-43
I-3
Index
C
ca n on ica l for m s 1-17, 6-351 ca r r ier fr equ en cy 4-29, 6-236, 6-365 ca r r ier sign a l 4-29, 6-114 ca scade, digit a l filt er 1-37 Ca u er filt er . S ee ellipt ic filt er cceps 4-23, 6-9, 6-52 exa m ple 4-23 cen t er fr equ en cy 2-40 cen t r a l fea t u r es 1-2 cepst r u m a pplica t ion s 4-23 com plex 4-23 in ver se 4-23, 4-25 over view 4-23 r ea l 4-23 S ee also r ea l cepst r u m , com plex cepst r u m cepst r u m a n a lysis 4-23 cheb1ap 2-5, 6-10, 6-54 exa m ple 2-9, 2-40 cheb1ord 2-5, 6-5, 6-55 cheb2ap 2-5, 6-10, 6-59 exa m ple 2-10 cheb2ord 2-5, 6-5, 6-60 chebwin 4-2, 6-8, 6-64 cheby1 2-5, 2-6, 6-5, 6-65 exa m ple 2-45 cheby2 2-5, 2-6, 6-5, 6-70 Ch ebysh ev er r or m in im iza t ion 2-22, 6-287 Ch ebysh ev t ype I filt er a n a log 6-66 a n a log pr ot ot ype 2-9, 2-38, 6-54
ba n dpa ss con figu r a t ion a n a log 6-66 digit a l 6-65 ba n dst op con figu r a t ion a n a log 6-67 digit a l 6-66 ch a r a ct er ist ics 2-9 design 6-65 digit a l 6-65 h igh pa ss con figu r a t ion a n a log 6-67 digit a l 6-66 lowpa ss con figu r a t ion a n a log 6-66 digit a l 6-65 or der est im a t ion 2-7, 6-55 Ch ebysh ev t ype II filt er a n a log 6-71 a n a log pr ot ot ype 2-38, 6-59 ba n dpa ss con figu r a t ion a n a log 6-71 digit a l 6-70 ba n dst op con figu r a t ion a n a log 6-72 digit a l 6-71 ch a r a ct er ist ics 2-10 design 6-70 digit a l 6-70 h igh pa ss con figu r a t ion a n a log 6-72 digit a l 6-71 lim it a t ion s 6-69 lowpa ss con figu r a t ion a n a log 6-71 digit a l 6-70 or der est im a t ion 2-7, 6-60 Ch ebysh ev win dow 4-9, 6-64
I-4
Index
fr equ en cy r espon se 4-9 chirp 1-9, 6-2, 6-75 ch ir p sign a l 1-9 ch ir p z -t r a n sfor m (CZT) 4-34, 6-105 com pa r ed t o discr et e F ou r ier t r a n sfor m 4-34 execu t ion t im e 4-35 for n a r r owba n d fr equ en cy a n a lysis 6-105 cla ssica l IIR filt er design 2-8 click-a n d-dr a g pa n n in g, in Sign a l Br owser 5-48 coefficien t s cor r ela t ion 6-88 filt er 1-15, 5-79, 6-13, 6-262, 6-263, 6-283 lin ea r pr edict ion 6-229 r eflect ion 1-37, 6-14, 6-263, 6-282, 6-283 sequ en ce 6-282 cohere 3-6, 3-16, 6-7, 6-79 coh er en ce 3-15, 6-79 defin ed 3-15 coh er en ce fu n ct ion 3-15 Color bu t t on 5-35 color or der in Sign a l Br owser 5-22 in Spect r u m Viewer 5-22 Color Or der t ext box 5-22 color , cu st om izin g in SP Tool 5-20 colu m n in dex vect or , en t er in g in Sign a l Br owser 5-47 colu m n , a r r a y 5-47 com m u n ica t ion s 4-10 com m u n ica t ion s sim u la t ion 4-29, 6-114, 6-236 S ee also m odu lat ion , dem odu la t ion , volt a ge con t r olled oscilla t ion Com pa ct Disc st a n da r d 4-20 com plex cepst r u m , defin ed 4-23 com plex con ju ga t e 6-90 Com plex Displa y m ode 5-47 com plex en velope 4-38
com plex n u m ber s, gr ou pin g by con ju ga t e 6-90 com plex sign a ls, in Sign a l Br owser 5-47 com pu t a t ion pa r a m et er s, in Spect r u m Viewer 5-103, 5-104 Con f. In t . ch eck box 5-107 con fiden ce in t er va l for cr oss spect r a l den sit y 3-14 for power spect r a l den sit y 3-14, 5-107 set t in g in Spect r u m Viewer 5-107 con ser va t ion of t ot a l power , u sin g pmtm 3-19 con t ext sen sit ive h elp in SP Tool 5-7 con t in u ou s sign a l. S ee sign a l con t in u ou s-t im e filt er . S ee a n a log filt er con t r ol syst em s 1-35 Con t r ol Syst em s Toolbox 1-35, 6-198 conv 1-14, 1-20, 6-2, 6-83 conv2 1-14, 6-2, 6-84 con ver sion a u t ocor r ela t ion sequ en ce t o filt er coefficien t s 6-13 a u t ocor r ela t ion sequ en ce t o r eflect ion coefficien t s 6-14 filt er coefficien t s t o a u t ocor r ela t ion sequ en ce 6-262 filt er coefficien t s t o r eflect ion coefficien t s 6-263, 6-283 r eflect ion coefficien t s t o a u t ocor r ela t ion sequ en ce 6-282 secon d-or der sect ion s t o st a t e-spa ce 6-316 secon d-or der sect ion s t o t r a n sfer fu n ct ion 6-318 secon d-or der sect ion s t o zer o-pole-ga in 6-320 st a t e-spa ce t o secon d-or der sect ion s 6-333 st a t e-spa ce t o zer o-pole-ga in 6-338 t r a n sfer fu n ct ion t o la t t ice 6-346 t r a n sfer fu n ct ion t o secon d-or der sect ion s 6-347
I-5
Index
t r a n sfer fu n ct ion t o st a t e-spa ce 6-350 zer o-pole-ga in t o secon d-or der sect ion 6-379 zer o-pole-ga in t o st a t e-spa ce 6-383 convmtx 1-39, 1-42, 6-3, 6-86 con volu t ion a n d cr oss-cor r ela t ion 3-3 a n d filt er in g 1-14, 6-148 con volu t ion m a t r ix 1-39, 6-86 defin ed 6-83 exa m ple 1-14 t wo-dim en sion a l 6-84 obt a in in g su bsect ion 6-84 con volu t ion m a t r ix 1-42, 6-86 defin ed 1-39 exa m ple 6-86 corrcoef 6-7, 6-88 cor r ela t ion 3-2 coefficien t m a t r ix 6-88 S ee also a u t ocor r ela t ion , cr oss-cor r ela t ion cosin e win dow 4-4 cov 6-7, 6-89 cova r ia n ce 3-2 m a t r ix 6-89 S ee also au t ocova r ia n ce, cr oss-cova r ia n ce cova r ia n ce m et h od 3-6, 3-22 defin ed 3-22 exa m ple 3-23 cova r ia n ce m et h od, in Spect r u m Viewer 5-105 cplxpair 6-9, 6-90 Cr ea t e bu t t on , in Spect r a pa n el 5-19, 5-97 cremez 2-17, 6-5, 6-91 cr oss spect r a l den sit y 3-14, 6-100 con fiden ce in t er va l 3-14 defin ed 3-5 cr oss-cor r ela t ion 6-367 bia sed 3-3 m u lt iple ch a n n els 3-4
n or m a liza t ion 3-4 t wo-dim en sion a l 6-372 u n bia sed 3-3 cr oss-cova r ia n ce 6-373 m u lt iple ch a n n els 3-4 csd 3-6, 3-14, 6-7, 6-100 CSD. S ee cr oss spect r a l den sit y cu t off fr equ en cy 2-38 defin ed 6-22 for Ka iser win dow filt er 5-75 czt 4-35, 6-6, 6-105 CZT. S ee ch ir p z -t r a n sfor m
D
da t a du plica t in g in SP Tool 5-16 edit in g in SP Tool 5-13, 5-15 en t er in g 1-13 expor t in g fr om SP Tool 5-6 im por t in g 1-13 im por t in g in t o SP Tool 5-3, 5-6, 5-7 m ea su r in g in SP Tool 5-31 m u lt ich a n n el 1-4, 1-7 viewin g in SP Tool 5-31 da t a com pr ession 4-10 da t a m at r ix 1-4, 1-7 da t a vect or 1-4 dct 4-36, 6-6, 6-108 exa m ple 4-37 decimate 6-9, 6-110 decim a t ion 6-110 F IR filt er for 6-201 deconv 4-33, 6-9, 6-113 exa m ple 4-33 decon volu t ion 4-33, 6-113 defa u lt plot , in Spect r u m Viewer 5-102
I-6
Index
Defa u lt Session ch eck box, in P r efer en ces dia log box 5-28 Defa u lt SP Tool session file 5-20, 5-28 defa u lt va lu es, u sin g em pt y m a t r ix 3-11 dela y a ddin g t o sign a l 2-25 gr ou p 1-28 n on in t eger 2-26 ph a se 1-28 demod 4-29, 4-30, 6-9, 6-114 exa m ple 4-30 dem odu la t ion 4-30, 6-114 exa m ple 4-30 m et h ods 4-30, 6-114 design , gen er a lized filt er 2-5 design ed filt er , in SP Tool 5-14 DF T. S ee discr et e F ou r ier t r a n sfor m dftmtx 6-6, 6-117 differ en ce equ a t ion , r ela t ion t o t r a n sfer fu n ct ion 1-32 differ en t ia t or 2-26, 6-167, 6-289 Digit a l Au dio Ta pe st a n da r d 4-20 digit a l filt er a n t i-ca u sa l 1-20 a s con volu t ion m a t r ix 1-40 Bu t t er wor t h 6-43 ca sca de 1-37 Ch ebysh ev t ype I 6-65 Ch ebysh ev t ype II 6-70 coefficien t s 1-15 design 2-2 ellipt ic 6-125 F IR 2-16 com pa r ed t o IIR 2-16 fixed-poin t im plem en t a t ion 1-37 fr equ en cy r espon se 1-24 gr ou p dela y 1-28, 6-182
iden t ifica t ion fr om fr equ en cy da t a 6-207 IIR 2-4 com pa r ed t o F IR 2-4 im plem en t a t ion 1-14, 6-142, 6-145 F F T-ba sed (F IR) 6-142 over la p-a dd m et h od 1-22 u sin g con volu t ion 1-14 u sin g filter fu n ct ion 1-16 im pu lse r espon se 1-14, 1-23, 6-196 in it ia l con dit ion s 1-17 lin ea r syst em m odels 1-32 n a m es 1-15 or der 1-15 in st a t e-spa ce r epr esen t a t ion 1-34 or der est im a t ion Bu t t er wor t h 6-48 Ch ebysh ev t ype I 6-55 Ch ebysh ev t ype II 6-60 ellipt ic 6-132 equ ir ipple F IR 6-294 ph a se dela y 1-28, 6-182 poles 1-30, 1-33 r epr esen t a t ion a l m odels 1-32 r epr esen t in g in MATLAB 1-32 secon d-or der sect ion s 1-37 specifica t ion s 2-7 st a r t u p t r a n sien t s 1-21, 1-22 st r u ct u r e la t t ice 1-37 t r a n sposed dir ect for m II 1-17 t im e-dom a in r epr esen t a t ion 1-16 t r a n sfer fu n ct ion r epr esen t a t ion 1-15 t wo-dim en sion a l 6-148 zer o-ph a se 1-20, 6-149 zer os 1-30, 1-33 zer os a n d poles 1-33 S ee also F IR filt er , IIR filt er
I-7
Index
digit a l filt er design F IR 2-16 IIR 2-4 digit a l fr equ en cy xvii dir ect design 2-13 descr ibed 2-13 su m m a r y 2-5 diric 6-2, 6-118 Dir ich let fu n ct ion 1-11, 6-118 defin ed 1-11 exa m ple 1-12 discr et e cosin e t r a n sfor m (DCT) 6-108 a pplica t ion s 4-36 en er gy com pa ct ion pr oper t y 4-37 exa m ple 4-37 in ver se 4-36, 6-190 r econ st r u ct in g sign a l fr om few coefficien t s 4-37 discr et e F ou r ier t r a n sfor m (DF T) 1-2, 1-43 a lgor it h m s 1-45 a n d IIR filt er im plem en t a t ion 1-22 a n d spect r a l a n a lysis 3-6 a pplica t ion s 6-137 depen den ce on sign a l len gt h 1-45 exa m ple 1-44 execu t ion t im e, u sin g ch ir p z -t r a n sfor m 4-35 in ver se 1-43, 6-192 m a t r ix 6-117 t wo-dim en sion a l 1-45, 6-193 m a t r ix 6-117 t wo-dim en sion a l 1-45, 6-141 S ee also fa st F ou r ier t r a n sfor m (F F T), fft discr et e pr ola t e sph er oida l sequ en ces (DP SSs) 3-19 discr et e-t im e F ou r ier t r a n sfor m 3-5 discr et iza t ion 2-41, 6-194
bilin ea r t r a n sfor m a t ion 2-43 pr ewa r pin g 2-44 im pu lse in va r ia n ce 2-42 disk, loa din g va r ia bles fr om 5-8 dpss 6-9, 6-119 dpss.mat 3-19 dpssclear 3-19, 6-9, 6-121 dpssdir 3-19, 6-9, 6-122 dpssload 3-19, 6-9, 6-123 DP SSs. S ee discr et e pr ola t e sph er oida l sequ en ces dpsssave 3-19, 6-9, 6-124 du t y cycle, specifyin g 1-8
E
ech o det ect ion 4-23 edge effect s 1-22 edge fr equ en cies, set t in g in F ilt er Design er 5-70 E dit Design bu t t on 5-18, 5-59 eig, in pmusic fu n ct ion 3-25 eigen a n a lysis defin ed 3-24 fr equ en cy est im a t or fu n ct ion s 3-24 eigen vect or m et h od 3-5, 3-23 S ee also m u lt iple sign a l cla ssifica t ion m et h od ellip 2-5, 2-6, 6-5, 6-125 ellipap 2-5, 6-10, 6-131 exa m ple 2-10 ellipord 2-5, 6-5, 6-132 ellipt ic filt er a n a log 6-126 a n a log pr ot ot ype 2-38, 6-131 ba n dpa ss con figu r a t ion a n a log 6-126 digit a l 6-125
I-8
Index
ba n dst op con figu r a t ion a n a log 6-127 digit a l 6-126 ch a r a ct er ist ics 2-10 design 6-125 digit a l 6-125 h igh pa ss con figu r a t ion a n a log 6-127 digit a l 6-126 lim it a t ion s 6-129 lowpa ss con figu r a t ion a n a log 6-126 digit a l 6-125 or der est im a t ion 2-7, 6-132 en er gy com pa ct ion 4-37 equ ir ipple ch a r a ct er ist ics Ch ebysh ev t ype I filt er (pa ssba n d) 2-9 Ch ebysh ev t ype II filt er (st opba n d) 2-10 Ch ebysh ev win dow 4-9 ellipt ic filt er 2-10, 6-125, 6-131 fr om P a r ks-McClella n design 6-287 equ ir ipple filt er 2-22 er r or m in im iza t ion bet ween desir ed a n d a ct u a l r espon se 2-22 for equ ir ipple filt er 5-75 for lea st squ a r es filt er 5-75 in t egr a l of squ a r e 2-22 m in im a x 2-22 weigh t in g in fr equ en cy ba n ds 2-24 est im a t ion cr oss spect r u m 3-14 power spect r u m 3-6 t r a n sfer fu n ct ion 3-14 S ee also pa r am et r ic m odelin g est im a t ion m et h ods in Spect r u m Viewer 5-103, 5-104
n on pa r a m et r ic F F T m et h od 5-105 m u lt iple sign a l cla ssifica t ion m et h od (MUSIC) 3-5, 5-106 m u lt it a per m et h od (MTM) 3-5, 5-105 Welch s m et h od 3-5, 5-106 pa r a m et r ic 3-5 Bu r g m et h od 5-104, 6-16 cova r ia n ce m et h od 6-17 m odified cova r ia n ce m et h od 6-18 Yu le-Wa lker AR m et h od 5-107 Yu le-Wa lker m et h od 6-19 E xpor t F ilt er s a s TF object s ch eck box, in P r efer en ces dia log box 5-29 E xpor t m en u it em 5-6 E xpor t in g Com pon en t s ch eck box, in P r efer en ces dia log box 5-29 expor t in g da t a fr om MATLAB 1-13 ext en sion s t o SP Tool 5-30
F
F a ct or y Set t in gs bu t t on , in P r efer en ces dia log box 5-30 fa st F ou r ier t r a n sfor m (F F T) 1-22, 1-43 a n d fr equ en cy r espon se 1-24 fft 1-22 pr im e fa ct or a lgor it h m 1-45, 6-139 r a dix-2 a lgor it h m 1-45, 6-139 r ole in sign a l pr ocessin g 1-43 t wo-dim en sion a l 6-141 fft 1-2, 1-22, 1-43, 6-6, 6-137 com plex in pu t s 1-45 exa m ple 1-44 execu t ion t im e 1-45, 6-140 pr im e fa ct or a lgor it h m 1-45, 6-139 r a dix-2 a lgor it h m 1-45, 6-139
I-9
Index
r ea l in pu t s 1-45 r ea r r a n gin g ou t pu t 1-45, 6-144 specifyin g n u m ber of poin t s 1-44 F F T len gt h in F ilt er Design er 5-20, 5-27 in F ilt er Viewer 5-25 F F T Len gt h edit box, in P r efer en ces dia log box 5-25, 5-27 F F T m et h od, in Spect r u m Viewer 5-105 F F T. S ee fa st F ou r ier t r a n sfor m fft2 1-45, 6-6, 6-141 r ea r r a n gin g ou t pu t 1-45 F F T-ba sed filt er in g 1-22 fftfilt 1-19, 6-2, 6-142 com pa r ed t o filter 6-142 fftshift 1-45, 6-6, 6-144 F ile Con t en t s list 5-8 filt er a n a log pr ot ot ype 2-8, 2-11, 6-21, 6-42, 6-54, 6-59, 6-131 a n a lyzin g in F ilt er Viewer 5-17 a pplyin g t o a sign a l 5-18 Bu t t er wor t h 2-7, 6-43 gen er a lized 2-14 Ch ebysh ev 2-7 Ch ebysh ev t ype I 6-65 Ch ebysh ev t ype II 6-70 coefficien t s 1-15, 2-17, 5-79 design F IR 6-287 gen er a lized 2-5 IIR 2-5 in ver se 6-203, 6-207 discr et iza t ion 2-41 ellipt ic 2-7, 6-125 equ ir ipple 2-22
expor t in g a s TF object s for Con t r ol Syst em Toolbox 5-29 gr ou p dela y 5-17 iden t ifica t ion fr om fr equ en cy da t a 6-203 im plem en t a t ion 1-22, 6-142, 6-145 im por t in g in t o SP Tool 5-7, 5-8, 5-11 im pu lse r espon se 5-17 lin ea r t im e-in va r ia n t digit a l 1-2 m a gn it u de r espon se 5-17 m ea su r em en t s 5-37 m edia n 4-28, 6-235 m in im a x 2-22 m in im u m ph a se 6-265 m u lt iba n d F IR 2-22 n a m es 1-15 n a m in g in SP Tool 5-16 or der 1-15, 2-7, 6-48, 6-55, 6-60, 6-132 or der select ion 2-7 ph a se r espon se 5-17 pr in cipa l su ppor t ed 1-2 Sa vit zky-Gola y 6-309, 6-311 secon d-or der sect ion s 6-322 sin gle ba n d F IR 2-20 specifica t ion s 2-7 st ep r espon se 5-17 t r a n sposed dir ect for m II st r u ct u r e 1-17 t wo-dim en sion a l 6-148 t ypes 2-17 viewin g in F ilt er Viewer 5-17 zer os a n d poles 5-17 S ee also F IR filt er , IIR filt er , digit a l filt er , a n a log filt er filter 1-2, 1-16, 1-20, 6-2, 6-145 com pa r ed t o fftfilt 6-142 com pa r ed t o filtfilt 1-21 fin a l con dit ion pa r a m et er s 1-17 im plem en t a t ion 1-17
I-10
Index
in it ia l con dit ion pa r a m et er s 1-17 in it ia l con dit ion s 6-150 filt er coefficien t s con ver t in g fr om a u t ocor r ela t ion sequ en ce 6-13 con ver t in g t o a u t ocor r ela t ion sequ en ce 6-262 con ver t in g t o r eflect ion coefficien t s 6-263, 6-283 filt er design in F ilt er Design er 5-59, 5-73, 5-76 st a n da r d ba n d con figu r a t ion s 5-59 u sin g specifica t ion lin es 5-70 F ilt er Design er 5-2, 5-17, 5-59, 6-329 a ct iva t in g 5-17, 5-59 ch a n gin g plot pr oper t ies 5-27 cla ssica l IIR filt er design 5-76 closin g 5-60 cu st om izin g 5-20 m a gn it u de plot 5-63, 5-69, 5-78 m ea su r in g r espon se ch a r a ct er ist ics 5-70 sa vin g da t a t o wor kspa ce 5-79, 5-110 set t in g edge fr equ en cies 5-70 set t in g pa ssba n d r ipple 5-70 set t in g st opba n d a t t en u a t ion 5-70 sin gle ba n d F IR filt er design 5-73 win dow 5-60 filt er pa r a m et er s, in F ilt er Viewer 5-20 filt er r espon se, pea ks a n d va lleys 5-37 filt er t ype design 5-14 im por t ed 5-14, 5-18 F ilt er Viewer 5-2, 5-17, 5-84, 6-330 a ct iva t in g 5-17, 5-84 cu st om izin g 5-20 defa u lt plot 5-85 plot s 5-86 pr efer en ces 5-86
set t in gs 5-86 su bplot s 5-86 viewin g fr equ en cy r espon se 5-82 viewin g gr ou p dela y 5-93 viewin g im pu lse r espon se 5-94 viewin g m a gn it u de r espon se 5-89 viewin g ph a se r espon se 5-91 viewin g st ep r espon se 5-95 viewin g zer o-pole plot 5-94 win dow 5-85 filter2 6-3, 6-148 filt er in g a n d con volu t ion 1-14 a n t i-ca u sa l 1-20 fr equ en cy dom a in 1-22 in it ia l con dit ion s 1-17 gen er a t in g 1-18 zer o-ph a se 1-20 filt er in g a lgor it h m 5-18 filtfilt 1-19, 1-20, 2-4, 6-3, 6-149 com pa r ed t o filter 1-21 exa m ple 1-20 in it ia l con dit ion s 1-21 filtic 1-18, 6-3, 6-150 F IR filt er a r bit r a r y fr equ en cy r espon se 6-157 com pa r ed t o IIR 2-16 design 2-16 decim a t ion 6-201 in t er pola t ion 6-201 lea st squ a r es m et h od 6-166 lin ea r ph a se 6-166 m u lt iba n d fr equ en cy r espon se 6-157 P a r ks-McClella n m et h od 6-287 win dow m et h od 6-152 differ en t ia t or 2-26, 6-167, 6-289 H ilber t t r a n sfor m er 2-25, 6-167, 6-289
I-11
Index
im plem en t a t ion 1-17, 6-145 F F T-ba sed 1-22, 6-142 over la p-a dd m et h od 1-22, 6-142 lin ea r ph a se 2-17, 6-287 or der est im a t ion , remez fu n ct ion 6-294 t ypes 6-169, 6-292 F IR filt er design 2-16 a n t i-sym m et r ic 2-25 a r bit r a r y r espon ses 2-31 com plex filt er s 2-17, 6-91 n on lin ea r ph a se 2-17, 6-91 r edu ced dela y 2-34 con st r a in ed lea st squ a r es 2-16, 2-27 lin ea r ph a se 2-28 m u lt iba n d 2-28, 2-29 weigh t ed 2-30 equ ir ipple 2-16, 2-22, 2-23, 5-73, 5-75 exa m ple 5-73, 5-113 in F ilt er Design er 5-59, 5-73 Ka iser win dow 5-73, 5-75 lea st squ a r es 2-16, 2-22, 2-23, 5-73, 5-75 lea st squ a r es com pa r ed t o equ ir ipple 2-23 lin ea r ph a se filt er s 2-17, 2-22 m u lt iba n d 2-16, 2-21, 2-22 or der select ion 5-75 pa r a m et er s in F ilt er Design er 5-75 P a r ks-McClella n m et h od 2-22 r a ised cosin e m et h od 2-17 r ole of Ka iser win dow 4-7 st a n da r d ba n d 2-20 win dowin g m et h od 2-16, 2-18 F IR filt er in g, in fr equ en cy dom a in 1-19 F IR la t t ice filt er , im plem en t a t ion 1-38 fir1 2-16, 2-20, 6-5, 6-152 a ccessin g fr om F ilt er Design er 5-73, 5-75 fir2 2-16, 2-20, 6-5, 6-157 exa m ple 2-21
fircls 2-16, 6-5, 6-160 fircls1 2-16, 6-6, 6-163 firls 2-16, 2-22, 6-6, 6-166
a ccessin g fr om F ilt er Design er 5-73, 5-75 com pa r ed t o remez 2-23 filt er ch a r a ct er ist ics 6-169 for differ en t ia t or design 2-26 weigh t vect or 2-24 firrcos 2-17, 6-6, 6-171 fixed-poin t im plem en t a t ion , digit a l filt er 1-37 fm 4-30 F M. S ee fr equ en cy m odu la t ion fopen 1-13 F ou r ier t r a n sfor m , eigen vect or equ iva len t 3-24 F ou r ier t r a n sfor m , t im e depen den t . S ee t im e-depen den t F ou r ier t r a n sfor m F ou r ier t r a n sfor m . S ee discr et e F ou r ier t r a n sfor m , fa st F ou r ier t r a n sfor m fread 1-13 freqs 1-26, 6-3, 6-173
freqspace 6-176
fr equ en cy 6-287 a n a log xvii a n gu la r 2-2 ca r r ier 4-29, 6-236, 6-365 cen t er 2-40 cu t off 2-38 digit a l xvii n or m a liza t ion 2-2 N yqu ist xvii, 2-2 pr ewa r pin g 6-25 t r a n sfor m a t ion 6-220, 6-223, 6-225, 6-227 vect or 2-24, 6-157, 6-160, 6-376 fr equ en cy a n a lysis in F ilt er Viewer 5-84 t im e-depen den t 6-323
I-12
Index
F r equ en cy Axis Ra n ge pop-u p m en u , in P r efer en ces dia log box 5-24, 5-25 F r equ en cy Axis Sca lin g pop-u p m en u , in P r efer en ces dia log box 5-24, 5-25 fr equ en cy a xis sca lin g, in Spect r u m Viewer 5-100 fr equ en cy dem odu la t ion 6-115 fr equ en cy dom a in du a lit y wit h t im e dom a in 1-22 F IR filt er in g 1-19 for filt er im plem en t a t ion 1-22 fr equ en cy dom a in ba sed m odelin g. S ee pa r a m et r ic m odelin g fr equ en cy est im a t or fu n ct ion s, in eigen a n a lysis 3-24 fr equ en cy est im a t or t ech n iqu es eigen vect or (E V) m et h od 3-23 m u lt iple sign a l classifica t ion (MUSIC) m et h od 3-23 fr equ en cy m odu la t ion 6-237 fr equ en cy poin t s freqz 1-24, 1-26 r a n ge 1-26 spa cin g 1-26 F r equ en cy Ra n ge pop-u p m en u , Spect r u m Viewer 5-100 fr equ en cy r espon se 1-24 a r bit r a r y 2-13, 6-157 exa m ple 1-25 in F ilt er Viewer 5-82, 5-84, 5-89 in ver se 6-203 Ka iser win dow 4-6 lin ea r ph a se 2-17 m a gn it u de 1-26 m in im ized er r or bet ween desir ed a n d a ct u a l 2-22 m on ot on ic 2-9 m u lt iba n d 2-13
of Bessel pr ot ot ype 2-11 of Bu t t er wor t h pr ot ot ype 2-8 of Ch ebysh ev t ype I pr ot ot ype 2-9 of Ch ebysh ev t ype II pr ot ot ype 2-10 of Ch ebysh ev win dow 4-9 of ellipt ic pr ot ot ype 2-10 ph a se 1-26 u n wr a ppin g 1-27 plot t in g 1-25 poin t s a t wh ich eva lu a t ed 1-24 spa cin g 6-176 specifyin g sa m plin g fr equ en cy 1-24 F r equ en cy Sca le pop-u p m en u , Spect r u m Viewer 5-100 fr equ en cy t r a n sfor m a t ion 2-38 exa m ple 2-40 lowpa ss t o ba n dpa ss 6-220 lowpa ss t o ba n dst op 6-223 lowpa ss t o h igh pa ss 6-225 lowpa ss t o lowpa ss 6-227 fr equ en cy vect or 6-287 freqz 1-24, 6-3, 6-177 fr equ en cy poin t s 1-24 sa m plin g fr equ en cy 1-24 spa cin g 6-176 F r om Disk r a dio bu t t on , in Im por t dia log box 5-8 F r om Wor kspa ce r a dio bu t t on , in Im por t dia log box 5-8 fscanf 1-13 F u ll View bu t t on 5-32
G
gauspuls 1-8, 1-10, 6-2, 6-180
Ga u ss-N ewt on m et h od 6-205, 6-209 gen er a lized Bu t t er wor t h filt er 2-14 gen er a lized cosin e win dow 4-4
I-13
Index
Gibbs effect 2-19 r edu ced by win dow 4-2 gr a ph ica l u ser in t er fa ce (GUI) xii, 1-3 gr id lin es, in F ilt er Design er 5-20, 5-27 gr ou p dela y 1-28, 5-17, 6-182 defin ed 1-28 exa m ple 1-29 of lin ea r r espon se filt er 2-17 pa ssba n d 2-11 viewin g in F ilt er Viewer 5-93 Gr ou p Dela y ch eck box, F ilt er Viewer 5-86 gr ou p dela y plot 5-86, 5-93 grpdelay 1-28, 6-3, 6-182 GU I. S ee gr a ph ica l u ser in t er fa ce GU I-ba sed t ools. S ee in t er a ct ive t ools
a n d in st a n t a n eou s a t t r ibu t es 4-39 exa m ple 4-39 H ilber t t r a n sfor m er 6-167, 6-289 h om om or ph ic syst em s 4-23 H or izon t a l bu t t on , for r u ler s 5-36, 5-38, 5-39
I
icceps 4-23, 4-25, 6-9, 6-189
H
hamming 4-2, 6-8, 6-185
H a m m in g win dow 2-20, 4-4, 6-185 HandleVisibility pr oper t y 5-57, 5-110 hanning 4-2, 6-8, 6-186 H a n n in g win dow 4-4, 6-186 h igh pa ss filt er a n a log pr ot ot ype design 2-6 Bessel 6-22 Bu t t er wor t h 6-44, 6-45 Ch ebysh ev t ype I 6-66, 6-67 Ch ebysh ev t ype II 6-71, 6-72 ellipt ic 6-126, 6-127 F IR design wit h win dow m et h od 2-21, 6-154 t r a n sfor m a t ion fr om lowpa ss t o 6-225 hilbert 2-26, 4-38, 6-6, 6-187 exa m ple 4-39 H ilber t t r a n sfor m 4-34, 4-38, 6-187 a n d a n a lyt ic sign a l 2-26
idea l lowpa ss filt er 2-18 ifft 1-43, 6-6, 6-192 specifyin g n u m ber of poin t s 1-45 ifft2 1-45, 6-6, 6-193 IIR filt er a r bit r a r y fr equ en cy r espon se 2-13 Bessel 2-11 Bu t t er wor t h 2-8 Ch ebysh ev t ype I 2-9 Ch ebysh ev t ype II 2-10 com pa r ed t o F IR 2-4 design 2-4 dir ect 2-13 Levin son -Du r bin r ecu r sion 6-218 m u lt iba n d 2-13 P r on ys m et h od 6-266 St eiglit z-McBr ide it er a t ion 6-341 Yu le-Wa lker 6-376 ellipt ic 2-10 im plem en t a t ion 6-145 fr equ en cy dom a in 1-22 zer o-ph a se 1-20 IIR filt er design 2-4, 2-5 a n a log pr ot ot ype 2-5 Bu t t er wor t h 2-7, 2-8, 5-76, 5-77 Ch ebysh ev 2-7, 2-9, 2-10, 5-76, 5-77
I-14
Index
cla ssica l (a n a log pr ot ot ype) 2-5, 2-8 com pa r ison of filt er t ypes 2-8 gen er a l st eps 2-37 illu st r a t ion 2-37 in F ilt er Design er 5-76 or der est im a t ion 2-7 plot t in g pr ot ot ypes 2-12 sin gle st ep 2-6 sin gle st ep or der est im a t ion 2-7 syst em m odel 2-7 dir ect m et h ods 2-13 Yu le-Wa lker 2-13 ellipt ic 2-7, 2-10, 5-76, 5-77 exa m ple 5-76, 5-77 gen er a lized Bu t t er wor t h 2-14 in F ilt er Design er 5-59, 5-76 m a xim a lly fla t 2-14 pa r a m et er s in F ilt er Design er 5-77 t o specifica t ion s 2-7 S ee also dir ect design , pa r a m et r ic m odelin g IIR la t t ice filt er , im plem en t a t ion 1-38 im a ge pr ocessin g 6-84 wit h fft2 a n d ifft2 1-45 impinvar 2-5, 2-42, 6-11, 6-194 Im por t As pop-u p m en u , in Im por t dia log box 5-9 Im por t m en u it em 5-4, 5-6 im por t ed filt er , in SP Tool 5-14 im pu lse in va r ia n ce 2-42, 6-194 lim it a t ion s 2-42 im pu lse r espon se 1-23, 5-17, 6-196 a n d im pu lse in va r ia n ce 2-42 com pu t in g wit h filter 1-23 com pu t in g wit h impz 1-23 defin ed 1-23 exa m ple 1-23 of idea l lowpa ss filt er 2-18 viewin g in F ilt er Viewer 5-94
Im pu lse Respon se ch eck box, F ilt er Viewer 5-86 im pu lse r espon se plot 5-86, 5-94 impz 6-3, 6-196 exa m ple 1-23 in dexin g, of vect or s 1-15 In h er it fr om pop-u p m en u , Spect r u m Viewer 5-100 in h er it in g pa r a m et er s 5-100 in it ia l con dit ion s 1-17, 1-21, 6-150 gen er a t in g 1-18 In it ia l Type pop-u p m en u , in P r efer en ces dia log box 5-21 in st a n t a n eou s a t t r ibu t es 4-39, 6-187 in t er a ct ive t ools 5-2 ext en ded exa m ple 5-113 F ilt er Design er 5-2, 5-59, 6-329 F ilt er Viewer 5-2, 5-84, 6-330 Sign a l Br owser 5-2, 5-43, 6-328 Spect r u m Viewer 5-2, 5-97, 6-331 SP Tool 5-2, 6-328 interp 6-9, 6-199 in t er pola t ion 6-199 F IR filt er design 6-201 in t er va l n ot a t ion xvii intfilt 6-6, 6-201 in ver se com plex cepst r u m 4-25 in ver se discr et e cosin e t r a n sfor m 6-190 a ccu r a cy of sign a l r econ st r u ct ion 4-38 in ver se discr et e F ou r ier t r a n sfor m 1-43, 6-192 ifft 1-43 m a t r ix 6-117 t wo-dim en sion a l 1-45, 6-193 in ver se filt er design 6-207, 6-266 a n a log 6-203 digit a l 6-207 in ver se F ou r ier t r a n sfor m , con t in u ou s. S ee sinc fu n ct ion
I-15
Index
invfreqs 2-5, 4-11, 4-16, 6-8, 6-203 invfreqz 2-5, 4-11, 4-16, 6-8, 6-207
K
kaiser 4-2, 6-8, 6-210
a ccessin g fr om F ilt er Design er 5-73 exa m ple 4-5 Ka iser win dow 4-4, 6-210 a n d F IR filt er design 4-7, 5-73 bet a pa r a m et er 4-4, 6-210 exa m ple 4-5 fr equ en cy r espon se 4-6 kaiserord 2-16, 6-6, 6-211 a ccessin g fr om F ilt er Design er 5-75
L
la dder coefficien t s 1-38 La gr a n ge in t er pola t ion filt er 6-201 La pla ce t r a n sfor m 1-41 equ iva len t t o st a t e-spa ce r epr esen t a t ion 1-41 latc2tf 1-39, 1-42, 6-3, 6-216 latcfilt 1-19, 1-39, 6-3, 6-217 la t t ice coefficien t s 1-38 la t t ice filt er 1-42 im plem en t a t ion 1-38 im plem en t a t ion wit h latcfilt 1-39 la t t ice for m con ver t in g fr om t r a n sfer fu n ct ion 6-346 la t t ice st r u ct u r e 1-37 la t t ice/la dder filt er im plem en t a t ion 1-38 im plem en t a t ion wit h latcfilt 1-39 lea st squ a r es m et h od, F IR filt er design 6-166 filt er ch a r a ct er ist ics 6-169 levinson 4-11, 6-8, 6-218 , 6-305
a n d pa r a m et r ic m odelin g 4-12 Levin son -Du r bin r ecu r sion 4-12, 6-218, 6-305 lin e color in F ilt er Viewer 5-35 in Sign a l Br owser 5-35 in Spect r u m Viewer 5-35 lin e select ion in F ilt er Viewer 5-34, 5-35 in Sign a l Br owser 5-34, 5-35 in Spect r u m Viewer 5-34, 5-35 lin e st yle cu st om izin g in SP Tool 5-20 in F ilt er Viewer 5-22, 5-35 in Sign a l Br owser 5-22, 5-35 in Spect r u m Viewer 5-22, 5-35 Lin e St yle Or der edit box, in P r efer en ces dia log box 5-22 lin ea r ph a se 2-16, 2-17, 6-166 filt er design 6-287 r ela t ed ch a r a ct er ist ics 2-17 lin ea r pr edict ion coefficien t s 6-229 lin ea r pr edict ion m odelin g 4-12 lin ea r pr edict ive codin g lin ea r swept -fr equ en cy cosin e. S ee ch ir p lin ea r syst em m odels 1-32 lin ea r syst em t r a n sfor m a t ion s 1-41 con ver sion ch a r t 1-41 lin ea r t im e-in va r ia n t differ en t ia l equ a t ion s, r epr esen t ed in st a t e-spa ce for m 1-40 load 1-13 lowpa ss filt er a n a log pr ot ot ype design 2-6 a n d im pu lse in va r ia n ce 2-42 Bessel 6-22 Bu t t er wor t h 6-43, 6-44 Ch ebysh ev t ype I 6-65, 6-66 Ch ebysh ev t ype II 6-70, 6-71
I-16
Index
ellipt ic 6-125, 6-126 F IR design , wit h win dow m et h od 2-21 for decim a t ion 6-110 for in t er pola t ion 6-199 idea l im pu lse r espon se 2-18 t r a n sla t ion of cu t off fr equ en cy 6-227 lp2bp 2-5, 2-39, 6-10, 6-220 exa m ple 2-40 lp2bs 2-5, 2-39, 6-10, 6-223 lp2hp 2-5, 2-39, 6-10, 6-225 lp2lp 2-5, 2-39, 6-10, 6-227 lpc 2-5, 4-11, 6-8, 6-229 S ee also lin ea r pr edict ive codin g, P r on ys m et h od LP C. S ee lin ea r pr edict ion coefficien t s
M
m a gn it u de of F ou r ier t r a n sfor m of sequ en ce 1-44 of fr equ en cy r espon se 1-26 viewin g in F ilt er Viewer 5-89 of t r a n sfer fu n ct ion est im a t e 3-15 vect or 2-24, 6-157, 6-160, 6-376 Ma gn it u de Axis Sca lin g pop-u p m en u , in P r efer en ces dia log box 5-24, 5-25 Ma gn it u de ch eck box, F ilt er Viewer 5-86 m a gn it u de plot 5-78 m a gn it u de plot , in F ilt er Design er 5-69, 5-78 m a gn it u de r espon se 5-17 m a gn it u de r espon se plot 5-86, 5-89 in F ilt er Design er 5-63 Ma gn it u de Sca le pop-u p m en u , Spect r u m Viewer 5-100 m a gn it u de sca le, in Spect r u m Viewer 5-100 m a n u fa ct u r in g 4-10
Ma r ker Size edit box, in P r efer en ces dia log box 5-21 m a t ch fr equ en cy (for pr ewa r pin g) 6-25 MAT-file dpss.mat 3-19 im por t in g 1-13 im por t in g in t o SP Tool 5-4, 5-6 loa din g in t o SP Tool 5-8 MAT-file for m a t , con ver t in g t o 1-13 m a t r ices con volu t ion 1-39, 6-86 cor r ela t ion coefficien t 6-88 cova r ia n ce 6-89 da t a 1-4, 1-7 discr et e F ou r ier t r a n sfor m 6-117 for secon d-or der sect ion s for m 1-37 in ver se discr et e F ou r ier t r a n sfor m 6-117 m a t r ix for m . S ee st a t e-spa ce for m maxflat 2-5, 2-14, 6-5, 6-233 m a xim a , loca l 5-37 m a xim a lly fla t 2-14 m ea su r em en t lin es 5-70 m ea su r em en t s in F ilt er Viewer 5-37 in Sign a l Br owser 5-37 in Spect r u m Viewer 5-37, 5-101 sa vin g in F ilt er Viewer 5-37 sa vin g in Sign al Br owser 5-37 sa vin g in Spect r u m Viewer 5-37 medfilt1 4-28, 6-9, 6-235 m edia n filt er 4-28, 6-235 m essa ge sign a l 4-29, 6-236 Met h od pop-u p m en u , Spect r u m Viewer 5-103 ME X-file 1-13 M-files 1-3 cr ea t in g xii, 1-3 m odifyin g xii
I-17
Index
viewin g xii m in im a , loca l 5-37 m in im a x m et h od, F IR filt er design 2-22 S ee also P a r ks-McClella n m et h od m in im u m ph a se filt er 6-265 m odels a u t or egr essive 6-16, 6-17, 6-18, 6-19 via Bu r g m et h od 6-239 via cova r ia n ce m et h od 6-243 via m odified cova r ia n ce m et h od 6-247 via Yu le-Wa lker AR m et h od 6-278 m odels, syst em r epr esen t a t ion 1-32 m odified cova r ia n ce m et h od 3-6, 3-22 defin ed 3-22 exa m ple 3-23 m odified per iodogr a m 3-9 modulate 4-29, 6-9 exa m ple 4-30 m et h od fla gs 4-29 m odu la t ion 6-236 a m plit u de defin ed 4-29 exa m ple 4-30 fr equ en cy m et h ods 4-29, 6-236 ph a se 4-30 pu lse t im e 4-30 pu lse widt h 4-30 qu a dr a t u r e a m plit u de 4-30 m ou se zoom 5-32 in F ilt er Design er 5-20 in F ilt er Viewer 5-20, 5-88 in Sign a l Br owser 5-20 in Spect r u m Viewer 5-20 t u r n in g off 5-33 Mou se Zoom bu t t on 5-32 m ovin g a ver a ge (MA) filt er 1-15
S ee also F IR filt er MTM. S ee m u lt it a per m et h od m u lt iba n d filt er F IR 2-21 F IR, wit h t r a n sit ion ba n ds 2-22 IIR 2-13 m u lt ich a n n el da t a 1-4, 1-7 m u lt ich a n n el sign a l 3-4 m u lt iple sign a l cla ssifica t ion m et h od (MUSIC) 3-5, 3-6, 3-23 defin ed 3-23 in Spect r u m Viewer 5-106 m u lt iplicit y, of zer os a n d poles 5-71 m u lt ir a t e filt er ba n k, im plem en t at ion 1-19 m u lt ir a t e filt er in g 1-19 m u lt it a per m et h od (MTM) 3-5, 3-6, 3-16 com pa r ed t o Welch s m et h od 3-19 defin ed 3-16 exa m ple 3-17 in Spect r u m Viewer 5-105 MUSIC. S ee m u lt iple sign a l cla ssifica t ion m et h od
N
N ew Design bu t t on 5-17, 5-59 n on in t eger dela y 2-26 n on r ecu r sive filt er . S ee F IR filt er n or m a liza t ion 3-3 cor r ela t ion 3-4, 6-367, 6-368 power spect r a l den sit y 3-12 N yqu ist fr equ en cy xvii, 2-2
O
object s, edit in g in SP Tool 5-15 on e-t im e m ou se zoom in g 5-32 Open Session m en u it em 5-6
I-18
Index
or der est im a t ion 2-7, 6-294 Bu t t er wor t h 6-48 Ch ebysh ev t ype I 6-55 Ch ebysh ev t ype II 6-60 ellipt ic 6-132 in F ilt er Design er 5-75, 5-78 or der select ion 2-7 in F ilt er Design er 5-75, 5-78 or der , of filt er 1-15, 2-7 or t h ogon a l win dows, in P SD est im a t es 3-16 oscilla t or , volt a ge con t r olled 6-365 over la p-a dd m et h od, F IR filt er im plem en t a t ion 1-22, 6-142
P
P a ge Set u p dia log box 5-45, 5-99 pa n n er 5-52 in Sign a l Br owser 5-20, 5-23, 5-48 P a n n er ch eck box, in P r efer en ces dia log box 5-23 pa r a m et er s in Spect r u m Viewer 5-99, 5-100, 5-103 in h er it in g in Spect r u m Viewer 5-100 pa r a m et r ic m odelin g 4-10, 6-207 a pplica t ion s 4-10 fr equ en cy dom a in ba sed 4-16 su m m a r y 2-5 t ech n iqu es 4-10 t im e dom a in ba sed lin ea r pr edict ive codin g 4-12, 4-13 St eiglit z-McBr ide m et h od 4-15 t im e-dom a in based 4-11 Bu r g m et h od 6-16 cova r ia n ce m et h od 6-17 m odified cova r ia n ce m et h od 6-18 Yu le-Wa lker m et h od 6-19 pa r en t h eses, in dica t in g open in t er va l xvii
P a r ks-McClella n m et h od, F IR filt er design 2-22, 6-287 pa r t ia l fr a ct ion 1-42 pa r t ia l fr a ct ion expa n sion 1-40 defin ed 1-35 det er m in in g wit h residue 1-41 exa m ple 1-35 pa r t ia l fr a ct ion for m 1-35, 6-302 pa ssba n d equ ir ipple 2-9, 2-10 gr ou p dela y 2-11 pa ssba n d r ipple, set t in g in F ilt er Design er 5-70 pa ssba n d zoom 5-33 P a ssba n d Zoom bu t t on 5-33 pburg 3-6, 3-21, 6-7, 6-239 exa m ple 3-21 pcov 3-6, 3-22, 6-7, 6-243 exa m ple 3-23 P ea ks bu t t on , Sign a l Br owser 5-37 per iodic sin c fu n ct ion 6-118 S ee also Dir ich let fu n ct ion per iodogr a m 3-7 m odified 3-9 per sist en t m ou se zoom in g 5-32 ph a se com pu t in g wit h angle 6-15 of F ou r ier t r a n sfor m of sequ en ce 1-44 of fr equ en cy r espon se 1-26 viewin g in F ilt er Viewer 5-91 of t r a n sfer fu n ct ion est im a t e 3-15 u n wr a ppin g 1-27, 6-360 P h a se ch eck box, F ilt er Viewer 5-86 ph a se dela y 1-28, 6-182 defin ed 1-28 exa m ple 1-29 of lin ea r r espon se filt er 2-17 ph a se dem odu la t ion 6-115
I-19
Index
ph a se dist or t ion elim in a t in g du r in g filt er in g 1-19 exa m ple 1-20 u sin g filtfilt 1-20 in F IR filt er s 1-20 n on lin ea r in IIR filt er s 1-20 ph a se m odifica t ion da t a depen den t , u sin g >cceps 4-25 ph a se m odu la t ion 4-30, 6-237 ph a se r espon se 5-17 ph a se r espon se plot 5-86, 5-91 P h a se Un it s pop-u p m en u , in P r efer en ces dia log box 5-25 ph a se u n it s, in F ilt er Viewer 5-25 P la y m en u it em , Sign a l Br owser 5-46 pla yin g a sign a l 5-46 plot a n a log pr ot ot ypes 2-12 coh er en ce fu n ct ion 3-16 com plex cepst r u m 4-24 DF T 1-44 fr equ en cy r espon se 1-25 m a gn it u de 1-26 ph a se 1-26 gr ou p dela y 1-29, 5-86, 5-93 im pu lse r espon se 5-86, 5-94 in F ilt er Viewer 5-84, 5-86, 5-88, 5-89 m a gn it u de r espon se 5-78, 5-86, 5-89 m odified per iodogr a m 3-10 m u lt it a per est im a t e 3-17, 3-18 per iodogr a m 3-7 ph a se dela y 1-29 ph a se r espon se 5-86, 5-91 power spect r a l den sit y 3-11 spect r a l den sit y 5-101
st ep r espon se 5-86, 5-95 st r ip plot 6-344 t ilin g in F ilt er Viewer 5-88 t r a n sfer fu n ct ion 3-15 zer o-pole 1-30, 5-86, 5-94, 6-385 plu g-in s 5-20, 5-30 pm 4-30 pmcov 3-6, 3-22, 6-7, 6-247 exa m ple 3-23 p-m odel. S ee pa r a m et r ic m odelin g pmtm 3-6, 6-7, 6-251 exa m ple 3-17 pmusic 3-6, 3-23, 6-7, 6-255 pole-zer o filt er . S ee IIR filt er poly 1-33, 1-42 poly2ac 6-4, 6-262 poly2rc 6-4, 6-263 polyn om ia l division 4-33, 6-113 m u lt iplica t ion 6-83 r oot s 1-33 st a biliza t ion 6-265 polyph a se filt er in g t ech n iqu es 1-19 polystab 6-9, 6-265 power spect r a l den sit y 6-273 bia s 3-12 com pu t a t ion pa r a m et er s 5-103, 5-104 con fiden ce in t er va l 3-14 defa u lt plot 5-102 defin ed 3-5 est im a t ion by Bu r g m et h od 3-6, 3-20, 5-104, 6-239 est im a t ion by cova r ia n ce m et h od 3-6, 3-22, 5-105, 6-243 est im a t ion by F F T m et h od 5-105 est im a t ion by m odified cova r ia n ce m et h od 3-6, 6-247
I-20
Index
est im a t ion by m u lt it a per m et h od 3-6, 3-16, 5-105 est im a t ion by MUSIC m et h od 3-6, 3-23, 5-106 est im a t ion by Welch s m et h od 3-6, 3-10, 5-106 est im a t ion by Yu le-Wa lker AR m et h od 3-6, 3-19, 5-107, 6-278 est im a t ion m et h ods 5-103, 5-104 in SP Tool 5-13 n or m a liza t ion 3-12 u n it s of 3-11 viewin g in Spect r u m Viewer 5-97, 5-102, 5-104 pr efer en ces r u ler s 5-21 sa vin g in Sign a l Br owser 5-45 pr efer en ces file in SP Tool 5-31 sigprefs.mat 5-31 P r efer en ces m en u it em 5-6, 5-20, 5-30 pr ewa r pin g 6-25 P r in t dia log box 5-45, 5-55, 5-99, 5-108, 5-120, 5-124 P r in t P r eview win dow H a n dle Gr a ph ics 5-57, 5-110 Sign a l Br owser 5-45, 5-55, 5-56 pr efer en ces 5-56, 5-120 Spect r u m Viewer 5-99, 5-108, 5-124 pr efer en ces 5-109 pr in t in g fr om Sign a l Br owser 5-2, 5-21, 5-22, 5-31, 5-33, 5-38, 5-117 fr om Spect r u m Viewer 5-2, 5-21, 5-22, 5-31, 5-33, 5-38, 5-98 pr ola t e-sph er oida l win dow 4-4 prony 2-5, 4-11, 4-13, 6-8, 6-266 P r on ys m et h od 4-13, 6-266 m odelin g 4-13
pr ot ot ype Bessel filt er 2-11, 6-21 Bu t t er wor t h filt er 2-8, 6-42 Ch ebysh ev t ype I filt er 6-54 Ch ebysh ev t ype II filt er 6-59 ellipt ic filt er 6-131 P SD. S ee power spect r a l den sit y psd. S ee pwelch 6-268 ptm 4-30 pu lse t im e dem odu la t ion 6-115 pu lse t im e m odu la t ion 4-30, 6-237 pu lse t r a in gen er a t or 6-269 pu lse t r a in s gen er a t in g 1-9 pulstran 1-9 pu lse widt h dem odu la t ion 6-115 pu lse widt h m odu la t ion 4-30, 6-237 pulstran 1-9, 6-2, 6-75, 6-119, 6-121, 6-122, 6-123, 6-124, 6-269 , 6-286, 6-346, 6-359 pwelch 3-6, 3-10, 6-7, 6-273 exa m ple 3-12 pwm 4-30 pyulear 3-6, 3-20, 6-7, 6-278 exa m ple 3-20, 3-21
Q
qam 4-30 qu a dr a t u r e a m plit u de dem odu la t ion 6-115 qu a dr a t u r e a m plit u de m odu la t ion 4-30, 6-237
R
r a da r a pplica t ion s 4-27 r a dix-2 a lgor it h m 1-45 r a ised cosin e filt er design 6-171 randn xiv
I-21
Index
r a n dom n u m ber , gen er a t ion xiv r a n ge n ot a t ion xvii Ra n ge pop-u p m en u , F ilt er Viewer 5-87 rc2poly 6-4, 6-283 rceps 4-23, 4-25, 6-9, 6-285 r ea l cepst r u m 6-285 defin ed 4-24 r econ st r u ct in g sign a l (m in im u m -ph a se) 4-25 r ebu ffer in g 6-33 r ect a n gu la r win dow 2-18, 4-2, 6-32 rectpuls 6-2, 6-286 r ecu r sive filt er . S ee IIR filt er r efer en ces 1-46, 3-27, 4-40 r eflect ion coefficien t s 1-37, 1-39 con ver t in g fr om a u t ocor r ela t ion sequ en ce 6-14 con ver t in g fr om filt er coefficien t s 6-263, 6-283 con ver t in g t o a u t ocor r ela t ion sequ en ce 6-282 remez 2-16, 2-22, 6-6, 6-287 a ccessin g fr om F ilt er Design er 5-73, 5-75 com pa r ed t o firls 2-23 filt er ch a r a ct er ist ics 6-292 for differ en t ia t or design 2-26 for H ilber t t r a n sfor m er design 2-25 or der est im a t ion 6-294 weigh t vect or 2-24 Rem ez exch a n ge a lgor it h m 2-22, 6-287 remezord 2-16, 6-6, 6-294 a ccessin g fr om F ilt er Design er 5-75 resample 6-10, 6-298 r esa m plin g 4-20, 6-298 in F IR filt er in g 1-19 S ee also decim a t ion , in t er pola t ion residue 1-41, 1-42 r esidu e for m . S ee pa r t ia l fr a ct ion for m residuez 1-42, 6-4, 6-302
Rever t pa n el 5-31 r ipple, pa ssba n d 5-70 rlevinson 6-9, 6-305 r oot s of Bessel filt er 6-21 polyn om ia l 1-33 roots 1-33, 1-42 r u ler color 5-21 Ru ler Color edit box, in P r efer en ces dia log box 5-21 Ru ler Ma r ker pop-u p m en u , in P r efer en ces dia log box 5-21 r u ler m a r ker s 5-21, 5-36 r u ler t ype in Sign a l Br owser 5-21 in Spect r u m Viewer 5-21 r u ler s br in gin g t o cen t er 5-35 cu st om izin g in SP Tool 5-20 dr a ggin g 5-36 fin d r u ler bu t t on s 5-35 h or izon t a l 5-36 h or izon t a l m ode 5-40 in F ilt er Viewer 5-26, 5-33 in Sign a l Br owser 5-20, 5-21, 5-23, 5-33 in Spect r u m Viewer 5-20, 5-21, 5-24, 5-33 pa r a m et er s 5-36 posit ion in g 5-38 pr efer en ces 5-21 sa vin g m ea su r em en t s 5-37 slope 5-36 slope m ode 5-42 t r a ck 5-36 t r a ck m ode 5-41 ver t ica l 5-36 ver t ica l m ode 5-39
I-22
Index
Ru ler s ch eck box, in P r efer en ces dia log box 5-23, 5-24, 5-26
S
sa m plin g fr equ en cy ch a n gin g in SP Tool 5-9 in SP Tool 5-16 Sa m plin g F r equ en cy edit box, in Im por t dia log box 5-4, 5-9 Sa m plin g F r equ en cy m en u it em 5-16 sa m plin g r a t e ch a n gin g by n on in t eger fa ct or 4-20, 6-298 ch a n gin g for ir r egu lar ly spa ced da t a 4-22 ch a n gin g wit h upfirdn 1-19 decr ea sin g by in t eger fa ct or 6-110 in cr ea sin g by in t eger fa ct or 6-199 Sa ve Ru ler s bu t t on 5-37 Sa ve Session m en u it em 5-6 sa vin g ch a n ges in SP Tool 5-30 sa vin g da t a fr om F ilt er Design er 5-79, 5-110 fr om Sign a l Br owser 5-57 sa vin g da t a , fr om F ilt er Design er 5-79, 5-110 sa vin g da t a , fr om Sign a l Br owser 5-57 sa vin g set t in gs, in F ilt er Viewer 5-86 Sa vit zky-Gola y filt er design 6-309 filt er in g 6-311 sawtooth 1-8, 6-2, 6-308 sa wt oot h wa ve 1-8 sca la r for st a t e-spa ce for m 1-34 r epr esen t in g ga in 1-33 Sca le pop-u p m en u , F ilt er Viewer 5-87 Sea r ch for P lu g-In s a t st a r t -u p ch eck box, in P r efer en ces dia log box 5-30
secon d-or der sect ion for m con ver t in g fr om t r a n sfer fu n ct ion 6-347 con ver t in g fr om zer o-pole-ga in 6-379 secon d-or der sect ion s 1-42 secon d-or der sect ion s for m 1-36 con ver t in g fr om st a t e-spa ce for m 6-333 con ver t in g t o st a t e-spa ce 6-316 con ver t in g t o t r a n sfer fu n ct ion 6-318 con ver t in g t o zer o-pole-ga in 6-320 defin ed 1-36 filt er in g 6-322 specifyin g in SP Tool 5-12 select in g da t a object s in SP Tool 5-15 sequ en ce a u t ocor r ela t ion 6-13, 6-14, 6-262 set t in gs r est or in g in SP Tool 5-30 r u ler s 5-21 sa vin g in Sign al Br owser 5-45 sa vin g in SP Tool 5-31 sgolay 6-309 , 6-311
sgolayfilt 6-311
sign a l a ddin g n oise 1-6 a n a lyt ic 4-38, 6-187 bu ffer in g 6-33 ca r r ier 4-29, 6-114 com plex 5-47 con t in u ou s (a n a log) 1-2 differ en t ia t ion 2-26 discr et e (digit a l) 1-2 gen er a t in g 1-7 im por t in g in t o SP Tool 5-3, 5-7, 5-8, 5-10 lin kin g t o spect r u m 5-100 m ea su r em en t s 5-37 m ea su r em en t s in Sign a l Br owser 5-36 m essa ge 4-29, 6-236
I-23
Index
m u lt ich a n n el 3-4 n a m in g in SP Tool 5-16 pea ks 5-37 pla yin g 5-46 plot t in g 1-6 r ebu ffer in g 6-33 r econ st r u ct ion fr om DCT coefficien t s 4-37 m in im u m ph a se 4-25, 6-285 r epr esen t in g in MATLAB 1-4 m u lt ich a n n el 1-4 sin gle ch a n n el 1-4 select in g in Sign a l Br owser 5-48 va lleys 5-37 viewin g in Sign a l Br owser 5-17, 5-48 S ee also wa vefor m Sign a l Br owser 5-2, 5-17, 5-43, 6-328 a ct iva t in g 5-17, 5-43 cu st om izin g 5-20 pr in t in g fr om 5-23, 5-43, 5-44, 5-54 sa vin g da t a t o wor kspa ce 5-57 win dow 5-44 Sign a l P r ocessin g Toolbox 1-2 sign a l t ype a r r a y 5-14 vect or 5-14 sigprefs.mat 5-31 sinc 1-10, 6-2, 6-313 ba n dlim it ed in t er pola t ion exa m ple 6-314 sin c fu n ct ion 1-10, 6-313 a n d ba n dlim it ed in t er pola t ion 6-314 ba sic exa m ple 1-10 defin ed 1-10 sin u soida l wa ve 1-8 Slepia n sequ en ces. S ee discr et e pr ola t e sph er oida l sequ en ces
Slope bu t t on , for r u ler s 5-36 Slope con t r ol 5-38, 5-41 son a r a pplica t ion s 4-27 sos2ss 1-42, 6-4, 6-316 sos2tf 1-42, 6-4, 6-318 sos2zp 1-42, 6-4, 6-320 specgram 4-27, 6-10, 6-323 exa m ple 4-27, 6-365 specifica t ion lin es 5-78 dr a ggin g t o edit filt er 5-70 specifica t ion s for filt er design 2-7 spect r a l a n a lysis 3-5 cr oss spect r a l den sit y 3-14 defin ed 3-5 power spect r a l den sit y 3-5 u sin g Spect r u m Viewer 5-97 spect r a l den sit y 3-5 S ee also power spect r a l den sit y, cr oss spect r a l den sit y spect r a l den sit y plot in Spect r u m Viewer 5-101 spect r ogr a m 4-27, 6-323 exa m ple 4-27, 6-365 spect r u m com pu t in g in SP Tool 5-19 im por t in g in t o SP Tool 5-7, 5-8, 5-13 lin kin g t o sign a l 5-100 m ea su r em en t s 5-37 m ea su r em en t s in Spect r u m Viewer 5-36, 5-101 n a m in g in SP Tool 5-16 pea ks 5-37 u pda t in g in SP Tool 5-19 va lleys 5-37 viewin g in Spect r u m Viewer 5-97 viewin g in SP Tool 5-19 spect r u m t ype, a u t o 5-15 Spect r u m Viewer 5-2, 5-19, 5-97, 6-331
I-24
Index
a ct iva t in g 5-19, 5-97 ch a n gin g plot pr oper t ies 5-102 cu st om izin g 5-20 defa u lt plot 5-102 pr in t in g fr om 5-24, 5-97, 5-98, 5-107, 5-108 set t in g con fiden ce in t er va ls 5-107 viewin g power spect r a l den sit y plot s 5-102 win dow 5-98 speech pr ocessin g 4-10, 4-21 spline 4-22 spt ext en sion 5-6 SP Tool 5-2, 6-328 a ct iva t in g fr om Sign a l Br owser 5-54 closin g 5-6 cu st om izin g 5-6, 5-20 loa din g 5-3 pr efer en ces 5-6 win dow 5-5 sptool com m a n d 6-11, 6-328 square 1-8, 6-2, 6-332 squ a r e wa ve 1-8 ss2sos 1-42, 6-4, 6-333 ss2tf 1-42, 6-337 ss2zp 1-42, 6-4, 6-338 st a biliza t ion , polyn om ia l 6-265 st a n da r ds Com pa ct Disc 4-20 Digit a l Au dio Ta pe 4-20 st a r t u p t r a n sien t s 1-22 r edu cin g 1-21, 6-149 st a t e-spa ce for m 1-40, 1-42 con ver t in g fr om secon d-or der sect ion s 6-316 con ver t in g fr om t r a n sfer fu n ct ion 6-350 con ver t in g fr om zer o-pole-ga in 6-383 con ver t in g t o secon d-or der sect ion 6-333 con ver t in g t o zer o-pole-ga in 6-338 defin ed 1-34
r epr esen t in g in MATLAB 1-34 specifyin g in SP Tool 5-11 st a t ist ica l oper a t ion s 3-2 St a y in Zoom -m ode Aft er Zoom ch eck box, in P r efer en ces dia log box 5-23, 5-24, 5-26, 5-27 St eiglit z-McBr ide m et h od 4-15, 6-341 st ep r espon se 5-17 viewin g in F ilt er Viewer 5-95 St ep Respon se ch eck box, F ilt er Viewer 5-86 st ep r espon se plot 5-86, 5-95 stmcb 2-5, 4-11, 4-15, 6-9, 6-341 st opba n d a t t en u a t ion , set t in g in F ilt er Design er 5-70 equ ir ipple 2-10 st r ip plot 6-344 defin ed 6-344 strips 6-2, 6-344 st r u ct u r e, digit a l filt er la t t ice 1-37 t r a n sposed dir ect for m II 1-17 su bplot s 5-84 in F ilt er Viewer 5-86 su bspa ce t h r esh olds, con t r ollin g in pmusic fu n ct ion 3-25 svd, in pmusic fu n ct ion 3-25 swept -fr equ en cy cosin e gen er a t or . S ee ch ir p syst em iden t ifica t ion 4-13 syst em m odels 1-32 a n d bilin ea r t r a n sfor m a t ion 2-44 a n d filt er design fu n ct ion s 2-7 a n d fr equ en cy t r a n sfor m a t ion fu n ct ion s 2-39
T
t a per s, in P SD est im a t es 3-16 t a ps 2-17
I-25
Index
t ext s, r ela t ed 1-46 tf2latc 1-39, 1-42, 6-4, 6-346 tf2ss 1-42, 6-4, 6-350 tf2zp 1-42, 6-339, 6-352 tfe 3-6, 3-14, 6-7, 6-354 thresh 3-25 t ilin g 5-88 t ilin g displa y, in F ilt er Viewer 5-26 t ilin g pr efer en ces, in F ilt er Viewer 5-20 Tim e Respon se Len gt h edit box, in P r efer en ces dia log box 5-25 t im e r espon se len gt h , in F ilt er Viewer 5-25 t im e vect or 1-6 r et u r n ed by modulate 4-30 t im e-depen den t F ou r ier t r a n sfor m 4-27 t im e-dom a in a n a lysis, in F ilt er Viewer 5-84 t im e-dom a in ba sed m odelin g. S ee pa r a m et r ic m odelin g t oolbox Con t r ol Syst em s Toolbox 1-35, 6-198, 6-340 Im a ge P r ocessin g Toolbox 6-109, 6-190, 6-235 Sign a l P r ocessin g Toolbox 1-2 Sym bolic Ma t h Toolbox 6-21 Syst em Iden t ifica t ion Toolbox 6-357 Tr a ck bu t t on , for r u ler s 5-36, 5-38, 5-40 t r a n sfer fu n ct ion 1-32, 1-35, 1-40, 1-42 coefficien t s 1-15, 5-79 defin ed 1-15 der iva t ion 1-15 est im a t e fr om in pu t a n d ou t pu t 6-354 est im a t in g u sin g Welch s m et h od 3-14 expor t in g fr om SP Tool 5-79 fa ct or ed for m 1-33 for a n a log filt er 1-41 r epr esen t in g in MATLAB 1-32 zer o-pole-ga in for m 1-33 t r a n sfer fu n ct ion for m
con ver t in g fr om secon d-or der sect ion s 6-318 con ver t in g t o la t t ice 6-346 con ver t in g t o secon d-or der sect ion s 6-347 con ver t in g t o st a t e-spa ce 6-350 specifyin g in SP Tool 5-11 t r a n sfor m 4-34 ch ir p z -t r a n sfor m (CZT) 4-34, 6-105 discr et e cosin e 6-108 discr et e F ou r ier 1-43 H ilber t 4-38, 6-187 in ver se discr et e cosin e 4-36, 6-190 in ver se discr et e F ou r ier 6-192 t r a n sfor m a t ion s bet ween syst em m odels 1-41 bilin ea r 2-43, 6-25 fr equ en cy 2-38, 6-220, 6-223, 6-225, 6-227 t r a n sit ion ba n d 2-23 t r a n sposed dir ect for m II 6-145 in it ia l con dit ion s 6-150 triang 4-2, 6-8, 6-358 com pa r ed t o bartlett 6-20 exa m ple 4-2 t r ia n gu la r win dow 6-358 tripuls 6-2, 6-359 t wo-dim en sion a l oper a t ion s a u t ocor r ela t ion 6-372 con volu t ion 6-84 obt a in in g su bsect ion 6-84 cr oss-cor r ela t ion 6-372 discr et e F ou r ier t r a n sfor m 1-45, 6-141 filt er in g 6-148 in ver se discr et e F ou r ier t r a n sfor m 1-45, 6-193 t wo-dim en sion a l sign a l pr ocessin g, wit h fft2 a n d ifft2 1-45
I-26
Index
U
u n it cir cle 6-265 u n it im pu lse fu n ct ion 1-7 u n it r a m p fu n ct ion 1-7 u n it sa m ple, m u lt ich a n n el r epr esen t a t ion 1-7 u n it st ep fu n ct ion 1-7 u n it s of power spect r a l den sit y (P SD) fu n ct ion 3-11 unwrap 1-27, 6-3, 6-360 U pda t e bu t t on 5-19, 5-97 upfirdn 1-19, 4-22, 6-10, 6-361
V
Va lleys bu t t on , Sign a l Br owser 5-37 va r ia n ce of cor r ela t ion sequ en ce est im a t e 3-4 of power spect r u m est im a t e 3-8 vco 4-29, 4-31, 6-10, 6-365 vect or da t a 1-4 displa y, in Sign a l Br owser 5-50 for filt er coefficien t s 1-16, 1-32 fr equ en cy 2-24, 6-157, 6-160, 6-287, 6-376 in SP Tool 5-14 in dexin g xvii, 1-15 m a gn it u de 2-24, 6-157, 6-160, 6-376 t im e 1-6 weigh t in g 2-24, 6-167, 6-288 Ver t ica l bu t t on , for r u ler s 5-36, 5-38 View bu t t on 5-17, 5-19 volt a ge con t r olled oscilla t or 4-31, 6-365
W
wa vefor m a per iodic 1-8
ch ir p 1-9 ch ir p, exa m ple 1-9 fr om sin u soids 1-6 gen er a t in g wit h diric fu n ct ion 1-11 gen er a t in g wit h pulstran 1-9 gen er a t in g wit h sinc fu n ct ion 1-10 lin ea r swept -fr equ en cy cosin e. S ee ch ir p per iodic 1-7 sa wt oot h 1-8, 6-308 exa m ple 1-8 sin u soida l pu lse, Ga u ssia n -m odu la t ed 1-8 squ a r e 1-8, 6-332 t r ia n gle 6-308 Welch s m et h od 3-6 bia s 3-12 com pa r ed t o t h e Bu r g m et h od 3-22 com pa r ed t o t h e MTM m et h od 3-19 com pa r ed t o t h e Yu le-Wa lker AR m et h od 3-20 for cr oss spect r a l den sit y est im a t ion 3-14, 6-102 for n on pa r a m et r ic syst em iden t ifica t ion 3-14 for power spect r a l den sit y est im a t ion 3-5, 3-10, 6-81, 6-275 in Spect r u m Viewer 5-106 n or m a liza t ion 3-12 wh it e n oise 1-6 win dow a pplied t o per iodogr a m 3-9 Ba r t let t 4-2, 6-20 Bla ckm a n 4-4, 6-30 boxca r 2-18 Ch ebysh ev 4-9, 6-64 for filt er design 2-18 gen er a lized cosin e 4-4 H a m m in g 2-20, 4-4, 6-185 H a n n in g 4-4, 6-186 Ka iser 4-4, 6-210
I-27
Index
r ect a n gu la r 2-18, 6-32 sh a pes, over view 4-2 specifyin g for fir1 2-21 t r ia n gu la r 6-358 win dow m et h od F IR filt er design 2-18 m u lt iba n d design 2-21 sin gle ba n d design 2-20 win dow m et h od, F IR filt er design ba n dpa ss con figu r a t ion 6-152 ba n dst op con figu r a t ion 6-152 h igh pa ss con figu r a t ion 6-152 lowpa ss con figu r a t ion 6-152 Wor kspa ce Con t en t s list , in Im por t dia log box 5-7 wor kspa ce, loa din g va r ia bles fr om 5-7
Z
zer o fr equ en cy com pon en t , cen t er in g wit h fftshift 1-45 zer o-or der h old. S ee a ver a gin g filt er zer o-ph a se filt er in g 6-149 zer o-pole a n a lysis exa m ple 1-30 zer o-pole plot s 6-385 zer o-pole ga in 1-42 zer o-pole plot 5-86, 5-94 viewin g in F ilt er Viewer 5-94 zer o-pole-ga in for m 1-40 con ver t in g fr om secon d-or der sect ion s 6-320 con ver t in g fr om st a t e-spa ce for m 6-338 con ver t in g t o secon d-or der sect ion 6-379 con ver t in g t o st a t e-spa ce 6-383 defin ed 1-33 r epr esen t in g in MATLAB 1-33 specifyin g in SP Tool 5-11 zer os a n d poles 5-17 in t r a n sfer fu n ct ion 1-33 m u lt iplicit y of 5-71 Zer os a n d P oles ch eck box, F ilt er Viewer 5-86 zoom con t r ols in F ilt er Design er 5-31 in F ilt er Viewer 5-31 in Sign a l Br owser 5-31 in Spect r u m Viewer 5-31 in SP Tool 5-31 Zoom In -X bu t t on 5-32 Zoom In -Y bu t t on 5-32 Zoom Ou t -X bu t t on 5-32 Zoom Ou t -Y bu t t on 5-32 zoom per sist en ce 5-32
X
X La bel edit box, in P r efer en ces dia log box 5-23 xcorr 3-2, 6-7, 6-367 a n d pa r a m et r ic m odelin g 4-12 xcorr2 6-7, 6-372 xcov 3-2, 6-7, 6-373
Y
Y La bel edit box, in P r efer en ces dia log box 5-23 yulewalk 2-5, 2-13, 6-5, 6-376 exa m ple 2-14 Yu le-Wa lker AR m et h od 3-5, 3-6, 3-19 com pa r ed t o Welch s m et h od 3-20 defin ed 3-19 exa m ple 3-20, 3-21 Yu le-Wa lker AR m et h od, in Spect r u m Viewer 5-107 Yu le-Wa lker equ a t ion s 2-13
I-28
Index
ch a n gin g 5-32 in F ilt er Design er 5-27 in F ilt er Viewer 5-26, 5-87 in Sign a l Br owser 5-23, 5-46 in Spect r u m Viewer 5-24 zoom in g in F ilt er Design er 5-77 in F ilt er Viewer 5-87 in Sign a l Br owser 5-46 in Spect r u m Viewer 5-103 on e-t im e 5-32 per sist en t 5-32 zp2sos 1-42, 6-4, 6-379 zp2ss 1-42, 6-4, 6-383 zp2tf 1-42, 6-384 zplane 1-30, 6-3, 6-385 z -t r a n sfor m 1-15, 1-32 ch ir p z -t r a n sfor m (CZT) 4-34, 6-105 discr et e F ou r ier t r a n sfor m 1-43
I-29
Index
I-30