You are on page 1of 720

Signal Processing

Toolbox
For Use with MATLAB ®

Computation

Visualization

Programming

User’s Guide
Version 4.2
How to Contact The MathWorks:


PHONE
508-647-7000 P h on e

508-647-7001 Fax
FAX


MAIL
Th e Ma t h Wor ks, In c.
24 P r im e P a r k Wa y
Na t ick, MA 01760-1500
Ma il

http://www.mathworks.com Web
INTERNET
ftp.mathworks.com An on ym ou s F TP ser ver
comp.soft-sys.matlab Newsgr ou p

@ support@mathworks.com
suggest@mathworks.com
Tech n ica l su ppor t
P r odu ct en h a n cem en t su ggest ion s
bugs@mathworks.com Bu g r epor t s
doc@mathworks.com Docu m en t a t ion er r or r epor t s
subscribe@mathworks.com Su bscr ibin g u ser r egist r a t ion
service@mathworks.com Or der st a t u s, licen se r en ewa ls, pa sscodes
info@mathworks.com 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 ser’s 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 o-
du 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 disclo-
su 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 New for MATLAB 5.0
J a n u a r y 1998 Secon d pr in t in g Revised for MATLAB 5.2
J a n u a r y 1999 (On lin e on ly) Revised for Ver sion 4.2 (Relea se 11)
Contents

B e fo re Yo u B e g in

Wh a t Is th e S ig n a l P ro c e s s in g To o lbo x ? . . . . . . . . . . . . . . . . . . . x i i

Ho w to U s e Th is Ma n u a l . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . x ii i

In s ta lla tio n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . x v

Ty p o g ra p h ic a l Co n v e n tio n s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . x v i
Tech n ica l Not a t ion s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . x v i i

S ig n a l P ro c e s s in g B a s ic s
1
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
F ilt er in g a n d F F Ts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
Sign a ls a n d Syst em s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
Key Ar ea s: F ilt er Design a n d Spect r a l An a lysis . . . . . . . . . . . . 1-3
Gr a ph ica l User In t er fa ce (GUI) . . . . . . . . . . . . . . . . . . . . . . . . . 1-3
E xt en sibilit y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3

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

i
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 . . . . . . . . . . . . . . . . . . . . . . 1-14


Con volu t ion a n d F ilt er in g . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-14
F ilt er s a n d Tr a n sfer F u n ct ion s . . . . . . . . . . . . . . . . . . . . . . . . . 1-15
F ilt er Coefficien t s a n d F ilt er Na m es . . . . . . . . . . . . . . . . . . 1-15
F ilt er in g wit h t h e filt er F u n ct ion . . . . . . . . . . . . . . . . . . . . . . . 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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-19


Mu lt ir a t e F ilt er Ba n k Im plem en t a t ion . . . . . . . . . . . . . . . . . . 1-19
An t i-Ca u sa l, Zer o-P h a se F ilt er Im plem en t a t ion . . . . . . . . . . . 1-20
F r equ en cy Dom a in F ilt er Im plem en t a t ion . . . . . . . . . . . . . . . . 1-22

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
Digit a l Dom a in . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-24
An a log Dom a in . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-26
Ma gn it u de a n d P h a se . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-26
Dela y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-28

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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-32
Discr et e-Tim e Syst em Models . . . . . . . . . . . . . . . . . . . . . . . . . . 1-32
Tr a n sfer F u n ct ion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-32
Zer o-P ole-Ga in . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-33
St a t e-Spa ce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-34
P a r t ia l F r a ct ion E xpa n sion (Residu e F or m ) . . . . . . . . . . . . 1-35
Secon d-Or der Sect ion s (SOS) . . . . . . . . . . . . . . . . . . . . . . . . 1-36
La t t ice St r u ct u r e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-37
Con volu t ion Ma t r ix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-39
Con t in u ou s-Tim e Syst em Models . . . . . . . . . . . . . . . . . . . . . . . 1-40
Lin ea r Syst em Tr a n sfor m a t ion s . . . . . . . . . . . . . . . . . . . . . . . . 1-41

ii Con ten ts
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

F ilte r D e s ig n
2
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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-16
Lin ea r P h a se F ilt er s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-17
Win dowin g Met h od . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-18
St a n da r d Ba n d F IR F ilt er Design : fir 1 . . . . . . . . . . . . . . . . 2-20
Mu lt iba n d F IR F ilt er Design : fir 2 . . . . . . . . . . . . . . . . . . . . 2-21
Mu lt iba n d F IR F ilt er Design wit h Tr a n sit ion Ba n ds . . . . . . . 2-22
Ba sic Con figu r a t ion s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-22
Th e Weigh t Vect or . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-24
An t i-Sym m et r ic F ilt er s / H ilber t Tr a n sfor m er s . . . . . . . . . . 2-25
Differ en t ia t or s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-26
Con st r a in ed Lea st Squ a r es F IR F ilt er Design . . . . . . . . . . . . . 2-27
Ba sic Lowpa ss a n d H igh pa ss CLS F ilt er Design . . . . . . . . . 2-28
Mu lt iba n d CLS F ilt er Design . . . . . . . . . . . . . . . . . . . . . . . . 2-29
Weigh t ed CLS F ilt er Design . . . . . . . . . . . . . . . . . . . . . . . . . 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 ....................... 2-37


An a log P r ot ot ype Design . . . . . . . . . . .................... 2-38
F r equ en cy Tr a n sfor m a t ion . . . . . . . . .................... 2-38
F ilt er Discr et iza t ion . . . . . . . . . . . . . . .................... 2-41
Im pu lse In va r ia n ce . . . . . . . . . . . . .................... 2-42
Bilin ea r Tr a n sfor m a t ion . . . . . . . . .................... 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
3
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
4
Win d o w s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
Ba sic Sh a pes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
Gen er a lized Cosin e Win dows . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4
Ka iser Win dow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4
Ka iser Win dows in F IR Design . . . . . . . . . . . . . . . . . . . . . . . . 4-7
Ch ebysh ev Win dow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 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
Lin ea r P r edict ion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12
P r on y’s Met h od (ARMA Modelin g) . . . . . . . . . . . . . . . . . . . . 4-13
St eiglit z-McBr ide Met h od (ARMA Modelin g) . . . . . . . . . . . 4-15
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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-34


Ch ir p z-Tr a n sfor m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-34
Discr et e Cosin e Tr a n sfor m . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-36
H ilber t Tr a n sfor m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-38

v
Re fe re n c e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-40

In te ra c tiv e To o ls
5
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 . . . . . . . . . . . . . . . . . . . . ......... . 5-20
Ru ler Set t in gs . . . . . . . . . . . . . . . . . . . . . . . . . . ......... . 5-21
Color Set t in gs . . . . . . . . . . . . . . . . . . . . . . . . . . . ......... . 5-22
Sign a l Br owser Set t in gs . . . . . . . . . . . . . . . . . . ......... . 5-23
Spect r u m Viewer Set t in gs . . . . . . . . . . . . . . . . . ......... . 5-24
F ilt er Viewer Set t in gs . . . . . . . . . . . . . . . . . . . . ......... . 5-25
F ilt er Viewer Tilin g Set t in gs . . . . . . . . . . . . . . ......... . 5-26
F ilt er Design er Set t in gs . . . . . . . . . . . . . . . . . . ......... . 5-27
Defa u lt Session Set t in g . . . . . . . . . . . . . . . . . . . ......... . 5-28
E xpor t in g Com pon en t s Set t in g . . . . . . . . . . . . . ......... . 5-29
P lu g-In s Set t in g . . . . . . . . . . . . . . . . . . . . . . . . . ......... . 5-30
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 . . 5-30
Con t r ols for Viewin g a n d Mea su r in g . . . . . . . . . . ......... . 5-31
Zoom Con t r ols . . . . . . . . . . . . . . . . . . . . . . . . . . ......... . 5-31
Ru ler Con t r ols . . . . . . . . . . . . . . . . . . . . . . . . . . ......... . 5-33
Ma k in g Sign a l Mea su r em en t s . . . . . . . . . . . . . ......... . 5-37

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
Open in g t h e Sign a l Br owser . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-43
Ba sic Sign a l Br owser F u n ct ion s . . . . . . . . . . . . . . . . . . . . . . . . 5-44
Men u s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-45
Zoom Con t r ols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-46
Ru ler a n d Lin e Displa y Con t r ols . . . . . . . . . . . . . . . . . . . . . 5-46
H elp Bu t t on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-46
Displa y Ma n a gem en t Con t r ols . . . . . . . . . . . . . . . . . . . . . . . 5-47
Ma in Axes Displa y Ar ea . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-47
P a n n er . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-48
Ma k in g Sign a l Mea su r em en t s . . . . . . . . . . . . . . . . . . . . . . . 5-49
Viewin g a n d E xplor in g Sign a ls . . . . . . . . . . . . . . . . . . . . . . . . . 5-49
Select in g a n d Displa yin g a Sign a l . . . . . . . . . . . . . . . . . . . . 5-49
P a n n er Displa y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-52
Ma n ipu la t in g Displa ys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-53
Wor kin g wit h Sign a ls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-54
P r in t in g Sign a l Da t a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-54
Sa vin g Sign a l Da t a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-57

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


Open in g t h e F ilt er Design er . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-59

v ii
Ba sic F ilt er Design er F u n ct ion s . . . . . . . . . . . . . . . . . . . . . . . . 5-60
Men u s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-60
F ilt er P op-Up Men u . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-60
Zoom Con t r ols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-61
H elp Bu t t on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-61
Gen er a l Con t r ols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-62
F ilt er Specifica t ion s P a n el—Design Met h ods . . . . . . . . . . . 5-63
F ilt er Mea su r em en t s P a n el—Design Met h ods . . . . . . . . . . 5-65
F ilt er Specifica t ion s P a n el—P ole/Zer o E dit or . . . . . . . . . . . 5-66
F ilt er Mea su r em en t s P a n el—P ole/Zer o E dit or . . . . . . . . . . 5-68
Ma gn it u de P lot (Displa y) Ar ea —Design Met h ods . . . . . . . . 5-69
Ma gn it u de P lot (Displa y) Ar ea —P ole/Zer o E dit or . . . . . . . . 5-71
Design in g F in it e Im pu lse Respon se (F IR) F ilt er s . . . . . . . . . . 5-73
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 5-73
F ilt er Design Opt ion s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-75
Or der Select ion for F IR F ilt er Design . . . . . . . . . . . . . . . . . 5-75
Design in g In fin it e Im pu lse Respon se (IIR) F ilt er s . . . . . . . . . 5-76
E xa m ple: Cla ssica l IIR F ilt er Design . . . . . . . . . . . . . . . . . . 5-76
F ilt er Design Opt ion s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-77
Or der Select ion for IIR F ilt er Design . . . . . . . . . . . . . . . . . . 5-78
Redesign in g a F ilt er Usin g t h e Ma gn it u de P lot . . . . . . . . . . . . 5-78
Sa vin g F ilt er Da t a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-79
Viewin g F r equ en cy Respon se P lot s . . . . . . . . . . . . . . . . . . . . . . 5-82

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


Open in g t h e F ilt er Viewer . . . . . . . . . .................... 5-84
Ba sic F ilt er Viewer F u n ct ion s . . . . . . .................... 5-84
Men u s . . . . . . . . . . . . . . . . . . . . . . . .................... 5-86
F ilt er Iden t ifica t ion P a n el . . . . . . . .................... 5-86
P lot s P a n el . . . . . . . . . . . . . . . . . . . .................... 5-86
F r equ en cy Axis Set t in gs . . . . . . . . .................... 5-87
Zoom Con t r ols . . . . . . . . . . . . . . . . .................... 5-87
H elp Bu t t on . . . . . . . . . . . . . . . . . . .................... 5-87
Ma in P lot s Ar ea . . . . . . . . . . . . . . . .................... 5-88

v ii i Con ten ts
Viewin g F ilt er P lot s . . . . . . . . . . . ... ... .... ... ... ... ... . 5-89
Viewin g Ma gn it u de Respon se . ... ... .... ... ... ... ... . 5-89
Viewin g P h a se Respon se . . . . . ... ... .... ... ... ... ... . 5-91
Viewin g Gr ou p Dela y . . . . . . . . ... ... .... ... ... ... ... . 5-93
Viewin g a Zer o-P ole P lot . . . . . ... ... .... ... ... ... ... . 5-94
Viewin g Im pu lse Respon se . . . ... ... .... ... ... ... ... . 5-94
Viewin g St ep Respon se . . . . . . ... ... .... ... ... ... ... . 5-95

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 . . . . . . . . . . . . . . 5-113


Cr ea t e, Im por t , a n d Na m e a Sign a l . . . . . . . . . . . . . . . . . . . . 5-113
Design a F ilt er . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-115
Apply t h e F ilt er t o a Sign a l . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-116
View, P la y, a n d P r in t t h e Sign a ls . . . . . . . . . . . . . . . . . . . . . . 5-117
Com pa r e Spect r a of Bot h Sign a ls . . . . . . . . . . . . . . . . . . . . . . 5-120

Re fe re n c e
6

ix
x Con ten ts
Befor e You Begin
Wh a t Is th e S ig n a l P ro c e s s in g To o lbo x ? . . . . . . . . . . . . . . . .xii

Ho w to U s e Th is Ma n u a l . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii

In s ta lla tio n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv

Ty p o g ra p h ic a l Co n v e n tio n s . . . . . . . . . . . . . . . . . . . . . . . . . . xvi
Tech n ica l Not a t ion s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xvii
Before You Begin

What Is the Signal Processing Toolbox?


Th is sect ion descr ibes h ow t o begin u sin g t h e Sign a l P r ocessin g Toolbox. It
expla in s h ow t o u se t h is m a n u a l a n d poin t s you t o a ddit ion a l books for t oolbox
in st a lla t ion in for m a t ion .
Th e Sign a l P r ocessin g Toolbox is a collect ion of t ools bu ilt on t h e MATLAB ®
n u m er ic com pu t in g en vir on m en t . Th e t oolbox su ppor t s a wide r a n ge of sign a l
pr ocessin g oper a t ion s, fr om wa vefor m gen er a t ion t o filt er design a n d
im plem en t a t ion , pa r a m et r ic m odelin g, a n d spect r a l a n a lysis. Th e t oolbox
pr ovides t wo ca t egor ies of t ools:

• Sign a l pr ocessin g fu n ct ion s


• Gr a ph ica l, in t er a ct ive t ools

Th e fir st ca t egor y of t ools is m a de u p of fu n ct ion s t h a t you ca n ca ll fr om t h e


com m a n d lin e or fr om you r own a pplica t ion s. Ma n y of t h ese fu n ct ion s a r e
MATLAB M-files, ser ies of MATLAB st a t em en t s t h a t im plem en t specia lized
sign a l pr ocessin g a lgor it h m s. You ca n view t h e MATLAB code for t h ese
fu n ct ion s u sin g t h e st a t em en t
type function_name

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
How to Use This Manual

How to Use This Manual


If you are a new user. Begin wit h Ch a pt er 1, “Sign a l P r ocessin g Ba sics.” Th is
ch a pt er in t r odu ces t h e MATLAB sign a l pr ocessin g en vir on m en t t h r ou gh t h e
t oolbox fu n ct ion s. It descr ibes t h e ba sic fu n ct ion s of t h e Sign a l P r ocessin g
Toolbox, r eviewin g it s u se in ba sic wavefor m gen er a t ion , filt er im plem en t a t ion
a n d a n a lysis, im pu lse a n d fr equ en cy r espon se, zer o-pole a n a lysis, lin ea r
syst em m odels, a n d t h e discr et e Fou r ier t r a n sfor m .
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
Before You Begin

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 MATLAB’s 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)

befor e r u n n in g t h e exa m ple.

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
Before You Begin

Typographical Conventions

To Indicate This Manual Uses Example

E xa m ple code Monospace type. To a ssign t h e va lu e 5 t o


A, en t er

A = 5

MATLAB Monospace type. MATLAB r espon ds wit h


ou t pu t
A =
5

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 .

New t er m s Italics. An array is a n or der ed


collect ion of
in for m a t ion .

Keys B o ld fa c e wit h a n P r ess t h e Re tu rn key.


in it ia l ca pit a l let t er.

Men u n a m es, B o ld fa c e wit h a n Ch oose t h e F ile m en u .


it em s, a n d GUI in it ia l ca pit a l let t er.
con t r ols

Ma t h em a t ica l Va r ia bles in italics. Th is vect or r epr esen t s


expr ession s F u n ct ion s, t h e polyn om ia l
oper a t or s, a n d
con st a n t s in p = x 2 + 2x + 3
st a n da r d t ype.

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 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.
x(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.
ω or w Digit a l fr equ en cy in r a dia n s per secon d.
f Digit a l fr equ en cy in H er t z.

[x, y) 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

x v ii
Before You Begin

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 Signal Processing Basics

Signal Processing Toolbox Central Features


Th is ch a pt er descr ibes h ow t o begin u sin g MATLAB a n d t h e Sign a l P r ocessin g
Toolbox for you r sign a l pr ocessin g a pplica t ion s. It a ssu m es a ba sic k n owledge
a n d u n der st a n din g of sign a ls a n d syst em s, in clu din g su ch t opics a s filt er a n d
lin ea r syst em t h eor y a n d ba sic F ou r ier a n a lysis.
Ma n y exa m ples t h r ou gh ou t t h e ch a pt er dem on st r a t e h ow t o a pply t oolbox
fu n ct ion s. If you a r e n ot a lr ea dy fa m ilia r wit h MATLAB’s sign a l pr ocessin g
ca pa bilit ies, u se t h is ch a pt er in con ju n ct ion wit h t h e soft wa r e t o t r y exa m ples
a n d lea r n a bou t t h e power fu l fea t u r es a va ila ble t o you .
Th e Sign a l P r ocessin g Toolbox fu n ct ion s a r e a lgor it h m s, expr essed m ost ly in
M-files, t h a t im plem en t a va r iet y of sign a l pr ocessin g t a sks. Th ese t oolbox
fu n ct ion s a r e a specia lized ext en sion of t h e MATLAB com pu t a t ion a l a n d
gr a ph ica l en vir on m en t .

Filtering and FFTs


Two of t h e m ost im por t a n t fu n ct ion s for sign a l pr ocessin g a r e n ot in t h e Sign a l
P r ocessin g Toolbox a t a ll, bu t a r e bu ilt -in MATLAB fu n ct ion s:
• filter a pplies a digit a l filt er t o a da t a sequ en ce.
• fft ca lcu la t es t h e discr et e F ou r ier t r a n sfor m of a sequ en ce.

Th e oper a t ion s t h ese fu n ct ion s per for m a r e t h e m a in com pu t a t ion a l


wor kh or ses of cla ssica l sign a l pr ocessin g. Bot h a r e descr ibed in t h is ch a pt er .
Th e Sign a l P r ocessin g Toolbox u ses m a n y ot h er st a n da r d MATLAB fu n ct ion s
a n d la n gu a ge fea t u r es, in clu din g polyn om ia l r oot fin din g, com plex a r it h m et ic,
m a t r ix in ver sion a n d m a n ipu la t ion , a n d gr a ph ics t ools.

Signals and Systems


Th e ba sic en t it ies t h a t t oolbox fu n ct ion s wor k wit h a r e sign a ls a n d syst em s.
Th e fu n ct ion s em ph a size digit a l, or discr et e, sign a ls a n d filt er s, a s opposed t o
a n a log, or con t in u ou s, sign a ls. Th e pr in cipa l filt er t ype t h e t oolbox su ppor t s is
t h e lin ea r , t im e-in va r ia n t digit a l filt er wit h a sin gle in pu t a n d a sin gle ou t pu t .
You ca n r epr esen t lin ea r t im e-in va r ia n t syst em s u sin g on e of sever a l m odels
(su ch a s t r a n sfer fu n ct ion , st a t e-spa ce, zer o-pole-ga in , a n d secon d-or der
sect ion ) a n d con ver t bet ween r epr esen t a t ion s.

1-2
Signal Processing Toolbox Central Features

Key Areas: Filter Design and Spectral Analysis


In a ddit ion t o it s cor e fu n ct ion s, t h e t oolbox pr ovides r ich , cu st om iza ble su ppor t
for t h e key a r ea s of filt er design a n d spect r a l a n a lysis. It is ea sy t o im plem en t
a design t ech n iqu e t h a t su it s you r a pplica t ion , design digit a l filt er s dir ect ly, or
cr ea t e a n a log pr ot ot ypes a n d discr et ize t h em . Toolbox fu n ct ion s a lso est im a t e
power spect r a l den sit y a n d cr oss spect r a l den sit y, u sin g eit h er pa r a m et r ic or
n on pa r a m et r ic t ech n iqu es. Ch a pt er s 2 a n d 3, r espect ively, det a il t oolbox
fu n ct ion s for filt er design a n d spect r a l a n a lysis.
Th er e a r e fu n ct ion s for com pu t a t ion a n d gr a ph ica l displa y of fr equ en cy
r espon se, a s well a s fu n ct ion s for syst em iden t ifica t ion ; gen er a t in g sign a ls;
discr et e cosin e, ch ir p-z, a n d H ilber t t r a n sfor m s; la t t ice filt er s; r esa m plin g;
t im e-fr equ en cy a n a lysis; a n d ba sic com m u n ica t ion syst em s sim u la t ion .

Graphical User Interface (GUI)


Th e power of t h e Sign a l P r ocessin g Toolbox is gr ea t ly en h a n ced by it s
ea sy-t o-u se gr a ph ica l u ser in t er fa ce. Th e GUI pr ovides a n in t egr a t ed set of
in t er a ct ive t ools for per for m in g a wide va r iet y of sign a l pr ocessin g t a sks. Th ese
t ools en a ble you t o u se t h e m ou se a n d m en u s t o m a n ipu la t e a r ich gr a ph ica l
en vir on m en t 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.

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
1 Signal Processing Basics

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 8.0000 1.2732


3.0000 6.0000 0.9549
7.0000 14.0000 2.2282
–9.0000 –18.0000 –2.8648
1.0000 2.0000 0.3183

1-5
1 Signal Processing Basics

Waveform Generation: Time Vectors and Sinusoids


A va r iet y of t oolbox fu n ct ion s gen er a t e wa vefor m s. Most r equ ir e you t o begin
wit h a vect or r epr esen t in g a t im e ba se. Con sider gen er a t in g da t a wit h a 1000
H z sa m ple fr equ en cy, for exa m ple. An a ppr opr ia t e t im e vect or is
t = (0:0.001:1)';

wh er e MATLAB’s 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))

-1

-2

-3

-4
0 0.01 0.02 0.03 0.04 0.05

1-6
Waveform Generation: Time Vectors and Sinusoids

Common Sequences: Unit Impulse, Unit Step, and


Unit Ramp
Sin ce MATLAB is a pr ogr a m m in g la n gu a ge, a n en dless va r iet y of differ en t
sign a ls is possible. H er e a r e som e st a t em en t s t h a t gen er a t e sever a l com m on ly
u sed sequ en ces, in clu din g t h e u n it im pu lse, u n it st ep, a n d u n it r a m p fu n ct ion s:
t = (0:0.001:1)';
y = [1; zeros(99,1)]; % impulse
y = ones(100,1); % step (filter assumes 0 initial cond.)
y = t; % ramp
y = t.^2;
y = square(4*t);

All of t h ese sequ en ces a r e colu m n vect or s – t h e la st t h r ee in h er it t h eir sh a pes


fr om t.

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 MATLAB’s colon oper a t or a n d t h e ones fu n ct ion .
c = a(:,ones(1,3));

Common Periodic Waveforms


Th e t oolbox pr ovides fu n ct ion s for gen er a t in g widely u sed per iodic wa vefor m s:

1-7
1 Signal Processing Basics

• 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 l’s 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])

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

Common Aperiodic Waveforms


Th e t oolbox a lso pr ovides fu n ct ion s for gen er a t in g sever a l widely u sed
a per iodic wa vefor m s:

• gauspuls gen er a t es a Ga u ssia n -m odu la t ed sin u soida l pu lse wit h a specified


t im e, cen t er fr equ en cy, a n d fr a ct ion a l ba n dwidt h . Opt ion a l pa r a m et er s

1-8
Waveform Generation: Time Vectors and Sinusoids

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

To plot t h e spect r ogr a m , u se


specgram(y,256,1000,256,250)

500

450

400

350

300
Frequency

250

200

150

100

50

0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6
Time

The pulstran Function


Th e pulstran fu n ct ion gen er a t es pu lse t r a in s fr om eit h er con t in u ou s or
sa m pled pr ot ot ype pu lses. Th e followin g exa m ple gen er a t es a pu lse t r a in
con sist in g of t h e su m of m u lt iple dela yed in t er pola t ion s of a Ga u ssia n pu lse.
Th e pu lse t r a in is defin ed t o h a ve a sa m ple r a t e of 50 kH z, a pu lse t r a in len gt h

1-9
1 Signal Processing Basics

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)

0.8

0.6

0.4

0.2

-0.2

-0.4

-0.6

-0.8
0 0.001 0.002 0.003 0.004 0.005 0.006 0.007 0.008 0.009 0.01

The Sinc Function


Th e sinc fu n ct ion com pu t es t h e m a t h em a t ica l sin c fu n ct ion for a n in pu t vect or
or m a t r ix x. Th e sin c 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:
Th e sin c fu n ct ion h a s a va lu e of 1 wh er e x is zer o, a n d a va lu e of

sin ( πx )
--------------------
πx
for a ll ot h er elem en t s of x.

1-10
Waveform Generation: Time Vectors and Sinusoids

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)

0.8

0.6

0.4

0.2

-0.2

-0.4
-5 -4 -3 -2 -1 0 1 2 3 4 5

The Dirichlet Function


Th e t oolbox fu n ct ion diric com pu t es t h e Dir ich let fu n ct ion , som et im es ca lled
t h e period ic sin c or aliased sin c fu n ct ion , for a n in pu t vect or or m a t r ix x. Th e
Dir ich let fu n ct ion is

⎧ – 1 k ( n – 1 ) x = 2 πk , k = 0 , ±1 , ±2 , …
⎪
dir ic(x ) = ⎨
sin ( n x ⁄ 2 )
⎪ --------------------------- otherwise
-
⎩ n sin ( x ⁄ 2 )

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 Signal Processing Basics

To plot t h e Dir ich let fu n ct ion over t h e r a n ge 0 t o 4π for n = 7 a n d n = 8, u se


x = linspace(0,4*pi,300);
plot(x,diric(x,7))
plot(x,diric(x,8))

n=7 n=8
1 1

0.8
0.5
0.6

0.4
0
0.2

0
-0.5
-0.2

-0.4 -1
0 5 10 15 0 5 10 15

1-12
Working with Data

Working with Data


Th e exa m ples in t h e pr ecedin g sect ion s obt a in da t a in on e of t wo wa ys:

• By dir ect in pu t , t h a t is, en t er in g t h e da t a m a n u a lly a t t h e keyboa r d


• By u sin g a MATLAB or t oolbox fu n ct ion , su ch a s sin, cos, sawtooth, square,
or sinc

Som e a pplica t ion s, h owever , m a y n eed t o im por t da t a fr om ou t side MATLAB.


Depen din g on you r da t a for m a t , you ca n do t h is in t h e followin g wa ys:

• Loa d da t a fr om a n ASCII file or MAT-file wit h MATLAB’s load com m a n d


• Rea d t h e da t a in t o MATLAB wit h a low-level file I/O fu n ct ion , su ch a s fopen,
fread, a n d fscanf
• Develop a ME X-file t o r ea d t h e da t a

Ot h er r esou r ces a r e a lso u sefu l, su ch a s a h igh -level la n gu a ge pr ogr a m (in


F or t r a n or C, for exa m ple) t h a t con ver t s you r da t a in t o MAT-file for m a t —see
t h e M A T L AB Application Program m in g In terface r efer en ce m a n u a l for det a ils.
MATLAB r ea ds su ch files u sin g t h e load com m a n d.
Sim ila r t ech n iqu es a r e a va ila ble for expor t in g da t a gen er a t ed wit h in
MATLAB. See Usin g M AT L AB for m or e det a ils on im por t in g a n d expor t in g
da t a , a n d see t h e on lin e M AT L AB Fu n ction R eferen ce for descr ipt ion s of file
loa din g a n d I/O r ou t in es.

1-13
1 Signal Processing Basics

Filter Implementation and Analysis


Th is sect ion descr ibes h ow t o filt er discr et e sign a ls u sin g MATLAB’s filter
fu n ct ion a n d ot h er fu n ct ion s in t h e Sign a l P r ocessin g Toolbox. It a lso discu sses
h ow t o u se t h e t oolbox fu n ct ion s t o a n a lyze filt er ch a r a ct er ist ics, in clu din g
im pu lse r espon se, m a gn it u de a n d ph a se r espon se, gr ou p dela y, a n d zer o-pole
loca t ion s.

Convolution and Filtering


Th e m a t h em a t ica l fou n da t ion of filt er in g is con volu t ion . MATLAB’s conv
fu n ct ion per for m s st a n da r d on e-dim en sion a l con volu t ion , con volvin g on e
vect or wit h a n ot h er .
conv([1 1 1],[1 1 1])

ans =

1 2 3 2 1

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 .

A digit a l filt er ’s ou t pu t y(n ) is r ela t ed t o it s in pu t x(n ) by con volu t ion wit h it s


im pu lse r espon se h (n ).

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); % a random vector of length 5
h = [1 1 1 1]/4; % length 4 averaging filter
y = conv(h,x);

1-14
Filter Implementation and Analysis

Filters and Transfer Functions


In gen er a l, t h e z-t r a n sfor m Y (z) of a digit a l filt er ’s ou t pu t y(n ) is r ela t ed t o t h e
z-t r a n sfor m X (z) of t h e in pu t by

b (1 ) + b (2 )z – 1 + L+ b (n b + 1 )z – n b
Y (z ) = H (z )X (z ) = ----------------------------------------------------------------------------------------
- X (z )
a (1 ) + a (2 )z – 1 + L+ a (n a + 1 )z –n a
wh er e H (z) is t h e filt er ’s tran sfer fu n ction . 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.

NOTE Th e filt er coefficien t s st a r t wit h su bscr ipt 1, r a t h er t h a n 0. Th is


r eflect s MATLAB’s st a n da r d in dexin g sch em e for vect or s.

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.

Filter Coefficients and Filter Names


Ma n y st a n da r d n a m es for filt er s r eflect t h e n u m ber of a a n d b coefficien t s
pr esen t :

• Wh en nb = 0 (t h a t is, b is a sca la r ), t h e filt er is a n In fin it e Im pu lse Respon se


(IIR), a ll-pole, r ecu r sive, or a u t or egr essive (AR) filt er .
• Wh en na = 0 (t h a t is, a is a sca la r ), t h e filt er is a F in it e Im pu lse Respon se
(F IR), a ll-zer o, n on r ecu r sive, or m ovin g a ver a ge (MA) filt er .
• If bot h na a n d nb a r e gr ea t er t h a n zer o, t h e filt er is a n IIR, pole-zer o,
r ecu r sive, or a u t or egr essive m ovin g a ver a ge (ARMA) filt er .

Th e a cr on ym s AR, MA, a n d ARMA a r e u su a lly a pplied t o filt er s a ssocia t ed


wit h filt er ed st och a st ic pr ocesses.

1-15
1 Signal Processing Basics

Filtering with the filter Function


It is sim ple t o wor k ba ck t o a differ en ce equ a t ion fr om t h e z-t r a n sfor m r ela t ion
sh own ea r lier . Assu m e t h a t a(1) = 1. Move t h e den om in a t or t o t h e left -h a n d
side a n d t a ke t h e in ver se z-t r a n sfor m .

y (n ) + a (2 )y (n – 1 ) + L+ a (n a + 1 )y (n – n a ) = b (1 )x (n ) + b (2 )x (n – 1 ) + L+ b (n b + 1 )x (n – n b )

In t er m s of cu r r en t a n d pa st in pu t s, a n d pa st ou t pu t s, y(n ) is

y (n ) = b (1 )x (n ) + b (2 )x (n – 1 ) + L+ b (n b + 1 )x (n – n b ) – a (2 )y (n – 1 ) – L– a (n a + 1 ) y (n – n a )

Th is is t h e st a n da r d t im e-dom a in r epr esen t a t ion of a digit a l filt er , com pu t ed


st a r t in g wit h y(1) a n d a ssu m in g zer o in it ia l con dit ion s. Th is r epr esen t a t ion ’s
pr ogr ession is

y (1 ) = b (1 )x (1 )
y (2 ) = b (1 )x (2 ) + b (2 )x (1 ) – a (2 )y (1 )
y (3 ) = b (1 )x (3 ) + b (2 )x (2 ) + b (3 )x (1 ) – a (2 )y (2 ) – a (3 )y (1 )
M = M
A filt er in t h is for m is ea sy t o im plem en t wit h t h e filter fu n ct ion . F or
exa m ple, a sim ple sin gle-pole filt er (lowpa ss) is
b = 1; % numerator
a = [1 –0.9]; % denominator

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
filter Function Implementation and Initial Conditions

filter Function Implementation and Initial Conditions


filter is im plem en t ed a s a t r a n sposed dir ect for m II st r u ct u r e
x(m) ...
b(n) b( 3 ) b( 2 ) b(1)

Σ z -1 ... Σ z -1 Σ z -1 Σ y(m)
z n -1 (m) z 2 (m) z 1 (m)
– a(n) – a( 3 ) – a( 2 )
...

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 = M
zn – 2 (m ) = b (n – 1 )x (m ) + z n – 1 (m – 1 ) – a (n – 1 )y (m )
zn – 1 (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); % two random sequences to
x2 = randn(5000,1); % 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
1 Signal Processing Basics

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
Other Functions for Filtering

Other Functions for Filtering


In a ddit ion t o filter, sever a l ot h er fu n ct ion s in t h e Sign a l P r ocessin g Toolbox
per for m t h e ba sic filt er in g oper a t ion . Th ese fu n ct ion s in clu de upfirdn, wh ich
per for m s F IR filt er in g wit h r esa m plin g, filtfilt, wh ich elim in a t es ph a se
dist or t ion in t h e filt er in g pr ocess, fftfilt, wh ich per for m s t h e F IR filt er in g
oper a t ion in t h e fr equ en cy dom a in , a n d latcfilt, wh ich filt er s u sin g a la t t ice
im plem en t a t ion .

Multirate Filter Bank Implementation


Th e fu n ct ion upfirdn a lt er s t h e sa m plin g r a t e of a sign a l by a n in t eger r a t io
P /Q. It com pu t es t h e r esu lt of t h e ca sca de of t h r ee syst em s: (1) u psa m plin g
(zer o in ser t ion ) by in t eger fa ct or p, (2) filt er in g by F IR filt er h, a n d (3)
down sa m plin g by in t eger fa ct or q.

FIR
x(n) P H Q 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
1 Signal Processing Basics

Anti-Causal, Zero-Phase Filter Implementation


In t h e ca se of F IR filt er s, it is possible t o design lin ea r ph a se filt er s t h a t , wh en
a pplied t o da t a (u sin g filter or conv), sim ply dela y t h e ou t pu t by a fixed
n u m ber of sa m ples. F or IIR filt er s, h owever , t h e ph a se dist or t ion is u su a lly
h igh ly n on lin ea r . Th e filtfilt fu n ct ion u ses t h e in for m a t ion in t h e sign a l a t
poin t s befor e a n d a ft er t h e cu r r en t poin t , in essen ce “look in g in t o t h e fu t u r e,”
t o elim in a t e ph a se dist or t ion .
To see h ow filtfilt does t h is, r eca ll t h a t if t h e z-t r a n sfor m of a r ea l sequ en ce
x(n ) is X(z), t h e z-t r a n sfor m of t h e t im e r ever sed sequ en ce x(n ) is X(1/z).
Con sider t h e pr ocessin g sch em e

Time Time
X(z) H(z) Reverse H(z) Reverse X(z)H(1/z)H(z)

X(z)H(z) X(1/z)H(1/z) X(1/z)H(1/z)H(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
Other Functions for Filtering

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; % 10 point averaging filter
y = filtfilt(b,1,x); % non–causal filtering
yy = filter(b,1,x); % normal filtering
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 1

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
1 Signal Processing Basics

Frequency Domain Filter Implementation


Du a lit y bet ween t h e t im e dom a in a n d t h e fr equ en cy dom a in m a k es it possible
t o per for m a n y oper a t ion in eit h er dom a in . Usu a lly on e dom a in or t h e ot h er is
m or e con ven ien t for a pa r t icu la r oper a t ion , bu t you ca n a lwa ys a ccom plish a
given oper a t ion in eit h er dom a in .
To im plem en t gen er a l IIR filt er in g in t h e fr equ en cy dom a in , m u lt iply t h e
discr et e F ou r ier t r a n sfor m (DF T) of t h e in pu t sequ en ce wit h t h e qu ot ien t of t h e
DF T of t h e filt er ,
n = length(x);
y = ifft(fft(x).*fft(b,n)./fft(a,n));

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 , n =1
x (n ) = ⎨
⎩ 0 , n ≠1

In MATLAB, you ca n gen er a t e a n im pu lse sequ en ce a n u m ber of wa ys; on e


st r a igh t for wa r d wa y is
imp = [1; zeros(49,1)];

Th e im pu lse r espon se of t h e sim ple filt er b = 1 a n d a = [1 –0.9] is


h = filter(b,a,imp);

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)

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
1 Signal Processing Basics

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 (1 ) + a (2 )e – j ω + L+ a (n a + 1 )e – j ω ( n a )
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)

100
Magnitude Response (dB)

-100

-200

-300

-400
0 100 200 300 400 500 600 700 800 900 1000
Frequency (Hertz)

-200
Phase (degrees)

-400

-600

-800

-1000
0 100 200 300 400 500 600 700 800 900 1000
Frequency (Hertz)

1-25
1 Signal Processing Basics

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 .

Magnitude and Phase


MATLAB pr ovides fu n ct ion s t o ext r a ct m a gn it u de a n d ph a se fr om a fr equ en cy
r espon se vect or h. Th e fu n ct ion abs r et u r n s t h e m a gn it u de of t h e r espon se;
angle r et u r n s t h e ph a se a n gle in r a dia n s. To ext r a ct a n d plot t h e m a gn it u de
a n d ph a se of a Bu t t er wor t h filt er .
[b,a] = butter(6,300/500); [h,w] = freqz(b,a,512,1000);
m = abs(h); p = angle(h);
semilogy(w,m);
plot(w,p*180/pi)

0 200
10

100
-5
10
0
-10
10
-100

-15
10 -200
0 100 200 300 400 0 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);

Obt a in t h e filt er ’s fr equ en cy r espon se wit h freqz, a n d plot t h e ph a se in


degr ees.
[H,f] = freqz(h,1,512,2);
plot(f,angle(H)*180/pi); grid

200

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 1

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
1 Signal Processing Basics

Use unwrap t o elim in a t e t h e 360° ju m ps.


plot(f,unwrap(angle(H))*180/pi); grid

-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 1

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 (ω) = – ---------------

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

To plot bot h t h e gr ou p a n d ph a se dela ys of a syst em on t h e sa m e gr a ph .


[b,a] = butter(10,200/1000);
gd = grpdelay(b,a,128);
[h,f] = freqz(b,a,128,2000);
pd = –unwrap(angle(h))*(2000/(2*pi))./f;
plot(f,gd,'–',f,pd,'– –')
axis([0 1000 –30 30])
legend('Group Delay','Phase Delay')

30
Group Delay
Phase Delay
20

10

−10

−20

−30
0 200 400 600 800 1000

1-29
1 Signal Processing Basics

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]');

Th e zer o-pole plot for t h e filt er is


zplane(zer,pol)

0.8

0.6

0.4

0.2
Imaginary part

-0.2

-0.4

-0.6

-0.8

-1

-1 -0.5 0 0.5 1
Real part

F or a syst em in zer o-pole for m , su pply colu m n vect or a r gu m en t s z a n d p t o


zplane.
zplane(z,p)

F or a syst em in t r a n sfer fu n ct ion for m , su pply r ow vect or s b a n d a a s


a r gu m en t s t o zplane.
zplane(b,a)

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
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
1 Signal Processing Basics

Linear System Models


Th e Sign a l P r ocessin g Toolbox pr ovides sever a l m odels for r epr esen t in g lin ea r
t im e-in va r ia n t syst em s. Th is flexibilit y let s you ch oose t h e r epr esen t a t ion a l
sch em e t h a t best su it s you r a pplica t ion a n d, wit h in t h e bou n ds of n u m er ic
st a bilit y, con ver t fr eely t o a n d fr om m ost ot h er m odels. Th is sect ion pr ovides a
br ief over view of su ppor t ed lin ea r syst em m odels a n d descr ibes h ow t o wor k
wit h t h ese m odels in MATLAB.

Discrete-Time System Models


Th e discr et e-t im e syst em m odels a r e r epr esen t a t ion a l sch em es for digit a l
filt er s. MATLAB su ppor t s sever a l discr et e-t im e syst em m odels:

• Tr a n sfer fu n ct ion
• Zer o-pole-ga in for m
• St a t e-spa ce for m
• P a r t ia l fr a ct ion expa n sion
• Secon d-or der sect ion for m
• La t t ice st r u ct u r e for m
• Con volu t ion m a t r ices

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 (1 ) + b (2 )z – 1 + L+ b (n b + 1 )z – n b
Y (z ) = ----------------------------------------------------------------------------------------
- X (z )
a (1 ) + a (2 )z –1 + L+ a (n a + 1 )z – n a
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
Linear System Models

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

q(z ) ( z – q (1 ) ) ( z – q (2 ) )Lz ( – q (n ) )
H (z ) = ---------- = k -----------------------------------------------------------------------------
p (z ) ( z – p (1 ) ) ( z – p (2 ) )Lz ( – p (n ) )
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];

Th e zer os a n d poles of t h is filt er a r e


q = roots(b)

q =

–0.7500 + 1.1990i
–0.7500 – 1.1990i

p = roots(a)

p =

–1.0000
–1.0000 + 0.0000i
–1.0000 – 0.0000i

k = b(1)/a(1)

k =

1-33
1 Signal Processing Basics

Ret u r n in g t o t h e or igin a l polyn om ia ls,


bb = k*poly(q)

bb =

2.0000 3.0000 4.0000

aa = poly(p)

aa =

1.0000 3.0000 3.0000 1.0000

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 – 2 – 3
= -------------------------------------------
-
1 + 3z + 3z + z 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
Linear System Models

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.

Partial Fraction Expansion (Residue Form)


E a ch t r a n sfer fu n ct ion a lso h a s a cor r espon din g partial fraction expan sion or
resid u e for m r epr esen t a t ion , given by

b (z ) r (1 ) r (n )
---------- = ---------------------------- - + k (1 ) + k (2 )z – 1 + L+ k (m – n + 1 )z – ( m
+ L+ ---------------------------- – n)
a (z ) 1 – p (1 )z – 1 1 – p (n )z – 1
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 ) r (j + 1 ) r (j + s r – 1 )
--------------------------
- + ----------------------------------
- + L+ -----------------------------------
-
1 – p (j )z – 1 ( 1 – p (j )z – 1 ) 2 ( 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
1 Signal Processing Basics

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
-
1 + 4z 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 , n = 0, 1, 2, …
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

respres = filter(r(1),[1 –p(1)],imp) + filter(r(2),[1 –p(2)],imp)

respres =

–4 32 –160 704 –2944

Second-Order Sections (SOS)


An y t r a n sfer fu n ct ion H (z) h a s a secon d-or der sect ion s r epr esen t a t ion

1-36
Linear System Models

L L
b 0 k + b 1 k z –1 + b 2 k z –2
H (z ) = ∏ H k (z ) = ∏ ---------------------------------------------------------
a 0 k + a 1 k z – 1 + a 2 k z –2
-
k =1 k =1

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
b 02 b 12 b 22 a 02 a 12 a 22
s os =
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
1 Signal Processing Basics

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) Σ ... Σ y(m)


k(1) k(n)

k(1) k(n)

z -1 Σ ... z -1 Σ

F IR La t t ice F ilt er

x(m) Σ ... Σ y(m)


–k(n) –k(1)

k(n) k(1)
Σ z -1 ... Σ z -1

IIR La t t ice F ilt er

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(2) k(1)

k(N) k(2) k(1)


g(m)
-1 -1
+ z + z + z -1

v(N+1) v(N) v(3) v(2) v(1)

f(m)
+ + + +

1-38
Linear System Models

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 is filt er ’s la t t ice (r eflect ion coefficien t ) r epr esen t a t ion is


k = tf2latc(a)

k =

0.3090
0.9800
0.0031
0.0081
–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 l’s 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
1 Signal Processing Basics

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 0 0
2 1 0
3 2 1
0 3 2
0 0 3

Two wa ys t o con volve b wit h x a r e


y1 = C*x;
y2 = conv(b,x);

Type t h is exa m ple in t o MATLAB; t h e r esu lt s for y1 a n d y2 a r e equ a l.

Continuous-Time System Models


Th e con t in u ou s-t im e syst em m odels a r e r epr esen t a t ion a l sch em es for a n a log
filt er s. Ma n y of t h e discr et e-t im e syst em m odels descr ibed ea r lier a r e a lso
a ppr opr ia t e for t h e r epr esen t a t ion of con t in u ou s-t im e syst em s:
• St a t e-spa ce for m
• P a r t ia l fr a ct ion expa n sion
• Tr a n sfer fu n ct ion
• Zer o-pole-ga in for m

It is possible t o r epr esen t a n y syst em of lin ea r t im e-in va r ia n t differ en t ia l


equ a t ion s a s a set of fir st -or der differ en t ia l equ a t ion s. In m a t r ix or state-space
for m , you ca n expr ess t h e equ a t ion s a s
·
x = Ax + Bu
y = Cx + Du

1-40
Linear System Models

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 (s ) b (1 )s n b + b (2 )s n b – 1 + L+ b (n b + 1 )
H (s ) = ---------- = ---------------------------------------------------------------------------------------------
-
a (s ) a (1 )s n a + a (2 )s n a – 1 + L+ a (n a + 1 )
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

z (s ) ( s – z (1 ) ) ( s – z (2 ) )Ls ( – z (n ) )
H (s ) = ---------- = k -----------------------------------------------------------------------------
p (s ) ( s – p (1 ) ) ( s – p (2 ) )Ls ( – p (n ) )

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.

Linear System Transformations


Th e Sign a l P r ocessin g Toolbox pr ovides a n u m ber of fu n ct ion s t h a t con ver t
bet ween t h e va r iou s lin ea r syst em m odels; see t h e r efer en ce descr ipt ion in
Ch a pt er 6 for a com plet e descr ipt ion of ea ch . You ca n u se t h e followin g ch a r t t o
fin d a n a ppr opr ia t e t r a n sfer fu n ct ion : fin d t h e r ow of t h e m odel t o con ver t from
on t h e left side of t h e ch a r t a n d t h e colu m n of t h e m odel t o con ver t to on t h e t op
of t h e ch a r t a n d r ea d t h e fu n ct ion n a m e(s) a t t h e in t er sect ion of t h e r ow a n d
colu m n .

1-41
1 Signal Processing Basics

Zero- Second-
Transfer State- pole Partial Lattice order Convolution
function space gain fraction filter sections matrix

Transfer tf2ss tf2zp residuez tf2latc convmtx


function roots residue

State-space ss2tf ss2zp ss2sos

Zero-pole zp2tf zp2ss zp2sos


gain poly

Partial residuez
fraction residue

Lattice filter latc2tf

Second- sos2tf sos2ss sos2zp


order
sections

Convolution
matrix

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
Discrete Fourier Transform

Discrete Fourier Transform


Th e discr et e F ou r ier t r a n sfor m , or DF T, is t h e pr im a r y t ool of digit a l sign a l
pr ocessin g. Th e fou n da t ion of t h e Sign a l P r ocessin g Toolbox is t h e F a st F ou r ier
Tr a n sfor m (F F T), a m et h od for com pu t in g t h e DF T wit h r edu ced execu t ion
t im e. Ma n y of t h e t oolbox fu n ct ion s (in clu din g z-dom a in fr equ en cy r espon se,
spect r u m a n d cepst r u m a n a lysis, a n d som e filt er design a n d im plem en t a t ion
fu n ct ion s) in cor por a t e t h e F F T.
MATLAB pr ovides t h e fu n ct ion s fft a n d ifft t o com pu t e t h e discr et e F ou r ier
t r a n sfor m a n d it s in ver se, r espect ively. F or t h e in pu t sequ en ce x a n d it s
t r a n sfor m ed ver sion X (t h e discr et e-t im e F ou r ier t r a n sfor m a t equ a lly spa ced
fr equ en cies a r ou n d t h e u n it cir cle), t h e t wo fu n ct ion s im plem en t t h e
r ela t ion sh ips
N –1

X (k + 1 ) = ∑ x (n + 1 )W nk n
n =0

N –1
1
x (n + 1 ) = ---- ∑ X (k + 1 )W n– k n
N
k =0

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
MATLAB’s vect or in dexin g sch em e, a n d


–j ⎛ -------⎞
⎝ N ⎠
WN = e

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
1 Signal Processing Basics

F or exa m ple, cr ea t e a t im e vect or a n d sign a l.


t = (0:1/99:1); % time vector
x = sin(2*pi*15*t) + sin(2*pi*40*t);% signal

Th e DF T of t h e sign a l, a n d t h e m a gn it u de a n d ph a se of t h e t r a n sfor m ed
sequ en ce, a r e t h en
y = fft(x); % Compute DFT of x.
m = abs(y); p = unwrap(angle(y)); % mag. and phase

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 0

40
-500
30

20
-1000
10

0 -1500
15 40 60 85 15 40 60 85

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
Discrete Fourier Transform

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
1 Signal Processing Basics

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
Cliffs, NJ : P r en t ice H a ll, 1983. P gs. 88-91.

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.

3 J a ckson , L.B. Digital Filters an d S ign al Processin g. Th ir d E d. Bost on :


Klu wer Aca dem ic P u blish er s, 1989.

4 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.

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.

6 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.

7 P r a t t ,W.K. Digital Im age Processin g. New Yor k: J oh n Wiley & Son s, 1991.

8 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.

9 P r oa kis, J .G., a n d D.G. Ma n ola kis. Digital S ign al Processin g: Prin ciples,
Algorith m s, an d Application s. Upper Sa ddle River , NJ : P r en t ice H a ll, 1996.

10 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.

11 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.

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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . ... .... 2-16


Lin ea r P h a se F ilt er s . . . . . . . . . . . . . . . . . . . . . . . . . . . ... .... 2-17
Win dowin g Met h od . . . . . . . . . . . . . . . . . . . . . . . . . . . . ... .... 2-18
Mu lt iba n d F IR F ilt er Design wit h Tr a n sit ion Ba n ds . ... .... 2-22
Con st r a in ed Lea st Squ a r es F IR F ilt er Design . . . . . . ... .... 2-27
Ar bit r a r y-Respon se F ilt er Design . . . . . . . . . . . . . . . . ... .... 2-31

S p e c ia l To p ic s in IIR F ilte r D e s ig n .. .... ... ... ... .... 2-37


An a log P r ot ot ype Design . . . . . . . . . . . .. .... ... ... ... .... 2-38
F r equ en cy Tr a n sfor m a t ion . . . . . . . . . . .. .... ... ... ... .... 2-38
F ilt er Discr et iza t ion . . . . . . . . . . . . . . . .. .... ... ... ... .... 2-41

Re fe re n c e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-45
2 Filter Design

Filter Requirements and Specification


Th e Sign a l P r ocessin g Toolbox pr ovides fu n ct ion s t h a t su ppor t a r a n ge of filt er
design m et h odologies. Th is ch a pt er expla in s h ow t o a pply t h e filt er design t ools
t o In fin ite Im pu lse R espon se (IIR) a n d Fin ite Im pu lse R espon se (F IR) filt er
design pr oblem s.
Th e goa l of filt er design is t o per for m fr equ en cy depen den t a lt er a t ion of a da t a
sequ en ce. A possible r equ ir em en t m igh t be t o r em ove n oise a bove 30 H z fr om
a da t a sequ en ce sa m pled a t 100 H z. A m or e r igor ou s specifica t ion m igh t ca ll for
a specific a m ou n t of pa ssba n d r ipple, st opba n d a t t en u a t ion , or t r a n sit ion
widt h . A ver y pr ecise specifica t ion cou ld a sk t o a ch ieve t h e per for m a n ce goa ls
wit h t h e m in im u m filt er or der , or it cou ld ca ll for a n a r bit r a r y m a gn it u de
sh a pe, or it m igh t r equ ir e a n F IR filt er .
F ilt er design m et h ods differ pr im a r ily in h ow per for m a n ce is specified. F or
“loosely specified” r equ ir em en t s, a s in t h e fir st ca se a bove, a Bu t t er wor t h IIR
filt er is oft en su fficien t . To design a fift h -or der 30 H z lowpa ss Bu t t er wor t h
filt er a n d a pply it t o t h e da t a in vect or x,
[b,a] = butter(5,30/50);
y = filter(b,a,x);

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 ≤ f ≤ 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
Filter Requirements and Specification

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 (Ws–Wp,
in H er t z).

0.8

0.6
Magnitude

0.4

0.2

0 -1 0 1
10 10 10
Frequency(rad/sec)

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
2 Filter Design

IIR Filter Design


Th e pr im a r y a dva n t a ge of IIR filt er s over F IR filt er s is t h a t t h ey t ypica lly m eet
a given set of specifica t ion s wit h a m u ch lower filt er or der t h a n a cor r espon din g
F IR filt er . Alt h ou gh IIR filt er s h a ve n on lin ea r ph a se, da t a pr ocessin g wit h in
MATLAB is com m on ly per for m ed “off-lin e,” t h a t is, t h e en t ir e da t a sequ en ce is
a va ila ble pr ior t o filt er in g. Th is a llows for a n on ca u sa l, zer o-ph a se filt er in g
a ppr oa ch (via t h e filtfilt fu n ct ion ), wh ich elim in a t es t h e n on lin ea r ph a se
dist or t ion of a n IIR filt er .
Th e cla ssica l IIR filt er s, Bu t t er wor t h , Ch ebysh ev t ypes I a n d II, ellipt ic, a n d
Bessel, a ll a ppr oxim a t e t h e idea l “br ickwa ll” filt er in differ en t wa ys. Th is
t oolbox pr ovides fu n ct ion s t o cr ea t e a ll t h ese t ypes of cla ssica l IIR filt er s in bot h
t h e a n a log a n d digit a l dom a in s (except Bessel, for wh ich on ly t h e a n a log ca se
is su ppor t ed), a n d in lowpa ss, h igh pa ss, ba n dpa ss, a n d ba n dst op
con figu r a t ion s. F or m ost filt er t ypes, you ca n a lso fin d t h e lowest filt er or der
t h a t fit s a given filt er specifica t ion in t er m s of pa ssba n d a n d st opba n d
a t t en u a t ion , a n d t r a n sit ion widt h (s).
Th e dir ect filt er design fu n ct ion yulewalk fin ds a filt er wit h m a gn it u de
r espon se a ppr oxim a t in g a desir ed fu n ct ion . Th is is on e wa y t o cr ea t e a
m u lt iba n d ba n dpa ss filt er .
You ca n a lso u se t h e pa r a m et r ic m odelin g or syst em iden t ifica t ion fu n ct ion s t o
design IIR filt er s. Th ese fu n ct ion s a r e discu ssed in t h e “P a r a m et r ic Modelin g”
sect ion of Ch a pt er 4.
Th e gen er a lized Bu t t er wor t h design fu n ct ion maxflat is discu ssed in t h e
sect ion “Gen er a lized Bu t t er wor t h F ilt er Design ” on pa ge 2-14.
Th e followin g t a ble su m m a r izes t h e va r iou s filt er m et h ods in t h e t oolbox a n d
list s t h e fu n ct ion s a va ila ble t o im plem en t t h ese m et h ods.

2-4
IIR Filter Design

Method Description Functions

An a log Usin g t h e poles a n d zer os of Com plet e design fu n ct ion s:


P r ot ot ypin g a cla ssica l lowpa ss
besself, butter, cheby1, cheby2, ellip
pr ot ot ype filt er in t h e
con t in u ou s (La pla ce) Or der est im a t ion fu n ct ion s:
dom a in , obt a in a digit a l
filt er t h r ou gh fr equ en cy buttord, cheb1ord, cheb2ord, ellipord
t r a n sfor m a t ion a n d filt er
discr et iza t ion . Lowpa ss a n a log pr ot ot ype fu n ct ion s:

besselap, buttap, cheb1ap, cheb2ap,


ellipap

Fr equ en cy t r a n sfor m a t ion fu n ct ion s:


lp2bp, lp2bs, lp2hp, lp2lp

Filt er discr et iza t ion fu n ct ion s:


bilinear, impinvar

Dir ect Design Design digit a l filt er yulewalk


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.

Pa r a m et r ic Fin d a digit a l filt er t h a t Tim e-dom a in m odelin g fu n ct ion s:


Modelin g * a ppr oxim a t es a pr escr ibed
lpc, prony, stmcb
t im e or fr equ en cy dom a in
r espon se.
Fr equ en cy-dom a in m odelin g fu n ct ion s:
invfreqs, invfreqz

Gen er a lized Design lowpa ss maxflat


Bu t t er wor t h Bu t t er wor t h filt er s wit h
Design m or e zer os t h a n poles.

* See the System Identification Toolbox for an extensive collection of parametric modeling tools.

2-5
2 Filter Design

Classical IIR Filter Design Using Analog Prototyping


Th e pr in cipa l IIR digit a l filt er design t ech n iqu e t h is t oolbox pr ovides is ba sed
on t h e con ver sion of cla ssica l lowpa ss a n a log filt er s t o t h eir digit a l equ iva len t s.
Th e followin g sect ion s descr ibe h ow t o design filt er s a n d su m m a r ize t h e
ch a r a ct er ist ics of t h e su ppor t ed filt er t ypes. See “Specia l Topics in IIR F ilt er
Design ” on pa ge 2-37 for det a iled st eps on t h e filt er design pr ocess.

Complete Classical IIR Filter Design


You ca n ea sily cr ea t e a filt er of a n y or der wit h a lowpa ss, h igh pa ss, ba n dpa ss,
or ba n dst op con figu r a t ion u sin g t h e filt er design fu n ct ion s.

Filter Type Design Function

Bu t t er wor t h [b,a] = butter(n,Wn,options)


[z,p,k] = butter(n,Wn,options)
[A,B,C,D] = butter(n,Wn,options)

Ch ebysh ev t ype I [b,a] = cheby1(n,Rp,Wn,options)


[z,p,k] = cheby1(n,Rp,Wn,options)
[A,B,C,D] = cheby1(n,Rp,Wn,options)

Ch ebysh ev t ype II [b,a] = cheby2(n,Rs,Wn,options)


[z,p,k] = cheby2(n,Rs,Wn,options)
[A,B,C,D] = cheby2(n,Rs,Wn,options)

E llipt ic [b,a] = ellip(n,Rp,Rs,Wn,options)


[z,p,k] = ellip(n,Rp,Rs,Wn,options)
[A,B,C,D] = ellip(n,Rp,Rs,Wn,options)

Bessel (a n a log on ly) [b,a] = besself(n,Wn,options)


[z,p,k] = besself(n,Wn,options)
[A,B,C,D] = besself(n,Wn,options)

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
IIR Filter Design

H er e a r e som e exa m ple digit a l filt er s.


[b,a] = butter(5,0.4); % lowpass Butterworth
[b,a] = cheby1(4,1,[0.4 0.7]); % bandpass Chebyshev type I
[b,a] = cheby2(6,60,0.8,'high'); % highpass Chebyshev type II
[b,a] = ellip(3,1,60,[0.4 0.7],'stop'); % bandstop elliptic

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.

Designing IIR Filters to Frequency Domain Specifications


Th is t oolbox pr ovides or der select ion fu n ct ion s t h a t ca lcu la 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.

Filter Type Order Estimation Function

Bu t t er wor t h [n,Wn] = buttord(Wp,Ws,Rp,Rs)

Ch ebysh ev t ype I [n,Wn] = cheb1ord(Wp, Ws, Rp, Rs)

Ch ebysh ev t ype II [n,Wn] = cheb2ord(Wp, Ws, Rp, Rs)

E llipt ic [n,Wn] = ellipord(Wp, Ws, Rp, Rs)

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
2 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);

An ellipt ic filt er t h a t m eet s t h e sa m e r equ ir em en t s is given by


[n,Wn] = ellipord([1000 2000]/5000,[500 2500]/5000,1,60)

n =
5

Wn =
0.2000 0.4000

[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.

Comparison of Classical IIR Filter Types


Th e t oolbox pr ovides five differ en t t ypes of cla ssica l IIR filt er s, ea ch opt im a l in
som e wa y. Th is sect ion sh ows t h e ba sic a n a log pr ot ot ype for m for ea ch a n d
su m m a r izes m a jor ch a r a ct er ist ics.

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 2N –1 zer o der iva t ives a t t h ese loca t ion s (m axim ally flat

2-8
IIR Filter Design

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

0.6
Magnitude

0.4

0.2

0 -1 0 1
10 10 10
Frequency(rad/sec)

Chebyshev Type I Filter


Th e Ch ebysh ev t ype I filt er m in im izes t h e a bsolu t e differ en ce bet ween t h e
idea l a n d a ct u a l fr equ en cy r espon se over t h e en t ir e pa ssba n d by in cor por a t in g
a n equ a l r ipple of Rp dB in t h e pa ssba n d. St opba n d r espon se is m a xim a lly fla t .
Th e t r a n sit ion fr om pa ssba n d t o st opba n d is m or e r a pid t h a n for t h e
Bu t t er wor t h filt er . | H (jΩ)| = 10 -Rp/20 a t Ω = 1.
1

0.8

0.6
Magnitude

0.4

0.2

0 -1 0 1
10 10 10
Frequency(rad/sec)

2-9
2 Filter Design

Chebyshev Type II Filter


Th e Ch ebysh ev t ype II filt er m in im izes t h e a bsolu t e differ en ce bet ween t h e
idea l a n d a ct u a l fr equ en cy r espon se over t h e en t ir e st opba n d, by in cor por a t in g
a n equ a l r ipple of Rs dB in t h e st opba n d. P a ssba n d r espon se is m a xim a lly fla t .
Th e st opba n d does n ot a ppr oa ch zer o a s qu ick ly a s t h e t ype I filt er (a n d does
n ot a ppr oa ch zer o a t a ll for even -va lu ed n). Th e a bsen ce of r ipple in t h e
pa ssba n d, h owever , is oft en a n im por t a n t a dva n t a ge. | H (jΩ)| = 10 -Rs/20 a t
Ω = 1.

0.8

0.6
Magnitude

0.4

0.2

0 -1 0 1
10 10 10
Frequency(rad/sec)

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
IIR Filter Design

Rs in decibels, ellipt ic filt er s m in im ize t r a n sit ion widt h . | H (jΩ)| = 10 -Rp/20 a t


Ω = 1.

0.8

0.6
Magnitude

0.4

0.2

0 -1 0 1
10 10 10
Frequency(rad/sec)

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
2 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.

0.8

0.6
Magnitude

0.4

0.2

0 -1 0 1
10 10 10
Frequency(rad/sec)

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
IIR Filter Design

Direct IIR Filter Design


Th is t oolbox u ses t h e t er m d irect m eth od s t o descr ibe t ech n iqu es for IIR design
t h a t fin d a filt er ba sed on specifica t ion s in t h e discr et e dom a in . Un like t h e
a n a log pr ot ot ypin g m et h od, dir ect design m et h ods a r e n ot con st r a in ed t o t h e
st a n da r d lowpa ss, h igh pa ss, ba n dpa ss, or ba n dst op con figu r a t ion s. Ra t h er ,
t h ese fu n ct ion s design filt er s wit h a n a r bit r a r y, per h a ps m u lt iba n d, fr equ en cy
r espon se. Th is sect ion discu sses t h e yulewalk fu n ct ion , wh ich is in t en ded
specifica lly for filt er design ; “P a r a m et r ic Modelin g” in Ch a pt er 4 discu sses
ot h er m et h ods t h a t m a y a lso be con sider ed dir ect , su ch a s P r on y’s m et h od,
Lin ea r P r edict ion , t h e St eiglit z-McBr ide m et h od, a n d in ver se fr equ en cy
design .
yulewalk design s r ecu r sive IIR digit a l filt er s by fit t in g a specified fr equ en cy
r espon se. yulewalk’s n a m e r eflect s it s m et h od for fin din g t h e filt er ’s
den om in a t or coefficien t s: it fin ds t h e in ver se F F T of t h e idea l desir ed power
spect r u m a n d solves t h e “m odified Yu le-Wa lker equ a t ion s” u sin g t h e r esu lt in g
a u t ocor r ela t ion fu n ct ion sa m ples. Th e st a t em en t
[b,a] = yulewalk(n,f,m)

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
2 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 1

Generalized Butterworth Filter Design


Th e t oolbox fu n ct ion maxflat en a bles you t o design gen er a lized Bu t t er wor t h
filt er s, t h a t is, Bu t t er wor t h filt er s wit h differ in g n u m ber s of zer os a n d poles.
Th is is desir a ble in som e im plem en t a t ion s wh er e poles a r e m or e expen sive
com pu t a t ion a lly t h a n zer os. maxflat is ju st lik e t h e butter fu n ct ion , except
t h a t it you ca n specify tw o or der 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 ) in st ea d of ju st on e. Th ese filt er s a r e m axim ally flat. Th is m ea n s
t h a t t h e r esu lt in g filt er is opt im a l for a n y n u m er a t or a n d den om in a t or or der s,
wit h t h e m a xim u m n u m ber of der iva t ives a t 0 a n d t h e Nyqu ist fr equ en cy ω=π
bot h set t o 0.

2-14
IIR Filter Design

F or exa m ple, wh en t h e t wo or der s a r e t h e sa m e, maxflat is t h e sa m e a s butter.


[b,a] = maxflat(3,3,0.25)

b =
0.0317 0.0951 0.0951 0.0317

a =
1.0000 –1.4590 0.9104 -0.1978

[b,a] = butter(3,0.25)

b =
0.0317 0.0951 0.0951 0.0317

a =
1.0000 –1.4590 0.9104 -0.1978

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 0.2849 0.2849 0.0950

a =
1.0000 -0.2402

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
2 Filter Design

FIR Filter Design


Digit a l filt er s wit h fin it e-du r a t ion im pu lse r espon se (a ll-zer o, or F IR filt er s)
h a ve bot h a dva n t a ges a n d disa dva n t a ges com pa r ed t o in fin it e-du r a t ion
im pu lse r espon se (IIR) filt er s.
F IR filt er s h a ve t h e followin g pr im a r y a dva n t a ges:

• Th ey ca n h a ve exa ct ly lin ea r ph a se.


• Th ey a r e a lwa ys st a ble.
• Th e design m et h ods a r e gen er a lly lin ea r .
• Th ey ca n be r ea lized efficien t ly in h a r dwa r e.
• Th e filt er st a r t u p t r a n sien t s h a ve fin it e du r a t ion .

Th e pr im a r y disa dva n t a ge of F IR filt er s is t h a t t h ey oft en r equ ir e a m u ch


h igh er filt er or der t h a n IIR filt er s t o a ch ieve a given level of per for m a n ce.
Cor r espon din gly, t h e dela y of t h ese filt er s is oft en m u ch gr ea t er t h a n for a n
equ a l per for m a n ce IIR filt er .

Method Description Functions

Win dowin g Apply win dow t o t r u n ca t ed fir1,fir2,kaiserord


in ver se Fou r ier t r a n sfor m of
desir ed “br ick wa ll” filt er

Mu lt iba n d E qu ir ipple or lea st squ a r es firls,remez,remezord


wit h a ppr oa ch over su b-ba n ds of t h e
Tr a n sit ion fr equ en cy r a n ge
Ba n ds

Con st r a in ed Min im ize squ a r ed in t egr a l fircls,fircls1


Lea st er r or over en t ir e frequ en cy
Squ a r es r a n ge su bject t o m a xim u m
er r or con st r a in t s

2-16
FIR Filter Design

Method Description Functions

Ar bit r a r y Ar bit r a r y r espon ses, in clu din g cremez


Respon se n on lin ea r ph a se a n d com plex
filt er s

Ra ised Lowpa ss r espon se wit h firrcos


Cosin e sm oot h , sin u soida l t r a n sit ion

Linear Phase Filters


E xcept for cremez, a ll of t h e F IR filt er design fu n ct ion s design lin ea r ph a se
filt er s on ly. Th e filt er coefficien t s, or “t a ps,” of su ch filt er s obey eit h er a n even
or odd sym m et r y r ela t ion . Depen din g on t h is sym m et r y, a n d on wh et h er t h e
or der n of t h e filt er is even or odd, a lin ea r ph a se filt er (st or ed in len gt h n +1
vect or b) h a s cer t a in in h er en t r est r ict ion s on it s fr equ en cy r espon se.

Linear
Phase Filter Response H(f), Response H(f),
Filter Type Order n Symmetry of Coefficients f=0 f = 1 (Nyquist)

Type I E ven even : No r est r ict ion No r est r ict ion


b (k ) = b (n + 2 – k ), k = 1 , …, n + 1
Type II Odd No r est r ict ion H (1) = 0

Type III E ven odd: H (0) = 0 H (1) = 0


b ( k ) = – b ( n + 2 – k ) , k = 1 , …, n + 1
Type IV Odd H (0) = 0 No r est r ict ion

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
2 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
π ω0 ω0 ω0
1 1
h (n ) = ------
2π ∫–π H (ω)e j ωn d ω = ------
2π ∫–ω e j ωn d ω
0
= ------- sin c(------- n )
π π

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 l’s 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
FIR Filter Design

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

0.8
Magnitude Response

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 1
Normalized Frequency (Nyquist == 1)

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
2 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.8
Magnitude Response

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 1
Normalized Frequency (Nyquist == 1)

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.

Standard Band FIR Filter Design: fir1


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 . It r esem bles t h e IIR filt er design fu n ct ion s in t h a t it is for m u la t ed
t o design filt er s in st a n da r d ba n d con figu r a t ion s: lowpa ss, ba n dpa ss, h igh pa ss,
a n d ba n dst op.

2-20
FIR Filter Design

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.

Multiband FIR Filter Design: fir2


Th e fu n ct ion fir2 a lso design s win dowed F IR filt er s, bu t wit h a n a r bit r a r ily
sh a ped piecewise lin ea r fr equ en cy r espon se. Th is is in con t r a st t o fir1, wh ich
on ly design s filt er s in st a n da r d lowpa ss, h igh pa ss, ba n dpa ss, a n d ba n dst op
con figu r a t ion s.
Th e com m a n ds
n = 50;
f = [0 .4 .5 1];
m = [1 1 0 0];
b = fir2(n,f,m);

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
2 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.)

Multiband FIR Filter Design with Transition Bands


Th e firls a n d remez fu n ct ion s pr ovide a m or e gen er a l m ea n s of specifyin g t h e
idea l desir ed filt er t h a n t h e fir1 a n d fir2 fu n ct ion s. Th ese fu n ct ion s design
H ilber t t r a n sfor m er s, differ en t ia t or s, a n d ot h er filt er s wit h odd sym m et r ic
coefficien t s (t ype III a n d t ype IV lin ea r ph a se). Th ey a lso let you in clu de
t r a n sit ion or “don ’t ca r e” r egion s in wh ich t h e er r or is n ot m in im ized, a n d
per for m ba n d depen den t weigh t in g of t h e m in im iza t ion .
firls is a n ext en sion of t h e fir1 a n d fir2 fu n ct ion s in t h a t it m in im izes t h e
in t egr a l of t h e squ a r e of t h e 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.
remez im plem en t s t h e P a r ks-McClella n a lgor it h m , wh ich 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
opt im a l fit s 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 ey m in im ize 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; t h ey a r e
som et im es ca lled m in im ax filt er s. F ilt er s design ed in 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 se, a n d h en ce a r e a lso k n own a s
equ iripple filt er s. Th e P a r k s-McClella n F IR filt er design a lgor it h m is per h a ps
t h e m ost popu la r a n d widely u sed F IR filt er design m et h odology.
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 = 20; % filter order
f = [0 .4 .5 1]; % frequency band edges
a = [1 1 0 0]; % desired amplitudes
b = remez(n,f,a);

2-22
FIR Filter Design

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

a n d com pa r e t h eir fr equ en cy r espon ses:


[H,w]=freqz(b);
[HH,w]=freqz(bb);
plot(w/pi,abs(H),w/pi,abs(HH),'--'), grid

0.8

0.6
Magnitude

0.4

0.2

0 -1 0 1
10 10 10
Frequency(rad/sec)

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
2 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 0.4 0.7 0.8 1]; % band edges in pairs
a = [0 0 1 1 0 0]; % 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 0.8 1]; % band edges in pairs
a = [0 0 1 1]; % highpass filter amplitude

f = [0 0.3 0.4 0.5 0.8 1]; % band edges in pairs


a = [1 1 0 0 1 1]; % bandstop filter amplitude

An exa m ple m u lt iba n d ba n dpa ss filt er is


f = [0 0.1 0.15 0.25 0.3 0.4 0.45 0.55 0.6 0.7 0.75 0.85 0.9 1];
a = [1 1 0 0 1 1 0 0 1 1 0 0 1 1];

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

The Weight Vector


Bot h firls a n d remez a llow you t o pla ce m or e or less em ph a sis on m in im izin g
t h e er r or in cer t a in fr equ en cy ba n ds r ela t ive t o ot h er s. To do t h is, specify a
weigh t vect or followin g t h e fr equ en cy a n d a m plit u de vect or s. An exa m ple

2-24
FIR Filter Design

lowpa ss equ ir ipple filt er wit h 10 t im es less r ipple in t h e st opba n d t h a n t h e


pa ssba n d is
n = 20; % filter order
f = [0 0.4 0.5 1]; % frequency band edges
a = [1 1 0 0]; % desired amplitudes
w = [1 10]; % weight vector
b = remez(n,f,a,w);

A lega l weigh t vect or is a lwa ys h a lf t h e len gt h of t h e f a n d a vect or s; t h er e m u st


be exa ct ly on e weigh t per ba n d.

Anti-Symmetric Filters / Hilbert Transformers


Wh en ca lled wit h a t r a ilin g 'h' or 'Hilbert' opt ion , remez a n d firls design
F IR filt er s wit h odd sym m et r y, t h a t is, t ype III (for even or der ) or t ype IV (for
odd or der ) lin ea r ph a se filt er s. An idea l H ilber t t r a n sfor m er h a s t h is
a n t i-sym m et r y pr oper t y a n d a n a m plit u de of 1 a cr oss t h e en t ir e fr equ en cy
r a n ge. Tr y t h e followin g a ppr oxim a t e H ilber t t r a n sfor m er s:
b = remez(21,[0.05 1],[1 1],'h'); % highpass Hilbert
bb = remez(20,[0.05 0.95],[1 1],'h'); % bandpass Hilbert

Highpass Hilbert Bandpass Hilbert

1 1

0.8 0.8

0.6 0.6

0.4 0.4

0.2 0.2

0 0
0 0.25 0.5 0.75 1 0 0.25 0.5 0.75 1
Frequency (Normalized) Frequency (Normalized)

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; % sampling frequency
t = (0:1/Fs:2)'; % two second time vector
x = sin(2*pi*300*t); % 300 Hz sine wave example signal
xh = filter(bb,1,x); % Hilbert transform of x

2-25
2 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 l’s 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
FIR Filter Design

Th e m a gn it u de r espon se plot s for t h e differ en t ia t or s sh own a bove a r e

Differentiator, odd order Differentiator, even order

3500 3500

3000 3000

2500 2500

2000 2000

1500 1500

1000 1000

500 500

0 0
0 100 200 300 400 500 0 100 200 300 400 500
Frequency (Normalized) Frequency (Normalized)

Constrained Least Squares FIR Filter Design


Th e Con st r a in ed Lea st Squ a r es (CLS) F IR filt er design fu n ct ion s im plem en t a
t ech n iqu e t h a t en a bles you t o design F IR filt er s wit h ou t explicit ly defin in g t h e
t r a n sit ion ba n ds for t h e m a gn it u de r espon se. Th e a bilit y t o om it t h e
specifica t ion of t r a n sit ion ba n ds is u sefu l in sever a l sit u a t ion s. F or exa m ple, it
m a y n ot be clea r wh er e a r igidly defin ed t r a n sit ion ba n d sh ou ld a ppea r if n oise
a n d sign a l in for m a t ion a ppea r t oget h er in t h e sa m e fr equ en cy ba n d. Sim ila r ly,
it m a y m a k e sen se t o om it t h e specifica t ion of t r a n sit ion ba n ds if t h ey a ppea r
on ly t o con t r ol t h e r esu lt s of Gibbs ph en om en a t h a t a ppea r in t h e filt er ’s
r espon se. See Selesn ick, La n g, a n d Bu r r u s [2] for discu ssion of t h is m et h od.
In st ea d of defin in g pa ssba n ds, st opba n ds, a n d t r a n sit ion r egion s, t h e CLS
m et h od a ccept s a cu t off fr equ en cy (for t h e h igh pa ss, lowpa ss, ba n dpa ss, or
ba n dst op ca ses), or pa ssba n d a n d st opba n d edges (for m u lt iba n d ca ses), for t h e
desir ed r espon se. In t h is wa y, t h e CLS m et h od defin es t r a n sit ion r egion s
im plicit ly, r a t h er t h a n explicit ly.
Th e k ey fea t u r e of t h e CLS m et h od is t h a t it en a bles you t o defin e u pper a n d
lower t h r esh olds t h a t con t a in t h e m a xim u m a llowa ble r ipple in t h e m a gn it u de
r espon se. Given t h is con st r a in t , t h e t ech n iqu e a pplies t h e lea st squ a r e er r or
m in im iza t ion t ech n iqu e over t h e fr equ en cy r a n ge of t h e filt er ’s r espon se,
in st ea d of over specific ba n ds. Th e er r or m in im iza t ion in clu des a n y a r ea s of
discon t in u it y in t h e idea l, “br ick wa ll” r espon se. An a ddit ion a l ben efit is t h a t

2-27
2 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

Con st r a in ed lea st squ a r e m u lt iba n d F IR filt er design . fircls

Con st r a in ed lea st squ a r e filt er design for lowpa ss a n d fircls1


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.

Basic Lowpass and Highpass CLS Filter Design


Th e m ost ba sic of t h e CLS design fu n ct ion s, fircls1, u ses t h is t ech n iqu e t o
design lowpa ss a n d h igh pa ss F IR filt er s. As a n exa m ple, con sider design in g a
filt er wit h or der 61 im pu lse r espon se a n d cu t off fr equ en cy of 0.3 (n or m a lized).
F u r t h er , defin e t h e u pper a n d lower bou n ds t h a t con st r a in t h e design pr ocess
a s:
• Ma xim u m pa ssba n d devia t ion fr om 1 (pa ssba n d r ipple) of 0.02.
• Ma xim u m st opba n d devia t ion fr om 0 (st opba n d r ipple) of 0.008.

dp = 0.02
ds = 0.008
1 0

2-28
FIR Filter Design

To a ppr oa ch t h is design pr oblem u sin g fircls1


n = 61;
wo = 0.3;
dp = 0.02;
ds = 0.008;
h = fircls1(n,wo,dp,ds,'plot');

0.8

0.6

0.4

0.2

-0.2
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

Multiband CLS Filter Design


fircls u ses t h e sa m e t ech n iqu e t o design F IR filt er s wit h a desir ed piecewise
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
2 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 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

Weighted CLS Filter Design


Weigh t ed CLS filt er design let s you design lowpa ss or h igh pa ss F IR filt er s wit h
r ela t ive weigh t in g of t h e er r or m in im iza t ion in ea ch ba n d. Th e fircls1
fu n ct ion en a bles you t o specify t h e pa ssba n d a n d st opba n d edges for t h e lea st
squ a r es weigh t in g fu n ct ion , a s well a s a con st a n t k t h a t specifies t h e r a t io of
t h e st opba n d t o pa ssba n d weigh t in g.
F or exa m ple, con sider specifica t ion s t h a t ca ll for a n F IR filt er wit h im pu lse
r espon se or der of 55 a n d cu t off fr equ en cy of 0.3 (n or m a lized). Also a ssu m e
m a xim u m a llowa ble pa ssba n d r ipple of 0.02 a n d m a xim u m a llowa ble st opba n d
r ipple of 0.004. In a ddit ion , a dd weigh t in g r equ ir em en t s:

2-30
FIR Filter Design

• 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 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

Arbitrary-Response Filter Design


Th e cremez filt er design fu n ct ion pr ovides a t ool for design in g F IR filt er s wit h
a r bit r a r y com plex r espon ses. It differ s fr om t h e ot h er filt er design fu n ct ion s in
h ow t h e fr equ en cy r espon se of t h e filt er is specified: it a ccept s t h e n a m e of a
fu n ct ion wh ich r et u r n s t h e filt er r espon se ca lcu la t ed over a gr id of fr equ en cies.
Th is ca pa bilit y m a k es cremez a h igh ly ver sa t ile a n d power fu l t ech n iqu e for
filt er design .

2-31
2 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.

Multiband Filter Design


Con sider a m u lt iba n d filt er wit h t h e followin g specia l fr equ en cy-dom a in
ch a r a ct er ist ics:

Band Amplitude Optimization


Weighting

[-1 -0.5] [5 1] 1

[-0.4 +0.3] [2 2] 10

[+0.4 +0.8] [2 1] 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
FIR Filter Design

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/pi–1,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.2 0 0.2 0.4 0.6 0.8 1
Normalized Frequency

2-33
2 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

1.5
Real Part

0.5

-0.5
0 5 10 15 20 25 30 35 40

0.2
Imag Part

-0.2
0 5 10 15 20 25 30 35 40

Filter Design with Reduced Delay


Con sider t h e design of a 62-t a p lowpa ss filt er wit h a h a lf-Nyqu ist cu t off. If we
specify a n ega t ive offset va lu e t o t h e lowpass filt er design fu n ct ion , t h e gr ou p
dela y offset for t h e design is sign ifica n t ly less t h a n t h a t obt a in ed for a st a n da r d
lin ea r -ph a se design . Th is filt er design m a y be com pu t ed a s follows.
b = cremez(61, [0 0.5 0.55 1], {'lowpass', –16});

2-34
FIR Filter Design

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/pi–1,fftshift(abs(h)));
1.4

1.2

1
Magnitude Response

0.8

0.6

0.4

0.2

0
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
Normalized Frequency

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/2–16=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
Group delay (in samples)

15

14

13

12

0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5
Normalized frequency (Nyquist == 1)

2-35
2 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
Special Topics in IIR Filter Design

Special Topics in IIR Filter Design


Th e cla ssic IIR filt er design t ech n iqu e fin ds a n a n a log lowpa ss filt er wit h cu t off
fr equ en cy of 1, t r a n sla t es t h is “pr ot ot ype” filt er t o t h e desir ed ba n d
con figu r a t ion , t h en t r a n sfor m s t h e filt er t o t h e digit a l dom a in . Th e t oolbox
pr ovides fu n ct ion s for ea ch st ep of t h is pr ocess.

Classical IIR Filter Design

Analog Lowpass Prototype Creation Frequency Transformation Discretization


buttap cheb1ap besselap lp2lp lp2hp bilinear
ellipap cheb2ap lp2bp lp2bs impinvar

Complete Design
butter 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
2 Filter Design

Analog Prototype Design


Th is t oolbox pr ovides a n u m ber of fu n ct ion s t o cr ea t e lowpa ss a n a log pr ot ot ype
filt er s wit h cu t off fr equ en cy of 1, t h e fir st st ep in t h e cla ssica l a ppr oa ch t o IIR
filt er design . Th e t a ble below su m m a r izes t h e a n a log pr ot ot ype design
fu n ct ion s for ea ch su ppor t ed filt er t ype; plot s for ea ch t ype a r e sh own in t h e
“IIR F ilt er Design ” sect ion a bove.

Filter Type Analog Prototype Function

Bessel [z,p,k] = besselap(n)

Bu t t er wor t h [z,p,k] = buttap(n)

Ch ebysh ev t ype I [z,p,k] = cheb1ap(n,Rp)

Ch ebysh ev t ype II [z,p,k] = cheb2ap(n,Rs)

E llipt ic [z,p,k] = ellipap(n,Rp,Rs)

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
Special Topics in IIR Filter Design

Freq. Transformation Transformation Function

Lowpa ss t o lowpa ss [numt,dent] = lp2lp(num,den,Wo)


s' = s ⁄ ω 0 [At,Bt,Ct,Dt] = lp2lp(A,B,C,D,Wo)

Lowpa ss t o h igh pa ss [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 [numt,dent] = lp2bp(num,den,Wo,Bw)


ω 0 ( s ⁄ ω0 ) 2 + 1 [At,Bt,Ct,Dt] = lp2bp(A,B,C,D,Wo,Bw)
s' = ------- -------------------------------
Bω s ⁄ ω0

Lowpa ss t o ba n dst op [numt,dent] = lp2bs(num,den,Wo,Bw)


Bω s ⁄ ω0 [At,Bt,Ct,Dt] = lp2bs(A,B,C,D,Wo,Bw)
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 = ω 1 ω2

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 .

2-39
2 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 state–space form.

Now, fin d t h e ba n dwidt h a n d cen t er fr equ en cy, a n d ca ll lp2bp.


u1 = 0.1*2*pi; u2 = 0.5*2*pi; % in radians per second
Bw = u2–u1;
Wo = sqrt(u1*u2);
[At,Bt,Ct,Dt] = lp2bp(A,B,C,D,Wo,Bw);

2-40
Special Topics in IIR Filter Design

F in a lly, ca lcu la t e t h e fr equ en cy r espon se a n d plot it s m a gn it u de.


[b,a] = ss2tf(At,Bt,Ct,Dt);% Convert to TF form.
w = linspace(.01,1,500)*2*pi;% Generate frequency vector.
h = freqs(b,a,w);% Compute frequency response.
semilogy(w/2/pi,abs(h)), grid% Plot log magnitude vs. freq.

0
10

-1
10

-2
10

-3
10

-4
10

-5
10

-6
10

-7
10
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
2 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 Function


Transformation

Im pu lse in va r ia n ce [numd,dend] = impinvar(num,den,Fs)

Bilin ea r t r a n sfor m [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
Special Topics in IIR Filter Design

Design a Ch ebysh ev t ype I filt er a n d plot it s fr equ en cy r espon se.


[bz,az] = impinvar(b,a,2);
freqz(bz,az)

0
Magnitude Response (dB)

-50

-100

-150
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized frequency (Nyquist == 1)

200

0
Phase (degrees)

-200

-400

-600

-800
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized frequency (Nyquist == 1)

Im pu lse in va r ia n ce r et a in s t h e cu t off fr equ en cies of 0.1 H z a n d 0.5 H z.

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 ) z–1
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

Ω
ω = 2 t a n – 1 ⎛ ----⎞
⎝ k ⎠

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
2 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);

Th e fr equ en cy r espon se of t h e r esu lt in g digit a l filt er is


[bz,az] = ss2tf(Ad,Bd,Cd,Dd); % convert to TF
freqz(bz,az)

0
Magnitude Response (dB)

-100

-200

-300
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized frequency (Nyquist == 1)

500
Phase (degrees)

-500

-1000
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized frequency (Nyquist == 1)

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
Special Topics in IIR Filter Design

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 = u2–u1; % 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
2 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
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.

2 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).

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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5
Welch ’s Met h od . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6
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

Re fe re n c e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-27
3 Statistical Signal Processing

Correlation and Covariance


Th e Sign a l P r ocessin g Toolbox pr ovides t ools for est im a t in g im por t a n t
fu n ct ion s of r a n dom sign a ls. In pa r t icu la r , t h er e a r e t ools t o est im a t e
cor r ela t ion a n d cova r ia n ce sequ en ces a n d spect r a l den sit y fu n ct ion s of discr et e
sign a ls. Th is ch a pt er expla in s t h e cor r ela t ion a n d cova r ia n ce fu n ct ion s a n d
discu sses t h e m a t h em a t ica lly r ela t ed fu n ct ion s for est im a t in g t h e power
spect r u m .
Th e fu n ct ion s xcorr a n d xcov est im a t e t h e cr oss-cor r ela t ion a n d
cr oss-cova r ia n ce sequ en ces of r a n dom pr ocesses. Th ey a lso h a n dle
a u t ocor r ela t ion a n d a u t ocova r ia n ce a s specia l ca ses.
Th e t r u e cr oss-cor r ela t ion sequ en ce is a st a t ist ica l qu a n t it y defin ed a s

γ 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 . 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 ) = γ 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 )

N – m –1
⎧
⎪ x n y n* + m
⎪ ∑ m ≥0
R̂ x y (m ) = ⎨
n =0
⎪
⎪ *
⎩ R̂ y x (– m ) m <0

3-2
Correlation and Covariance

wh er e we a ssu m e for t h is discu ssion t h a t x n a n d y n a r e in dexed fr om 0 t o N -1,


*
a n d R̂ y x (– m ) fr om -(N -1) t o N -1. Th e xcorr fu n ct ion eva lu a t es t h is su m wit h
a n efficien t F F T-ba sed a lgor it h m , given in pu t s x n a n d y n st or ed in len gt h N
vect or s x a n d y. It s oper a t ion is equ iva len t t o con volu t ion wit h on e of t h e t wo
su bsequ en ces r ever sed in t im e.
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.

Bias and Normalization


An est im a t e of a qu a n t it y is biased if it s expect ed va lu e is n ot equ a l t o t h e
qu a n t it y it est im a t es. Th e expect ed va lu e of t h e ou t pu t of xcorr is
N – m –1

E {R̂ x y (m )} = ∑ E {x n y * n + m } = ( N – m )γ x y (m )
n =0

3-3
3 Statistical Signal Processing

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')

divides t h e ou t pu t by norm(x)*norm(y) so t h a t , for a u t ocor r ela t ion s, t h e


sa m ple a t 0 la g is 1.

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 (2M -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]

t h en t h e r esu lt of xcorr(S) is or ga n ized a s


R = [Rs1s1 Rs1s2 Rs1s3 Rs2s1 Rs2s2 Rs2s3 Rs3s1 Rs3s2 Rs3s3]

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 ( ω) = ∑ γ x x (m )e –j ωm
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 ( ω) = ∑ γ x y (m )e –j ωm
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
3 Statistical Signal Processing

“P a r a m et r ic Modelin g” in Ch a pt er 4 for det a ils a bou t lpc a n d ot h er pa r a m et r ic


est im a t ion fu n ct ion s.

Method Description Functions

Bu r g Au t or egr essive (AR) spect r a l pburg


(3-20) 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

Cova r ia n ce Au t or egr essive (AR) spect r a l pcov


(3-22) 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

Modified Au t or egr essive (AR) spect r a l pmcov


Cova r ia n ce est im a t ion of a t im e-ser ies by
(3-22) 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

Mu lt it a per Spect r a l est im a t e fr om com bin a t ion pmtm


(3-16) of m u lt iple or t h ogon a l win dows (or
“t a per s”)

MUSIC Mu lt iple sign a l cla ssifica t ion or pmusic


(3-23) eigen vect or m et h od

Welch Aver a ged per iodogr a m s of pwelch, csd,


(3-6) over la pped, win dowed sign a l sect ion s tfe, cohere

Yu le-Wa lk er AR Au t or egr essive (AR) spect r a l pyulear


(3-19) 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

Welch’s 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

20
Power Spectrum (dB)

15

10

-5

-10
0 100 200 300 400 500 600 700 800 900 1000
Frequency (Hz)

3-7
3 Statistical Signal Processing

Short Periodogram
30
Power Spectrum (dB)

20

10

-10

-20
0 100 200 300 400 500 600 700 800 900 1000
Frequency (Hz)

Periodogram
30

20
Power Spectrum (dB)

10

-10

-20

-30
0 100 200 300 400 500 600 700 800 900 1000
Frequency (Hz)

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

20
Power Spectrum (dB)

15

10

-5

-10
0 100 200 300 400 500 600 700 800 900 1000
Frequency (Hz)

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
3 Statistical Signal Processing

Th e a pplica t ion of a H a n n in g win dow r esu lt s in


w = hanning(256)';
Pxx = ( abs(fft(w.*xn( 1:256))).^2 + ...
abs(fft(w.*xn(129:384))).^2 + ...
abs(fft(w.*xn(257:512))).^2 + ...
abs(fft(w.*xn(385:640))).^2 + ...
abs(fft(w.*xn(513:768))).^2 + ...
abs(fft(w.*xn(641:896))).^2 ) / (norm(w)^2*6);
plot((0:255)/256*Fs,10*log10(Pxx))

Averaged Modified Periodogram (128 sample overlap, Hanning window)


25

20
Power Spectrum (dB)

15

10

-5

-10
0 100 200 300 400 500 600 700 800 900 1000
Frequency (Hz)

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].

Power Spectral Density Function


Th e pwelch fu n ct ion a ver a ges a n d sca les t h e m odified per iodogr a m s of sect ion s
of a sign a l. Sim ply specify t h e pa r a m et er s t h a t con t r ol t h e a lgor it h m a s
a r gu m en t s t o t h e fu n ct ion .
An est im a t e for t h e P SD of a sequ en ce xn u sin g pwelch’s defa u lt F F T len gt h
(256), win dow (H a n n in g of len gt h 256), a n d over la p sa m ples (n on e) is
Pxx = pwelch(xn);

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)
Welch’s Spectral Estimate Pxx(f) / fs
−5

−10
Power Spectral Density (dB)

−15

−20

−25

−30

−35

−40
0 50 100 150 200 250 300 350 400 450 500
Frequency (Hz)

If you wa n t t o plot t h e P SD you r self, obt a in t h e fr equ en cy vect or t h r ou gh a n


a ddit ion a l ou t pu t a r gu m en t .
[Pxx,f] = pwelch(xn,nfft,Fs,256,noverlap);
plot(f,10*log10(Pxx))

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
3 Statistical Signal Processing

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.

Bias and Normalization in Welch’s Method


In st u dyin g t h e ou t pu t of pwelch sh own ea r lier , sever a l r evea lin g
ch a r a ct er ist ics a bou t t h e sign a l xn a r e eviden t . Th e n oise floor is fla t a t 0
decibels (dB), im plyin g wh it e n oise of va r ia n ce 1. F u r t h er m or e, t h e “sign a l”
pa r t of xn is con cen t r a t ed in t wo pea ks a t 50 a n d 120 H z. Th e r ela t ion of t h e
pea k h eigh t s is m ea n in gfu l. F or in st a n ce, t h e 50 H z pea k is 6 dB below t h e 120
H z pea k , ver ifyin g t h a t t h e h igh er fr equ en cy sin u soid h a s t wice t h e m a gn it u de
a s t h e lower (10 6/20 = 2.0). Un like t h e r ela t ive h eigh t s, t h e a ct u a l h eigh t of t h e
pea k s does n ot t ell u s m u ch a bou t t h e or igin a l a m plit u de of t h e sin u soids
wit h ou t a ddit ion a l a n a lysis.
To obt a in u sefu l in for m a t ion a bou t t h e pea k a m plit u des of t h e u n der lyin g
sin u soids, n ot e t h a t t h e expect ed va lu e of t h e est im a t ed P SD is

1 π
E { P̂ x x (ω) } = ------------------2-
2π w ∫–π 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 dow’s 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 :

2
w = ∑ 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 100 200 300 400 500

−20

−30

−40

−50

−60

−70
0 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
3 Statistical Signal Processing

Cross-Spectral Density Function


To est im a t e t h e cr oss-spect r a l den sit y of t wo equ a l len gt h sign a ls x a n d y u sin g
Welch ’s m et h od, t h e csd fu n ct ion for m s t h e per iodogr a m a s t h e pr odu ct of t h e
F F T of x a n d t h e con ju ga t e of t h e F F T of y. Un lik e t h e r ea l-va lu ed P SD, t h e
CSD is a com plex fu n ct ion . csd h a n dles t h e sect ion in g a n d win dowin g of x a n d
y in t h e sa m e wa y a s t h e pwelch fu n ct ion .
Pxy = csd(x,y,nfft,Fs,window,noverlap)

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
[Pxx–Pxxc(:,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.

Transfer Function Estimate


On e a pplica t ion of Welch ’s m et h od is n on pa r a m et r ic syst em iden t ifica t ion .
Assu m e t h a t H is a lin ea r , t im e in va r ia n t syst em , a n d x(n ) a n d y(n ) a r e t h e
in pu t t o a n d ou t pu t of H , r espect ively. Th en t h e P SD of x(n ) is r ela t ed t o t h e
CSD of x(n ) a n d y(n ) by

P x y (ω) = H (ω)P x x (ω)

An est im a t e of t h e t r a n sfer fu n ct ion bet ween x(n ) a n d y(n ) is

P̂ x y (ω)
Ĥ (ω) = -----------------
P̂ x x (ω)

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 100 200 300 400 500

Transfer Function Magnitude Estimate


1

0.8

0.6

0.4

0.2

0
0 100 200 300 400 500
Frequency (Hz)

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
3 Statistical Signal Processing

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
Coherence Function Estimate

0.8

0.6

0.4

0.2

0
0 50 100 150 200 250 300 350 400 450 500
Frequency

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)) % plot in decibels
axis([30 150 –20 30])

30

25

20

15
Magnitude (dB)

10

-5

-10

-15

-20
40 60 80 100 120 140
Frequency (Hz)

3-17
3 Statistical Signal Processing

By lower in g t h e t im e-ba n dwidt h pr odu ct , t h e pea k s becom e n a r r ower .


[P1,f] = pmtm(xn,3/2,1024,Fs);
plot(f,10*log10(P1)) % plot in decibels
axis([30 150 –20 30])

30

25

20

15
Magnitude (dB)

10

-5

-10

-15

-20
40 60 80 100 120 140
Frequency (Hz)

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

200

150

100

50

0
40 60 80 100 120 140
Frequency (Hz)

3-18
Spectral Analysis

Th is con ser va t ion of t ot a l power is ver ifia ble n u m er ica lly.


sum(P)

ans =
1.8447e+03

sum(P1)

ans =
1.8699e+03

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 ) L r (n ) a (2 ) – r (2 )
* a (3 ) – r (3 )
r (2 ) r (1 ) L r (n – 1 ) =
M O O M M M
r (n ) L r (2 ) r (1 ) 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
3 Statistical Signal Processing

Th e spect r a l den sit y est im a t e is

1
P YuleAR(f ) = ----------------------
-
a e (f ) 2
H

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','Yule–Walker AR')

−20
Welch
Yule–Walker AR
−30

−40
Magnitude (dB)

−50

−60

−70

−80

−90
0 500 1000 1500 2000 2500 3000 3500 4000
Frequency (Hz)

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','Yule–Walker AR')

−20
Burg
Yule–Walker AR
−30

−40
Magnitude (dB)

−50

−60

−70

−80

−90
0 500 1000 1500 2000 2500 3000 3500 4000
Frequency (Hz)

3-21
3 Statistical Signal Processing

Com pa r e t h e spect r u m of a n oisy sign a l com pu t ed u sin g t h e Bu r g m et h od a n d


t h e Welch m et h od.
Fs = 1000;
t = 0:1/Fs:1;
xn = sin(2*pi*50*t) + 2*sin(2*pi*120*t) + randn(size(t));
[P1,f] = pwelch(xn,1024 ,Fs);
[P2,f] = pburg(xn,17,1024,Fs); % 17th order model
plot(f,10*log10(P1),':',f,10*log10(P2)), grid
ylabel('Magnitude (dB)'); xlabel('Frequency (Hz)');
axis([0 200 –50 0])
legend('Welch','Burg')
0
Welch
−5 Burg

−10

−15
Magnitude (dB)

−20

−25

−30

−35

−40

−45

−50
0 50 100 150 200
Frequency (Hz)

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 .

Covariance and Modified Covariance Methods


Th e cova r ia n ce 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 pr edict ion er r or . Th e m odified cova r ia n ce m et h od 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. Th e t oolbox fu n ct ion s
pcov a n d pmcov im plem en t t h e r espect ive m et h ods.

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

−60
Magnitude (dB)

−70

−80

−90

−100
0 500 1000 1500 2000 2500 3000 3500 4000
Frequency (Hz)

MUSIC and Eigenvector Analysis Methods


Th e pmusic fu n ct ion pr ovides t wo r ela t ed spect r a l a n a lysis m et h ods:

• Th e m u lt iple sign a l cla ssifica t ion m et h od (MUSIC) developed by Sch m idt


• Th e eigen vect or (E V) m et h od developed by J oh n son

See Ma r ple [2] (pgs. 373-378) for a su m m a r y of t h ese m et h ods.


Bot h of t h ese m et h ods a r e fr equ en cy est im a t or t ech n iqu es ba sed on
eigen a n a lysis of t h e a u t ocor r ela t ion m a t r ix. Th is t ype of spect r a l a n a lysis
ca t egor izes t h e in for m a t ion in a cor r ela t ion or da t a m a t r ix, a ssign in g
in for m a t ion t o eit h er a sign a l su bspa ce or a n oise su bspa ce.

3-23
3 Statistical Signal Processing

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.
Th e MUSIC est im a t e is given by t h e for m u la

1 1
P music(f ) = ---------------------------------------------------------------
N
- = ------------------------------------------
N -
⎛ ⎞
e H (f ) ⎜ ∑ v k v kH ⎟ e (f ) ∑ v kH e (f ) 2
⎜ ⎟
⎝ k = p + 1 ⎠ k =p+1

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 (j2 πf ) exp (j2 πf ⋅ 2 ) exp (j2 πf ⋅ 4 ) … exp (j2 π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 l’s 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).
Th e expr ession v kH 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)
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 E V m et h od weigh t s t h e su m m a t ion by t h e eigen va lu es of t h e cor r ela t ion


m a t r ix:

1
P ev (f ) = ----------------------------------------------------------
N
-
⎛ ⎞
⎜ v kH e (f ) 2⎟ ⁄ λ k
⎜ ∑ ⎟
⎝ k = p + 1 ⎠

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.

Controlling Subspace Thresholds


To pr ovide u ser con t r ol over t h e a ssign m en t s of eigen vect or s t o t h e sign a l a n d
n oise su bspa ces, t h e pmusic fu n ct ion a ccept s a t h r esh old a r gu m en t thresh.
thresh is a t wo-elem en t vect or wh er e t h e fir st elem en t is 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 a n d t h e secon d elem en t is a
t h r esh old t est :

• If thresh(2) ≤ 1, t h en thresh(1) specifies 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. In t h is ca se t h e va lu es of thresh(1) m u st be
in t h e r a n ge [0, N ), wh er e N is:
- Th e colu m n len gt h of xR if xR is a da t a m a t r ix
- Th e m a t r ix size if xR is a cor r ela t ion m a t r ix
- Th e win dow len gt h if xR is a sign a l vect or
• If thresh(1)≥ N , t h en thresh(2) is a va lu e gr ea t er t h a n or equ a l t o 1 t h a t
specifies t h e 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. Th a t is, if a given eigen va lu e is less t h a n or equ a l
t o t h e pr odu ct thresh(2)m in {λk }, t h en t h e given eigen vect or is a ssign ed t o
t h e n oise su bspa ce.
• If thresh(1) < N a n d thresh(2) ≥ 1, thresh(1) st ill specifies t h e m a xim u m
n u m ber of eigen vect or s in t h e sign a l su bspa ce. H owever , t h e t h r esh old t est
specified by thresh(2) ca n a lso a ssign eigen vect or s t o t h e n oise su bspa ce.
• If thresh(1) ≥ N a n d thresh(2) < 1, t h er e a r e n o n oise eigen vect or s. Th is is
a n in va lid ca se a n d pmusic gen er a t es a n er r or .

3-25
3 Statistical Signal Processing

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,
Algorith m s, an d Application s. E n glewood Cliffs, NJ : P r en t ice H a ll, 1996.

5 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-27
3 Statistical Signal Processing

3-28
4

Specia l Topics
Win d o w s . . . . . . . . . . . . . . . . . ... ... ... .... ... ... ... .... . 4-2
Ba sic Sh a pes . . . . . . . . . . . . . . ... ... ... .... ... ... ... .... . 4-2
Gen er a lized Cosin e Win dows . ... ... ... .... ... ... ... .... . 4-4
Ka iser Win dow . . . . . . . . . . . . ... ... ... .... ... ... ... .... . 4-4
Ch ebysh ev Win dow . . . . . . . . . ... ... ... .... ... ... ... .... . 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 ... ... ... ... .... ... ... ... .... 4-34
Ch ir p z-Tr a n sfor m . . . . . . ... ... ... ... .... ... ... ... .... 4-34
Discr et e Cosin e Tr a n sfor m ... ... ... ... .... ... ... ... .... 4-36
H ilber t Tr a n sfor m . . . . . . . ... ... ... ... .... ... ... ... .... 4-38

Re fe re n c e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-40
4 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

Ba r t let t win dow bartlett

Bla ckm a n win dow blackman

Rect a n gu la r win dow boxcar

Ch ebysh ev win dow chebwin

H a m m in g win dow hamming

H a n n in g win dow hanning

Ka iser win dow kaiser

Tr ia n gu la r win dow triang

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 triang’s r esu lt a r e sligh t ly st eeper t h a n t h ose of
bartlett’s in t h is ca se:
w = bartlett(8);
[w(2:7) triang(6)]

ans =

0.2857 0.1667
0.5714 0.5000
0.8571 0.8333
0.8571 0.8333
0.5714 0.5000
0.2857 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
4 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 dow’s F ou r ier t r a n sfor m is n ega t ive (see Ka y [1], pg. 80).

Generalized Cosine Windows


Bla ck m a n , H a m m in g, H a n n in g, a n d r ect a n gu la r win dows a r e a ll specia l ca ses
of t h e gen eralized cosin e w in d ow . Th ese win dows a r e com bin a t ion s of
sin u soida l sequ en ces wit h fr equ en cies 0, 2π/(N -1), a n d 4π/(N -1), wh er e N is t h e
win dow len gt h . On e wa y t o gen er a t e t h em is
ind = (0:n–1)'*2*pi/(n–1);
w = A – B*cos(ind) + C*cos(2*ind);

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
Normalized Magnitude (dB)

-60

-80

-100

-120

-140
beta = 1
beta = 2
-160 beta = 3

-180
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency (Nyquist == 1)

4-5
4 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
Normalized Magnitude (dB)

-40

-60

-80

-100

-120
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency (Nyquist == 1)

4-6
Windows

Kaiser Windows in FIR Design


Th er e a r e t wo design for m u la s t h a t ca n h elp you design F IR filt er s t o m eet a
set of filt er specifica t ion s u sin g a Ka iser win dow. To a ch ieve a sidelobe h eigh t
of −α dB, t h e beta pa r a m et er is

⎧ 0.1102 ( α – 8.7 ), α > 50


⎪
β = ⎨ 0.5842 ( α – 21 ) 0.4 + 0.07886 ( α – 21 ) , 50 ≥ α ≥ 21
⎪
⎩ 0 , α < 21

F or a t r a n sit ion widt h of Δω r a d/sec, u se t h e len gt h

α–8
n = ----------------------- + 1
2.285 Δω
F ilt er s design ed u sin g t h ese h eu r ist ics will m eet t h e specifica t ion s
a ppr oxim a t ely, bu t you sh ou ld ver ify t h is. To design a lowpa ss filt er wit h cu t off
fr equ en cy 0.5π r a d/sec, t r a n sit ion widt h 0.2π r a d/sec, a n d 40 dB of a t t en u a t ion
in t h e st opba n d, t r y
[n,wn,beta] = kaiserord([0.4 0.6]*pi,[1 0],[0.01 0.01],2*pi);
h = fir1(n,wn,kaiser(n+1,beta),'noscale');

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
4 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
40 dB
Magnitude (dB)

-40

-60

-80

-100
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency (Nyquist == 1)

F or det a ils on kaiserord, see t h e r efer en ce descr ipt ion in Ch a pt er 6.

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 5 10 15 20 25 30 35 40 45 50
Sample Number

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
Normailzed Magnitude (dB)

-20

-40

-60

-80
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency (Nyquist == 1)

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
4 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 Functions Description

Tim e arburg 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 .
arcov 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.
armcov 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.
aryule 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 .
lpc, 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
levinson im pu lse r espon se m a t ch es a given sequ en ce.
prony 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.
stmcb 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.
Fr equ en cy invfreqz, Gen er a t e digit a l or a n a log filt er coefficien t s given com plex
invfreqs fr equ en cy r espon se da t a .

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.

Time-Domain Based Modeling


Th e lpc, prony, a n d stmcb fu n ct ion s fin d t h e coefficien t s of a digit a l r a t ion a l
t r a n sfer fu n ct ion t h a t a ppr oxim a t es a given t im e-dom a in im pu lse r espon se.
Th e a lgor it h m s differ in com plexit y a n d a ccu r a cy of t h e r esu lt in g m odel.

4-11
4 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;

Th e coefficien t s for a fou r t h -or der a ll-pole filt er t h a t m odels t h e syst em a r e


a = lpc(x,4)

a =
1.0000 0.0395 0.0338 0.0668 0.1264

lpc fir st ca lls xcorr t o fin d a bia sed est im a t e of t h e cor r ela t ion fu n ct ion of x,
a n d t h en u ses t h e Levin son -Du r bin r ecu r sion , im plem en t ed in t h e levinson
fu n ct ion , t o fin d t h e m odel coefficien t s a. Th e Levin son -Du r bin r ecu r sion is a
fa st a lgor it h m for solvin g a syst em of sym m et r ic Toeplit z lin ea r equ a t ion s.
lpc’s en t ir e a lgor it h m for n = 4 is
r = xcorr(x);
r(1:length(x)–1) = []; % remove corr. at negative lags
a = levinson(r,4)

a =
1.0000 0.0395 0.0338 0.0668 0.1264

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

Prony’s Method (ARMA Modeling)


Th e prony fu n ct ion m odels a sign a l u sin g a specified n u m ber of poles a n d zer os.
Given a sequ en ce x a n d n u m er a t or a n d den om in a t or or der s nb a n d na,
r espect ively, t h e st a t em en t
[b,a] = prony(x,nb,na)

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
4 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 –0.2181 –0.6084 0.5369

a =
1.0000 –0.1619 –0.4765 0.4940

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 1.11649535105007
–0.03731609173676 –0.03731609173676
–0.08249198453223 –0.08249198453223
–0.04583930972315 –0.04583930972315
–0.14255125351637 –0.02829072973977
0.20400424807471 0.01433198229497
0.02685697779814 0.01148698991026
0.18956307836948 0.02266475846451
0.02717716288172 0.00206242734272
0.08057060786906 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

Steiglitz-McBride Method (ARMA Modeling)


stmcb det er m in es t h e coefficien t s for t h e syst em b(z)/a(z) given a n a ppr oxim a t e
im pu lse r espon se x, a s well a s t h e desir ed n u m ber of zer os a n d poles. Th is
fu n ct ion iden t ifies a n u n kn own syst em ba sed on bot h in pu t a n d ou t pu t
sequ en ces t h a t descr ibe t h e syst em ’s beh a vior , or ju st t h e im pu lse r espon se of
t h e syst em . In it s defa u lt m ode, stmcb wor ks like prony
[b,a] = stmcb(x,3,3)

b =
1.1165 –0.6213 –0.8365 1.3331

a =
1.0000 –0.5401 –0.6109 1.1298

stmcb a lso fin ds syst em s t h a t m a t ch given in pu t a n d ou t pu t sequ en ces


y = filter(1,[1 1],x); % Create an output signal.
[b,a] = stmcb(y,x,0,1)

b =
1

a =
1 1

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, stmcb’s 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
4 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);
[ x–impz(1,a1,10) x–impz(b2,a2,10) x–impz(b3,a3,10) ]

ans =

0.1165 0 0
–0.0058 0 –0.0190
–0.0535 0.0000 0.0818
0.0151 –0.0000 –0.0176
–0.1473 –0.1143 –0.0476
0.2005 0.1897 0.0869
0.0233 0.0154 –0.0103
0.1901 0.1669 –0.0093
0.0275 0.0251 0.0294
0.0808 0.0751 0.0022

sum(ans.^2)

ans =

0.1226 0.0834 0.0182

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.

Frequency-Domain Based Modeling


Th e invfreqs a n d invfreqz fu n ct ion s im plem en t t h e in ver se oper a t ion s of
freqs a n d freqz; t h ey fin d a n a n a log or digit a l t r a n sfer fu n ct ion of a specified
or der t h a t m a t ch es a given com plex fr equ en cy r espon se. Th ou gh t h e followin g
exa m ples dem on st r a t e invfreqz, t h e discu ssion a lso a pplies t o invfreqs.

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) % design Butterworth lowpass

b =
0.0466 0.1863 0.2795 0.1863 0.0466

a =
1.0000 –0.7821 0.6800 –0.1827 0.0301

[h,w] = freqz(b,a,64); % compute frequency resp.


[bb,aa] = invfreqz(h,w,4,4) % model: nb = 4, na = 4

bb =

0.0466 0.1863 0.2795 0.1863 0.0466

aa =

1.0000 –0.7821 0.6800 –0.1827 0.0301

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) % find third-order IIR

bb =

0.0464 0.1785 0.2446 0.1276

aa =

1.0000 –0.9502 0.7382 –0.2006

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
4 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 MATLAB’s \


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
B (w (k )) 2
m in
b, a
∑ w t (k ) h (k ) – -------------------
A (w (k ))
-
k =1

To u se t h is a lgor it h m , specify a pa r a m et er for t h e it er a t ion cou n t a ft er t h e


weigh t vect or pa r a m et er
wt = ones(size(w)); % create unity weighting vector
[bbb,aaa] = invfreqz(h,w,3,3,wt,30) % 30 iterations

bbb =

0.0464 0.1829 0.2572 0.1549

aaa =

1.0000 –0.8664 0.6630 –0.1614

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
1.2 Second Estimate

0.8

0.6

0.4

0.2

0
0 0.2 0.4 0.6 0.8 1

To ver ify t h e su per ior it y of t h e fit n u m er ica lly


sum(abs(h–freqz(bb,aa,w)).^2) % total error, algorithm 1

ans =

0.0200

sum(abs(h–freqz(bbb,aaa,w)).^2) % total error, algorithm 2

ans =

0.0096

4-19
4 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

Resa m ple a t n ew r a t e resample

Decim a t ion decimate

In t er pola t ion interp

Apply F IR filt er wit h r esa m plin g upfirdn

Cu bic splin e in t er pola t ion spline

Ot h er 1-D in t er pola t ion interp1

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 Size Bytes Class

Fs 1x1 8 double array


mtlb 4001x1 32008 double array

Grand total is 4002 elements using 32016 bytes

Fs

Fs =
7418

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
4 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

Com plex cepst r u m cceps

Rea l cepst r u m rceps

In ver se com plex cepst r u m 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π ∫–π 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
4 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)];

Th e com plex cepst r u m of t h is n ew sign a l is


c = cceps(s2);
plot(t,c)

0.5

-0.5

-1

-1.5
0 0.2 0.4 0.6 0.8 1 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π ∫–π 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)

wh er e y is t h e r ea l cepst r u m a n d ym is t h e m in im u m ph a se r econ st r u ct ion of x.

Inverse Complex Cepstrum


To in ver t t h e com plex cepst r u m , u se t h e icceps fu n ct ion . In ver sion is
com plica t ed by t h e fa ct t h a t t h e cceps fu n ct ion per for m s a da t a depen den t
ph a se m odifica t ion so t h a t t h e u n wr a pped ph a se of it s in pu t is con t in u ou s a t
zer o fr equ en cy. Th e ph a se m odifica t ion is equ iva len t t o a n in t eger dela y. Th is
dela y t er m is r et u r n ed by cceps if you a sk for a secon d ou t pu t . F or exa m ple,
x = 1:10;
[xh,nd] = cceps(x)

xh =
Columns 1 through 7
2.2428 -0.0420 -0.0210 0.0045 0.0366 0.0788 0.1386
Columns 8 through 10
0.2327 0.4114 0.9249

nd =
1

4-25
4 Special Topics

To in ver t t h e com plex cepst r u m , u se icceps wit h t h e or igin a l dela y pa r a m et er .


icceps(xh,nd)

ans =
Columns 1 through 7
1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000
Columns 8 through 10
8.0000 9.0000 10.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
FFT-Based Time-Frequency Analysis

FFT-Based Time-Frequency Analysis


Th e Sign a l P r ocessin g Toolbox pr ovides a fu n ct ion , specgram, t h a t r et u r n s t h e
t im e-depen den t F ou r ier t r a n sfor m for a sequ en ce, or displa ys t h is in for m a t ion
a s a spect r ogr a m . Th e tim e-d epen d en t Fou rier tran sform is t h e discr et e-t im e
F ou r ier t r a n sfor m for a sequ en ce, com pu t ed u sin g a slidin g win dow. Th is for m
of t h e F ou r ier t r a n sfor m , a lso k n own a s t h e sh or t -t im e F ou r ier t r a n sfor m
(STF T), h a s n u m er ou s a pplica t ion s in speech , son a r , a n d r a da r pr ocessin g. Th e
spectrogram of a sequ en ce is t h e m a gn it u de of t h e t im e-depen den t F ou r ier
t r a n sfor m ver su s t im e.
To displa y t h e spect r ogr a m of a lin ea r F M sign a l
Fs = 10000;
t = 0:1/Fs:2;
x = vco(sawtooth(2*pi*t,.75),[0.1 0.4]*Fs,Fs);
specgram(x,512,Fs,kaiser(256,5),220)

5000

4500

4000

3500

3000
Frequency

2500

2000

1500

1000

500

0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8
Time

Not e t h a t t h e spect r ogr a m displa y is a n im a ge, n ot a plot .

4-27
4 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 ((n–1)/2 & ((n–1)/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 User’s 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

Modu la t ion modulate

Dem odu la t ion demod

Volt a ge con t r olled oscilla t ion vco

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 Description

amdsb–sc or am Am plit u de m odu la t ion , dou ble side-ba n d, su ppr essed


ca r r ier
amdsb–tc 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
4 Special Topics

Method Description

amssb Am plit u de m odu la t ion , sin gle side-ba n d


fm F r equ en cy m odu la t ion
pm P h a se m odu la t ion
ptm P u lse t im e m odu la t ion
pwm P u lse widt h m odu la t ion
qam 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');

To plot por t ion s of t h e or igin a l, m odu la t ed, a n d dem odu la t ed sign a l


figure; plot(t(1:150),x(1:150)); title('Original Signal');
figure; plot(t(1:150),y(1:150)); title('Modulated Signal');
figure; plot(t(1:150),z(1:150)); title('Demodulated Signal');

Original Signal Modulated Signal


1 2

0.5 1

0 0

-0.5 -1

-1 -2
0 0.05 0.1 0.15 0 0.05 0.1 0.15

Demodulated Signal
1

0.5

-0.5

-1
0 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)

wh er e Fc is t h e ca r r ier fr equ en cy a n d Fs is t h e sa m plin g fr equ en cy.


To sca le t h e fr equ en cy m odu la t ion r a n ge
y = vco(x,[Fmin Fmax],Fs)

4-31
4 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

Now u se deconv t o decon volve b fr om c


[q,r] = deconv(c,a)

q =
4 5 6

r =
0 0 0 0 0

See t h e S ystem Id en tification T oolbox User’s Gu id e for a dva n ced a pplica t ion s
of sign a l decon volu t ion .

4-33
4 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 DCT’s
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:M–1)));
zplane([],z.')

0.5
Imaginary part

-0.5

-1

-1.5 -1 -0.5 0 0.5 1 1.5


Real part

czt(x,M,W,A) com pu t es t h e z-t r a n sfor m of x on t h ese poin t s.

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
4 Special Topics

Discrete Cosine Transform


Th e t oolbox fu n ct ion dct com pu t es t h e u n it a r y discr et e cosin e t r a n sfor m , or
DCT, for a n in pu t vect or or m a t r ix. Ma t h em a t ica lly, t h e u n it a r y DCT of a n
in pu t sequ en ce x is
N
π(2 n – 1 )( k – 1 )
y (k ) = ∑ w (n )x (n ) cos -------------------------------------------,
2N
k = 1 , …, N
n =1

wh er e

⎧ 1
⎪ ---------, n =1
⎪ N
w (n ) = ⎨
⎪ 2
⎪ ----N
, 2≤n ≤N
⎩

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
π( 2 n – 1 )( k – 1 )
x (n ) = ∑ w (k )y (k ) cos ------------------------------------------
2N
-, n = 1 , …, N
k =1

wh er e

⎧ 1
⎪ ---------, k =1
⎪ N
w (k ) = ⎨
⎪ 2
⎪ ----N
, 2≤k ≤N
⎩

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); % compute DCT
y2 = find(abs(y) < 53); % use 12 coefs.
y(y2) = zeros(size(y2)); % zero out points < 53
z = idct(y); % reconstruct signal using inverse DCT

P lot t h e or igin a l a n d r econ st r u ct ed sequ en ces.


plot(t,x)
plot(t,z), axis([0 1 –1 1])

Original Signal
1

0.5

-0.5

-1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

Reconstructed Signal
1

0.5

-0.5

-1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

4-37
4 Special Topics

On e m ea su r e of t h e a ccu r a cy of t h e r econ st r u ct ion is


norm(x–z)/norm(x)

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.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
4 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.


E n glewood Cliffs, NJ : P r en t ice H a ll, 1989.

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.

4 P r a t t ,W.K. Digital Im age Processin g. New Yor k: J oh n Wiley & Son s, 1991.

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


5 Interactive Tools

SPTool: An Interactive Signal Processing Environment


Th e Sign a l P r ocessin g Toolbox in clu des a n in t er a ct ive gr a ph ica l u ser in t er fa ce
(GUI), ca lled SP Tool, for per for m in g digit a l sign a l pr ocessin g t a sks. SP Tool
pr ovides a n ea sy-t o-u se in t er fa ce t o m a n y of t h e m ost im por t a n t t oolbox
fu n ct ion s. Wit h it , you ca n u se t h e m ou se a n d on -scr een con t r ols t o im por t ,
view, m ea su r e, a n d pr in t digit a l sign a ls; design , view, a n d im plem en t digit a l
filt er s; a n d a n a lyze t h e fr equ en cy con t en t of sign a ls.
Th is ch a pt er descr ibes h ow t o u se t h e differ en t com pon en t s of SP Tool. Wh er e
a ppr opr ia t e, we poin t you t o ot h er a r ea s of t h e m a n u a l t h a t descr ibe h ow t o
per for m sim ila r t a sks by ca llin g fu n ct ion s fr om t h e com m a n d lin e or fr om
M-files.
Th e sect ion “E xa m ple: Gen er a t ion of Ba n dlim it ed Noise” a t t h e en d of t h is
ch a pt er descr ibes h ow t o u se t h is gr a ph ica l en vir on m en t for a com plet e filt er
design a n d a n a lysis t a sk.

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.

Example: Importing Signal Data from a MAT-File


Th is exa m ple u ses t h e sa m ple file mtlb.mat, wh ich is in t h e
toolbox/signal/signal dir ect or y.

5-3
5 Interactive Tools

1 Select Im p o rt fr om t h e F ile m en u .

Th e Im p o rt to S P To o l win dow is displa yed.

2 Ma ke su r e t h a t S i g n a l is displa yed in t h e Im p o rt As pop-u p m en u .

3 P r ess t h e F ro m D is k r a dio bu t t on .

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


field. mtlb is t r a n sfer r ed t o t h e D a ta field.

6 Click on Fs 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 S a m p lin g


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 .

Basic SPTool Functions


Wh en you fir st open SP Tool, it con t a in s a collect ion of defa u lt sign a ls, filt er s,
a n d spect r a . You ca n im por t a ddit ion a l sign a ls, filt er s, a n d spect r a in t o SP Tool,
a n d you ca n a lso design filt er s u sin g t h e F ilt er Design er a n d cr ea t e spect r a
u sin g t h e Spect r u m Viewer . You ca n sa ve a n d expor t da t a fr om SP Tool a n d
cu st om ize m a n y pr oper t ies of t h e SP Tool en vir on m en t . Th e followin g figu r e
sh ows t h e SP Tool win dow a n d it s F ile a n d He lp m en u s, wh ich a r e descr ibed
below.

5-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 .

Importing Signals, Filters, and Spectra


You ca n 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 k spa ce or fr om a file.
Select Im p o rt… fr om t h e F ile m en u t o open t h e Im p o rt to S P To o l win dow:

Display all MATLAB workspace variables in the Workspace Contents


Workspace Contents list box by clicking here. or File Contents list.

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.

Loading Variables from the MATLAB Workspace


To im por t va r ia bles fr om t h e MATLAB wor k spa ce, fir st list t h e wor kspa ce
va r ia bles in t h e Wo rk s p a c e Co n te n ts list . Th en select t h e va r ia bles t o be
im por t ed in t o SP Tool:

5-7
5 Interactive Tools

1 Click t h e F ro m Wo rk s p a c e r a dio bu t t on .

Th e con t en t s of t h e MATLAB wor k spa ce a r e displa yed in t h e Wo rk s p a c e


Co n te n ts list .

2 You ca n n ow im por t on e or m or e va r ia bles fr om t h e Wo rk s p a c e Co n te n ts


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.

Loading Variables from Disk


To im por t va r ia bles fr om a MAT-file on disk , fir st list t h e file’s va r ia bles in t h e
F ile Co n te n ts list . Th en select t h e va r ia bles t o be im por t ed in t o SP Tool:

1 Click t h e F ro m D is k r a dio bu t t on .

2 Type t h e n a m e of t h e file you wa n t t o im por t in t o t h e MAT-fi le N a m e field


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


SP Tool (see below).

Importing Workspace Contents and File Contents


On ce you ’ve loa ded t h e con t en t s of t h e wor k spa ce or a file in t o t h e Wo rk s p a c e
Co n te n ts or F i le Co n te n ts list , you ca n select on e or m or e va r ia bles fr om t h e
list t o im por t in t o SP Tool. You ca n im por t a va r ia ble a s a sign a l, a filt er , or a
spect r u m . You ca n a lso im por t a va r ia ble wh ose va lu e r epr esen t s a sa m plin g
fr equ en cy or ot h er design pa r a m et er .
Depen din g on wh et h er you ’r e im por t in g a sign a l, a filt er , or a spect r u m , you
ca n cu st om ize differ en t pa r a m et er s befor e you im por t t h e da t a in t o SP Tool. In
ea ch ca se, h owever , t h e gen er a l pr ocedu r e for specifyin g a va r ia ble or a va lu e
is t h e sa m e. In t h e followin g exa m ple, t h e select ed va r ia ble is bein g im por t ed
a s a sign a l. See “Im por t in g a Sign a l” on pa ge 5-10, “Im por t in g a F ilt er ” on pa ge

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


F ile Co n te n ts list t o select it .

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.

3 To ch a n ge t h e sa m plin g fr equ en cy of t h e va r ia ble you ’r e im por t in g, you ca n


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
5 Interactive Tools

4 P r ess OK .

Th e sign a l is im por t ed in t o SP Tool wit h t h e specified n a m e a n d sa m plin g


fr equ en cy.

5 To im por t a n ot h er va r ia ble, select Im p o rt… a ga in , pr ess t h e F ro m


Wo rk s p a c e or F ro m F ile r a dio bu t t on , a n d r epea t st eps 1 t h r ou gh 4 for ea ch
va r ia ble t h a t you wa n t t o loa d in t o SP Tool.

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.

Importing a Signal. Wh en you im por t a sign a l, you specify:

• 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 l’s 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 ) = ----------- = ------------------------------------------------------------------------------------
A (z ) a (1 ) + a (2 )z –1 + L+ a (n + 1 )z – n
- 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
5 Interactive Tools

Z (z ) ( z – z ( 1 ) ) ( z – z ( 2 ) )Lz ( – z (m ))
H (z ) = ---------- = k ---------------------------------------------------------------------------------
P (z ) ( z – p ( 1 ) ) ( z – p ( 2 ) )Lz ( – p (n ))
- 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
b 0 k + b 1 k z – 1 + b 2 k z –2
H (z ) = ∏ H k (z ) = ∏ ---------------------------------------------------------
1 + a 1 k z –1 + a 2 k z – 2
-
k =1 k =1

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
b 02 b 12 b 22 1 a 12 a 22
s os =
M M M M M M
b0L b1L b2L 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

Importing a Spectrum. Wh en you im por t a spect r u m , you specify:

• 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 .

Working with Signals, Filters, and Spectra


Wh en a sign a l, filt er , or spect r u m is im por t ed in t o SP Tool or cr ea t ed in SP Tool,
it is displa yed in t h e a ppr opr ia t e list box, a s sh own below. Usin g t h e Ed it m en u
fu n ct ion s a n d SP Tool bu t t on s, you ca n edit va r iou s pr oper t ies of t h e da t a in
SP Tool a n d in voke a ll of SP Tool’s digit a l sign a l pr ocessin g fu n ct ion s.

5-13
5 Interactive Tools

Signals list

Filters list

Spectra list

Signal View button Spectrum View button

Filter View button

Component Lists in SPTool


E a ch sign a l, filt er , a n d spect r u m in SP Tool is displa yed in t h e a ppr opr ia t e
S i g n a ls list , F ilte rs list , or S p e c tra list .

• Sign a ls a r e displa yed wit h t h e sign al type [vector] or [array]:


- A vector sign al ([vector]) h a s on e colu m n of da t a .
- An array sign al ([array]) h a s m or e t h a n on e colu m n of da t a .
• F ilt er s a r e displa yed wit h t h e filter type [design] or [imported]:
- A d esign ed filter ([design]) is a filt er t h a t wa s cr ea t ed u sin g t h e F ilt er
Design er . Th is t ype of filt er ca n a lso be edit ed in t h e F ilt er Design er .
- An im ported filter ([imported]) is a filt er t h a t wa s im por t ed fr om t h e
MATLAB wor k spa ce or a file, or on e t h a t wa s edit ed in t h e P ole/Zer o
E dit or .

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.

Selecting Data Objects in SPTool


E a ch sign a l, filt er , a n d spect r u m in SP Tool is on e da t a object . A da t a object is
select ed wh en it is h igh ligh t ed. Wh en you fir st im por t or cr ea t e a da t a object ,
it is select ed.
Th e S ig n a ls list sh ows a ll vect or a n d a r r a y sign a ls in t h e cu r r en t SP Tool
session .
Th e F ilte rs list sh ows a ll design ed a n d im por t ed filt er s in t h e cu r r en t SP Tool
session .
Th e S p e c tra list sh ows a ll spect r a in t h e cu r r en t SP Tool session .
You ca n select a sin gle da t a object in a list , a r a n ge of da t a object s in a list , or
m u lt iple sepa r a t e da t a object s in a list . You ca n a lso h a ve da t a object s
sim u lt a n eou sly select ed in differ en t list s:

• To select a sin gle u n select ed da t a object , click on it . All ot h er da t a object s in


t h a t list box becom e u n select ed.
• To a dd or r em ove a r a n ge of da t a object s, S h i ft -click on t h e da t a object s a t
t h e t op a n d bot t om of t h e sect ion of t h e list t h a t you wa n t t o a dd.
• To a dd a sin gle da t a object t o a select ion or r em ove a sin gle da t a object fr om
a m u lt iple select ion , Ctrl -click on t h e object . You ca n a lso u se t h e r igh t
m ou se bu t t on .

Editing Data Objects in SPTool


Th e Ed it m en u en t r ies a r e a va ila ble on ly wh en t h er e is a t lea st on e select ed
da t a object (sign a l, filt er , or spect r u m ) in SP Tool. Use t h e Ed it m en u t o
du plica t e a n d clea r object s in SP Tool a n d t o edit object n a m es a n d ch a n ge
sa m plin g fr equ en cies.
A sign a l, filt er , or spect r u m m u st be select ed t o be edit ed. Wh en you click on a n
Ed it m en u en t r y, a ll selected da t a object s a r e displa yed in a pop-u p m en u .

5-15
5 Interactive Tools

To edit a n SP Tool object :

1 Select a sign a l, filt er , or spect r u m .

2 Select t h e a ppr opr ia t e Ed it m en u fu n ct ion .

Th e pop-u p m en u sh ows t h e n a m es of a ll select ed da t a object s.

3 Dr a g t o ch oose a specific sign a l, filt er , or spect r u m for edit in g.

Duplicate. Use D u p li c a te fr om t h e Ed it m en u t o m a ke a copy of t h e select ed


sign a l, filt er , or spect r u m in SP Tool.
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


r en a m e.
Th e N a m e Ch a n g e dia log box is displa yed.

2 Type in t h e n ew n a m e a n d pr ess OK .

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

1 Select S a m p lin g F re qu e n c y ... a n d dr a g t o ch oose t h e sign a l or filt er you


wa n t t o ch a n ge.
Th e S a m p li n g F re q u e n c y ... dia log box is displa yed.

2 Type in t h e va lu e, va r ia ble n a m e, or expr ession a n d pr ess OK .

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
5 Interactive Tools

Edit Design. Use t h e F ilte r pa n el’s 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
5 Interactive Tools

2 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 a n d com plet e


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
5 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

Signal Browser Settings


Th e S ig n a l B ro w s e r pr efer en ces let you set opt ion a l x-a xis a n d y-a xis la bels,
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.
E xcept for zoom per sist en ce, t h ese pr efer en ces a lso a pply t o pr in t in g fr om t h e
Sign a l Br owser . See “P r in t in g Sign a l Da t a ” on pa ge 5-54 for det a ils on pr in t in g
fr om t h e Sign a l Br owser .

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
5 Interactive Tools

Spectrum Viewer Settings


Th e S p e c tru m Vi e w e r pr efer en ces let you set a xis pa r a m et er s, 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 oggle zoom per sist en ce.
E xcept for zoom per sist en ce, t h ese pr efer en ces a lso a pply t o pr in t in g fr om t h e
Spect r u m Viewer . See “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 e Spect r u m Viewer .

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

Filter Viewer Settings


Th e F i lte r Vi e w e r pr efer en ces let you set k ey filt er plot con figu r a t ion
pa r a m et er s a n d t oggle zoom per sist en ce.

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
5 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 .

Filter Viewer Tiling Settings


Th e F ilte r Vie w e r–Tilin g pr efer en ces let you ch a n ge t h e wa y t h e F ilt er Viewer
displa ys t h e a n a lysis plot s.

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

Filter Designer Settings


Th e F i lte r D e s ig n e r pr efer en ces let you set key filt er con figu r a t ion a n d plot
pa r a m et er s.

FFT Length. Specifies t h e n u m ber of poin t s u sed t o ca lcu la t e a filt er ’s fr equ en cy


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
5 Interactive Tools

Default Session Setting


Th e D e fa u lt S e s s io n pr efer en ce let s you specify wh et h er or n ot t o loa d a
defa u lt session file wh en SP Tool is la u n ch ed.

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

Exporting Components Setting


Th e Ex p o rti n g Co m p o n e n ts pr efer en ce let s you specify wh et h er or n ot t o
expor t filt er s cr ea t ed in SP Tool a s TF object s for t h e Con t r ol Syst em Toolbox.

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 User’s 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
5 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 .

Saving and Discarding Changes to Preferences Settings


Th e bu t t on s a t t h e bot t om of t h e P re fe re n c e s pa n els let you sa ve or disca r d
a n y ch a n ges you h a ve m a de, or r et u r n t o t h e defa u lt set t in gs.

Factory Settings. Rest or es t h e pr efer en ces in t h e cu r r en t pa n el t o t h eir or igin a l


set t in gs; t h a t is, t h e set t in gs a t t h e t im e t h e Sign a l P r ocessin g Toolbox wa s
fir st in st a lled.

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


P re fe re n c e s dia log box. Set t in gs in a ll pa n els r ever t t o t h eir pr eviou s st a t e.

OK. Applies ch a n ges in a ll P re fe re n c e s pa n els a n d closes t h e P re fe re n c e s


dia log box. Set t in gs in a ll pa n els a r e sa ved in a MAT-file ca lled sigprefs.mat.
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.

Controls for Viewing and Measuring


Th e GUI t ools sh a r e com m on con t r ols for viewin g a n d m ea su r in g sign a ls.
Th ese con t r ols a r e descr ibed in t h is sect ion . Not a ll t ools u se a ll of t h e viewin g
a n d m ea su r in g con t r ols; specific det a ils a bou t t h e t ools a n d pr ocedu r es for
viewin g a n d m ea su r in g a r e descr ibed in t h e sect ion on ea ch t ool.

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.

Th e F ilt er Design er h a s on e a ddit ion a l viewin g bu t t on , t h e P a s s B a n d bu t t on .

Th e F ilt er Viewer h a s a su bset of t h e zoom con t r ol bu t t on s.

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
5 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 ,
t h e F ilt er Design er , a n d t h e F ilt er 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
5 Interactive Tools

Find ruler buttons Selection pop-up menu Selection display

Color… button

Ruler control buttons

Edit boxes

Rulers panel

Display peaks and valleys


buttons
Save Rulers… button

Selecting a Line to Measure. Wh en t h er e is on ly on e sign a l displa yed, t h e displa yed


sign a l is a u t om a t ica lly select ed a n d is m ea su r ed wh en you u se t h e r u ler s.
Wh en t h er e is m or e t h a n on e sign a l displa yed, on ly on e sign a l (lin e) m a y be
select ed a n d m ea su r ed a t a t im e.
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 t h e S e le c ti o n pop-u p m en u a n d dr a g t o select t h e lin e.

Line Selection Display. Th e lin e color a n d st yle of t h e select ed sign a l a r e displa yed.

Color… Button. Use t o edit t h e lin e st yle or displa y color of t h e select ed lin 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
5 Interactive Tools

Ruler Control Buttons. Use t h e r u ler con t r ol bu t t on s t o select t h e t ype of


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
wor kspa ce.

Th e Sa ve Ru ler s dia log box is displa yed.

2 Type a va r ia ble n a m e in t h e edit field a n d pr ess OK .

Making Signal Measurements


Use t h e r u ler s t o m a ke m ea su r em en t s on a select ed lin e, wh ich is a vect or or a
colu m n of a m a t r ix in t h e Sign a l Br owser , a filt er r espon se in t h e F ilt er Viewer ,
or a spect r u m in t h e Spect r u m Viewer . To m a ke a m ea su r em en t :

1 Select a lin e a s descr ibed in “Select in g a Lin e t o Mea su r e” on pa ge 5-34.

2 Apply a r u ler t o t h e displa y a s descr ibed in “Ru ler Con t r ol Bu t t on s” on pa ge


5-36.

5-37
5 Interactive Tools

3 P osit ion a r u ler wh er e you wa n t it in t h e m a in a xes a r ea by click in g a n d


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

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), x 2 (t h e posit ion of r u ler 2 on


t h e x-a xis), a n d d x (t h e va lu e of x 2 -x 1 ).

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
5 Interactive Tools

Ru le rs pa n el a r e y 1 (t h e posit ion of r u ler 1 on t h e y-a xis), y 2 (t h e posit ion of


r u ler 2 on t h e y-a xis), a n d d y (t h e va lu e of y 2 -y 1 ).

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
5 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
Using the Signal Browser: Interactive Signal Analysis

Using the Signal Browser: Interactive Signal Analysis


Th e Sign a l Br owser t ool is a n in t er a ct ive sign a l explor a t ion en vir on m en t . It
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 t h e
S ig n a ls colu m n of SP Tool.
Usin g t h e Sign a l Br owser you ca n :

• View a n d com pa r e vect or or a r r a y sign a ls


• Zoom in on a r a n ge of sign a l da t a t o exa m in e it m or e closely
• Mea su r e a va r iet y of ch a r a ct er ist ics of sign a l da t a
• P la y sign a l da t a on a u dio h a r dwa r e
• P r in t sign a l da t a

Opening the Signal Browser


To open or a ct iva t e t h e Sign a l Br owser fr om SP Tool:

1 Click on on e or m or e sign a ls in t h e S ig n a ls list of SP Tool.

2 P r ess Vie w in t h e S i g n a ls pa n el of SP Tool.

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
5 Interactive Tools

Basic Signal Browser Functions


Th e Sign a l Br owser h a s t h e followin g com pon en t s:

• A m a in a xes (displa y) a r ea for viewin g sign a ls gr a ph ica lly


• Displa y m a n a gem en t con t r ols: Arra y S ig n a ls … a n d t h e com plex sign a l
displa y pop-u p m en u
• Zoom con t r ols for get t in g a closer look a t sign a l fea t u r es
• Ru ler s 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 pa n n er for seein g wh a t pa r t of t h e sign a l is cu r r en t ly bein g displa yed a n d
for qu ickly m ovin g t h e view t o ot h er fea t u r es of t h e sign a l
• Men u opt ion s for pr in t in g sign a l da t a
• A m en u opt ion for pla yin g a select ed sign a l t h r ou gh a u dio equ ipm en t

Display management controls Viewing (zoom) controls Measuring (line and ruler) controls

Main axes
(display) area

Panner

5-44
Using the Signal Browser: Interactive Signal Analysis

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 AB 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
5 Interactive Tools

Options Menu. Use P la y fr om t h e Op tio n s m en u t o pla y t h e select ed sign a l.

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.

Ruler and Line Display Controls


Usin g t h e r u ler s a n d lin e displa y con t r ols, you ca n m ea su r e a va r iet y of
ch a r a ct er ist ics of sign a ls 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 r u ler s a n d m odifyin g lin e displa ys in t h e Sign a l
Br owser .
Th e r u ler s a r e 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
r u ler displa y in t h e S i g 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. 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
Using the Signal Browser: Interactive Signal Analysis

Display Management Controls

Array Signals… Button. Use t h is t o en t er a colu m n in dex vect or for a select ed


a r r a y sign a l. All a r r a y sign a ls st a r t ou t wit h on ly t h e fir st colu m n displa yed.
Th e Arra y S i g n a ls … bu t t on is en a bled wh en a t lea st on e a r r a y sign a l is
select ed in SP Tool:

1 P r ess Arra y S i g n a ls …

Th e Co lu m n S e le c tio n fo r Arra y S i g n a ls dia log box is displa yed.

All a r r a y sign a ls t h a t a r e select ed in SP Tool a r e sh own in t h e list .

2 Select a sign a l fr om t h e list .

3 Type a colu m n in dex vect or for t h e select ed sign a l.

Va lid in dex vect or s a r e of t h e for m 1 or 1:3 or [1 3 5].

Complex Signal Display. Use t o specify wh et h er t h e Sign a l Br owser plot s t h e r ea l


pa r t , t h e im a gin a r y pa r t , t h e m a gn it u de, or t h e a n gle of a com plex sign a l.
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.

Main Axes Display Area


Th e S ig n a ls list in SP Tool sh ows a ll sign a ls in t h e cu r r en t SP Tool session . On e
or m or e sign a ls m a y be select ed. Th e sign a l da t a of a ll select ed sign a ls a r e
displa yed gr a ph ica lly in t h e m a in a xes displa y a r ea of t h e Sign a l Br owser .

5-47
5 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.
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.

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
Using the Signal Browser: Interactive Signal Analysis

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.

Making Signal Measurements


Use t h e r u ler s t o m a k e a va r iet y of m ea su r em en t s 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.

Viewing and Exploring Signals


You ca n open or a ct iva t e t h e Sign a l Br owser in SP Tool by select in g on e or m or e
sign a ls a n d pr essin g Vie w in t h e Sign a l pa n el. Th e select ed sign a ls a r e loa ded
in t o t h e Sign a l Br owser . See “Viewin g a Sign a l” on pa ge 5-17 for det a ils.

Selecting and Displaying a Signal


Wh en t h e Sign a l Br owser is a ct iva t ed, a ll select ed sign a ls a r e displa yed in t h e
m a in a xes displa y a r ea a n d in t h e pa n n er . Th e da t a of t h e select ed sign a ls a r e
plot t ed a ga in st a n equ a lly spa ced t im e vect or in bot h t h e m a in a xes displa y a n d
t h e pa n n er .

5-49
5 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
Using the Signal Browser: Interactive Signal Analysis

Wh en t h e sign a l is a n a r r a y, on ly t h e fir st colu m n is in it ia lly displa yed in bot h


t h e m a in a xes a n d t h e pa n n er .

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
5 Interactive Tools

in bot h t h e m a in a xes a n d t h e pa n n er , a n d it s la bel is displa yed in t h e


S e le c tio n pop-u p m en u .

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
Using the Signal Browser: Interactive Signal Analysis

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


S a m p lin g F re qu e n c y … fr om t h e Ed it m en u in SP Tool. See “E dit in g Da t a
Object s in SP Tool” on pa ge 5-15.

Displaying Complex Signals. You ca n ch a n ge h ow com plex n u m ber s a r e displa yed


by select in g Re a l , Im a g in a ry , Ma g n itu d e , or An g le fr om t h e pop-u p m en u .
See “Ar r a y Sign a ls… Bu t t on ” on pa ge 5-47.

Changing Signal Browser Displays. Usin 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, you ca n set opt ion a l x-a xis a n d y-a xis la bels,

5-53
5 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.

Working with Signals


On ce a sign a l is displa yed, you ca n br owse it in a va r iet y of wa ys:

• You ca n zoom in on a specific a r ea of t h e displa y (see “Zoom Con t r ols” on pa ge


5-31).
• You ca n m a r k off a segm en t of t h e displa y wit h t h e r u ler s (see “Ru ler
Con t r ols” on pa ge 5-33) a n d sa ve r u ler set t in gs (see “Sa ve Ru ler s… Bu t t on ”
on pa ge 5-37).
• You ca n select a segm en t of t h e displa y wit h t h e pa n n er (see “P a n n er
Displa y” on pa ge 5-52).
• You ca n m a ke cer t a in m ea su r em en t s on t h e displa yed sign a ls (see “Ma k in g
Sign a l Mea su r em en t s” on pa ge 5-37).
• Wh en t h er e is m or e t h a n on e sign a l in t h e displa y, you ca n select wh ich on e
you wa n t t o m ea su r e (see “Select in g a Lin e t o Mea su r e” on pa ge 5-34).

You ca n u se t h e ot h er GUI t ools t o m a n ipu la t e sign a ls in a va r iet y of wa ys:

• You ca n in t er a ct ively design a n d a n a lyze filt er s t o be a pplied t o sign a ls (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 a n d
“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).
• You ca n cr ea t e a spect r u m for a sign a l a n d in t er a ct ively a n a lyze it s spect r a l
den sit y wit h a va r iet y of est im a t ion m et h ods (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).

You a ccess t h e F ilt er Design er , F ilt er Viewer , a n d Spect r u m Viewer t ools fr om


SP Tool. You ca n a ccess SP Tool fr om t h e Sign a l Br owser in on e of t wo wa ys:
• Click on a n a ct ive SP Tool win dow
• Act iva t e SP Tool u sin g t h e Win d o w m en u in t h e Sign a l Br owser

Printing Signal Data


You ca n pr in t a ll of t h e sign a l da t a t h a t you ca n displa y a n d m a n ipu la t e in t h e
Sign a l Br owser . You r pr in t ou t will con t a in u p t o t h r ee com pon en t s:

5-54
Using the Signal Browser: Interactive Signal Analysis

• 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
5 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
Using the Signal Browser: Interactive Signal Analysis

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.

Saving Signal Data


Aft er cr ea t in g a sign a l in SP Tool (by a pplyin g a filt er t o a n im por t ed sign a l, for
exa m ple), you ca n expor t t h e sign a l in for m a t ion t o t h e wor kspa ce or t o disk
u sin g Ex p o rt... fr om t h e F ile m en u in SP Tool. Th e sign a l in for m a t ion is st or ed
in a st r u ct u r e t h a t you ca n a ccess t o r et r ieve t h e sign a l da t a a n d sa m ple
fr equ en cy. Th e sign a l st r u ct u r e a lso con t a in s a n u m ber of fields t h a t a r e u sed
in t er n a lly by SP Tool.
To see t h e fields of t h e sign a l st r u ct u r e, t r y expor t in g a sign a l t o t h e wor k spa ce:

5-57
5 Interactive Tools

1 Im por t a sign a l in t o SP Tool if t h er e a r e n on e cu r r en t ly loa ded (see


“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 l’s 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
Using the Filter Designer: Interactive Filter Design

Using the Filter Designer: Interactive Filter Design


Th e F ilt er Design er pr ovides a n in t er a ct ive gr a ph ica l en vir on m en t for t h e
design of digit a l IIR a n d F IR filt er s ba sed on specifica t ion s t h a t you en t er on a
m a gn it u de or pole-zer o plot . Usin g t h e F ilt er Design er , you ca n design IIR a n d
F IR 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 fr equ en cy ba n d
con figu r a t ion s (h igh pa ss, lowpa ss, ba n dpa ss, ba n dst op, a n d m u lt iba n d).
Usin g t h e F ilt er Design er you ca n :

• Design IIR filt er s wit h st a n da r d ba n d con figu r a t ion s, u sin g t h e Bu t t er wor t h ,


Ch ebysh ev t ype I, Ch ebysh ev t ype II, a n d ellipt ic design opt ion s
• Design F IR filt er s wit h st a n da r d ba n d con figu r a t ion s, u sin g t h e equ ir ipple,
lea st squ a r es, a n d Ka iser win dow design opt ion s
• Design F IR a n d IIR filt er s wit h a r bit r a r y ba n d con figu r a t ion s, u sin g t h e
P ole/Zer o E dit or
• Redesign a filt er by m a n u a lly a dju st in g in dica t or s in t h e m a gn it u de plot , or
by gr a ph ica lly r eposit ion in g t h e t r a n sfer fu n ct ion ’s poles a n d zer os
• Over la y a spect r u m on t h e filt er ’s m a gn it u de r espon se plot

Wh en you h a ve design ed a filt er t o you r specifica t ion s, you ca n a pply t h e filt er


t o a select ed sign a l u sin g t h e Ap p ly bu t t on in SP Tool (see “Applyin g a F ilt er ”
on pa ge 5-18).

NOTE For in for m a t ion on u sin g filt er design fu n ct ion s fr om t h e com m a n d


lin e or fr om M-files, see Ch a pt er 2.

Opening the Filter Designer


You ca n open or a ct iva t e t h e F ilt er Design er fr om SP Tool by pr essin g t h e N e w
D e s ig n or Ed i t D e s ig n bu t t on s:

• To cr ea t e a filt er , pr ess N e w D e s i g n in SP Tool. A defa u lt filt er is gen er a t ed


a n d displa yed in t h e F ilt er Design er . You ca n view t h e filt er in a va r iet y of
wa ys in t h e F ilt er Viewer a n d m odify it in t h e F ilt er Design er .
• To edit a filt er , select it in SP Tool a n d pr ess Ed it D e s ig n . You ca n m odify t h e
filt er in a va r iet y of wa ys in t h e F ilt er Design er .

5-59
5 Interactive Tools

See “Design in g a F ilt er ” on pa ge 5-17 for com plet e det a ils.

Basic Filter Designer Functions


Th e F ilt er Design er h a s t h e followin g com pon en t s:
• A pop-u p m en u for select in g differ en t filt er design m et h ods
• A m a gn it u de plot (displa y) a r ea for gr a ph ica lly a dju st in g filt er r espon ses
• A pole-zer o plot (displa y) a r ea for gr a ph ica lly a dju st in g filt er t r a n sfer
fu n ct ion s
• A S p e c ific a tio n s pa n el for viewin g a n d m odifyin g t h e design pa r a m et er s or
pole-zer o loca t ion s of t h e cu r r en t filt er
• A Me a s u re m e n ts pa n el for viewin g t h e r espon se ch a r a ct er ist ics a n d
st a bilit y of t h e cu r r en t filt er
• Specifica t ion lin es for gr a ph ica lly a dju st in g t h e m a gn it u de r espon se
pa r a m et er s of a filt er
• Mea su r em en t lin es for m ea su r in g t h e m a gn it u de r espon se pa r a m et er s of a
filt er
• Zoom con t r ols for get t in g a closer look a t t h e m a gn it u de r espon se or pole-zer o
fea t u r es

Th e followin g sect ion s descr ibe t h e differ en t com pon en t s of t h e F ilt er


Design er ’s in t er fa ce a n d h ow you ca n u se t h em t oget h er t o cr ea t e a n d edit
filt er s.

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.

Filter Pop-Up Menu


Th e F ilte r pop-u p m en u displa ys a ll of t h e filt er s cu r r en t ly select ed in SP Tool.
Select a filt er in t h e m en u t o m a k e it t h e cu r r en t filt er in t h e F ilt er Design er .

5-60
Using the Filter Designer: Interactive Filter Design

Viewing (zoom) controls

General controls

Specifications panel for


setting filter parameters

Apply the specifications,


or revert to the previous Measurements
specifications panel for
viewing filter
Magnitude response and pole-zero display area characteristics

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
5 Interactive Tools

object in t h e F ilt er Design er , 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 .

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
Using the Filter Designer: Interactive Filter Design

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.

Filter Specifications Panel—Design Methods


Wh en you design a n ew filt er wit h t h e design m et h ods, t h e F ilt er Design er
in it ia lly con t a in s t h e specifica t ion s a n d m a gn it u de r espon se plot for a n or der
22, lowpa ss, equ ir ipple filt er .
Use t h e Ty p e pop-u p m en u in t h e S p e c ific a tio n s pa n el t o select a ba n d
con figu r a t ion . Use t h e edit boxes below it in t h e pa n el t o ch a n ge t h e ba n d edge
fr equ en cies a n d t h e a m ou n t of r ipple in t h e pa ssba n d a n d a t t en u a t ion in t h e
st opba n d. Ch eck t h e Min i m u m Ord e r box t o let t h e F ilt er Design er
a u t om a t ica lly det er m in e t h e lowest filt er or der t h a t a ch ieves t h e cu r r en t
specifica t ion s.
Th e design pa r a m et er s a va ila ble in t h e S p e c ific a tio n s pa n el depen d on t h e
filt er design select ed in t h e Alg o ri th m pop-u p m en u , t h e ba n d con figu r a t ion
select ed in t h e Ty p e pop-u p m en u , a n d t h e st a t e of t h e Min im u m Ord e r ch eck
box.

Specifications Parameters – Automatic Order Selection. Wh en t h e Mi n im u m Ord e r


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
5 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 Parameters—Manual 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 Highpass Bandpass Bandstop


Equiripple FIR F p, F s, Wp, Ws F p, F s, Wp, Ws F p1, F p2, F s1, F s2, Wp, Ws F p1, F p2, F s1, F s2, Wp, Ws
Least Squares FIR F p, F s, Wp, Ws F p, F s, Wp, Ws F p1, F p2, F s1, F s2, Wp, Ws F p1, F p2, F s1, F s2, Wp, Ws
Kaiser Window FIR F c, Bet a F c, Bet a F c1, F c2, Bet a F c1, F c2, Bet a
Butterworth IIR F 3db F 3db F 3db 1, F 3db 2 F 3db 1, F 3db 2
Chebyshev Type I IIR F p, Rp F p, Rp F p1, F p2, Rp F p1, F p2, Rp
Chebyshev Type II IIR F s, Rs F s, Rs F s1, F s2, Rs F s1, F s2, Rs
Elliptic IIR F p, Rp, Rs F p, Rp, 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


filt er design m et h od fr om t h e Alg o ri th m pop-u p
m en u .

2 Click-a n d-dr a g t o select t h e ba n d con figu r a t ion


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 el’s edit a ble fields


t o ch a n ge t h e va lu es for ba n d edge fr equ en cies, r ipple, a t t en u a t ion , a n d
ot h er filt er ch a r a ct er ist ics.

5-64
Using the Filter Designer: Interactive Filter Design

4 P r ess En te r a ft er t ypin g in a n edit a ble t ext box t o en t er t h e va lu e. If Au to


D e s i g n is n ot ch ecked, pr ess t h e Ap p ly bu t t on below t h e S p e c ifi c a tio n s
pa n el t o u pda t e t h e m a gn it u de plot .

5 To specify a filt er or der , pr ess Min im ize Ord e r t o deselect t h e ch eck box a n d
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 .

Filter Measurements Panel—Design Methods


Wh en you design a filt er , t h e Me a s u re m e n ts pa n el (sh own a t left ) displa ys t h e
va lu es of filt er pa r a m et er s t h a t d o n ot a ppea r in t h e S p e c i fi c a tio n s pa n el. F or
exa m ple, wh en t h e F ilt er Design er pr ovides a n F s pa r a m et er in t h e
S p e c ific a tio n s pa n el, it displa ys t h e Ac tu a l F s va lu e in t h e Me a s u re m e n ts
pa n el. Sim ila r ly, wh en t h e Min im u m Ord e r opt ion is select ed in t h e
S p e c ific a tio n s pa n el, t h e com pu t ed filt er or der is displa yed in t h e Ord e r field
of t h e Me a s u re m e n ts pa n el. Th e va lu es in t h e Me a s u re m e n ts pa n el a r e
u pda t ed wh en ever t h e m a gn it u de plot is r edr a wn .

Measurement Parameters – Automatic Order Selection. Th e pa r a m et er com bin a t ion s


t h a t a ppea r in t h e Me a s u re m e n ts pa n el a r e sh own in t h e followin g t wo t a bles.
Th e fir st t a ble list s t h e pa r a m et er s t h a t a ppea r wh en Min im u m Ord e r is
ch ecked (a u t om a t ic or der select ion ). Th e st opba n d edge fr equ en cy pa r a m et er s
list ed (F s, F s1, F s2) a r e t h e actu al edge fr equ en cies for t h e design , r a t h er t h a n
t h e d esired fr equ en cies en t er ed in t h e S p e c ific a tio n s pa n el.

5-65
5 Interactive Tools

Lowpass Highpass Bandpass Bandstop


Or der, Rp, Rs, Wp, Or der, Rp, Rs, Wp,
Equiripple FIR Or der, Rp, Rs, Wp, Ws Or der, Rp, Rs, Wp, Ws
Ws Ws
Least Squares FIR 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, Or der, F c1, F c2, Bet a , Rp,
Kaiser Window FIR
Rp, Rs Rp, Rs Rs Rs
Butterworth IIR Or der, Rp, F 3db Or der, Rp, F 3db Or der, Rp, F 3db 1, F 3db 2 Or der, Rp, F 3db 1, F 3db 2
Chebyshev Type I IIR Or der, F s Or der, F s Or der, F s1, F s2 Or der, F s1, F s2
Chebyshev Type II IIR Or der, F s Or der, F s Or der, F s1, F s2 Or der, F s1, F s2
Elliptic IIR Or der, F s Or der, F s 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 Highpass Bandpass Bandstop


Equiripple FIR Rp, Rs Rp, Rs Rp, Rs Rp, Rs
Least Squares FIR Rp, Rs Rp, Rs Rp, Rs Rp, Rs
Kaiser Window FIR Fp, Fs, R p, R s Fp, Fs, R p, R s Fp1, Fp2, Fs1, Fs2, R p, R s Fp1, Fp2, Fs1, Fs2, R p, R s
Butterworth IIR Fp, Fs, R p, R s Fp, Fs, R p, R s Fp1, Fp2, Fs1, Fs2, R p, R s Fp1, Fp2, Fs1, Fs2, R p, R s
Chebyshev Type I IIR Fs, R s Fs, R s Fs1, Fs2, R s Fs1, Fs2, R s
Chebyshev Type II IIR Fp, R p Fp, R p Fp1, Fp2, R p Fp1, Fp2, R p
Elliptic IIR Fs Fs F s1, F s2 F s1, F s2

Filter Specifications Panel—Pole/Zero Editor


Wh en you design a n ew filt er u sin g t h e P ole/Zer o E dit or , t h e F ilt er Design er
in it ia lly displa ys a pole-zer o plot for t h e defa u lt or der -22 filt er .
Th e gen er a l pole-zer o (fa ct or ed) for m of t h e t r a n sfer fu n ct ion of a digit a l filt er
is:

Z (z ) ( z – z 1 ) ( z – z 2 )Lz ( – zm )
H (z ) = ---------- = k ----------------------------------------------------------------
P (z ) ( z – p 1 ) ( z – p 2 )Lz ( – pn )

wh er e z 1 , z 2 , ..., z m a r e t h e filt er zer os, p 1 , p 2 , ..., p n a r e t h e filt er poles, a n d k is


t h e over a ll t r a n sfer fu n ct ion ga in . Th e n u m ber of zer os a n d poles do n ot n eed
t o be t h e sa m e.
Th e con t r ols in t h e S p e c ific a ti o n s pa n el a llow you t o set t h e over a ll ga in a n d
t o n u m er ica lly a dju st t h e posit ion of ea ch pole a n d zer o u sin g pola r or
r ect a n gu la r coor din a t es.

5-66
Using the Filter Designer: Interactive Filter Design

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
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
±j θ
z = Me

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
5 Interactive Tools

1 Click-a n d-dr a g t o select t h e P o le /Ze ro Ed ito r


opt ion fr om t h e Alg o rith m pop-u p m en u .

2 E n t er t h e desir ed filt er ga in in t h e Ga in edit box.

Pole 3 Select a pole or zer o (or con ju ga t e pa ir ) by click in g


Zero on on e of t h e or sym bols on t h e plot .

4 Ch oose t h e coor din a t es t o wor k in by specifyin g P o la r or R e c ta n g u la r fr om


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.

Filter Measurements Panel—Pole/Zero Editor


Wh en you design a filt er , t h e Me a s u re m e n ts pa n el (sh own a t left ) displa ys
u sefu l in for m a t ion a bou t t h e filt er bein g design ed. Th e pa n el a lwa ys sh ows t h e
n u m ber of zer os a n d poles (t h e la r ger of wh ich is t h e or der of t h e filt er ), a n d
in dica t es wh et h er t h e filt er is st a ble or u n st a ble (poles ou t side t h e u n it cir cle).
Th e pa n el a lso sh ows t h e ph a se ch a r a ct er ist ics of t h e filt er . Wh er e m is t h e
t ot a l n u m ber of zer os, t h e fou r possible ph a se con dit ion s a r e:
• Mi n im u m P h a s e , wh ich in dica t es t h a t bet ween 1 a n d m -1 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 in side t h e u n it cir cle
zi ≤ 1 i = 1 , …, m

5-68
Using the Filter Designer: Interactive Filter Design

• S tric tly Mi n im u m P h a s e , wh ich in dica t es t h a t a ll of t h e zer os a r e in side t h e


u n it cir cle
zi < 1 i = 1 , …, m

• 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 ≥ 1 i = 1 , …, m

• S tric tly Ma x im u m P h a s e , wh ich in dica t es t h a t a ll of t h e zer os a r e ou t side


t h e u n it cir cle
zi > 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 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
Add Zeros Pointer 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 .

All va lu es in t h e Me a s u re m e n ts pa n el a r e u pda t ed con t in u ou sly a s a pole or


zer o is r eposit ion ed.

Magnitude Plot (Display) Area—Design Methods


Th e r espon se of t h e filt er select ed in t h e F ilte r pop-u p m en u is displa yed
gr a ph ica lly in t h e m a gn it u de r espon se plot a r ea of t h e F ilt er Design er , a n d it s
ch a r a ct er ist ics a r e sh own in t h e S p e c ific a tio n s a n d Me a s u re m e n ts pa n els.

5-69
5 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 e’s cu r r en t posit ion .

5-70
Using the Filter Designer: Interactive Filter Design

Magnitude Plot (Display) Area—Pole/Zero Editor


Th e plot a r ea of t h e P ole/Zer o E dit or displa ys t h e filt er t r a n sfer fu n ct ion ’s pole
a n d zer os on t h e com plex z-pla n e. Th e u n it cir cle is sh own in da sh ed lin es,
a lon g wit h t h e ver t ica l a n d h or izon t a l gr id lin es, t o pr ovide a visu a l r efer en ce
for pole-zer o pla cem en t .
You ca n zoom in on t h e z-pla n e (see “Zoom Con t r ols” on pa ge 5-31) a n d you ca n
dr a g t h e pole a n d zer o sym bols t o r edesign t h e filt er t r a n sfer fu n ct ion visu a lly
(see t h e n ext sect ion ).

Positioning Poles and Zeros. You ca n r edesign t h e t r a n sfer fu n ct ion by sim ply
clickin g a n d dr a ggin g on on e of t h e pole or zer o sym bols. P oles or zer os a ppea r
gr een (r a t h er t h a n t h e u su a l blu e) wh en select ed. In a con ju ga t e pa ir of poles
or zer os, bot h con ju ga t es a r e select ed wh en eit h er is click ed; con ju ga t e pa ir s
m ove t oget h er wh en dr a gged, m a in t a in in g equ a l dist a n ce fr om t h e r ea l a xis a t
a ll t im es. To u n gr ou p con ju ga t es, select t h e desir ed pa ir a n d u n ch eck
Co n ju g a te p a ir in t h e S p e c i fi c a tio n s pa n el.

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
5 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 o’s 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 Description

Use t h is t ool t o select a n d dr a g poles a n d zer os on


Dr a g Poles/Zer os Tool
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
Add Poles Tool
(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
Add Zer os Tool
(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
Delet e Poles/Zer os Tool 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
Using the Filter Designer: Interactive Filter Design

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.

Designing Finite Impulse Response (FIR) Filters


Th e F ilt er Design er pr ovides t h r ee opt ion s for ba sic F IR filt er design . Th ese
opt ion s a llow you t o cr ea t e F IR filt er s wit h st a n da r d ba n d con figu r a t ion s
(lowpa ss, h igh pa ss, ba n dpa ss, or ba n dst op con figu r a t ion s on ly). Th e t h r ee
opt ion s for F IR filt er design in t h e Alg o rith m pop-u p m en u a r e:

• Equ irip p le F IR , wh ich a ccesses t h e t oolbox fu n ct ion remez t o cr ea t e a n


equ ir ipple F IR filt er .
• Le a s t S qu a re s F IR , wh ich a ccesses t h e t oolbox fu n ct ion firls t o cr ea t e a n
F IR filt er u sin g t h e lea st squ a r e design m et h od.
• Ka is e r Win d o w F IR , wh ich a ccesses t h e fir1 fu n ct ion t o cr ea t e a n F IR filt er
u sin g a Ka iser win dow.

Example: FIR Filter Design, Standard Band Configuration


In t h e followin g exa m ple, u se t h e Ka iser win dow filt er design opt ion :

1 Select Ka i s e r Wi n d o w F IR a s t h e filt er design fr om t h e Alg o rith m pop-u p


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.

NOTE You m u st pr ess Ap p ly befor e you ch a n ge t h e followin g pa r a m et er s.

5 Ch eck t h e Mi n im u m Ord e r ch eck box t o en a ble a u t om a t ic or der select ion .

5-73
5 Interactive Tools

6 Set F p 1 t o 290 a n d F p 2 t o 525.

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
Using the Filter Designer: Interactive Filter Design

Filter Design Options


Wh en t h e Min i m u m Ord e r opt ion is disa bled, you ca n specify pa r a m et er s t h a t
defin e ch a r a ct er ist ics u n iqu e t o cer t a in filt er t ypes:
• F or equ ir ipple a n d lea st squ a r es filt er s: t h e weigh t s for er r or m in im iza t ion
• F or Ka iser win dow filt er s: t h e cu t off fr equ en cy a n d β pa r a m et er of t h e Ka iser
win dow

Order Selection for FIR Filter Design


As descr ibed ea r lier , t h e F IR filt er design opt ion s a va ila ble t h r ou gh t h e F ilt er
Design er ca ll t h e t oolbox fu n ct ion s remez, firls, a n d fir1. In ca lcu la t in g filt er
or der , t h e F ilt er Design er u ses t h e sa m e gu idelin es a s t h e t oolbox fu n ct ion s:

• Th e Eq u iri p p le F IR design opt ion ca lls t h e remezord or der est im a t ion


fu n ct ion t o det er m in e a filt er or der t h a t m eet s a set of specifica t ion s. In som e
ca ses, remezord u n der est im a t es t h e filt er or der n. If t h e filt er does n ot
a ppea r t o m eet t h e given specifica t ion s u sin g Mi n im u m Ord e r or der
select ion , deselect Mi n im u m Ord e r a n d m a n u a lly specify a sligh t ly la r ger
or der (n+1 or n+2).
• Th e Le a s t S qu a re s F IR design opt ion ca lls t h e t oolbox fu n ct ion firls.
Beca u se t h e t oolbox does n ot pr ovide a n or der est im a t ion fu n ct ion for u se
wit h firls, you ca n n ot u se t h e Min im u m Ord e r opt ion wit h t h e Le a s t
S qu a re s F IR m et h od.
• Th e Ka is e r Win d o w F IR design opt ion ca lls kaiserord, t h e or der est im a t ion
fu n ct ion , wh ich som et im es u n der est im a t es t h e filt er or der n. If t h e filt er does
n ot a ppea r t o m eet t h e given specifica t ion s u sin g Mi n im u m Ord e r or der
select ion , deselect Mi n im u m Ord e r a n d m a n u a lly specify a sligh t ly la r ger
or der (n+1 or n+2).

All of t h e F IR filt er design opt ion s in t h e F ilt er Design er r equ ir e 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. F or m or e in for m a t ion on
or der select ion wit h t h e F IR filt er design opt ion s, see t h e r efer en ce descr ipt ion s
of remez, remezord, kaiserord, firls, a n d fir1 in Ch a pt er 6.

5-75
5 Interactive Tools

Designing Infinite Impulse Response (IIR) Filters


Th e F ilt er Design er let s you design a n u m ber of cla ssica l IIR filt er s, in clu din g
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.

Example: Classical IIR Filter Design


In t h e followin g exa m ple, design a sim ple Ch ebysh ev t ype I filt er :

1 Select Ch e by s h e v Ty p e I IIR a s t h e filt er design fr om t h e Alg o rith m


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


S a m p lin g F re qu 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.

NOTE You m u st pr ess Ap p ly befor e you ch a n ge t h e followin g pa r a m et er s.

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


r edr a w t h e m a gn it u de r espon se.

5-76
Using the Filter Designer: Interactive Filter Design

Th e F ilt er Design er ca lls t h e a ppr opr ia t e filt er design fu n ct ion t o cr ea t e t h e


filt er .

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.

Filter Design Options


Wh en t h e Min i m u m Ord e r opt ion is disa bled, you ca n specify pa r a m et er s t h a t
defin e ch a r a ct er ist ics u n iqu e t o cer t a in filt er t ypes:

• F or Bu t t er wor t h filt er s: t h e -3 dB fr equ en cies


• F or Ch ebysh ev t ype I filt er s: t h e pa ssba n d edge fr equ en cies
• F or Ch ebysh ev t ype II filt er s: t h e st opba n d edge fr equ en cies
• F or ellipt ic filt er s: t h e pa ssba n d edge fr equ en cies

In t h e followin g exa m ple, r edesign t h e Ch ebysh ev t ype I filt er fr om t h e


pr eviou s exa m ple a s a Bu t t er wor t h filt er , u sin g a -3 dB fr equ en cy of 800 H z:

5-77
5 Interactive Tools

1 Select t h e B u tte rw o rth IIR filt er design fr om t h e Alg o rith m m en u .

Th e m a gn it u de r espon se plot ch a n ges t o r eflect t h e n ew design .

2 Type a va lu e of 800 in t h e F 3d b t ext field.

3 P r ess Ap p ly t o u pda t e t h e r espon se plot .

Order Selection for IIR Filter Design


Th e IIR filt er design opt ion s a va ila ble t h r ou gh t h e F ilt er Design er ca ll t h e
t oolbox filt er design fu n ct ion s. In ca lcu la t in g t h e or der for a given filt er , t h e
F ilt er Design er u ses t h e cor r espon din g or der est im a t ion fu n ct ion if t h e
Min im u m Ord e r ch eck box is select ed.
F or det a ils on or der select ion wit h t h e IIR filt er design opt ion s, see t h e
r efer en ce descr ipt ion s of buttord, cheb1ord, cheb2ord, a n d ellipord in
Ch a pt er 6.

Redesigning a Filter Using the Magnitude Plot


Aft er design in g a filt er in t h e F ilt er Design er , you ca n r edesign it by dr a ggin g
t h e specifica t ion lin es in t h e m a gn it u de plot . Use t h e specifica t ion lin es t o
ch a n ge 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 (see
“Specifica t ion Lin es” on pa ge 5-70 for det a ils). In t h e followin g exa m ple, cr ea t e
a Ch ebysh ev filt er a n d m odify it by dr a ggin g t h e specifica t ion lin es:

1 Cr ea t e a Ch ebysh ev t ype I h igh pa ss filt er wit h a sa m ple fr equ en cy of


2000 H z. Set t h e followin g pa r a m et er s:
Fp = 800
Fs = 700
Rp = 2.5
Rs = 35

2 Ch eck Min i m u m Ord e r so t h e F ilt er Design er ca n ca lcu la t e t h e lowest filt er


or der t h a t pr odu ces t h e desir ed ch a r a ct er ist ics.

3 P r ess Ap p ly t o u pda t e t h e r espon se plot .

4 P osit ion t h e cu r sor over t h e gr een lin e specifyin g t h e st opba n d.

Th e cu r sor ch a n ges t o t h e u p/down dr a g in dica t or .

5-78
Using the Filter Designer: Interactive Filter Design

5 Dr a g t h e lin e u n t il t h e Rs (st opba n d a t t en u a t ion ) field r ea ds 100.

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.

Saving Filter Data


Aft er design in g a filt er in t h e F ilt er Design er , you ca n expor t t h e filt er
in for m a t ion t o t h e wor kspa ce or t o disk u sin g Ex p o rt... fr om t h e F i le m en u in
SP Tool. Th e filt er in for m a t ion is st or ed in a st r u ct u r e t h a t you ca n a ccess t o
r et r ieve t h e coefficien t s a n d design pa r a m et er s of t h e filt er you cr ea t ed. Th e
filt er st r u ct u r e a lso con t a in s a n u m ber of fields t h a t a r e u sed in t er n a lly by
SP Tool.
To see t h e fields of t h e filt er st r u ct u r e, fir st expor t a filt er t o t h e wor kspa ce:

1 Cr ea t e a n ew filt er by pr essin g N e w D e s ig n in SP Tool. Th e n ew filt er is


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 :

• tf.num con t a in s t h e n u m er a t or coefficien t s


• tf.den con t a in s t h e den om in a t or coefficien t s

5-79
5 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 ) = ----------- = --------------------------------------------------------------------------------------
A (z ) a (1 ) + a (2 )z – 1 + L+ a (n a + 1 )z – n
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 Algorithm

fdbutter Bu t t er wor t h IIR


fdcheby1 Ch ebysh ev Type I IIR
fdcheby2 Ch ebysh ev Type II IIR
fdellip E llipt ic IIR
fdfirls Lea st Squ a r es F IR
fdkaiser Ka iser Win dow F IR
fdremez 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
Using the Filter Designer: Interactive Filter Design

wh ose la bel m a t ch es t h e currentModule st r in g. F or exa m ple, if t h e specs


st r u ct u r e is
currentModule: 'fdkaiser'
fdremez: [1x1 struct]
fdfirls: [1x1 struct]
fdkaiser: [1x1 struct]

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 Description

Beta Ka iser win dow β pa r a m et er.


f 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
5 Interactive Tools

Parameter Description

Fpass 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.
Fstop 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.
m 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.
order Filt er or der.
Rp Pa ssba n d r ipple (dB)
Rs St opba n d a t t en u a t ion (dB)
setOrderFlag 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.
type 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.

w3db -3 dB fr equ en cy for Bu t t er wor t h IIR design s.


wind Vect or of Ka iser win dow coefficien t s.
Wn Cu t off fr equ en cy for t h e Ka iser win dow F IR filt er wh en
setOrderFlag = 1.

wt Vect or of weigh t s, on e weigh t per fr equ en cy ba n d.

Viewing Frequency Response Plots


It is oft en u sefu l t o view a filt er ’s fr equ en cy r espon se, im pu lse r espon se, a n d
st ep r espon se du r in g t h e filt er design pr ocess. You ca n u se t h e F ilt er Viewer t o
view fr equ en cy-dom a in in for m a t ion a bou t filt er s in t h e F ilt er Design er :

5-82
Using the Filter Designer: Interactive Filter Design

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.

Th e F ilt er Viewer is a ct iva t ed wit h t h e select ed filt er s displa yed.

4 To edit on e of t h e filt er s you ’r e viewin g, you ca n r ea ct iva t e t h e F ilt er


Design er fr om t h e Win d o w m en u in t h e F ilt er Viewer .

5 Wh en you wa n t t o r eview a filt er ’s ch a r a ct er ist ics a ft er you ’ve edit ed it ,


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
5 Interactive Tools

Using the Filter Viewer: Interactive Filter Analysis


An im por t a n t a spect of filt er design is filt er a n a lysis, wh ich en com pa sses bot h
fr equ en cy a n d t im e-dom a in a n a lysis of a filt er . Th e F ilt er Viewer is a
GUI-ba sed fr equ en cy a n a lysis t ool t h a t pr ovides a n in t er a ct ive en vir on m en t
for t h e gr a ph ica l displa y of digit a l filt er ch a r a ct er ist ics.
Th e F ilt er Viewer ca n displa y six differ en t ch a r a ct er ist ics su bplot s of a select ed
filt er . An y com bin a t ion of t h e six su bplot s m a y be displa yed.
Usin g t h e F ilt er Viewer you ca n :

• View m a gn it u de-r espon se plot s for on e or m or e filt er s


• View ph a se-r espon se plot s for on e or m or e filt er s
• View gr ou p-dela y plot s for on e or m or e filt er s
• View zer o-pole plot s for on e or m or e filt er s
• View im pu lse-r espon se plot s for on e or m or e filt er s
• View st ep-r espon se plot s for on e or m or e filt er s
• Zoom in t o explor e filt er r espon se det a ils
• Modify select ed plot pa r a m et er s a n d displa y ch a r a ct er ist ics
• Mea su r e a va r iet y of ch a r a ct er ist ics of t h e filt er r espon se

F or in for m a t ion on fr equ en cy a n a lysis u sin g t oolbox fu n ct ion s fr om t h e


com m a n d lin e or fr om M-files, see “F r equ en cy Respon se” in Ch a pt er 1 of t h is
m a n u a l.

Opening the Filter Viewer


Open or a ct iva t e t h e F ilt er Viewer fr om SP Tool:

1 Select on e or m or e filt er s fr om t h e F ilte rs list in SP Tool.

2 P r ess Vie w in t h e F ilte rs pa n el in SP Tool.

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.

Basic Filter Viewer Functions


Th e F ilt er Viewer h a s t h e followin g com pon en t s:

5-84
Using the Filter Viewer: Interactive Filter Analysis

• 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

Frequency Axis panel

Rulers panel, including controls for measuring filter responses

Th e filt er s’m 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
5 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.

Filter Identification Panel


Th is pa n el displa ys t h e va r ia ble n a m es a n d 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. To ch a n ge n a m es or sa m plin g fr equ en cies, u se
N a m e … or S a m p lin g F re qu e n c y … fr om t h e Ed it m en u in SP Tool.

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
Using the Filter Viewer: Interactive Filter Analysis

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.

Frequency Axis Settings


You ca n ch a n ge fr equ en cy a xis sca lin g a n d r a n ge pa r a m et er s for plot s in t h e
F ilt er Viewer .
Click on t h e opt ion in t h e F re q u e n c y Ax i s pa n el you wa n t t o edit a n d dr a g t o
select a va lu e. Th e opt ion s in clu de:
• 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 .

• 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 r epr esen t s t h e filt er ’s sa m plin g fr equ en cy.
Th e fr equ en cy r a n ge ca n n ot be n ega t ive if S c a le is set t o lo g .
You ca n a lso ch a n ge t h e fr equ en cy a xis 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 i lte r Vi e 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.

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
5 Interactive Tools

in t h e F ilt er 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 .

Main Plots Area


On e or m or e of t h e six filt er r espon se su bplot s m a y be displa yed gr a ph ica lly in
t h e m a in plot s a r ea of t h e F ilt er Viewer . You ca n specify h ow t h e su bplot s a r e
a r r a n ged by select in g F i lte r Vi e w e r Tilin g fr om t h e P re fe re n c e s dia log box in
SP Tool. Th e opt ion s a r e 2-by -3 Gri d , 3-b y -2 Grid , Ve rti c a l (6-by -1 Grid ) , a n d
Ho rizo n ta l (1-by -6 Grid ) .
Th e followin g figu r e sh ows t h e F ilt er Viewer wh en fou r su bplot s a r e t u r n ed on
a n d t h e 2-by-3 gr id opt ion is select ed.

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
Using the Filter Viewer: Interactive Filter Analysis

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.
Aft er you zoom in on a su bplot , you ca n click a n d dr a g t o pa n a r ou n d t h e
su bplot :

1 P r ess Mo u s e Zo o m t o t u r n on m ou se zoom m ode.

2 Click on a fea t u r e of a su bplot t o zoom in on it .

3 If per sist en t zoom in g is en a bled, pr ess Mo u s e Zo o m a ga in t o t u r n off m ou se


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


cu r sor is displa yed, a n d dr a g t h e m ou se t o pa n a r ou n d t h e su bplot .

Viewing Filter Plots


Th is sect ion h a s a br ief descr ipt ion a n d pict u r e of ea ch of t h e six filt er r espon se
plot s a va ila ble in t h e F ilt er Viewer . A sequ en ce of con n ect ed exa m ples sh ows
you h ow t o displa y ea ch plot on it s own ; you ca n a lso displa y a n y com bin a t ion
of plot s, a s n eeded.
E a ch plot in t h e exa m ple sequ en ce displa ys t h e r espon se of a n or der 22
equ ir ipple lowpa ss filt er wit h a sa m plin g fr equ en cy of 1 H z.
Rega r dless of h ow m a n y or wh a t com bin a t ion of plot s is displa yed, you ca n
zoom in on a n d pa n ea ch su bplot in depen den t ly.

Viewing Magnitude Response


A m a gn it u de r espon se plot is gen er a lly t h e sim plest wa y t o obt a in a h igh -level
view of a filt er ’s sh a pe a n d fit t o specifica t ion s. In t h e followin g exa m ple, u se
t h e F ilt er Design er t o cr ea t e a st a n da r d defa u lt filt er a n d t h en view it s
m a gn it u de r espon se plot in t h e F ilt er Viewer :

5-89
5 Interactive Tools

1 F r om SP Tool, pr ess Cre a te .

Th e F ilt er Design er is a ct iva t ed a n d a st a n da r d defa u lt filt er is cr ea t ed a n d


displa yed.

Th is is a n or der 22 equ ir ipple lowpa ss filt er wit h a sa m plin g fr equ en cy of


1 H z.

2 Use t h e Win d o w m en u in t h e F ilt er Design er t o a ct iva t e SP Tool.

3 P r ess Vie w fr om t h e F ilte rs pa n el in SP Tool t o a ct iva t e t h e F ilt er Viewer .

Th e F ilt er Viewer is displa yed wit h a m a gn it u de r espon se plot a n d a ph a se


r espon se plot .

5-90
Using the Filter Viewer: Interactive Filter Analysis

4 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 off t h e ph a se plot .

Th e m a gn it u de plot for t h e defa u lt filt er is displa yed.

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.

Viewing Phase Response


In a ddit ion t o displa yin g m a gn it u de r espon se, t h e F ilt er Viewer ca n ca lcu la t e
a n d plot t h e filt er ’s ph a se r espon se. Ph ase respon se is t h e a n gu la r com pon en t
of a filt er ’s fr equ en cy r espon se. To displa y on ly a ph a se r espon se plot for t h e
cu r r en t filt er :

5-91
5 Interactive Tools

1 Click t h e ch eck box n ext t o t h e Ma g n itu d e opt ion t o t u r n off t h e m a gn it u de


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
Using the Filter Viewer: Interactive Filter Analysis

Viewing Group Delay


Grou p d elay is a m ea su r e of t h e a ver a ge dela y of a filt er a s a fu n ct ion of
fr equ en cy. To displa y on ly a gr ou p dela y plot for t h e cu r r en t ly select ed filt er (s):

1 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 off t h e ph a se plot .

2 Click t h e ch eck box n ext t o t h e Gro u p D e la y opt ion t o t u r n on t h e gr ou p


dela y 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 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
5 Interactive Tools

Viewing a Zero-Pole Plot


Th e zero-pole plot displa ys t h e poles a n d zer os of t h e t r a n sfer fu n ct ion a n d t h eir
pr oxim it y t o t h e u n it cir cle. An r epr esen t s a pole of t h e t r a n sfer fu n ct ion ; a
r epr esen t s a zer o of t h e t r a n sfer fu n ct ion . To displa y on ly a zer o-pole plot for
t h e cu r r en t ly select ed filt er (s):

1 Click t h e ch eck box n ext t o t h e Gro u p D e la y opt ion t o t u r n off t h e gr ou p


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


zer o-pole plot a n d u pda t e t h e displa y.

Viewing Impulse Response


Th e im pu lse respon se plot displa ys t h e r espon se of t h e cu r r en t 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.
To displa y on ly a n im pu lse r espon se plot for t h e cu r r en t ly select ed filt er (s):

5-94
Using the Filter Viewer: Interactive Filter Analysis

1 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 off t h e


zer o-pole plot .

2 Click t h e ch eck box n ext t o t h e Im p u ls e Re s p o n s e opt ion t o t u r n on t h e


im pu lse r espon se plot a n d u pda t e t h e displa y.

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.

Viewing Step Response


Th e step respon se plot displa ys t h e r espon se of t h e cu r r en t filt er (s) t o a
discr et e-t im e u n it -h eigh t st ep fu n ct ion . To displa y on ly a st ep r espon se plot for
t h e cu r r en t ly select ed filt er (s):

5-95
5 Interactive Tools

1 Click t h e ch eck box n ext t o t h e Im p u ls e R e s p o n s e opt ion t o t u r n off t h e


im pu lse r espon se plot .

2 Click t h e ch eck box n ext t o t h e S te p Re s p o n s e opt ion t o t u r n on t h e st ep


r espon se plot a n d u pda t e t h e displa y.

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
Using the Spectrum Viewer: Interactive PSD Analysis

Using the Spectrum Viewer: Interactive PSD Analysis


Th e Spect r u m Viewer pr ovides a n in t er a ct ive en vir on m en t for t h e est im a t ion
of power spect r a l den sit y for on e da t a ch a n n el. It a llows you t o view a n d m odify
spect r a cr ea t ed in SP Tool.
Usin g t h e Spect r u m Viewer you ca n :

• View a n d com pa r e spect r a l den sit y plot s


• Use differ en t est im a t ion m et h ods, in clu din g Bu r g, F F T, MTM, MUSIC,
Welch , a n d Yu le-Wa lker AR
• Modify spect r u m pa r a m et er s su ch a s F F T len gt h , win dow t ype, a n d sa m ple
fr equ en cy
• P r in t spect r u m da t a

F or in for m a t ion on spect r a l a n a lysis u sin g t oolbox fu n ct ion s fr om t h e com m a n d


lin e or fr om M-files, see Ch a pt er 3 of t h is m a n u a l.

Opening the Spectrum Viewer


You ca n open or a ct iva t e t h e Spect r u m Viewer fr om SP Tool by pr essin g on e of
t h e followin g bu t t on s: Cre a te , Vie w , a n d U p d a te . See “Cr ea t in g a Spect r u m ”
on pa ge 5-19, “Viewin g a Spect r u m ” on pa ge 5-19, a n d “Upda t in g a Spect r u m ”
on pa ge 5-19 for com plet e det a ils.
H er e is a br ief su m m a r y of ea ch m et h od of a ct iva t in g t h e Spect r u m Viewer :

• To cr ea t e a spect r u m , select a sign a l in SP Tool a n d pr ess Cre a te . P r ess


Ap p ly in t h e Spect r u m Viewer .
A defa u lt spect r u m of t h e select ed sign a l is gen er a t ed a n d displa yed. 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 .
• To view a spect r u m , select on e or m or e spect r a in SP Tool a n d pr ess Vie w in
t h e S p e c tra pa n el.
• To u pda t e a spect r u m , select exa ct ly on e sign a l a n d on e spect r u m in SP Tool
a n d pr ess U p d a te . P r ess Ap p ly in t h e Spect r u m Viewer .

Th e spect r u m is u pda t ed t o r eflect t h e da t a in t h e cu r r en t ly select ed sign a l.

5-97
5 Interactive Tools

Basic Spectrum Viewer Functions


Th e Spect r u m Viewer win dow h a s t h e followin g com pon en t s:

• A P a ra m e te rs pa n el for viewin g a n d m odifyin g t h e pa r a m et er s or m et h od of


t h e cu r r en t spect r u m
• A sign a l 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 sign a l
lin ked t o t h e cu r r en t spect r u m
• A m a in a xes (displa y) a r ea for viewin g spect r a gr a ph ica lly
• Zoom con t r ols for get t in g a closer look a t spect r a l fea t u r es
• Ru ler s a n d lin e-displa y con t r ols for m a k in g spect r a l m ea su r em en t s a n d
com pa r ison s
• Spect r u m m a n a gem en t con t r ols: In h e rit fro m ..., Re v e rt , a n d Ap p ly
• Men u opt ion s for m odifyin g plot displa y ch a r a ct er ist ics
• Men u opt ion s for pr in t in g spect r u m da t a

Ruler and line display controls

Zoom controls

Signal ID

Parameters panel

Main axes area

5-98
Using the Spectrum Viewer: Interactive PSD Analysis

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 .
Click on t h e opt ion you wa n t t o edit a n d dr a g t o select a va lu e.

5-99
5 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 l’s 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.

Spectrum Management Buttons

Inherit from… Ch oose a spect r u m fr om t h is m en u t o let t h e a ct ive spect r u m


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
Using the Spectrum Viewer: Interactive PSD Analysis

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 .

Ruler and Line Display Controls


Usin g t h e r u ler s a n d lin e-displa y con t r ols, you ca n m ea su r e a va r iet y of
ch a r a ct er ist ics of spect r a 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 r u ler s a n d m odifyin g lin e displa ys 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 .

Main Axes Display Area


Th e S p e c tra list in SP Tool sh ows a ll spect r a in t h e cu r r en t SP Tool session . On e
or m or e spect r a m a y be select ed. Th e spect r a l da t a of a ll select ed spect r a a r e
displa yed gr a ph ica lly in t h e m a in a xes displa y a r ea of t h e Spect r u m Viewer .

NOTE If a spect r u m is n ot displa yed, or if it is displa yed wit h t h e wr on g


sign a l in for m a t ion , pr ess Ap p ly t o r ecom pu t e t h e spect r a l da t a .

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
5 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.

Making Spectrum Measurements


Use t h e r u ler s t o m a ke a va r iet y of m ea su r em en t s on t h e select ed spect r u m .
See “Ma kin g Sign a l Mea su r em en t s” on pa ge 5-37 for det a ils.

Viewing Spectral Density Plots


Spect r a l den sit y est im a t ion is a t ech n iqu e t h a t fin ds t h e a ppr oxim a t e
fr equ en cy con t en t of a sign a l. Th e Spect r u m Viewer ca lcu la t es sin gle-ch a n n el
power spect r a l den sit y (P SD). Wh en you fir st gen er a t e a spect r u m , t h e
Spect r u m Viewer sh ows a defa u lt power spect r a l den sit y fu n ct ion of t h e in pu t
da t a . By defa u lt , t h e Spect r u m Viewer u ses t h e Welch m et h od of P SD
est im a t ion wit h a len gt h -256 H a n n in g win dow a n d a n F F T len gt h of 1024.
You ca n ch a n ge plot pr oper t ies a n d com pu t a t ion pa r a m et er s for a displa yed
spect r u m , a n d you ca n set con fiden ce in t er va ls.

Controlling and Manipulating Plots


Changing Plot Properties
You ca n con t r ol t h e a xes u n it s a n d sca lin g pr oper t ies t h a t a ffect t h e Spect r u m
Viewer ’s plot s.

5-102
Using the Spectrum Viewer: Interactive PSD Analysis

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.

Choosing Computation Parameters


Th e Spect r u m Viewer let s you con t r ol t h e P SD est im a t ion pa r a m et er s of t h e
select ed spect r u m . Differ en t pa r a m et er s a r e a va ila ble, depen din g on wh ich
m et h od of P SD com pu t a t ion you ch oose. Set t h ese pa r a m et er s fr om t h e
P a ra m e te rs pa n el, a s illu st r a t ed in t h e followin g st eps:

1 Click on t h e Me th o d pop-u p m en u a n d dr a g t o select on e of t h e followin g


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
5 Interactive Tools

2 Modify t h e a ppr opr ia t e pa r a m et er s.

- 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 .

Computation Methods and Parameters


You ca n ch oose fr om seven P SD com pu t a t ion m et h ods. E a ch m et h od h a s it s
own set of pa r a m et er s.
Th is sect ion sh ows t h e P a ra m e te rs pa n el for ea ch of t h e P SD com pu t a t ion
m et h ods. F or det a iled defin it ion s a n d va lu es for ea ch pa r a m et er , u se
con t ext -sen sit ive h elp (see “H elp Bu t t on ” on pa ge 5-101).

Burg. F or t h e Bu r g 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

5-104
Using the Spectrum Viewer: Interactive PSD Analysis

Covariance. F or t h e Cova r ia n ce 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

FFT. F or t h e F F T m et h od, you ca n specify t h e followin g


pa r a m et er :
• N fft

Mod. Covar. F or t h e Modified Cova r ia n ce 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

MTM. F or t h e MTM m et h od, you ca n specify t h e followin g


pa r a m et er s:
• NW
• N fft

5-105
5 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:
• NFFT
• N w in d
• Wi n d o w
• Ov e rla p
• S c a lin g
Select on e of t h e followin g fr om t h e pop-u p m en u :
- U n bia s e d
- P eaks

5-106
Using the Spectrum Viewer: Interactive PSD Analysis

• 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.

Setting Confidence Intervals


By defa u lt , t h e Spect r u m Viewer does n ot com pu t e con fiden ce in t er va ls for
spect r a l den sit y. You ca n en a ble t h e com pu t a t ion of con fiden ce in t er va ls for t h e
Welch a n d MTM m et h ods by followin g t h ese st eps:

1 Click t h e Co n f. In t. ch eck box so t h a t it is select ed.

2 Type a va lu e for t h e con fiden ce level in t h e Co n f. In t. edit box.

Th is va lu e m u st be a sca la r bet ween 0 a n d 1.

3 P r ess Ap p ly .

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.

Printing Spectrum Data


You ca n pr in t a ll of t h e spect r u m da t a t h a t you ca n displa y a n d m a n ipu la t e in
t h e Spect r u m Viewer . You r pr in t ou t will a lwa ys con t a in :
• Th e plot s of on e or m or e spect r a , a s displa yed in t h e m a in a xes a r ea
• A legen d displa yed in t h e m a in a xes a r ea t o la bel ea ch spect r u m by n a m e,
lin e color /st yle, m et h od, a n d F F T len gt h

Th e r u ler m ea su r em en t s of t h e cu r r en t ly select ed spect r u m will be displa yed


a t t h e bot t om of t h e figu r e, u n less you su ppr ess t h em wit h t h e Ru le rs ch eck

5-107
5 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
Using the Spectrum Viewer: Interactive PSD Analysis

P rin t P re v ie 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:
• 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
5 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.

Saving Spectrum Data


Aft er cr ea t in g a spect r u m in SP Tool, you ca n expor t spect r u m in for m a t ion t o
t h e wor kspa ce or t o disk u sin g E x p o rt... fr om t h e F ile m en u in SP Tool. Th e
spect r u m in for m a t ion is st or ed in a st r u ct u r e t h a t you ca n a ccess t o r et r ieve t h e
spect r a l power a n d fr equ en cy da t a . Th e spect r u m st r u ct u r e a lso con t a in s a
n u m ber of fields t h a t a r e u sed in t er n a lly by SP Tool.

5-110
Using the Spectrum Viewer: Interactive PSD Analysis

To see t h e fields of t h e spect r u m st r u ct u r e, t r y expor t in g a spect r u m t o t h e


wor k spa ce:

1 Cr ea t e a n ew spect r u m if n on e a r e cu r r en t ly loa ded. La bel t h e spect r u m


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 followin g st r u ct u r e fields descr ibe t h e spect r u m .

Field Description

P Th e spect r a l power vect or.


f Th e spect r a l fr equ en cy vect or.
confid 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 Th e n a m e of t h e sign a l fr om wh ich t h e spect r u m wa s
gen er a t ed.
Fs Th e a ssocia t ed sign a l’s sa m ple r a t e.

5-111
5 Interactive Tools

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.

5-112
Example: Generation of Bandlimited Noise

Example: Generation of Bandlimited Noise


Th is sect ion pr ovides a com plet e exa m ple of u sin g t h e GUI-ba sed in t er a ct ive
t ools t o design a n d im plem en t a n F IR digit a l filt er , a pply it t o a sign a l, a n d
displa y sign a ls a n d spect r a . Th e st eps in clu de:

• Im por t in g a n d n a m in g a sign a l u sin g SP Tool


• Design in g a filt er u sin g t h e F ilt er Design er
• In SP Tool, a pplyin g t h e filt er t o t h e sign a l t o cr ea t e a n ot h er sign a l
• Viewin g t h e t im e dom a in in for m a t ion of t h e or igin a l a n d filt er ed sign a ls
u sin g t h e Sign a l Br owser
• Com pa r in g t h e spect r a of bot h sign a ls u sin g t h e Spect r u m Viewer

Create, Import, and Name a Signal


You ca n im por t a n exist in g sign a l in t o SP Tool, or you ca n cr ea t e a n ew sign a l
a n d edit a n d n a m e it in SP Tool. In t h is st ep, you ’ll cr ea t e a n ew sign a l a t t h e
com m a n d lin e a n d t h en im por t it in t o SP Tool.

1 At t h e com m a n d lin e, cr ea t e a r a n dom sign a l by t ypin g:

x = randn(5000,1);

2 Act iva t e SP Tool by t ypin g:


sptool

Th e SP Tool win dow is displa yed.

5-113
5 Interactive Tools

3 Select Im p o rt... fr om t h e F ile m en u :

Th e Im p o rt to S P To o l win dow is displa yed.

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 Click in t h e S a m p li n g F re qu e n c y field a n d t ype 5000.
d Na m e t h e sign a l by clickin g in t h e N a m e field a n d t ypin g noise.

e P r ess OK .

Th e SP Tool win dow is r ea ct iva t ed, a n d t h e sign a l noise[vector] is select ed


in t h e S i g n a ls list .

5-114
Example: Generation of Bandlimited Noise

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


S a m p li n g F re q u e n c y t ext box in t h e F ilt er Design er .

3 Specify t h e filt er pa r a m et er s sh own a t left :

a Ma ke su r e Equ i rip p le F IR is select ed in t h e Alg o rith m pop-u p m en u .

b Select ba n d p a s s fr om t h e Ty p e pop-u p m en u .

c 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.

d Set t h e st opba n d edge fr equ en cies by en t er in g 500 for F s 1 a n d 1500 for


F s2.

e Type .01 in t o t h e R p field a n d 75 in t o t h e R s field.


Rp set s t h e m a xim u m pa ssba n d r ipple a n d Rs set s t h e st opba n d
a t t en u a t ion for t h e filt er .
f P r ess t h e Ap p ly bu t t on t o com pu t e t h e n ew filt er .

5-115
5 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 .

Th e r esu lt in g filt er is a n or der 78 ba n dpa ss equ ir ipple filt er .

Apply the Filter to a Signal


In t h is st ep, you a pply t h e filt er t o t h e sign a l in SP Tool. Th e n ew, filt er ed sign a l
is a u t om a t ica lly cr ea t ed in SP Tool.

5-116
Example: Generation of Bandlimited Noise

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


select t h e filt er (n a m ed filt1[design]) fr om t h e F ilte rs list , a s sh own
below.

3 P r ess Ap p ly t o a pply t h e filt er filt1 t o t h e sign a l noise.

Th e Ap p ly F i lte r dia log box is displa yed.

4 Na m e t h e n ew sign a l by clickin g in t h e Ou tp u t S ig n a l field a n d t ypin g


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 .

View, Play, and Print the Signals


You ca n view a n d pr in t t h e t im e dom a in in for m a t ion of t h e sign a ls u sin g t h e
Sign a l Br owser . You ca n a lso pla y t h e sign a ls, if you r com pu t er h a s a u dio
ou t pu t ca pa bilit ies. In t h is st ep, you ’ll displa y bot h sign a ls in t h e Sign a l
Br owser , select a n d pla y ea ch sign a l, a n d pr in t bot h sign a ls.

5-117
5 Interactive Tools

1 S h ift -click on t h e noise a n d blnoise sign a ls in t h e S ig n a ls list of SP Tool t o


select bot h sign a ls.

2 P r ess Vie w in t h e S ig n a ls pa n el.

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 .

3 Click-a n d-dr a g in t h e S e le c tio n pop-u p m en u t o select t h e blnoise sign a l.

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
Example: Generation of Bandlimited Noise

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


sign a l by click in g on it in t h e m a in a xes displa y a r ea ). Select P la y fr om t h e
Op tio n s m en u a ga in .

6 Befor e pr in t in g t h e t wo sign a ls t oget h er , u se t h e lin e con t r ols t o m a xim ize


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
5 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 .

Compare Spectra of Both Signals


You ca n get a n idea of t h e fr equ en cy con t en t of t h e t wo sign a ls by displa yin g
t h eir power spect r a u sin g t h e Spect r u m Viewer , a s descr ibed below.

1 Rea ct iva t e SP Tool by select in g it fr om t h e Win d o w m en u of t h e Sign a l


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
Example: Generation of Bandlimited Noise

3 P r ess Cre a te 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 (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


spect r u m of t h e noise sign a l is displa yed in t h e m a in a xes displa y a r ea .

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
5 Interactive Tools

7 P r ess Cre a te in t h e S p e c tra pa n el.

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 spect r u m of t h e blnoise sign a l is displa yed in t h e m a in a xes displa y


a r ea .

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
Example: Generation of Bandlimited Noise

10 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 .

11 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


displa y bot h spect r a t oget h er .

12 To select on e of t h e spect r a for m ea su r in g or edit in g, u se t h e S e le c tio n


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.

13 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
5 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
6 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 Swept -fr equ en cy cosin e gen er a t or.


diric Dir ich let or per iodic sin c fu n ct ion .
gauspuls Ga u ssia n -m odu la t ed sin u soida l pu lse gen er a t or.
pulstran P u lse t r a in gen er a t or.
rectpuls Sa m pled a per iodic r ect a n gle gen er a t or.
sawtooth Sa wt oot h or t r ia n gle wa ve gen er a t or.
sinc Sin c fu n ct ion .
square Squ a r e wave gen er a t or.
strips St r ip plot .
tripuls Sa m pled a per iodic t r ia n gle gen er a t or.

Filter Analysis and Implementation

abs Absolu t e va lu e (m a gn it u de).


angle P h a se a n gle.
conv Con volu t ion a n d polyn om ia l m u lt iplica t ion .
conv2 Two-dim en sion a l con volu t ion .
fftfilt 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.
filter 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 Two-dim en sion a l digit a l filt er in g.


filtfilt Zer o-ph a se digit a l filt er in g.
filtic 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 .
freqs F r equ en cy r espon se of a n a log filt er s.
freqspace F r equ en cy spa cin g for fr equ en cy r espon se.
freqz F r equ en cy r espon se of digit a l filt er s.
grpdelay Aver a ge filt er delay (gr ou p delay).
impz Im pu lse r espon se of digit a l filt er s.
latcfilt La t t ice a n d la t t ice-la dder filt er im plem en t a t ion .
sgolayfilt Savit zky-Gola y filt er in g.
sosfilt Secon d-or der (biqu a dr a t ic) IIR filt er in g.
unwrap Un wr a p ph a se a n gles.
zplane Zer o-pole plot .

Linear System Transformations

ac2poly Con ver sion of a u t ocor r ela t ion sequ en ce t o pr edict ion
polyn om ia l.
ac2rc Con ver sion of a u t ocor r ela t ion sequ en ce t o r eflect ion
coefficien t s.
convmtx Con volu t ion m a t r ix.
latc2tf La t t ice filt er t o t r a n sfer fu n ct ion con ver sion .

6-3
6 Reference

Linear System Transformations

poly2ac Con ver sion of pr edict ion polyn om ia l t o a u t ocor r ela t ion
sequ en ce.
poly2rc Con ver sion of pr edict ion polyn om ia l t o r eflect ion
coefficien t s.
rc2ac Con ver sion of r eflect ion coefficien t s t o a u t ocor r ela t ion
sequ en ce.
rc2poly Con ver sion of r eflect ion coefficien t s t o pr edict ion
polyn om ia l.
residuez z-t r a n sfor m pa r t ia l-fr a ct ion expa n sion .
sos2ss Con ver sion of secon d-or der sect ion s t o st a t e-spa ce.
sos2tf Con ver sion of secon d-or der sect ion s t o t r a n sfer fu n ct ion .
sos2zp Con ver sion of secon d-or der sect ion s t o zer o-pole-ga in .
ss2sos Con ver sion of st a t e-spa ce t o secon d-or der sect ion s.
ss2tf Con ver sion of st a t e-spa ce t o t r a n sfer fu n ct ion .
ss2zp Con ver sion of st a t e-spa ce t o zer o-pole-ga in .
tf2latc Con ver sion of t r a n sfer fu n ct ion t o la t t ice filt er.
tf2sos Con ver sion of t r a n sfer fu n ct ion t o secon d-or der sect ion s.
tf2ss Con ver sion of t r a n sfer fu n ct ion t o st a t e-spa ce.
tf2zp Con ver sion of t r a n sfer fu n ct ion t o zer o-pole-ga in .
zp2sos Con ver sion of zer o-pole-ga in t o secon d-or der sect ion s.
zp2ss Con ver sion of zer o-pole-ga in t o st a t e-spa ce.
zp2tf Con ver sion of zer o-pole-ga in t o t r a n sfer fu n ct ion .

6-4
IIR Filter Design—Classical and Direct

besself Bessel a n a log filt er design .


butter Bu t t er wor t h a n a log a n d digit a l filt er design .
cheby1 Ch ebysh ev t ype I filt er design (pa ssba n d r ipple).
cheby2 Ch ebysh ev t ype II filt er design (st opba n d r ipple).
ellip E llipt ic (Ca u er ) filt er design .
maxflat Gen er a lized digit a l Bu t t er wor t h filt er design .
yulewalk Recu r sive digit a l filt er design .

IIR Filter Order Selection

buttord Bu t t er wor t h filt er or der select ion .


cheb1ord Ch ebysh ev t ype I filt er or der select ion .
cheb2ord Ch ebysh ev t ype II filt er or der select ion .
ellipord E llipt ic filt er or der select ion .

FIR Filter Design

cremez Com plex a n d n on lin ea r-ph a se equ ir ipple F IR filt er design .


fir1 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.
fir2 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.
fircls 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
6 Reference

FIR Filter Design

fircls1 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.
firls Lea st squ a r e lin ea r-ph a se F IR filt er design .
firrcos Ra ised cosin e F IR filt er design .
intfilt In t er pola t ion F IR filt er design .
kaiserord 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.
remez Pa r ks-McClella n opt im a l F IR filt er design .
remezord Pa r ks-McClella n opt im a l F IR filt er or der est im a t ion .
sgolay Sa vit zk y-Golay filt er design .

Transforms

czt Ch ir p z-t r a n sfor m .


dct Discr et e cosin e t r a n sfor m (DCT).
dftmtx Discr et e Fou r ier t r a n sfor m m a t r ix.
fft On e-dim en sion a l fa st Fou r ier t r a n sfor m .
fft2 Two-dim en sion a l fa st Fou r ier t r a n sfor m .
fftshift 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.
hilbert H ilber t t r a n sfor m .
idct In ver se discr et e cosin e t r a n sfor m .
ifft On e-dim en sion a l in ver se fa st Fou r ier t r a n sfor m .
ifft2 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 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.
corrcoef Cor r ela t ion coefficien t m a t r ix.
cov Cova r ia n ce m a t r ix.
csd 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.
pburg Power spect r u m est im a t e u sin g t h e Bu r g m et h od.
pcov 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.
pmcov 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.
pmtm 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).
pmusic Power spect r u m est im a t e u sin g MUSIC eigen vect or
m et h od.
pwelch 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.
pyulear Power spect r u m est im a t e u sin g Yu le-Wa lker AR m et h od.
tfe 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 .
xcorr Cr oss-cor r ela t ion fu n ct ion est im a t e.
xcorr2 Two-dim en sion a l cr oss-cor r ela t ion .
xcov 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
6 Reference

Windows

bartlett Ba r t let t win dow.


blackman Bla ckm a n win dow.
boxcar Rect a n gu la r win dow.
chebwin Ch ebysh ev win dow.
hamming H a m m in g win dow.
hanning H a n n in g win dow.
kaiser Ka iser win dow.
triang Tr ia n gu la r win dow.

Parametric Modeling

arburg 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.
arcov 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.
armcov 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.
aryule 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.
invfreqs 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 .
invfreqz Discr et e-t im e filt er iden t ifica t ion fr om fr equ en cy da t a .
levinson Levin son -Du r bin r ecu r sion .
lpc Lin ea r pr edict ion coefficien t s.
prony P r on y’s m et h od for t im e dom a in IIR filt er design .

6-8
Parametric Modeling

rlevinson Rever se Levin son -Du r bin r ecu r sion .


stmcb Lin ea r m odel u sin g St eiglit z-McBr ide it er a t ion .

Specialized Operations

buffer 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.


cceps Com plex cepst r a l a n a lysis.
cplxpair Gr ou p com plex n u m ber s in t o com plex con ju ga t e pa ir s.
decimate Decr ea se t h e sa m plin g r a t e for a sequ en ce (decim a t ion ).
deconv Decon volu t ion a n d polyn om ia l division .
demod Dem odu la t ion for com m u n ica t ion s sim u la t ion .
dpss Discr et e pr ola t e sph er oida l sequ en ces (Slepia n sequ en ces).
dpssclear Rem ove discr et e pr ola t e sph er oida l sequ en ces fr om
da t a ba se.
dpssdir Discr et e pr ola t e sph er oida l sequ en ces da t a ba se dir ect or y.
dpssload Loa d discr et e pr ola t e sph er oida l sequ en ces fr om da t a ba se.
dpsssave Save discr et e pr ola t e sph er oida l sequ en ces in da t a ba se.
icceps In ver se com plex cepst r u m .
interp 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 ).
medfilt1 On e-dim en sion a l m edia n filt er in g.
modulate Modu la t ion for com m u n ica t ion s sim u la t ion .
polystab St a bilize polyn om ia l.
rceps 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
6 Reference

Specialized Operations

resample 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.


specgram Tim e-depen den t fr equ en cy a n a lysis (spect r ogr a m ).
upfirdn Upsa m ple, a pply a n F IR filt er, a n d down sa m ple.
vco Volt a ge con t r olled oscilla t or.

Analog Prototype Design

besselap Bessel a n a log lowpa ss filt er pr ot ot ype.


buttap Bu t t er wor t h a n a log lowpa ss filt er pr ot ot ype.
cheb1ap Ch ebysh ev t ype I a n a log lowpa ss filt er pr ot ot ype.
cheb2ap Ch ebysh ev t ype II a n a log lowpa ss filt er pr ot ot ype.
ellipap E llipt ic a n a log lowpa ss filt er pr ot ot ype.

Frequency Translation

lp2bp Lowpa ss t o ba n dpa ss a n a log filt er t r a n sfor m a t ion .


lp2bs Lowpa ss t o ba n dst op a n a log filt er t r a n sfor m a t ion .
lp2hp Lowpa ss t o h igh pa ss a n a log filt er t r a n sfor m a t ion .
lp2lp Lowpa ss t o lowpa ss a n a log filt er t r a n sfor m a t ion .

6-10
Filter Discretization

bilinear 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 .
impinvar 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 .

Interactive Tools

sptool In t er a ct ive digit a l sign a l pr ocessin g t ool (SP Tool).

6-11
abs

Purpose 6a bs
Absolu t e va lu e (m a gn it u de).

Syntax y = abs(x)

Description 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


r et u r n s t h e com plex m odu lu s (m a gn it u de):
abs(x) = sqrt(real(x).^2 + imag(x).^2)

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 Ca lcu la t e t h e m a gn it u de of t h e F F T of a sequ en ce:


t = (0:99)/100; % time vector
x = sin(2*pi*15*t) + sin(2*pi*40*t); % signal
y = fft(x); % compute DFT of x
m = abs(y); % magnitude

P lot t h e m a gn it u de:
f = (0:length(y)–1)'/length(y)*100; % frequency vector
plot(f,m)

See Also angle P h a se a n gle.

6-12
ac2poly

Purpose 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.

Syntax a = ac2poly(r)
[a,efinal] = ac2poly(r)

Description 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 Con sider t h e a u t ocor r ela t ion sequ en ce


r = [5.0000 –1.5450 –3.9547 3.9331 1.4681 –4.7500];

Th e equ iva len t pr edict ion polyn om ia l is


a = ac2poly(r)

a =

1.0000 0.6147 0.9898 0.0004 0.0034 –0.0077

See Also ac2rc Con ver sion of a u t ocor r ela t ion sequ en ce t o r eflect ion
coefficien t s.
poly2ac Con ver sion of pr edict ion polyn om ia l t o
a u t ocor r ela t ion sequ en ce.
rc2poly 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 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.

Syntax [k,r0] = ac2rc(r)

Description [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 .

See Also ac2poly Con ver sion of a u t ocor r ela t ion sequ en ce t o pr edict ion
polyn om ia l.
poly2rc Con ver sion of pr edict ion polyn om ia l t o r eflect ion
coefficien t s.
rc2ac 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 6a n gle
P h a se a n gle.

Syntax p = angle(h)

Description 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 π.
F or com plex sequ en ce h = x + iy = m eip , t h e m a gn it u de a n d ph a se a r e given by
m = abs(h)
p = angle(h)

To con ver t t o t h e or igin a l h fr om it s m a gn it u de a n d ph a se:


i = sqrt(–1)
h = m.*exp(i*p)

Th e angle 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 Ca lcu la t e t h e ph a se of t h e F F T of a sequ en ce:


t = (0:99)/100; % time vector
x = sin(2*pi*15*t) + sin(2*pi*40*t); % signal
y = fft(x); % compute DFT of x
p = unwrap(angle(y)); % phase

P lot t h e ph a se:
f = (0:length(y)–1)'/length(y)*100; % frequency vector
plot(f,p)

Algorithm angle ca n be expr essed a s:

angle(x) = imag(log(x)) = atan2(imag(x),real(x))

See Also abs Absolu t e va lu e (m a gn it u de).

6-15
arburg

Purpose 6a r bu r g
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.

Syntax a = arburg(x,p)
[a,e] = arburg(x,p)
[a,e,k] = arburg(x,p)

Description a = arburg(x,p) u ses t h e Bu r g m et h od t o fit a p-t h or der a u t or egr essive (AR)


m odel t o t h e in pu t sign a l, x, 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 . x is a ssu m ed t o be t h e ou t pu t of a n AR syst em
dr iven by wh it e n oise. 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 ) = ------------ = ---------------------------------------------------------------------
-
A (z ) –1
1 + a 2 z + … + a (p + 1 )z
–p

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 arcov 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.
armcov 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.
aryule 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.
lpc Lin ea r pr edict ion coefficien t s.
pburg Power spect r u m est im a t e u sin g t h e Bu r g m et h od.
prony P r on y’s m et h od for t im e dom a in IIR filt er design .

6-16
arcov

Purpose 6a r cov
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.

Syntax a = arcov(x,p)
[a,e] = arcov(x,p)

Description a = arcov(x,p) u ses t h e cova r ia n ce m et h od t o fit a p-t h or der a u t or egr essive


(AR) m odel t o t h e in pu t sign a l, x, wh ich is a ssu m ed t o be t h e ou t pu t of a n AR
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 arburg 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.
armcov 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.
aryule 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.
lpc Lin ea r pr edict ion coefficien t s.
pcov 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.
prony P r on y’s m et h od for t im e dom a in IIR filt er design .

6-17
armcov

Purpose 6a r m cov
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.

Syntax a = armcov(x,p)
[a,e] = armcov(x,p)

Description a = armcov(x,p) u ses t h e m odified cova r ia n ce m et h od t o fit a p-t h or der


a u t or egr essive (AR) m odel t o t h e in pu t sign a l, x, wh ich is a ssu m ed t o be t h e
ou t pu t of a n AR 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 a n d ba ck wa r d pr edict ion er r or s 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 ) = ------------ = ---------------------------------------------------------------------
-
A (z ) –1
1 + a 2 z + … + a (p + 1 )z
–p

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 arburg 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.
arcov 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.
aryule 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.
lpc Lin ea r pr edict ion coefficien t s.
pmcov 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.
prony P r on y’s m et h od for t im e dom a in IIR filt er design .

6-18
aryule

Purpose 6a r yu le
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.

Syntax a = aryule(x,p)
[a,e] = aryule(x,p)
[a,e,k] = aryule(x,p)

Description a = aryule(x,p) u ses t h e Yu le-Wa lker m et h od, a lso ca lled t h e


a u t ocor r ela t ion m et h od, t o fit a p-t h or der a u t or egr essive (AR) m odel t o t h e
win dowed in pu t sign a l, x, 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 . x is a ssu m ed t o be t h e
ou t pu t of a n AR syst em dr iven by wh it e n oise. 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] = 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 arburg 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.
arcov 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.
armcov 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.
lpc Lin ea r pr edict ion coefficien t s.
prony P r on y’s m et h od for t im e dom a in IIR filt er design .
pyulear 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 6ba r tlet t


Ba r t let t win dow.

Syntax w = bartlett(n)

Description w = bartlett(n) r et u r n s a n n-poin t Ba r t let t win dow in t h e colu m n vect or w.


Th e coefficien t s of a Ba r t let t win dow a r e:

• F or n odd

⎧ 2--------------------
(k – 1 )
-,
n +1
1 ≤ k ≤ -------------
⎪ n – 1 2
w [ k ] = ⎨
⎪ 2 – 2--------------------
(k – 1 ) n +1
-, ------------- ≤ k ≤ n
⎩ n –1 2

• F or n even

⎧ 2--------------------
(k – 1 )
-,
n
1 ≤ k ≤ ---
⎪ n – 1 2
w [ k ] = ⎨
⎪ 2--------------------
(n – k )
-,
n
--- + 1 ≤ k ≤ n
⎩ n – 1 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 n–2 poin t s of bartle9tt(n) a r e equ iva len t t o triang(n–2).

See Also blackman Bla ck m a n win dow.


boxcar Rect a n gu la r win dow.
chebwin Ch ebysh ev win dow.
hamming H a m m in g win dow.
hanning H a n n in g win dow.
kaiser Ka iser win dow.
triang 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 6bessela p
Bessel a n a log lowpa ss filt er pr ot ot ype.

Syntax [z,p,k] = besselap(n)

Description [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 ) )Ls ( – 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 )!⎞ 1 ⁄n
⎛ -------------
-
⎝ 2 n n ! ⎠

Algorithm 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.

See Also besself Bessel a n a log filt er design .


buttap Bu t t er wor t h a n a log lowpa ss filt er pr ot ot ype.
cheb1ap Ch ebysh ev t ype I a n a log lowpa ss filt er pr ot ot ype.
cheb2ap Ch ebysh ev t ype II a n a log lowpa ss filt er pr ot ot ype.
ellipap E llipt ic a n a log lowpa ss filt er pr ot ot ype.

Also see t h e S ym bolic M ath T oolbox User’s Gu id e.

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 6besself
Bessel a n a log filt er design .

Syntax [b,a] = besself(n,Wn)


[b,a] = besself(n,Wn,'ftype')
[z,p,k] = besself(...)
[A,B,C,D] = besself(...)

Description besself design s lowpa ss, ba n dpa ss, h igh pa ss, a n d ba n dst op a n a log Bessel
filt er s. An a log Bessel filt er s a r e ch a r a ct er ized by a lm ost con st a n t gr ou p dela y
a cr oss t h e en t ir e pa ssba n d, t h u s pr eser vin g t h e wa ve sh a pe of filt er ed sign a ls
in t h e pa ssba n d. Digit a l Bessel filt er s do n ot r et a in t h is qu a lit y, a n d besself
t h er efor e does n ot su ppor t t h e design of digit a l Bessel filt er s.

[b,a] = besself(n,Wn) design s a n or der n lowpa ss a n a log 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 ) s n + a (2 )s n –1 + L+ a (n + 1 )
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.
To obt a in st a t e-spa ce for m , u se fou r ou t pu t a r gu m en t s:

[A,B,C,D] = besself(n,Wn) or

[A,B,C,D] = besself(n,Wn,'ftype') wh er e A, B, C, a n d D a r e

·
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) % plot frequency response

Frequency Response
0
10
Magnitude

-5
10 2 3 4 5
10 10 10 10
Frequency (radians)

200
Phase (degrees)

-200 2 3 4 5
10 10 10 10
Frequency (radians)

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 besself per for m s a fou r -st ep a lgor it h m :

1 It fin ds lowpa ss a n a log pr ot ot ype poles, zer os, a n d ga in u sin g t h e besselap


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
wit h desir ed cu t off fr equ en cies, u sin g a st a t e-spa ce t r a n sfor m a t ion .
4 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
for m , a s r equ ir ed.

See Also besselap Bessel a n a log lowpa ss filt er pr ot ot ype.


butter Bu t t er wor t h a n a log a n d digit a l filt er design .
cheby1 Ch ebysh ev t ype I filt er design (pa ssba n d r ipple).
cheby2 Ch ebysh ev t ype II filt er design (st opba n d r ipple).
ellip E llipt ic (Ca u er ) filt er design .

6-24
bilinear

Purpose 6bilin ea r
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 .

Syntax [zd,pd,kd] = bilinear(z,p,k,Fs)


[zd,pd,kd] = bilinear(z,p,k,Fs,Fp)
[numd,dend] = bilinear(num,den,Fs)
[numd,dend] = bilinear(num,den,Fs,Fp)
[Ad,Bd,Cd,Dd] = bilinear(A,B,C,D,Fs)
[Ad,Bd,Cd,Dd] = bilinear(A,B,C,D,Fs,Fp)

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

Ω
ω = 2 t a n – 1 ⎛ --------⎞
⎝ 2 f s ⎠

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 p (z + 1 )
t a n ⎛ π ----⎞
⎝ f s ⎠

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

f
⎛ Ω t a n ⎛ π ----p ⎞ ⎞
⎜ ⎝ f s ⎠ ⎟
ω = 2 t a n – 1 ⎜ -----------------------------⎟
⎜ 2 πf p ⎟
⎝ ⎠

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 (s ) n u m (1 )s n n + L+ n u m (n n )s + n u m (n n + 1 )
-------------------- = ------------------------------------------------------------------------------------------------------------------
-
d en (s ) d en (1 )s n d + L+ d en (n d )s + d en (n d + 1 )

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


st a t e-spa ce syst em in m a t r ices A, B, C, D,
·
x = Ax + Bu
y = Cx + Du
t o t h e discr et e-t im e syst em

x [n + 1 ] = A d x [n ] + B d u [n ]
y [n ] = C d x [n ] + Dd u [n ]

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


pd = (1+p/k)./(1–p/k);
zd = (1+z/k)./(1–z/k);
kd = real(k*prod(fs–z)./prod(fs–p));

4 It a dds ext r a zer os a t -1 so t h e r esu lt in g syst em h a s equ iva len t n u m er a t or


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

1 1 –1
A d = ⎛ I + ⎛ ---⎞ A ⎞ ⎛ I – ⎛ ---⎞ A ⎞
⎝ ⎝ k ⎠ ⎠ ⎝ ⎝ k ⎠ ⎠
2k 1 –1
B d = ------- ⎛⎝ I – ⎛⎝ ---⎞⎠ A ⎞⎠ B
r k
1 –1
C d = r C ⎛ I – ⎛ ---⎞ A ⎞
⎝ ⎝ k ⎠ ⎠
1 1 –1
D d = ⎛ ---⎞ C ⎛ I – ⎛ ---⎞ A ⎞ B + D
⎝ k ⎠ ⎝ ⎝ k ⎠ ⎠

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
qu a n t iza t ion n oise pr oper t ies in t h e r esu lt in g syst em .

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 impinvar 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 .
lp2bp Lowpa ss t o ba n dpa ss a n a log filt er t r a n sfor m a t ion .
lp2bs Lowpa ss t o ba n dst op a n a log filt er t r a n sfor m a t ion .
lp2hp Lowpa ss t o h igh pa ss a n a log filt er t r a n sfor m a t ion .
lp2lp 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 6bla ck m a n
Bla ckm a n win dow.

Syntax w = blackman(n)
w = blackman(n,sflag)

Description w = blackman(n) r et u r n s t h e n-poin t sym m et r ica lly sa m pled Bla ck m a n


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
equ a t ion for a Bla ck m a n win dow is

k –1 k –1
w [ k ] = 0.42 – 0.5 cos ⎛ 2 π -------------⎞ + 0.08 cos ⎛ 4 π -------------⎞ , k = 1 , …, n
⎝ n – 1 ⎠ ⎝ n – 1 ⎠

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 w = (0.42 – 0.5*cos(2*pi*(0:N–1)/(N–1)) + ...


0.08*cos(4*pi*(0:N–1)/(N–1)))';

Diagnostics An er r or m essa ge is displa yed wh en in cor r ect a r gu m en t s a r e u sed:


Order cannot be less than zero.
Sampling must be either 'symmetric' or 'periodic'.

A wa r n in g m essa ge is displa yed for n on in t eger n:


Warning: Rounding order to nearest integer.

6-30
blackman

See Also bartlett Ba r t let t win dow.


boxcar Rect a n gu la r win dow.
chebwin Ch ebysh ev win dow.
hamming H a m m in g win dow.
hanning H a n n in g win dow.
kaiser Ka iser win dow.
triang 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 6boxca r
Rect a n gu la r win dow.

Syntax w = boxcar(n)

Description w = boxcar(n) r et u r n s a r ect a n gu la r win dow of len gt h n in t h e colu m n vect or


w. Th is fu n ct ion is pr ovided for com plet en ess; a r ect a n gu la r win dow is
equ iva len t t o n o win dow a t a ll.

Algorithm w = ones(n,1);

See Also bartlett Ba r t let t win dow.


blackman Bla ck m a n win dow.
chebwin Ch ebysh ev win dow.
hamming H a m m in g win dow.
hanning H a n n in g win dow.
kaiser Ka iser win dow.
triang 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 6bu ffer


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.

Syntax y = buffer(x,n)
y = buffer(x,n,p)
y = buffer(x,n,p,opt)
[y,z] = buffer(...)
[y,z,opt] = buffer(...)

Description y = buffer(x,n) pa r t it ion s a len gt h -L sign a l vect or x in t o n on over la ppin g


da t a segm en t s (fr a m es) of len gt h n. E a ch da t a fr a m e occu pies on e colu m n of
m a t r ix ou t pu t y, wh ich h a s n r ows a n d ceil(L/n) colu m n s. If L is n ot even ly
divisible by n, t h e la st colu m n is zer o-pa dded t o len gt h n.

y = buffer(x,n,p) over la ps or u n der la ps su ccessive fr a m es in t h e ou t pu t


m a t r ix by p sa m ples:

• 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 2 6 10 14 18 22 26
0 3 7 11 15 19 23 27
0 4 8 12 16 20 24 28
1 5 9 13 17 21 25 29
2 6 10 14 18 22 26 30
3 7 11 15 19 23 27 0
4 8 12 16 20 24 28 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/(n–p)).

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 11 21
2 12 22
3 13 23 8 18 28
4 14 24 skipped 9 19 29
5 15 25 10 20 30
6 16 26
7 17 27

Th e n u m ber of colu m n s in y is ceil(L/(n–p)).

y = buffer(x,n,p,opt) specifies a vect or of sa m ples t o pr ecede x(1) in a n


over la ppin g bu ffer , or t h e n u m ber of in it ia l sa m ples t o sk ip in a n u n der la ppin g
bu ffer :

• 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 5 9 13 17 21 25
2 6 10 14 18 22 26
3 7 11 15 19 23 27
4 8 12 16 20 24 28
5 9 13 17 21 25 29
6 10 14 18 22 26 30
7 11 15 19 23 27 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/(n–p)) % when length(opt) = p

or
m = floor((L–n)/(n–p))+1 % when opt = 'nodelay'

If y is a n u n der 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–opt)/(n–p)) + (rem((L–opt),(n–p)) >= n)

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*(n–p) % when length(opt) = p

or
length(z) = L – ((m–1)*(n–p)+n) % when opt = 'nodelay'

a n d for a n u n der la ppin g bu ffer h a s len gt h


length(z) = (L–opt) – m*(n–p)

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*(n–p) + 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((L–opt)/(n–p)) + (rem((L–opt),(n–p)) >= 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) % for column vector x

[y,z] = buffer([z,x],n) % 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 Example 1: Continuous Overlapping Buffers


F ir st cr ea t e a bu ffer con t a in in g 100 fr a m es, ea ch wit h 11 sa m ples.
data = buffer(1:1100,11); % 11 samples per frame

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 = 4; % new frame size
p = 1; % overlap
opt = –5; % value of y(1)
z = []; % 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), % Loop over each source frame (column)
x = data(:,i); % A single frame of the D/A output

[y,z,opt] = buffer([z;x],n,p,opt);

disp(y); % Do something with the buffer of data


pause
end

6-38
buffer

H er e’s wh a t h a ppen s du r in g t h e fir st fou r it er a t ion s.

Iteration Input frame [z;x]' opt (input) opt (output) Output buffer (y) Overflow (z)

–5 3 6
1 4 7
i=1 [1:11] –5 9 [10 11]
2 5 8
3 6 9

9 12 15 18
10 13 16 19
i=2 [10 11 12:22] 9 21 [22]
11 14 17 20
12 15 18 21

21 24 27 30
22 25 28 31
i=3 [22 23:33] 21 33 []
23 26 29 32
24 27 30 33

33 36 39
i=4 34 37 40
[34:44] 33 42 [43 44]
35 38 41
36 39 42

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.

Example 2: Continuous Underlapping Buffers


Aga in cr ea t e a bu ffer con t a in in g 100 fr a m es, ea ch wit h 11 sa m ples.
data = buffer(1:1100,11); % 11 samples per frame

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 = 4; % new frame size
p = –2; % underlap
opt = 1; % skip the first input element, x(1)
z = []; % 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), % Loop over each source frame (column)
x = data(:,i); % A single frame of the D/A output

[y,z,opt] = buffer([z;x],n,p,opt);

disp(y); % Do something with the buffer of data


pause
end

6-40
buffer

H er e’s wh a t h a ppen s du r in g t h e fir st t h r ee it er a t ion s.

Iteration Input frame [z;x]' opt (input) opt (output) Output buffer (y) Overflow (z)

1 – skip
2 8
3 9
i=1 [1:11] 1 2 4 10 []
5 11
6 –
skip
7 –

12 skip
13
14
15
i=2 [12:22] 2 0 [20 21 22]
16
17
18
skip
19

– – skip
20 26
21 27
i=3 [20 21 22 23:33] 0 0 22 28 [32 33]
23 29
24 30 skip
25 31

Diagnostics E r r or m essa ges a r e displa yed wh en p≥n 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 6bu t ta p
Bu t t er wor t h a n a log lowpa ss filt er pr ot ot ype.

Syntax [z,p,k] = buttap(n)

Description [z,p,k] = buttap(n) r et u r n s t h e zer os, poles, a n d ga in of a n or der n


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 ) = ---------- = -----------------------------------------------------------------------------
p (s ) ( s – p (1 ) ) ( s – p (2 ) )Ls ( – p (n ) )
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 n–1 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

2 1
H ( ω) = -----------------------------------
-
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 z = [];
p = exp(sqrt(–1)*(pi*(1:2:2*n–1)/(2*n)+pi/2)).';
k = real(prod(–p));

See Also besselap Bessel a n a log lowpa ss filt er pr ot ot ype.


butter Bu t t er wor t h a n a log a n d digit a l filt er design .
cheb1ap Ch ebysh ev t ype I a n a log lowpa ss filt er pr ot ot ype.
cheb2ap Ch ebysh ev t ype II a n a log lowpa ss filt er pr ot ot ype.
ellipap 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 6bu t t er
Bu t t er wor t h a n a log a n d digit a l filt er design .

Syntax [b,a] = butter(n,Wn)


[b,a] = butter(n,Wn,'ftype')
[b,a] = butter(n,Wn,'s')
[b,a] = butter(n,Wn,'ftype','s')
[z,p,k] = butter(...)
[A,B,C,D] = butter(...)

Description butter design s lowpa ss, ba n dpa ss, h igh pa ss, a n d ba n dst op digit a l a n d a n a log
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 ) = ----------- = ---------------------------------------------------------------------------------
A (z ) 1 + a (2 )z – 1 + L+ a (n + 1 )z – n
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.
To obt a in st a t e-spa ce for m , u se fou r ou t pu t a r gu m en t s:

[A,B,C,D] = butter(n,Wn) or

[A,B,C,D] = butter(n,Wn,'ftype') wh er e A, B, C, a n d D a r e

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 ) s n + a (2 )s n –1 + L+ a (n + 1 )
butter’s 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

[b,a] = butter(n,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, 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.

To obt a in st a t e-spa ce for m , u se fou r ou t pu t a r gu m en t s:

[A,B,C,D] = butter(n,Wn,'s') or

[A,B,C,D] = butter(n,Wn,'ftype','s') wh er e A, B, C, a n d D a r e

·
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

Th e filt er ’s fr equ en cy r espon se is


freqz(b,a,128,1000)
100

0
Magnitude (dB)

−100

−200

−300

−400
0 100 200 300 400 500
Frequency (Hz)

200
Phase (degrees)

−200

−400

−600

−800
0 100 200 300 400 500
Frequency (Hz)

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.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.

Algorithm 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


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
wit h desir ed cu t off fr equ en cies, u sin g a st a t e-spa ce t r a n sfor m a t ion .
4 F or digit a l filt er design , butter 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
for m , a s r equ ir ed.

See Also besself Bessel a n a log filt er design .


buttap Bu t t er wor t h a n a log lowpa ss filt er pr ot ot ype.
buttord Bu t t er wor t h filt er or der select ion .
cheby1 Ch ebysh ev t ype I filt er design (pa ssba n d r ipple).
cheby2 Ch ebysh ev t ype II filt er design (st opba n d r ipple).
ellip E llipt ic (Ca u er ) filt er design .
maxflat Gen er a lized digit a l Bu t t er wor t h filt er design .

6-47
buttord

Purpose 6bu t tor d


Bu t t er wor t h filt er or der select ion .

Syntax [n,Wn] = buttord(Wp,Ws,Rp,Rs)


[n,Wn] = buttord(Wp,Ws,Rp,Rs,'s')

Description buttord select s t h e m in im u m or der digit a l or a n a log Bu t t er wor t h filt er


r equ ir ed t o m eet a set of filt er design specifica t ion s:

Wp 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).
Ws 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).
Rp 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.
Rs 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.

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
Magnitude Response (dB)

-100

-200

-300
0 50 100 150 200 250 300 350 400 450 500
Frequency (Hertz)

0
Phase (degrees)

-100

-200

-300

-400
0 50 100 150 200 250 300 350 400 450 500
Frequency (Hertz)

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)

100
Magnitude Response (dB)

-100

-200

-300
0 50 100 150 200 250 300 350 400 450 500
Frequency (Hertz)

500
Phase (degrees)

-500

-1000
0 50 100 150 200 250 300 350 400 450 500
Frequency (Hertz)

Algorithm buttord’s 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 butter Bu t t er wor t h a n a log a n d digit a l filt er design .


cheb1ord Ch ebysh ev t ype I filt er or der select ion .
cheb2ord Ch ebysh ev t ype II filt er or der select ion .
ellipord E llipt ic filt er or der select ion .
kaiserord 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 6cceps
Com plex cepst r a l a n a lysis.

Syntax xhat = cceps(x)


[xhat,nd] = cceps(x)
[xhat,nd,xhat1] = cceps(x)
[...] = cceps(x,n)

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 icceps In ver se com plex cepst r u m .


hilbert H ilber t t r a n sfor m .
rceps Rea l cepst r u m a n d m in im u m ph a se r econ st r u ct ion .
unwrap 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 6ch eb1a p


Ch ebysh ev t ype I a n a log lowpa ss filt er pr ot ot ype.

Syntax [z,p,k] = cheb1ap(n,Rp)

Description [z,p,k] = cheb1ap(n,Rp) r et u r n s t h e zer os, poles, a n d ga in of a n or der n


Ch ebysh ev t ype I a n a log lowpa ss filt er pr ot ot ype wit h Rp dB of r ipple in t h e
pa ssba n d. 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 ) = ---------- = -----------------------------------------------------------------------------
p (s ) ( s – p (1 ) ) ( s – p (2 ) )Ls ( – p (n ) )
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 besselap Bessel a n a log lowpa ss filt er pr ot ot ype.


buttap Bu t t er wor t h a n a log a n d digit a l filt er design .
cheb2ap Ch ebysh ev t ype I a n a log lowpa ss filt er pr ot ot ype.
cheby1 Ch ebysh ev t ype I filt er design (pa ssba n d r ipple).
ellipap 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 6ch eb1or d


Ch ebysh ev t ype I filt er or der select ion .

Syntax [n,Wn] = cheb1ord(Wp,Ws,Rp,Rs)


[n,Wn] = cheb1ord(Wp,Ws,Rp,Rs,'s')

Description cheb1ord 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 I filt er


r equ ir ed t o m eet a set of filt er design specifica t ion s:

Wp 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).
Ws 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).
Rp 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.
Rs 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.

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
50
Magnitude Response (dB)

-50

-100

-150

-200
0 50 100 150 200 250 300 350 400 450 500
Frequency (Hertz)

0
Phase (degrees)

-100

-200

-300
0 50 100 150 200 250 300 350 400 450 500
Frequency (Hertz)

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
0
Magnitude Response (dB)

-100

-200

-300
0 50 100 150 200 250 300 350 400 450 500
Frequency (Hertz)

0
Phase (degrees)

-200

-400

-600

-800
0 50 100 150 200 250 300 350 400 450 500
Frequency (Hertz)

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 buttord Bu t t er wor t h filt er or der select ion .


cheby1 Ch ebysh ev t ype I filt er design (pa ssba n d r ipple).
cheb2ord Ch ebysh ev t ype II filt er or der select ion .
ellipord E llipt ic filt er or der select ion .
kaiserord 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 6ch eb2a p


Ch ebysh ev t ype II a n a log lowpa ss filt er pr ot ot ype.

Syntax [z,p,k] = cheb2ap(n,Rs)

Description [z,p,k] = cheb2ap(n,Rs) fin ds t h e zer os, poles, a n d ga in of a n or der n


Ch ebysh ev t ype II a n a log lowpa ss filt er pr ot ot ype wit h st opba n d r ipple Rs dB
down fr om t h e pa ssba n d pea k va lu e. cheb2ap 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 sca la r k. If n is odd, z is len gt h
n–1. Th e t r a n sfer fu n ct ion is

z (s ) ( s – z (1 ) ) ( s – z (2 ) )Ls ( – z (n ) )
H (s ) = ---------- = k -----------------------------------------------------------------------------
p (s ) ( s – p (1 ) ) ( s – p (2 ) )Ls ( – p (n ) )
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


filt er in t o a h igh pa ss filt er wh ile pr eser vin g t h e per for m a n ce a t ω = 1.
2 cheb2ap su bt r a ct s t h e filt er t r a n sfer fu n ct ion fr om u n it y.

See Also besselap Bessel a n a log lowpa ss filt er pr ot ot ype.


buttap Bu t t er wor t h a n a log lowpa ss filt er pr ot ot ype.
cheb1ap Ch ebysh ev t ype I a n a log lowpa ss filt er pr ot ot ype.
cheby2 Ch ebysh ev t ype II filt er design (st opba n d r ipple).
ellipap 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 6ch eb2or d


Ch ebysh ev t ype II filt er or der select ion .

Syntax [n,Wn] = cheb2ord(Wp,Ws,Rp,Rs)


[n,Wn] = cheb2ord(Wp,Ws,Rp,Rs,'s')

Description 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


r equ ir ed t o m eet a set of filt er design specifica t ion s:

Wp 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).
Ws 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).
Rp 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.
Rs 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.

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
Magnitude Response (dB)

-20

-40

-60

-80
0 50 100 150 200 250 300 350 400 450 500
Frequency (Hertz)

0
Phase (degrees)

-50

-100

-150

-200
0 50 100 150 200 250 300 350 400 450 500
Frequency (Hertz)

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

[b,a] = cheby2(n,Rs,Wn);
freqz(b,a,512,1000)
title('n=4 Chebyshev Type II Bandpass Filter')
n = 4 Chebyshev Type II Bandpass Filter
0
Magnitude Response (dB)

-20

-40

-60

-80
0 50 100 150 200 250 300 350 400 450 500
Frequency (Hertz)

400
Phase (degrees)

200

-200

-400
0 50 100 150 200 250 300 350 400 450 500
Frequency (Hertz)

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 buttord Bu t t er wor t h filt er or der select ion .


cheb1ord Ch ebysh ev t ype I filt er or der select ion .
cheby2 Ch ebysh ev t ype II filt er design (st opba n d r ipple).
ellipord E llipt ic filt er or der select ion .
kaiserord 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 6ch ebwin


Ch ebysh ev win dow.

Syntax w = chebwin(n,r)

Description w = chebwin(n,r) r et u r n s t h e colu m n vect or w, con t a in in g t h e len gt h n


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 bartlett Ba r t let t win dow.


blackman Bla ck m a n win dow.
boxcar Rect a n gu la r win dow.
hamming H a m m in g win dow.
hanning H a n n in g win dow.
kaiser Ka iser win dow.
triang 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 6ch eby1


Ch ebysh ev t ype I filt er design (pa ssba n d r ipple).

Syntax [b,a] = cheby1(n,Rp,Wn)


[b,a] = cheby1(n,Rp,Wn,'ftype')
[b,a] = cheby1(n,Rp,Wn,'s')
[b,a] = cheby1(n,Rp,Wn,'ftype','s')
[z,p,k] = cheby1(...)
[A,B,C,D] = cheby1(...)

Description cheby1 design s lowpa ss, ba n dpa ss, h igh pa ss, a n d ba n dst op digit a l a n d a n a log
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 ) 1 + a (2 )z – 1 + L+ a (n + 1 )z – n
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.
To obt a in st a t e-spa ce for m , u se fou r ou t pu t a r gu m en t s:

[A,B,C,D] = cheby1(n,Rp,Wn) or

[A,B,C,D] = cheby1(n,Rp,Wn,'ftype') wh er e A, B, C, a n d D a r e

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 ) s n + a (2 )s n –1 + L+ a (n + 1 )
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

[b,a] = cheby1(n,Rp,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.


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.
To obt a in st a t e-spa ce for m , u se fou r ou t pu t a r gu m en t s:

[A,B,C,D] = cheby1(n,Rp,Wn,'s') or

[A,B,C,D] = cheby1(n,Rp,Wn,'ftype','s') wh er e A, B, C, a n d D a r e defin ed


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

Th e fr equ en cy r espon se of t h e filt er is


freqz(b,a,512,1000)
n = 9 Chebyshev Type I Lowpass Filter
100
Magnitude Response (dB)

-100

-200

-300
0 50 100 150 200 250 300 350 400 450 500
Frequency (Hertz)

-200
Phase (degrees)

-400

-600

-800

-1000
0 50 100 150 200 250 300 350 400 450 500
Frequency (Hertz)

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.

Algorithm 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


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
wit h desir ed cu t off fr equ en cies, u sin g a st a t e-spa ce t r a n sfor m a t ion .
4 F or digit a l filt er design , cheby1 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
for m , a s r equ ir ed.

See Also besself Bessel a n a log filt er design .


butter Bu t t er wor t h a n a log a n d digit a l filt er design .
cheb1ap Ch ebysh ev t ype I a n a log lowpa ss filt er pr ot ot ype.
cheb1ord Ch ebysh ev t ype I filt er or der select ion .
cheby2 Ch ebysh ev t ype II filt er design (st opba n d r ipple).
ellip E llipt ic (Ca u er ) filt er design .

6-69
cheby2

Purpose 6ch eby2


Ch ebysh ev t ype II filt er design (st opba n d r ipple).

Syntax [b,a] = cheby2(n,Rs,Wn)


[b,a] = cheby2(n,Rs,Wn,'ftype')
[b,a] = cheby2(n,Rs,Wn,'s')
[b,a] = cheby2(n,Rs,Wn,'ftype','s')
[z,p,k] = cheby2(...)
[A,B,C,D] = cheby2(...)

Description cheby2 design s lowpa ss, h igh pa ss, ba n dpa ss, a n d ba n dst op digit a l a n d a n a log
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 ) 1 + a (2 )z – 1 + L+ a (n + 1 )z – n
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.
To obt a in st a t e-spa ce for m , u se fou r ou t pu t a r gu m en t s:

[A,B,C,D] = cheby2(n,Rs,Wn) or

[A,B,C,D] = cheby2(n,Rs,Wn,'ftype') wh er e A, B, C, a n d D a r e

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 ) s n + a (2 )s n – 1 + L+ a (n + 1 )
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.
To obt a in st a t e-spa ce for m , u se fou r ou t pu t a r gu m en t s:

[A,B,C,D] = cheby2(n,Rs,Wn,'s') or

[A,B,C,D] = cheby2(n,Rs,Wn,'ftype','s') wh er e A, B, C, a n d D a r e

·
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

Th e fr equ en cy r espon se of t h e filt er is


freqz(b,a,512,1000)

n = 9 Chebyshev Type II Filter


20
Magnitude Response (dB)

-20

-40

-60

-80
0 50 100 150 200 250 300 350 400 450 500
Frequency (Hertz)

100

0
Phase (degrees)

-100

-200

-300

-400
0 50 100 150 200 250 300 350 400 450 500
Frequency (Hertz)

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.

Algorithm 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


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
wit h desir ed cu t off fr equ en cies, u sin g a st a t e-spa ce t r a n sfor m a t ion .
4 F or digit a l filt er design , cheby2 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
for m , a s r equ ir ed.

See Also besself Bessel a n a log filt er design .


butter Bu t t er wor t h a n a log a n d digit a l filt er design .
cheb2ap Ch ebysh ev t ype II a n a log lowpa ss filt er pr ot ot ype.
cheb2ord Ch ebysh ev t ype II filt er or der select ion .
cheby1 Ch ebysh ev t ype I filt er design (pa ssba n d r ipple).
ellip E llipt ic (Ca u er ) filt er design .

6-74
chirp

Purpose 6ch ir p
Swept -fr equ en cy cosin e gen er a t or .

Syntax y = chirp(t,f0,t1,f1)
y = chirp(t,f0,t1,f1,'method')
y = chirp(t,f0,t1,f1,'method',phi)

Description y = chirp(t,f0,t1,f1) gen er a t es sa m ples of a lin ea r swept -fr equ en cy cosin e


sign a l a t t h e t im e in st a n ces defin ed in a r r a y t, wh er e f0 is t h e in st a n t a n eou s
fr equ en cy a t t im e 0, a n d f1 is t h e in st a n t a n eou s fr equ en cy a t t im e t1. f0 a n d
f1 a r e bot h in H er t z. If u n specified, f0 is 0, t1 is 1, a n d f1 is 100.

y = chirp(t,f0,t1,f1,'method') specifies a lt er n a t ive sweep m et h od


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 Com pu t e t h e spect r ogr a m of a ch ir p wit h lin ea r in st a n t a n eou s fr equ en cy


devia t ion :
t = 0:0.001:2; % 2 secs @ 1kHz sample rate
y = chirp(t,0,1,150); % Start @ DC, cross 150Hz at t=1 sec
specgram(y,256,1e3,256,250) % Display the spectrogram

500

450

400

350

300
Frequency

250

200

150

100

50

0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6
Time

6-76
chirp

Com pu t e t h e spect r ogr a m of a ch ir p wit h qu a dr a t ic in st a n t a n eou s fr equ en cy


devia t ion :
t = –2:0.001:2; % ±2 secs @ 1kHz sample rate
y = chirp(t,100,1,200,'quadratic'); % Start @ 100Hz, cross 200Hz
% at t=1 sec
specgram(y,128,1e3,128,120) % Display the spectrogram

500

450

400

350

300
Frequency

250

200

150

100

50

0
0 0.5 1 1.5 2 2.5 3 3.5
Time

6-77
chirp

See Also cos 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).
diric Dir ich let or per iodic sin c fu n ct ion .
gauspuls Ga u ssia n -m odu la t ed sin u soida l pu lse gen er a t or.
pulstran P u lse t r a in gen er a t or.
rectpuls Sa m pled a per iodic r ect a n gle gen er a t or.
sawtooth Sawt oot h or t r ia n gle wave gen er a t or.
sin 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).
sinc Sin c fu n ct ion .
square Squ a r e wa ve gen er a t or.
tripuls Sa m pled a per iodic t r ia n gle gen er a t or.

6-78
cohere

Purpose 6coh er 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.

Syntax Cxy = cohere(x,y)


Cxy = cohere(x,y,nfft)
[Cxy,f] = cohere(x,y,nfft,Fs)
Cxy = cohere(x,y,nfft,Fs,window)
Cxy = cohere(x,y,nfft,Fs,window,noverlap)
Cxy = cohere(x,y,...,'dflag')
cohere(x,y)

Description Cxy = cohere(x,y) fin ds t h e m a gn it u de squ a r ed coh er en ce bet ween len gt h n


sign a l vect or s x a n d y. Th e coh er en ce is a fu n ct ion of t h e power spect r a of x a n d
y a n d t h e cr oss spect r u m of x a n d y:

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:
• 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 cohere 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 coh er en ce 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 cohere 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 you om it
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, 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.

You ca n u se t h e em pt y m a t r ix [] t o specify t h e defa u lt va lu e for a n y in pu t


a r gu m en t except x or y. F or exa m ple,
Cxy = cohere(x,y,[],[],kaiser(128,5));

u ses 256 a s t h e va lu e for nfft a n d 2 a s t h e va lu e for Fs.

Cxy = cohere(x,y,...,'dflag') specifies a det r en d opt ion , wh er e dflag is

• 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


fr equ en cy in t h e cu r r en t figu r e win dow.

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.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 1
Frequency

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 window's length to be no greater than the FFT length.
Requires NOVERLAP to be strictly less than the window length.
Requires positive integer values for NFFT and NOVERLAP.
Requires vector (either row or column) input.
Requires inputs X and Y to have the same length.

Algorithm cohere est im a t es t h e m a gn it u de squ a r ed coh er en ce fu n ct ion [1] u sin g Welch ’s


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


sect ion , a n d m u lt iplies ea ch sect ion by window.
2 It ca lcu la t es t h e len gt h nfft fa st F ou r ier t r a n sfor m of ea ch sect ion .
3 It a ver a ges t h e squ a r es of t h e spect r a of t h e x sect ion s t o for m Pxx, a ver a ges
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 csd 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.
pwelch 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.
tfe 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 6con v
Con volu t ion a n d polyn om ia l m u lt iplica t ion .

Syntax c = conv(a,b)

Description conv(a,b) con volves vect or s a a n d b. Th e con volu t ion su m is

N –1

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 Th e con volu t ion of a = [1 2 3] a n d b = [4 5 6] is


c = conv(a,b)

c =
4 13 28 27 18

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 .

See Also conv2 Two-dim en sion a l con volu t ion .


convmtx Con volu t ion m a t r ix.
convn 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).
deconv Decon volu t ion a n d polyn om ia l division .
filter 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.
residuez z-t r a n sfor m pa r t ia l fr a ct ion expa n sion .
xcorr Cr oss-cor r ela t ion fu n ct ion est im a t e.

6-83
conv2

Purpose 6con v2
Two-dim en sion a l con volu t ion .

Syntax C = conv2(A,B)
C = conv2(A,B,'shape')

Description C = conv2(A,B) com pu t es t h e t wo-dim en sion a l con volu t ion of m a t r ices A a n d


B. If on e of t h ese m a t r ices descr ibes a t wo-dim en sion a l F IR filt er , t h e ot h er
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+mb–1,na+nb–1]

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) = [ma–mb+1,na–nb+1]
wh en size(A) > size(B)

conv2 execu t es m ost qu ickly wh en size(A) > size(B).

Th e conv2 fu n ct ion is pa r t of t h e st a n da r d MATLAB la n gu a ge.

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];

Given a n y im a ge, t h e followin g lin e ext r a ct s t h e h or izon t a l edges:


h = conv2(I,s);

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 conv Con volu t ion a n d polyn om ia l m u lt iplica t ion .


convn 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).
deconv Decon volu t ion a n d polyn om ia l division .
filter2 Two-dim en sion a l digit a l filt er in g.
xcorr Cr oss-cor r ela t ion fu n ct ion est im a t e.
xcorr2 Two-dim en sion a l cr oss-cor r ela t ion .

6-85
convmtx

Purpose 6con vm t x
Con volu t ion m a t r ix.

Syntax A = convmtx(c,n)
A = convmtx(r,n)

Description 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 + n–1)-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 + n–1). 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 Gen er a t e a sim ple con volu t ion m a t r ix:


h = [1 2 3 2 1];
convmtx(h,7)
ans =

1 2 3 2 1 0 0 0 0 0 0
0 1 2 3 2 1 0 0 0 0 0
0 0 1 2 3 2 1 0 0 0 0
0 0 0 1 2 3 2 1 0 0 0
0 0 0 0 1 2 3 2 1 0 0
0 0 0 0 0 1 2 3 2 1 0
0 0 0 0 0 0 1 2 3 2 1

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)

t h a n by u sin g a con volu t ion m a t r ix:


n = length(x);
y = convmtx(c,n)*x

Algorithm convmtx u ses t h e fu n ct ion toeplitz t o gen er a t e t h e con volu t ion m a t r ix.

6-86
convmtx

See Also conv Con volu t ion a n d polyn om ia l m u lt iplica t ion .


convn 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).
conv2 Two-dim en sion a l con volu t ion .
dftmtx Discr et e Fou r ier t r a n sfor m m a t r ix.

6-87
corrcoef

Purpose 6cor r coef


Cor r ela t ion coefficien t m a t r ix.

Syntax C = corrcoef(X)
C = corrcoef(X,Y)

Description corrcoef r et u r n s a m a t r ix of cor r ela t ion coefficien t s ca lcu la t ed fr om a n in pu t


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.
Th e corrcoef fu n ct ion is pa r t of t h e st a n da r d MATLAB la n gu a ge.

See Also cov Cova r ia n ce m a t r ix.


mean Aver a ge va lu e (see t h e on lin e M AT L AB Fu n ction
R eferen ce).
median Media n va lu e (see t h e on lin e M AT L AB Fu n ction
R eferen ce).
std 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).
xcorr Cr oss-cor r ela t ion fu n ct ion est im a t e.
xcov 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 6cov
Cova r ia n ce m a t r ix.

Syntax c = cov(x)
c = cov(x,y)

Description 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)/(n–1) 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.

Th e cov 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 [n,p] = size(x);


x = x–ones(n,1)*(sum(x)/n);
y = x'*x/(n–1);

See Also corrcoef Cor r ela t ion coefficien t m a t r ix.


mean Aver a ge va lu e (see t h e on lin e M AT L AB Fu n ction
R eferen ce).
median Media n va lu e (see t h e on lin e M AT L AB Fu n ction
R eferen ce).
std 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).
xcorr Cr oss-cor r ela t ion fu n ct ion est im a t e.
xcov 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 6cp lxpa ir


Gr ou p com plex n u m ber s in t o com plex con ju ga t e pa ir s.

Syntax y = cplxpair(x)
y = cplxpair(x,tol)

Description y = cplxpair(x) r et u r n s x wit h com plex con ju ga t e pa ir s gr ou ped t oget h er .


cplxpair or der s t h e con ju ga t e pa ir s by in cr ea sin g r ea l pa r t . Wit h in a pa ir , t h e
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.
Th e cplxpair 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 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.5878i
–0.8090 + 0.5878i
0.3090 – 0.9511i
0.3090 + 0.9511i
1.0000

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 6cr em ez
Com plex a n d n on lin ea r -ph a se equ ir ipple F IR filt er design .

Syntax b = cremez(n,f,'fresp')
b = cremez(n,f,'fresp',w)
b = cremez(n,f,{'fresp',p1,p2,...},w)
b = cremez(n,f,a,w)
b = cremez(...,'sym')
b = cremez(...,'skip_stage2')
b = cremez(...,'debug')
b = cremez(...,{lgrid})
[b,delta,opt] = cremez(...)

Description cremez a llows a r bit r a r y fr equ en cy-dom a in con st r a in t s t o be specified for t h e


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)
H ilber t t r a n sfor m filt er .

b = cremez(n,f,a,w) is a syn on ym for


b = cremez(n,f,{'multiband',a},w).

b = cremez(...,'sym') im poses a sym m et r y con st r a in t on t h e im pu lse


r espon se of t h e design , wh er e 'sym' m a y be on e of t h e followin g:

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 F r equ en cy gr id vect or u sed for t h e filt er design opt im iza t ion
opt.des Desir ed fr equ en cy r espon se for ea ch poin t in opt.fgrid
opt.wt Weigh t in g for ea ch poin t in opt.fgrid
opt.H Act u a l fr equ en cy r espon se for ea ch poin t in opt.fgrid
opt.error E r r or a t ea ch poin t in opt.fgrid
opt.iextr Vect or of in dices in t o opt.fgrid for ext r em a l fr equ en cies
opt.fextr 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

−100
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Normalized Angular Frequency (×π rads/sample)

0
Phase (degrees)

−1000

−2000

−3000

−4000
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Normalized Angular Frequency (×π rads/sample)

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; % Filter order


f = [–1 1]; % Frequency band edges
w = [1 1]; % Weights for optimization
gf = linspace(–1,1,256); % Grid of frequency points
d = allpass(n,f,gf,w); % 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.1

−0.2
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Normalized Angular Frequency (×π rads/sample)

0
Phase (degrees)

−1000

−2000

−3000
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Normalized Angular Frequency (×π rads/sample)

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.1

−0.2
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Normalized Angular Frequency (×π rads/sample)

0
Approximation
Phase (degrees)

Desired
−1000

−2000

−3000
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Normalized Angular Frequency (×π rads/sample)

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 Th e followin g dia gn ost ic m essa ges a r ise fr om in cor r ect u sa ge of cremez:
Not enough input arguments.

F must contain an even number of band edge entries.

Band edges must be monotonically increasing.

Expecting a string argument.

Invalid argument arg specified.

Invalid default symmetry option sym returned from response


function fresp. Must be one of 'none', 'real', 'even', or 'odd'.

Frequency band edges must be in the range [–1,+1] for designs with
SYM = 'sym'.

Frequency band edges must be in the range [0,+1] for designs with
SYM = 'sym'.

Incorrect size of results from response function fresp. Sizes must


be the same size as the frequency grid GF.

Both –1 and 1 have been specified as frequencies in F, and the


frequency spacing is too close to move either of them toward its
neighbor.

Internal error: Grid frequencies out of range.

Internal error: domain must be "whole" or "half".

Internal error: obtained a negative bandwidth.

Internal error: two extremal frequecies at the same grid point.

Internal error: dBrange must be > 0.

6-98
cremez

See Also fir1 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.
fir2 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.
firls Lea st squ a r e lin ea r -ph a se F IR filt er design .
remez P a r ks-McClella n opt im a l F IR filt er design .
private/bandpass Ba n dpa ss filt er design fu n ct ion .
private/bandstop Ba n dst op filt er design fu n ct ion .
private/different Differ en t ia t or filt er design fu n ct ion .
iator
private/highpass H igh pa ss filt er design fu n ct ion .
private/hilbfilt H ilber t filt er design fu n ct ion .
private/lowpass Lowpa ss filt er design fu n ct ion .
private/multiband 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 6csd
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.

Syntax Pxy = csd(x,y)


Pxy = csd(x,y,nfft)
[Pxy,f] = csd(x,y,nfft,Fs)
Pxy = csd(x,y,nfft,Fs,window)
Pxy = csd(x,y,nfft,Fs,window,noverlap)
Pxy = csd(x,y,...,'dflag')
[Pxy,Pxyc,f] = csd(x,y,nfft,Fs,window,noverlap,p)
csd(x,y,...)

Description Pxy = csd(x,y) est im a t es t h e cr oss spect r a l den sit y of t h e len gt h n sequ en ces
x a n d y u sin g t h e Welch m et h od of spect r a l est im a t ion . Pxy = csd(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 csd 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 cr oss 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 csd 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 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 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.
You ca n u se t h e em pt y m a t r ix [] t o specify t h e defa u lt va lu e for a n y in pu t
a r gu m en t except x or y. F or exa m ple,
csd(x,y,[],10000)

is equ iva len t t o


csd(x)

bu t wit h a sa m plin g fr equ en cy of 10,000 H z in st ea d of t h e defa u lt of 2 H z.

Pxy = csd(x,y,...,'dflag') specifies a det r en d opt ion , wh er e dflag is:

• 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

0
Cross Spectrum Magnitude (dB)

-10

-20

-30

-40

-50

-60

-70
0 1000 2000 3000 4000 5000
Frequency

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


det r en ded sect ion .
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 pr odu ct of t h e
t r a n sfor m of t h e y sect ion a n d t h e con ju ga t e of t h e t r a n sfor m ed x sect ion .

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
Pxy, t h e cr oss spect r a l den sit y of x a n d y.
Th e n u m ber of sect ion s t h a t csd a ver a ges is k, wh er e k is
fix((length(x)–noverlap)/(length(window)–noverlap))

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 window's length to be no greater than the FFT length.


Requires NOVERLAP to be strictly less than the window length.
Requires positive integer values for NFFT and NOVERLAP.
Requires vector (either row or column) input.
Requires inputs X and Y to have the same length.
Requires confidence parameter to be a scalar between 0 and 1.

See Also cohere 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.
pburg Power spect r u m est im a t e u sin g t h e Bu r g m et h od.
pmtm 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).
pmusic Power spect r u m est im a t e u sin g MUSIC eigen vect or
m et h od.
pwelch 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.
pyulear Power spect r u m est im a t e u sin g Yu le-Wa lker AR
m et h od.
tfe 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 6czt
Ch ir p z-t r a n sfor m .

Syntax y = czt(x,m,w,a)
y = czt(x)

Description 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
st a r t in g poin t on t h a t con t ou r . Th e con t ou r , a spir a l or “ch ir p” in t h e z-pla n e, is
given by
z = a*(w.^–(0:m–1))

y = czt(x) u ses t h e followin g defa u lt va lu es:

• 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

E st a blish fr equ en cy a n d CZT pa r a m et er s:


Fs = 1000; f1 = 100; f2 = 150; % in Hertz
m = 1024;
w = exp(–j*2*pi*(f2–f1)/(m*Fs));
a = exp(j*2*pi*f1/Fs);

Com pu t e bot h t h e DF T a n d CZT of t h e filt er :


y = fft(h,1000);
z = czt(h,m,w,a);

Cr ea t e fr equ en cy vect or s a n d com pa r e t h e r esu lt s:


fy = (0:length(y)–1)'*1000/length(y);
fz = ((0:length(z)–1)'*(f2–f1)/length(z)) + f1;
plot(fy(1:500),abs(y(1:500))); axis([1 500 0 1.2])
title('FFT')
figure
plot(fz,abs(z)); axis([f1 f2 0 1.2])
title('CZT')
FFT CZT

1 1

0.8 0.8

0.6 0.6

0.4 0.4

0.2 0.2

0 0
100 200 300 400 500 100 110 120 130 140

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 If m, w, or a is n ot a sca la r , czt gives t h e followin g er r or m essa ge:


Inputs M, W, and A must be scalars.

6-106
czt

See Also fft On e-dim en sion a l fa st Fou r ier t r a n sfor m .


freqz F r equ en cy r espon se of digit a l filt er s.

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 6dct
Discr et e cosin e t r a n sfor m (DCT).

Syntax y = dct(x)
y = dct(x,n)

Description y = dct(x) r et u r n s t h e u n it a r y discr et e cosin e t r a n sfor m of x

N
π(2 n – 1 )(k – 1 )
y (k ) = w (k ) ∑ x (n ) cos -------------------------------------------,
2N
k = 1 , …, N
n =1

wh er e

⎧ 1
⎪ ---------, k =1
⎪ N
w (k ) = ⎨
⎪ 2
⎪ ----N
, 2≤k ≤N
⎩

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 F in d h ow m a n y DCT coefficien t s r epr esen t 99% of t h e en er gy in a sequ en ce:


x = (1:100) + 50*cos((1:100)*2*pi/40);
X = dct(x);
[XX,ind] = sort(abs(X)); ind = fliplr(ind);
i = 1;
while (norm([X(ind(1:i)) zeros(1,100–i)])/norm(X)<.99)
i = i + 1;
end

i =
3

See Also fft On e-dim en sion a l fa st Fou r ier t r a n sfor m .


idct In ver se discr et e cosin e t r a n sfor m .
dct2 Two-dim en sion a l DCT (see Im age Processin g T oolbox
User’s Gu id e).
idct2 Two-dim en sion a l in ver se DCT (see Im age Processin g
T oolbox User’s 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 6decim a t e
Decr ea se t h e sa m plin g r a t e for a sequ en ce (decim a t ion ).

Syntax y = decimate(x,r)
y = decimate(x,r,n)
y = decimate(x,r,'fir')
y = decimate(x,r,n,'fir')

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 Decim a t e a sign a l by a fa ct or of fou r :


t = 0:.00025:1; % time vector
x = sin(2*pi*30*t) + sin(2*pi*60*t);
y = decimate(x,4);

6-110
decimate

View t h e or igin a l a n d decim a t ed sign a ls:


stem(x(1:120)), axis([0 120 –2 2]) % original signal
title('Original Signal')
figure
stem(y(1:30)) % decimated signal
title('Decimated Signal')

Original Signal Decimated Signal


2 2

1 1

0 0

-1 -1

-2 -2
0 50 100 0 10 20 30

Algorithm decimate u ses decim a t ion a lgor it h m s 8.2 a n d 8.3 fr om [1]:

1 It design s a lowpa ss filt er . By defa u lt , decimate u ses a Ch ebysh ev t ype I


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 If r is n ot a n in t eger , decimate gives t h e followin g er r or m essa ge:


Resampling rate R must be an integer.

If n specifies a n IIR filt er wit h or der gr ea t er t h a n 13, decimate gives t h e


followin g wa r n in g:
Warning: IIR filters above order 13 may be unreliable.

6-111
decimate

See Also interp 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 ).


resample 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.
spline 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).
upfirdn 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 6decon v
Decon volu t ion a n d polyn om ia l division .

Syntax [q,r] = deconv(b,a)

Description [q,r] = deconv(b,a) decon volves vect or a ou t of vect or b, u sin g lon g division .
Th e r esu lt (qu ot ien t ) is r et u r n ed in vect or q a n d t h e r em a in der in vect or r su ch
t h a t b = conv(q,a) + r.
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 e con volu t ion of a = [1 2 3] a n d b = [4 5 6] is


c = conv(a,b)

c =
4 13 28 27 18

Use deconv t o divide b ba ck ou t :


[q,r] = deconv(c,a)

q =
4 5 6

r =
0 0 0 0 0

Algorithm 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 .

See Also conv Con volu t ion a n d polyn om ia l m u lt iplica t ion .


filter 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.
residuez z-t r a n sfor m pa r t ia l fr a ct ion expa n sion .

6-113
demod

Purpose 6dem od
Dem odu la t ion for com m u n ica t ion s sim u la t ion .

Syntax x = demod(y,Fc,Fs,'method')
x = demod(y,Fc,Fs,'method',opt)
x = demod(y,Fc,Fs,'pwm','centered')
[x1,x2] = demod(y,Fc,Fs,'qam')

Description demod per for m s dem odu la t ion , t h a t is, it obt a in s t h e or igin a l sign a l fr om a
m odu la t ed ver sion of t h e sign a l. demod u n does t h e oper a t ion per for m ed by
modulate.

x = demod(y,Fc,Fs,'method') a n d

x = demod(y,Fc,Fs,'method',opt) dem odu la t e t h e r ea l ca r r ier sign a l y wit h


a ca r r ier fr equ en cy Fc a n d sa m plin g fr equ en cy Fs, u sin g on e of t h e opt ion s
list ed below for method. (Not e t h a t som e m et h ods a ccept a n opt ion , opt.)
amdsb–sc 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 , s u p p re s s e 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
or 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);
am [b,a] = butter(5,Fc*2/Fs);
x = filtfilt(b,a,x);
amdsb–tc 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
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);
If you specify opt, demod su bt r a ct s sca la r opt fr om x. Th e defa u lt
va lu e for opt is 0.
amssb 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 .
pm 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 .
ptm 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.
pwm 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.
qam 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);

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 Modu la t ion for com m u n ica t ion s sim u la t ion .
vco Volt a ge con t r olled oscilla t or.

6-116
dftmtx

Purpose 6dft m t x
Discr et e F ou r ier t r a n sfor m m a t r ix.

Syntax A = dftmtx(n)

Description 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

com pu t es t h e discr et e F ou r ier t r a n sfor m of x.


Th e in ver se discr et e F ou r ier t r a n sfor m m a t r ix is
Ai = conj(dftmtx(n))/n

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

t h a n by u sin g t h e F ou r ier t r a n sfor m m a t r ix:


n = length(x);
y2 = x*dftmtx(n);
norm(y1–y2)

ans =
1.8297e-009

Algorithm dftmtx u ses a n ou t er pr odu ct t o gen er a t e t h e t r a n sfor m m a t r ix.

See Also convmtx Con volu t ion m a t r ix.


fft On e-dim en sion a l fa st Fou r ier t r a n sfor m .

6-117
diric

Purpose 6dir ic
Dir ich let or per iodic sin c fu n ct ion .

Syntax y = diric(x,n)

Description y = diric(x,n) r et u r n s a vect or or a r r a y y t h e sa m e size a s x. Th e elem en t s


of y a r e t h e Dir ich let fu n ct ion of t h e elem en t s of x. n m u st be a posit ive in t eger .
Th e Dir ich let fu n ct ion , or per iodic sin c fu n ct ion , is

x
⎧ ------ - (n – 1 )
⎪ – 1 2 π x = 0 , ± 2 π, ± 4 π, …
dir ic(x , n ) = ⎨
⎪ sin ( n x ⁄ 2 ) else
⎩ ---------------------------
n sin ( x ⁄ 2 )
-

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 If n is n ot a posit ive in t eger , diric gives t h e followin g er r or m essa ge:


Requires n to be a positive integer.

See Also cos 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).
gauspuls Ga u ssia n -m odu la t ed sin u soida l pu lse gen er a t or.
pulstran P u lse t r a in gen er a t or.
rectpuls Sa m pled a per iodic r ect a n gle gen er a t or.
sawtooth Sawt oot h or t r ia n gle wave gen er a t or.
sin 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).
sinc Sin c or sin (πt )/πt fu n ct ion .
square Squ a r e wa ve gen er a t or.
tripuls Sa m pled a per iodic t r ia n gle gen er a t or.

6-118
dpss

Purpose 6dpss
Discr et e pr ola t e sph er oida l sequ en ces (Slepia n sequ en ces).

Syntax [e,v] = dpss(n,nw)


[e,v] = dpss(n,nw,k)
[e,v] = dpss(n,nw,[k1 k2])
[e,v] = dpss(n,nw,'spline')
[e,v] = dpss(n,nw,'spline',Ni)
[e,v] = dpss(n,nw,'linear')
[e,v] = dpss(n,nw,'linear',Ni)
[e,v] = dpss(...,'trace')
[e,v] = dpss(...,'int','trace')

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 ≤ k1 ≤ k2 ≤ (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 |ω| ≤ (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
|ω| ≤ (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 dpssclear Rem ove discr et e pr ola t e sph er oida l sequ en ces fr om
da t a ba se.
dpssdir Discr et e pr ola t e sph er oida l sequ en ces da t a ba se
dir ect or y.
dpssload Loa d discr et e pr ola t e sph er oida l sequ en ces fr om
da t a ba se.
dpsssave Save discr et e pr ola t e sph er oida l sequ en ces in
da t a ba se.
pmtm 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 6dpssclea r
Rem ove discr et e pr ola t e sph er oida l sequ en ces fr om da t a ba se.

Syntax dpssclear(n,nw)

Description dpssclear(n,nw) r em oves sequ en ces wit h len gt h n a n d t im e-ba n dwidt h


pr odu ct nw fr om t h e DP SS MAT-file da t a ba se dpss.mat.

See Also dpss Discr et e pr ola t e sph er oida l sequ en ces (Slepia n
sequ en ces).
dpssdir Discr et e pr ola t e sph er oida l sequ en ces da t a ba se
dir ect or y.
dpssload Loa d discr et e pr ola t e sph er oida l sequ en ces fr om
da t a ba se.
dpsssave 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 6dpssdir
Discr et e pr ola t e sph er oida l sequ en ces da t a ba se dir ect or y.

Syntax dpssdir
dpssdir(n)
dpssdir(nw,'nw')
dpssdir(n,nw)
index = dpssdir

Description dpssdir m a n a ges t h e da t a ba se dir ect or y t h a t con t a in s t h e gen er a t ed DP SS


sa m ples in t h e DP SS MAT-file da t a ba se dpss.mat.

dpssdir list s t h e dir ect or y of sa ved sequ en ces in dpss.mat.

dpssdir(n) list s t h e sequ en ces sa ved wit h len gt h n.

dpssdir(nw,'nw') list s t h e sequ en ces sa ved wit h t im e-ba n dwidt h pr odu ct nw.

dpssdir(n,nw) list s t h e sequ en ces sa ved wit h len gt h n a n d t im e-ba n dwidt h


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 dpss Discr et e pr ola t e sph er oida l sequ en ces (Slepia n
sequ en ces).
dpssclear Rem ove discr et e pr ola t e sph er oida l sequ en ces fr om
da t a ba se.
dpssload Loa d discr et e pr ola t e sph er oida l sequ en ces fr om
da t a ba se.
dpsssave 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 6dpssloa d
Loa d discr et e pr ola t e sph er oida l sequ en ces fr om da t a ba se.

Syntax [e,v] = dpssload(n,nw)

Description [e,v] = dpssload(n,nw) loa ds a ll sequ en ces wit h len gt h n a n d


t im e-ba n dwidt h pr odu ct nw 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 fr om t h e DP SS MAT-file da t a ba se dpss.mat.

See Also dpss Discr et e pr ola t e sph er oida l sequ en ces (Slepia n
sequ en ces).
dpssclear Rem ove discr et e pr ola t e sph er oida l sequ en ces fr om
da t a ba se.
dpssdir Discr et e pr ola t e sph er oida l sequ en ces da t a ba se
dir ect or y.
dpsssave 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 6dpsssa ve
Sa ve discr et e pr ola t e sph er oida l sequ en ces in da t a ba se.

Syntax dpsssave(nw,e,v)
status = dpsssave(nw,e,v)

Description dpsssave(nw,e,v) sa ves t h e sequ en ces 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 in t h e DP SS MAT-file da t a ba se
dpss.mat.

• 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 dpss Discr et e pr ola t e sph er oida l sequ en ces (Slepia n
sequ en ces).
dpssclear Rem ove discr et e pr ola t e sph er oida l sequ en ces fr om
da t a ba se.
dpssdir Discr et e pr ola t e sph er oida l sequ en ces da t a ba se
dir ect or y.
dpssload 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 6ellip
E llipt ic (Ca u er ) filt er design .

Syntax [b,a] = ellip(n,Rp,Rs,Wn)


[b,a] = ellip(n,Rp,Rs,Wn,'ftype')
[b,a] = ellip(n,Rp,Rs,Wn,'s')
[b,a] = ellip(n,Rp,Rs,Wn,'ftype','s')
[z,p,k] = ellip(...)
[A,B,C,D] = ellip(...)

Description ellip design s lowpa ss, ba n dpa ss, h igh pa ss, a n d ba n dst op digit a l a n d a n a log
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 ) 1 + a (2 )z – 1 + L+ a (n + 1 )z – n
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.

To obt a in st a t e-spa ce for m , u se fou r ou t pu t a r gu m en t s:

[A,B,C,D] = ellip(n,Rp,Rs,Wn) or

[A,B,C,D] = ellip(n,Rp,Rs,Wn,'ftype') wh er e A, B, C, a n d D a r e

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 ) s n + a (2 )s n –1 + L+ a (n + 1 )
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

[b,a] = ellip(n,Rp,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 . 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.
To obt a in st a t e-spa ce for m , u se fou r ou t pu t a r gu m en t s:

[A,B,C,D] = ellip(n,Rp,Rs,Wn,'s') or

[A,B,C,D] = ellip(n,Rp,Rs,Wn,'ftype','s') wh er e A, B, C, a n d D a r e

·
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

Th e filt er ’s fr equ en cy r espon se is


freqz(b,a,512,1000)
title('n=6 Lowpass Elliptic Filter')
n = 6 Lowpass Elliptic Filter
0
Magnitude Response (dB)

-20

-40

-60

-80

-100
0 50 100 150 200 250 300 350 400 450 500
Frequency (Hertz)

200
Phase (degrees)

-200

-400

-600
0 50 100 150 200 250 300 350 400 450 500
Frequency (Hertz)

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.

Algorithm 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


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
wit h t h e desir ed cu t off fr equ en cies u sin g a st a t e-spa ce t r a n sfor m a t ion .

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
for m , a s r equ ir ed.

See Also besself Bessel a n a log filt er design .


butter Bu t t er wor t h a n a log a n d digit a l filt er design .
cheby1 Ch ebysh ev t ype I filt er design (pa ssba n d r ipple).
cheby2 Ch ebysh ev t ype II filt er design (st opba n d r ipple).
ellipap E llipt ic a n a log lowpa ss filt er pr ot ot ype.
ellipord E llipt ic filt er or der select ion .

6-130
ellipap

Purpose 6ellipa p
E llipt ic a n a log lowpa ss filt er pr ot ot ype.

Syntax [z,p,k] = ellipap(n,Rp,Rs)

Description [z,p,k] = ellipap(n,Rp,Rs) r et u r n s t h e zer os, poles, a n d ga in of a n or der n


ellipt ic a n a log lowpa ss filt er pr ot ot ype, wit h 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 pea k va lu e in t h e pa ssba n d. Th e zer os a n d
poles a r e r et u r n ed 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 sca la r k.
If n is odd, z is len gt h n – 1. Th e t r a n sfer fu n ct ion is

z (s ) ( s – z (1 ) ) ( s – z (2 ) )Ls ( – z (n ) )
H (s ) = ---------- = k -----------------------------------------------------------------------------
p (s ) ( s – p (1 ) ) ( s – p (2 ) )Ls ( – p (n ) )
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
r esu lt . Th e cu toff frequ en cy 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 a m a gn it u de r espon se of 10 -Rp/20 .

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.

See Also besselap Bessel a n a log lowpa ss filt er pr ot ot ype.


buttap Bu t t er wor t h a n a log lowpa ss filt er pr ot ot ype.
cheb1ap Ch ebysh ev t ype I a n a log lowpa ss filt er pr ot ot ype.
cheb2ap Ch ebysh ev t ype II a n a log lowpa ss filt er pr ot ot ype.
ellip 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 6ellipord
E llipt ic filt er or der select ion .

Syntax [n,Wn] = ellipord(Wp,Ws,Rp,Rs)


[n,Wn] = ellipord(Wp,Ws,Rp,Rs,'s')

Description ellipord select s t h e m in im u m or der digit a l or a n a log ellipt ic filt er r equ ir ed t o


m eet a set of lowpa ss filt er design specifica t ion s:

Wp 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).
Ws 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).
Rp 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.
Rs 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.

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
0
Magnitude Response (dB)

-20

-40

-60

-80
0 50 100 150 200 250 300 350 400 450 500
Frequency (Hertz)

50

0
Phase (degrees)

-50

-100

-150

-200
0 50 100 150 200 250 300 350 400 450 500
Frequency (Hertz)

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


0
Magnitude Response (dB)

-100

-200

-300
0 50 100 150 200 250 300 350 400 450 500
Frequency (Hertz)

400
Phase (degrees)

200

-200

-400
0 50 100 150 200 250 300 350 400 450 500
Frequency (Hertz)

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 buttord Bu t t er wor t h filt er or der select ion .


cheb1ord Ch ebysh ev t ype I filt er or der select ion .
cheb2ord Ch ebysh ev t ype II filt er or der select ion .
ellip 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 6fft
On e-dim en sion a l fa st F ou r ier t r a n sfor m .

Syntax y = fft(x)
y = fft(x,n)

Description fft com pu t es t h e discr et e F ou r ier t r a n sfor m of a vect or or m a t r ix. Th is


fu n ct ion im plem en t s t h e t r a n sfor m given by
N –1

X (k + 1 ) = ∑ x (n + 1 )W nk n
n =0

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
sa m e m a n n er .
Th e fft 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 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))

-1

-2

-3

-4

-5

-6
0 5 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);

Th e power spect r a l den sit y, a m ea su r em en t of t h e en er gy a t va r iou s


fr equ en cies, is
Pyy = Y.*conj(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 dct Discr et e cosin e t r a n sfor m (DCT).


dftmtx Discr et e Fou r ier t r a n sfor m m a t r ix.
fft2 Two-dim en sion a l fa st Fou r ier t r a n sfor m .
fftshift Rea r r a n ge t h e ou t pu t s of fft a n d fft2.
filter 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.
freqz F r equ en cy r espon se of digit a l filt er s.
ifft On e-dim en sion a l in ver se fa st Fou r ier t r a n sfor m .
pwelch 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 6fft 2
Two-dim en sion a l fa st F ou r ier t r a n sfor m .

Syntax Y = fft2(X)
Y = fft2(X,m,n)

Description Y = fft2(X) per for m s a t wo-dim en sion a l F F T, pr odu cin g a r esu lt Y t h e sa m e


size a s X. If X is a vect or , Y h a s t h e sa m e or ien t a t ion a s X.

Y = fft2(X,m,n) t r u n ca t es or zer o pa ds X, if n ecessa r y, t o cr ea t e a n m-by-n


a r r a y befor e per for m in g t h e F F T. Th e r esu lt Y is a lso m-by-n.
Th e fft2 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 fft2(x) is sim ply

fft(fft(x).').'

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 fft On e-dim en sion a l fa st Fou r ier t r a n sfor m .


fftshift Rea r r a n ge t h e ou t pu t s of fft a n d fft2.
ifft On e-dim en sion a l in ver se fa st Fou r ier t r a n sfor m .
ifft2 Two-dim en sion a l in ver se fa st Fou r ier t r a n sfor m .

6-141
fftfilt

Purpose 6fft filt


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.

Syntax y = fftfilt(b,x)
y = fftfilt(b,x,n)

Description fftfilt filt er s da t a u sin g t h e efficien t F F T-ba sed m et h od of overlap-ad d , a


fr equ en cy dom a in filt er in g t ech n iqu e t h a t wor ks on ly for F IR filt er s.

y = fftfilt(b,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 b. It r et u r n s t h e da t a vect or y. Th e oper a t ion per for m ed by
fftfilt is descr ibed in t h e tim e d om ain by t h e differ en ce equ a t ion

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

Y (z ) = ( b (1 ) + b (2 )z – 1 + L+ b (n b + 1 )z – n b )X (z )
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 Sh ow t h a t t h e r esu lt s fr om fftfilt a n d filter a r e iden t ica l:


b = [1 2 3 4];
x = [1 zeros(1,99)]';
norm(fftfilt(b,x) – filter(b,1,x))

ans =
9.5914e–15

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

a n d con volves ea ch block wit h t h e filt er b by


y = ifft(fft(x(i:i+L–1),nfft).*fft(b,nfft));

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


nb–1 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 nb–1

2L nb–1

3L nb–1
. . .

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)

Th is essen t ia lly com pu t es


y = ifft(fft(B,nfft).*fft(X,nfft))

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 conv Con volu t ion a n d polyn om ia l m u lt iplica t ion .


filter 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.
filtfilt 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 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.

Syntax y = fftshift(x)

Description 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)

t h e DC com pon en t is n ea r t h e cen t er of t h e m a t r ix.

See Also fft On e-dim en sion a l fa st Fou r ier t r a n sfor m .


fft2 Two-dim en sion a l fa st Fou r ier t r a n sfor m .

6-144
filter

Purpose 6filt er
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 .

Syntax y = filter(b,a,x)
[y,zf] = filter(b,a,x)
[...] = filter(b,a,x,zi)
[...] = filter(b,a,x,zi,dim)

Description filter filt er s r ea l or com plex da t a u sin g a digit a l filt er . Th e filt er r ea liza t ion
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


t o em pt y t o get t h e defa u lt in it ia l con dit ion s.
Th e filter 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-145
filter

Example F in d a n d gr a ph t h e 100-poin t u n it im pu lse r espon se of a digit a l filt er :


x = [1 zeros(1,100)];
[b,a] = butter(12,400/1000);
y = filter(b,a,x);
stem(y)

0.4

0.3

0.2

0.1

-0.1

-0.2
0 20 40 60 80 100 120

Algorithm filter is im plem en t ed a s a t r a n sposed dir ect for m II st r u ct u r e

x(m) ...
b(n) b( 3 ) b( 2 ) b(1)

Σ z -1 ... Σ z -1 Σ z -1 Σ y(m)
z n -1 (m) z 2 (m) z 1 (m)
– a(n) – a( 3 ) – a( 2 )
...

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 = M
zn – 2 (m ) = b (n – 1 )x (m ) + z n – 1 (m – 1 ) – a (n – 1 )y (m )
zn – 1 (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 (1 ) + b (2 )z –1 + L+ b (n b + 1 )z – n b
Y (z ) = ----------------------------------------------------------------------------------------
- X (z )
a (1 ) + a (2 )z – 1 + L+ a (n a + 1 )z – n a

Diagnostics If a(1) = 0, filter gives t h e followin g er r or m essa ge:


First denominator coefficient must be nonzero.

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 fftfilt 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.
filter2 Two-dim en sion a l digit a l filt er in g.
filtfilt Zer o-ph a se digit a l filt er in g.
filtic 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 6filt er 2
Two-dim en sion a l digit a l filt er in g.

Syntax Y = filter2(B,X)
Y = filter2(B,X,'shape')

Description Y = filter2(B,X) filt er s t h e t wo-dim en sion a l da t a in X wit h t h e


t wo-dim en sion a l F IR filt er in t h e m a t r ix B. Th e r esu lt , Y, is com pu t ed u sin g
t wo-dim en sion a l con volu t ion a n d is t h e sa m e size a s X.

Y = filter2(B,X,'shape') r et u r n s Y com pu t ed wit h size specified by shape:

• 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 .

See Also conv2 Two-dim en sion a l con volu t ion .


filter 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 6filt filt


Zer o-ph a se digit a l filt er in g.

Syntax y = filtfilt(b,a,x)

Description y = filtfilt(b,a,x) per for m s zer o-ph a se digit a l filt er in g by pr ocessin g t h e


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 filtfilt is a n M-file t h a t u ses t h e filter fu n ct ion . In a ddit ion t o t h e


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 fftfilt 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.
filter 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.
filter2 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 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 .

Syntax z = filtic(b,a,y,x)
z = filtic(b,a,y)

Description 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(nb–1) a n d elem en t s of y beyon d y(na–1) 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 .

Th e t r a n sposed dir ect for m II st r u ct u r e is


x(m) ...

b(n) b( 3 ) b( 2 ) b(1)

Σ z -1 ... Σ z -1 Σ z -1 Σ y(m)
z n -1 (m) z 2 (m) z 1 (m)
– a(n) – a( 3 ) – a( 2 )
...

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 filtic per for m s a r ever se differ en ce equ a t ion t o obt a in t h e dela y st a t es z.

Diagnostics If a n y of t h e in pu t a r gu m en t s y, x, b, or a is n ot a vect or (t h a t is, if a n y


a r gu m en t is a sca la r or a r r a y), filtic gives t h e followin g er r or m essa ge:
Requires vector inputs.

See Also filter 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.
filtfilt 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 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.

Syntax b = fir1(n,Wn)
b = fir1(n,Wn,'ftype')
b = fir1(n,Wn,window)
b = fir1(n,Wn,'ftype',window)
b = 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.

Th e gr ou p dela y of t h e F IR filt er design ed by fir1 is n/2.

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 ≤ n ≤ 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 ), 1≤n ≤N

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 ≤ w ≤ 0.65:
b = fir1(48,[0.35 0.65]);
freqz(b,1,512)

50
Magnitude (dB)

−50

−100
0 0.2 0.4 0.6 0.8 1
Normalized Angular Frequency (×π rads/sample)

0
Phase (degrees)

−500

−1000

−1500

−2000

−2500
0 0.2 0.4 0.6 0.8 1
Normalized Angular Frequency (×π rads/sample)

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

Ch eck t h e spect r a of t h e or igin a l a n d filt er ed sign a ls.


[Py,fy] = pburg(y,10,512,Fs);
[Pyfilt,fyfilt] = pburg(yfilt,10,512,Fs);
plot(fy,10*log10(Py),':',fyfilt,10*log10(Pyfilt)); grid
ylabel('Magnitude (dB)'); xlabel('Frequency (Hz)');
legend('Chirp','Filtered Chirp')

−40
Chirp
−50 Filtered Chirp

−60

−70
Magnitude (dB)

−80

−90

−100

−110

−120

−130

−140
0 500 1000 1500 2000 2500 3000 3500 4000 4500
Frequency (Hz)

P la y t h e t wo sign a ls u sin g sound.


sound(y,Fs);
sound(yfilt,Fs);

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 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.
fir2 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.
fircls 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.
fircls1 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.
firls Lea st squ a r e lin ea r-ph a se F IR filt er design .
freqz F r equ en cy r espon se of digit a l filt er s.
kaiserord E st im a t e pa r a m et er s for fir1 wit h Ka iser win dow.
remez 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 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.

Syntax b = fir2(n,f,m)
b = fir2(n,f,m,window)
b = fir2(n,f,m,npt)
b = fir2(n,f,m,npt,window)
b = fir2(n,f,m,npt,lap)
b = 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
specifica t ion .
See t h e “Algor it h m ” sect ion for m or e on npt a n d lap.

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 1

See Also butter Bu t t er wor t h a n a log a n d digit a l filt er design .


cheby1 Ch ebysh ev t ype I filt er design (pa ssba n d r ipple).
cheby2 Ch ebysh ev t ype II filt er design (st opba n d r ipple).
ellip E llipt ic (Ca u er ) filt er design .
fir1 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.
maxflat Gen er a lized digit a l Bu t t er wor t h filt er design .
remez Pa r ks-McClella n opt im a l F IR filt er design .
yulewalk Recu r sive digit a l filt er design .

6-159
fircls

Purpose 6fir cls


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.

Syntax b = fircls(n,f,amp,up,lo)
fircls(n,f,amp,up,lo,'design_flag')

Description b = fircls(n,f,amp,up,lo) gen er a t es a len gt h n+1 lin ea r ph a se F IR filt er b.


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 Design a n or der 50 ba n dpa ss filt er :


n = 50;
f = [0 0.4 0.8 1];
amp = [0 1 0];
up = [0.02 1.02 0.01];
lo = [–0.02 0.98 –0.01];
b = fircls(n,f,amp,up,lo,'plots'); % plots magnitude response

-2
0 0.2 0.4 0.6 0.8 1 1.2 1.4
0.02
Band #1

0
-0.02
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4
1.02
Band #2

1
0.98
0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8
0.01
Band #3

0
-0.01
0.8 0.85 0.9 0.95 1
Frequency

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 .

6-161
fircls

See Also fircls1 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.
firls Lea st squ a r e lin ea r-ph a se F IR filt er design .
remez 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 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.

Syntax b = fircls1(n,wo,dp,ds)
b = fircls1(n,wo,dp,ds,'high')
b = fircls1(n,wo,dp,ds,wt)
b = fircls1(n,wo,dp,ds,wt,'high')
b = fircls1(n,wo,dp,ds,wp,ws,k)
b = fircls1(n,wo,dp,ds,wp,ws,k,'high')
b = 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
∫0 A (ω) – D (ω) 2 d ω
-----------------------------------------------------
π
- = k
∫w A (ω) – D (ω) 2 d ω
s

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 Design a n or der 55 lowpa ss filt er wit h a cu t off fr equ en cy a t 0.3:


n = 55; wo = 0.3;
dp = 0.02; ds = 0.008;
b = fircls1(n,wo,dp,ds,'plots'); % plot magnitude response

0.5

0
0 0.2 0.4 0.6 0.8 1
0.04
0.02
0
-0.02
-0.04
0 0.05 0.1 0.15 0.2 0.25

0.01

-0.01

0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

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 .

See Also fircls 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.
firls Lea st squ a r e lin ea r-ph a se F IR filt er design .
remez 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 6fir ls
Lea st squ a r e lin ea r -ph a se F IR filt er design .

Syntax b = firls(n,f,a)
b = firls(n,f,a,w)
b = firls(n,f,a,'ftype')
b = firls(n,f,a,w,'ftype')

Description firls design s a lin ea r -ph a se F IR filt er t h a t m in im izes t h e weigh t ed,


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

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 a m plit u de


r espon se is

f = [0 .3 .4 .6 .7 .9]
a = [0 1 0 0 .5 .5]

Desired amplitude
response (a) 1.0

0.5

Normalized
0.0 frequency (f)
0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 (Nyquist)

"Don't care"/transition regions

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 n or der 255 lowpa ss filt er wit h t r a n sit ion ba n d:


b = firls(255,[0 0.25 0.3 1],[1 1 0 0]);

Design a 31 coefficien t differ en t ia t or :


b = firls(30,[0 0.9],[0 0.9],'differentiator');

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

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 1

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 MATLAB’s \ 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 Response H(f), Response H(f),
Filter Type Order n Symmetry of Coefficients f=0 f = 1 (Nyquist)

Type I E ven even : No r est r ict ion No r est r ict ion


b ( k ) = b ( n + 2 – k ) , k = 1 , …, n + 1
Type II Odd No r est r ict ion H (1) = 0

Type III E ven odd: H (0) = 0 H (1) = 0


b (k ) = – b (n + 2 – k ), k = 1 , …, n + 1
Type IV Odd H (0) = 0 No r est r ict ion

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].

A m or e ser iou s wa r n in g m essa ge is


Warning: Matrix is close to singular or badly scaled.

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 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.
fir2 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.
firrcos Ra ised cosin e F IR filt er design .
remez 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


Ra ised cosin e F IR filt er design .
b = firrcos(n,F0,df,Fs)
b = firrcos(n,F0,df)
b = firrcos(n,F0,r,Fs,'rolloff')
b = firrcos(...,'type')
b = firrcos(...,'type',delay)
b = firrcos(...,'type',delay,window)
[b,a] = firrcos(...)

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

−20
Magnitude (dB)

−40

−60

−80

−100

−120
0 0.2 0.4 0.6 0.8 1
Frequency (Hz)

See Also fir1 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.
fir2 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.
firls Lea st squ a r e lin ea r-ph a se F IR filt er design .
remez Pa r ks-McClella n opt im a l F IR filt er design .

6-172
freqs

Purpose 6freqs
F r equ en cy r espon se of a n a log filt er s.

Syntax h = freqs(b,a,w)
[h,w] = freqs(b,a)
[h,w] = freqs(b,a,n)
freqs(b,a)

Description freqs r et u r n s t h e com plex fr equ en cy r espon se H (jw ) (La pla ce t r a n sfor m ) of a n
a n a log filt er :

B (s ) b (1 )s n b + b (2 )s n b – 1 + L+ b (n b + 1 )
H (s ) = ----------- = ---------------------------------------------------------------------------------------------
-
A (s ) a (1 )s n a + a (2 )s n a – 1 + L+ a (n a + 1 )
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.

h = freqs(b,a,w) r et u r n s t h e com plex fr equ en cy r espon se of t h e a n a log filt er


specified by coefficien t vect or s b a n d a. freqs eva lu a t es t h e fr equ en cy r espon se
a lon g t h e im a gin a r y a xis in t h e com plex pla n e a t t h e fr equ en cies specified in
r ea l vect or w.

[h,w] = freqs(b,a) a u t om a t ica lly pick s a set of 200 fr equ en cy poin t s w on


wh ich t o com pu t e t h e fr equ en cy r espon se h.

[h,w] = freqs(b,a,n) picks n fr equ en cies on wh ich t o com pu t e t h e fr equ en cy


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


ver su s fr equ en cy in t h e cu r r en t figu r e win dow.
freqs wor ks on ly for r ea l in pu t syst em s a n d posit ive fr equ en cies.

6-173
freqs

Example F in d a n d gr a ph t h e fr equ en cy r espon se of t h e t r a n sfer fu n ct ion given by

0.2 s 2 + 0.3 s + 1
H (s ) = -----------------------------------------
s 2 + 0.4 s + 1
a = [1 0.4 1];
b = [0.2 0.3 1];
w = logspace(–1,1);
freqs(b,a,w)

1
10
Magnitude

0
10

-1
10 -1 0 1
10 10 10
Frequency

0
Phase (degrees)

-50

-100

-150 -1 0 1
10 10 10
Frequency

You ca n a lso cr ea t e t h e plot wit h


h = freqs(b,a,w);
mag = abs(h);
phase = angle(h);
subplot(2,1,1), loglog(w,mag)
subplot(2,1,2), semilogx(w,phase)

To con ver t t o H er t z, degr ees, a n d decibels, u se


f = w/(2*pi);
mag = 20*log10(mag);
phase = phase*180/pi;

6-174
freqs

Algorithm freqs eva lu a t es t h e polyn om ia ls a t ea ch fr equ en cy poin t , 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:
s = i*w;
h = polyval(b,s)./polyval(a,s);

See Also abs Absolu t e va lu e (m a gn it u de).


angle P h a se a n gle.
freqz F r equ en cy r espon se of digit a l filt er s.
invfreqs 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 .
logspace 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).
polyval 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 6fr eqspa ce


F r equ en cy spa cin g for fr equ en cy r espon se.

Syntax f = freqspace(n)
f = freqspace(n,'whole')
[f1,f2] = freqspace(n)
[f1,f2] = freqspace([m n])
[x1,y1] = freqspace(n,'meshgrid')
[x1,y1] = freqspace([m n],'meshgrid')

Description freqspace r et u r n s t h e im plied fr equ en cy r a n ge for equ a lly spa ced fr equ en cy
r espon ses. Th is is u sefu l wh en cr ea t in g fr equ en cy vect or s for u se wit h freqz.

f = freqspace(n) r et u r n s t h e fr equ en cy vect or f a ssu m in g n even ly spa ced


poin t s a r ou n d t h e u n it cir cle. F or n even or odd, f is (0:2/n:1). F or n even ,
freqspace r et u r n s (n + 2)/2 poin t s. F or N odd, it r et u r n s (n + 1)/2 poin t s.

f = freqspace(n,'whole') r et u r n s n even ly spa ced poin t s a r ou n d t h e wh ole


u n it cir cle. In t h is ca se, f is 0:2/n:2*(n–1)/n.

[f1,f2] = freqspace(n) r et u r n s t h e t wo-dim en sion a l fr equ en cy vect or s f1


a n d f2 for a n n-by-n m a t r ix. F or n odd, bot h f1 a n d f2 a r e [–1 + 1/n:2/n:1–
1/n]. F or n even , bot h f1 a n d f2 a r e [–1:2/n:1–2/n].

[f1,f2] = freqspace([m n]) r et u r n s t h e t wo-dim en sion a l fr equ en cy vect or s


f1 a n d f2 for a n m-by-n m a t r ix.

[x1,y1] = freqspace(n,'meshgrid') a n d

[x1,y1] = freqspace([m n],'meshgrid') a r e equ iva len t t o

[f1,f2] = freqspace(...);
[x1,y1] = meshgrid(f1,f2);

See t h e on lin e M AT L AB Fu n ction R eferen ce for det a ils on t h e meshgrid


fu n ct ion .

See Also freqz F r equ en cy r espon se of digit a l filt er s.


invfreqz 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 6freqz
F r equ en cy r espon se of digit a l filt er s.

Syntax [h,w] = freqz(b,a,n)


[h,f] = freqz(b,a,n,Fs)
[h,w] = freqz(b,a,n,'whole')
[h,f] = freqz(b,a,n,'whole',Fs)
h = freqz(b,a,w)
h = freqz(b,a,f,Fs)
freqz(...)

Description freqz r et u r n s t h e com plex fr equ en cy r espon se H (ejω) of a digit a l filt er , given
t h e (r ea l or com plex) 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.
[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 of t h e
digit a l filt er

B (z ) b (1 ) + b (2 )z – 1 + L+ b (n b + 1 )z – n b
H (z ) = ----------- = ----------------------------------------------------------------------------------------
-
A (z ) a (1 ) + a (2 )z – 1 + L+ a (n a + 1 )z – n a
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


cir cle, so f h a s r a n ge [0,Fs).

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 P lot t h e m a gn it u de a n d ph a se r espon se of a n F IR filt er .


b = fir1(80,0.5,kaiser(81,8));
freqz(b,1);

50
Magnitude (dB)

−50

−100

−150
0 0.2 0.4 0.6 0.8 1
Normalized Angular Frequency (×π rads/sample)

0
Phase (degrees)

−1000

−2000

−3000

−4000

−5000
0 0.2 0.4 0.6 0.8 1
Normalized Angular Frequency (×π rads/sample)

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 abs Absolu t e va lu e (m a gn it u de).


angle P h a se a n gle.
fft On e-dim en sion a l fa st Fou r ier t r a n sfor m .
filter 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.
freqs F r equ en cy r espon se of a n a log filt er s.
impz Im pu lse r espon se of digit a l filt er s.
invfreqz Discr et e-t im e filt er iden t ifica t ion fr om fr equ en cy
da t a .
logspace 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 6ga u spu ls


Ga u ssia n -m odu la t ed sin u soida l pu lse gen er a t or .

Syntax yi = gauspuls(t,fc,bw)
yi = gauspuls(t,fc,bw,bwr)
[yi,yq] = gauspuls(…)
[yi,yq,ye] = gauspuls(…)
tc = gauspuls('cutoff',fc,bw,bwr,tpe)

Description gauspuls gen er a t es Ga u ssia n -m odu la t ed sin u soida l pu lses.

yi = gauspuls(t,fc,bw) r et u r n s a u n it y-a m plit u de Ga u ssia n RF pu lse a t t h e


t im es in dica t ed in a r r a y t, wit h a cen t er fr equ en cy fc in H er t z a n d a fr a ct ion a l
ba n dwidt h bw, wh ich m u st be gr ea t er t h a n 0. Th e defa u lt va lu e for fc is
1000 H z a n d for bw is 0.5.

yi = gauspuls(t,fc,bw,bwr) r et u r n s a u n it y-a m plit u de Ga u ssia n RF pu lse


wit h a fr a ct ion a l ba n dwidt h of bw a s m ea su r ed a t a level of bwr dB wit h r espect
t o t h e n or m a lized sign a l pea k . Th e fr a ct ion a l ba n dwidt h r efer en ce level bwr
m u st be less t h a n 0, beca u se it in dica t es a r efer en ce level less t h a n t h e pea k
(u n it y) en velope a m plit u de. Th e defa u lt va lu e for bwr is -6 dB.

[yi,yq] = gauspuls(…) r et u r n s bot h t h e in -ph a se a n d qu a dr a t u r e pu lses.

[yi,yq,ye] = gauspuls(…) r et u r n s t h e RF sign a l en velope.

tc = gauspuls('cutoff',fc,bw,bwr,tpe) r et u r n s t h e cu t off t im e tc (gr ea t er


t h a n or equ a l t o 0) a t wh ich t h e t r a ilin g pu lse en velope fa lls below tpe dB wit h
r espect t o t h e pea k en velope a m plit u de. Th e t r a ilin g pu lse en velope level tpe
m u st be less t h a n 0, beca u se it in dica t es a r efer en ce level less t h a n t h e pea k
(u n it y) en velope a m plit u de. Th e defa u lt va lu e for tpe is -60 dB.

Remarks 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.

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 : 1e–6 : tc;
yi = gauspuls(t,50e3,0.6);
plot(t,yi)
1

0.8

0.6

0.4

0.2

-0.2

-0.4

-0.6

-0.8
-4 -2 0 2 4
-5
x 10

See Also chirp Swept -fr equ en cy cosin e gen er a t or.


cos 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).
diric Dir ich let or per iodic sin c fu n ct ion .
pulstran P u lse t r a in gen er a t or.
rectpuls Sa m pled a per iodic r ect a n gle gen er a t or.
sawtooth Sawt oot h or t r ia n gle wave gen er a t or.
sin 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).
sinc Sin c or sin (πt )/πt fu n ct ion .
square Squ a r e wa ve gen er a t or.
tripuls Sa m pled a per iodic t r ia n gle gen er a t or.

6-181
grpdelay

Purpose 6grpd ela y


Aver a ge filt er dela y (gr ou p dela y).

Syntax [gd,w] = grpdelay(b,a,n)


[gd,f] = grpdelay(b,a,n,Fs)
[gd,w] = grpdelay(b,a,n,'whole')
[gd,f] = grpdelay(b,a,n,'whole',Fs)
gd = grpdelay(b,a,w)
gd = grpdelay(b,a,f,Fs)
grpdelay(b,a)

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 (ω) = – ---------------

wh er e ω is fr equ en cy a n d θ is t h e ph a se a n gle of H (ejω).

[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


digit a l filt er

B (z ) b (1 ) + b (2 )z – 1 + L+ b (n b + 1 )z – n b
H (z ) = ----------- = ----------------------------------------------------------------------------------------
-
A (z ) a (1 ) + a (2 )z – 1 + L+ a (n a + 1 )z –n a
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

[gd,w] = grpdelay(b,a,n,'whole') a n d

[gd,f] = grpdelay(b,a,n,'whole',Fs) u se n poin t s a r ou n d t h e wh ole u n it


cir cle (fr om 0 t o 2π, or fr om 0 t o Fs).

gd = grpdelay(b,a,w) a n d

gd = grpdelay(b,a,f,Fs) r et u r n t h e gr ou p dela y eva lu a t ed a t t h e poin t s in w


(in r a dia n s) or f (in H er t z), r espect ively, wh er e Fs is t h e sa m plin g fr equ en cy in
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


t h e cu r r en t figu r e win dow.
grpdelay wor k s for bot h r ea l a n d com plex in pu t syst em s.

Examples P lot t h e gr ou p dela y of Bu t t er wor t h filt er b(z)/a(z):


[b,a] = butter(6,0.2);
grpdelay(b,a,128)

12

10
Group delay (in samples)

0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized frequency (Nyquist == 1)

6-183
grpdelay

P lot bot h t h e gr ou p a n d ph a se dela ys of a syst em on t h e sa m e gr a ph :


gd = grpdelay(b,a,512);
gd(1) = []; % avoid NaNs
[h,w] = freqz(b,a,512); h(1) = []; w(1) = [];
pd = –unwrap(angle(h))./w;
plot(w,gd,w,pd,':')
xlabel('Frequency (rads/sec)'); grid;
legend('Group Delay','Phase Delay');

12
Group Delay
10 Phase Delay

−2

−4

−6

−8
0 0.5 1 1.5 2 2.5 3 3.5
Frequency (rads/sec)

Algorithm 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 .

See Also cceps Com plex cepst r a l a n a lysis.


fft On e-dim en sion a l fa st Fou r ier t r a n sfor m .
freqz F r equ en cy r espon se of digit a l filt er s.
hilbert H ilber t t r a n sfor m .
icceps In ver se com plex cepst r u m .
rceps 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 6h a m m in g
H a m m in g win dow.

Syntax w = hamming(n)
w = hamming(n,sflag)

Description 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
H a m m in g win dow a r e

k
w [ k + 1 ] = 0.54 – 0.46 cos ⎛ 2 π -------------⎞ , k = 0 , …, n – 1
⎝ n – 1 ⎠

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 An er r or m essa ge is displa yed wh en in cor r ect a r gu m en t s a r e u sed:


Order cannot be less than zero.
Sampling must be either 'symmetric' or 'periodic'.

A wa r n in g m essa ge is displa yed for n on in t eger n:


Warning: Rounding order to nearest integer.

See Also bartlett Ba r t let t win dow.


blackman Bla ck m a n win dow.
boxcar Rect a n gu la r win dow.
chebwin Ch ebysh ev win dow.
hanning H a n n in g win dow.
kaiser Ka iser win dow.
triang 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 6h a n n in g
H a n n in g win dow.

Syntax w = hanning(n)
w = hanning(n,sflag)

Description 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
H a n n in g win dow a r e

k
w [ k ] = 0.5 ⎛ 1 – cos ⎛ 2 π -------------⎞ ⎞ , k = 1 , …, n
⎝ ⎝ n + 1 ⎠ ⎠

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 An er r or m essa ge is displa yed wh en in cor r ect a r gu m en t s a r e u sed:


Order cannot be less than zero.
Sampling must be either 'symmetric' or 'periodic'.

A wa r n in g m essa ge is displa yed for n on in t eger n:


Warning: Rounding order to nearest integer.

See Also bartlett Ba r t let t win dow.


blackman Bla ck m a n win dow.
boxcar Rect a n gu la r win dow.
chebwin Ch ebysh ev win dow.
hamming H a m m in g win dow.
kaiser Ka iser win dow.
triang 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 6h ilber t
H ilber t t r a n sfor m .

Syntax y = hilbert(x)

Description 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
- 1 for i = 1, (n/2) + 1
- 2 for i = 2, 3, ..., (n/2)
- 0 for i = (n/2) + 2, ... , n
3 It ca lcu la t es t h e elem en t -wise pr odu ct of y a n d h.
4 It ca lcu la t es t h e in ver se F F T of t h e sequ en ce obt a in ed in st ep 3 a n d r et u r n s
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 fft On e-dim en sion a l fa st Fou r ier t r a n sfor m .


ifft On e-dim en sion a l in ver se fa st Fou r ier t r a n sfor m .
rceps 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 6icceps
In ver se com plex cepst r u m .

Syntax x = icceps(xhat,nd)

Description x = icceps(xhat,nd) r et u r n s t h e in ver se com plex cepst r u m of t h e (a ssu m ed


r ea l) sequ en ce xhat, r em ovin g nd sa m ples of dela y. If xhat wa s obt a in ed wit h
cceps(x), t h en t h e a m ou n t of dela y t h a t wa s a dded t o x wa s t h e elem en t of
round(unwrap(angle(fft(x)))/pi) cor r espon din g t o π r a dia n s.

See Also cceps Com plex cepst r a l a n a lysis.


hilbert H ilber t t r a n sfor m .
rceps Rea l cepst r u m a n d m in im u m ph a se r econ st r u ct ion .
unwrap 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 6idct
In ver se discr et e cosin e t r a n sfor m .

Syntax x = idct(y)
x = idct(y,n)

Description 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
π(2 n – 1 )(k – 1 )
x (n ) = ∑ w (k )y (k ) cos ------------------------------------------
2N
-, n = 1 , …, N
k =1

wh er e

⎧ 1
⎪ ---------, k =1
⎪ N
w (k ) = ⎨
⎪ 2
⎪ ----N
, 2≤k ≤N
⎩

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


t r a n sfor m in g.
If y is a m a t r ix, idct t r a n sfor m s it s colu m n s.

See Also dct Discr et e cosin e t r a n sfor m (DCT).


dct2 Two-dim en sion a l DCT (see Im age Processin g T oolbox User’s
Gu id e).
idct2 Two-dim en sion a l in ver se DCT (see Im age Processin g T oolbox
User’s Gu id e).
ifft 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 6ifft
On e-dim en sion a l in ver se fa st F ou r ier t r a n sfor m .

Syntax y = ifft(x)
y = ifft(x,n)

Description ifft com pu t es t h e in ver se F ou r ier t r a n sfor m of a vect or or a r r a y. Th is fu n ct ion


im plem en t s t h e in ver se t r a n sfor m given by
N –1
1
x (n + 1 ) = ----
N ∑ X (k + 1 )W n–k 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
colu m n s in t h e sa m e m a n n er .
Th e ifft 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 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.

See Also fft On e-dim en sion a l fa st Fou r ier t r a n sfor m .


fft2 Two-dim en sion a l fa st Fou r ier t r a n sfor m .
fftshift Rea r r a n ge t h e ou t pu t s of fft a n d fft2.
ifft2 Two-dim en sion a l in ver se fa st Fou r ier t r a n sfor m .

6-192
ifft2

Purpose 6ifft 2
Two-dim en sion a l in ver se fa st F ou r ier t r a n sfor m .

Syntax Y = ifft2(X)
Y = ifft2(X,m,n)

Description Y = ifft2(X) r et u r n s t h e t wo-dim en sion a l in ver se fa st F ou r ier t r a n sfor m


(F F T) of t h e a r r a y X. If X is a vect or , Y h a s t h e sa m e or ien t a t ion a s X.

Y = ifft2(X,m,n) t r u n ca t es or zer o pa ds X, if n ecessa r y, t o cr ea t e a n m-by-n


a r r a y befor e per for m in g t h e in ver se F F T. Th e r esu lt Y is a lso m-by-n.
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.

See Also fft On e-dim en sion a l fa st Fou r ier t r a n sfor m .


fft2 Two-dim en sion a l fa st Fou r ier t r a n sfor m .
fftn 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).
fftshift Rea r r a n ge t h e ou t pu t s of fft a n d fft2.
ifft On e-dim en sion a l in ver se fa st Fou r ier t r a n sfor m .
ifftn 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 6im pin va r


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 .

Syntax [bz,az] = impinvar(b,a,Fs)


[bz,az] = impinvar(b,a)
[bz,az] = impinvar(b,a,Fs,tol)

Description [bz,az] = impinvar(b,a,Fs) cr ea t es a digit a l filt er wit h n u m er a t or a n d


den om in a t or coefficien t s bz a n d az, r espect ively, wh ose im pu lse r espon se is
equ a l t o t h e im pu lse r espon se of t h e a n a log filt er wit h coefficien t s b a n d a,
sca led by 1/Fs.

[bz,az] = impinvar(b,a) u ses t h e defa u lt va lu e of 1 H z for Fs.

[bz,az] = impinvar(b,a,Fs,tol) u ses t h e t oler a n ce specified by tol t o


det er m in e wh et h er poles a r e r epea t ed. A la r ger t oler a n ce in cr ea ses t h e
likelih ood t h a t impinvar will con sider n ea r by poles t o be r epea t ed. Th e defa u lt
is 0.001, or 0.1% of a pole’s m a gn it u de. Not e t h a t t h e a ccu r a cy of t h e pole va lu es
is st ill lim it ed t o t h e a ccu r a cy obt a in a ble by t h e roots fu n ct ion .

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 0.1324 0.5192 0.1273 0

az =

1.0000 -3.9216 5.7679 -3.7709 0.9246

Algorithm impinvar per for m s t h e im pu lse-in va r ia n t m et h od of a n a log-t o-digit a l t r a n sfer


fu n ct ion con ver sion discu ssed in r efer en ce [1]:

1 It fin ds t h e pa r t ia l fr a ct ion expa n sion of t h e syst em r epr esen t ed by b a n d a.


2 It r epla ces t h e poles p by t h e poles exp(p/Fs).

6-194
impinvar

3 It fin ds t h e t r a n sfer fu n ct ion coefficien t s of t h e syst em fr om t h e r esidu es


fr om st ep 1 a n d t h e poles fr om st ep 2.

See Also bilinear 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 .
lp2bp Lowpa ss t o ba n dpa ss a n a log filt er t r a n sfor m a t ion .
lp2bs Lowpa ss t o ba n dst op a n a log filt er t r a n sfor m a t ion .
lp2hp Lowpa ss t o h igh pa ss a n a log filt er t r a n sfor m a t ion .
lp2lp 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 6im pz
Im pu lse r espon se of digit a l filt er s.

Syntax [h,t] = impz(b,a)


[h,t] = impz(b,a,n)
[h,t] = impz(b,a,n,Fs)
impz(b,a)
impz(...)

Description [h,t] = impz(b,a) com pu t es t h e im pu lse r espon se of t h e filt er wit h


n u m er a t or coefficien t s b a n d den om in a t or coefficien t s a. impz ch ooses t h e
n u m ber of sa m ples a n d r et u r n s t h e r espon se in colu m n vect or h a n d t im es (or
sa m ple in t er va ls) in colu m n vect or t (wh er e t = (0:n–1)' a n d n is t h e
com pu t ed im pu lse r espon se len gt h ).

[h,t] = impz(b,a,n) com pu t es n sa m ples of t h e im pu lse r espon se. If n is a


vect or of in t eger s, impz com pu t es t h e im pu lse r espon se a t t h ose in t eger
loca t ion s wh er e 0 is t h e st a r t in g poin t of t h e filt er .

[h,t] = impz(b,a,n,Fs) com pu t es n sa m ples a n d sca les t so t h a t sa m ples a r e


spa ced 1/Fs u n it s a pa r t . Fs is 1 by defa u lt . Lea ve n em pt y, [], t o let impz select
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
0 5 10 15 20 25 30 35 40 45

Algorithm impz filt er s a len gt h n im pu lse sequ en ce u sin g

filter(b,a,[1 zeros(1,n–1)])

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 Un it im pu lse r espon se (see Con trol S ystem T oolbox
User’s Gu id e).
stem 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 6in t er p
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 ).

Syntax y = interp(x,r)
y = interp(x,r,l,alpha)
[y,b] = interp(x,r,l,alpha)

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 In t er pola t e a sign a l by a fa ct or of fou r :


t = 0:0.001:1; % time vector
x = sin(2*pi*30*t) + sin(2*pi*60*t);
y = interp(x,4);
stem(x(1:30)); title('Original Signal');
figure
stem(y(1:120)); title('Interpolated Signal');
Original Signal Interpolated Signal
2 2

1.5 1.5

1 1

0.5 0.5

0 0

-0.5 -0.5

-1 -1

-1.5 -1.5

-2 -2
0 5 10 15 20 25 30 0 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 ≤ alpha ≤ 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 If r is n ot a n in t eger , interp gives t h e followin g er r or m essa ge:


Resampling rate R must be an integer.

See Also decimate Decr ea se t h e sa m plin g r a t e for a sequ en ce


(decim a t ion ).
interp1 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).
resample 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.
spline 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).
upfirdn 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 6in t filt


In t er pola t ion F IR filt er design .

Syntax b = intfilt(r,l,alpha)
b = intfilt(r,n,'Lagrange')

Description b = intfilt(r,l,alpha) design s a lin ea r ph a se F IR filt er t h a t per for m s idea l


ba n dlim it ed in t er pola t ion u sin g t h e n ea r est 2*l n on zer o sa m ples, wh en u sed
on a sequ en ce in t er lea ved wit h r–1 con secu t ive zer os ever y r sa m ples. It
a ssu m es a n or igin a l ba n dlim it edn ess of alpha t im es t h e Nyqu ist fr equ en cy.
Th e r et u r n ed filt er is iden t ica l t o t h a t u sed by interp.

b = intfilt(r,n,'Lagrange') or b = intfilt(r,n,'l') design s a n F IR


filt er t h a t per for m s nt h -or der La gr a n ge polyn om ia l in t er pola t ion on a sequ en ce
in t er lea ved wit h r–1 con secu t ive zer os ever y r sa m ples. b h a s len gt h (n + 1)*r
for n even , a n d len gt h (n + 1)*r–1 for n odd.
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);

In t er pola t e u sin g t h e filter com m a n d:


y = filter(h1,1,xr);

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

0.5

-0.5

-1

-1.5
100 110 120 130 140 150 160 170 180 190 200
Sample Number

intfilt’s ot h er t ype of filt er per for m s La gr a n ge polyn om ia l in t er pola t ion of


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') % Lagrange interpolation

h2 =
0.2500 0.5000 0.7500 1.0000 0.7500 0.5000 0.2500

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 ge’s 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 .

See Also decimate Decr ea se t h e sa m plin g r a t e for a sequ en ce


(decim a t ion ).
interp 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 ).
resample 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 6in vfr eqs


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 .

Syntax [b,a] = invfreqs(h,w,nb,na)


[b,a] = invfreqs(h,w,nb,na,wt)
[b,a] = invfreqs(h,w,nb,na,wt,iter)
[b,a] = invfreqs(h,w,nb,na,wt,iter,tol)
[b,a] = invfreqs(h,w,nb,na,wt,iter,tol,'trace')
[b,a] = invfreqs(h,w,'complex',nb,na,...)

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 ) = ----------- = ---------------------------------------------------------------------------------------------
-
A (s ) a (1 )s n a + a (2 )s n a – 1 + L+ a (n a + 1 )
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.

Examples 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 2.0000 3.0000 2.0000 3.0000

aa =

1.0000 2.0000 3.0000 2.0000 1.0000 4.0000

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 invfreqs’s
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 2.1015 2.6694 0.9113 -0.1218

aaa =

1.0000 3.4676 7.4060 6.2102 2.5413 0.0001

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 MATLAB’s \


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
B ( w ( k )) 2
m in
b, a
∑ w t (k ) h (k ) – -------------------
A (w (k ))
-
k =1

6-205
invfreqs

See Also freqs F r equ en cy r espon se of a n a log filt er s.


freqz F r equ en cy r espon se of digit a l filt er s.
invfreqz Discr et e-t im e filt er iden t ifica t ion fr om fr equ en cy
da t a .
prony P r on y’s 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 6in vfr eqz


Discr et e-t im e filt er iden t ifica t ion fr om fr equ en cy da t a .

Syntax [b,a] = invfreqz(h,w,nb,na)


[b,a] = invfreqz(h,w,nb,na,wt)
[b,a] = invfreqz(h,w,nb,na,wt,iter)
[b,a] = invfreqz(h,w,nb,na,wt,iter,tol)
[b,a] = invfreqz(h,w,nb,na,wt,iter,tol,'trace')
[b,a] = invfreqz(h,w,'complex',nb,na,...)

Description invfreqz is t h e in ver se oper a t ion of freqz; it fin ds a discr et e-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 , 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 ) = ----------- = ----------------------------------------------------------------------------------------
-
A (z ) a (1 ) + a (2 )z – 1 + L+ a (n a + 1 )z – n a
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 2.0000 3.0000 2.0000 3.0000

aa =

1.0000 2.0000 3.0000 2.0000 1.0000 4.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 invfreqz’s
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 0.2788 0.0069 0.0971 0.1980

aaa =

1.0000 –0.8944 0.6954 0.9997 –0.8933 0.6949

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 MATLAB’s \


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
B ( w ( k )) 2
m in
b, a
∑ w t (k ) h (k ) – -------------------
A (w (k ))
-
k =1

See Also freqs F r equ en cy r espon se of a n a log filt er s.


freqz F r equ en cy r espon se of digit a l filt er s.
invfreqs 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 .
prony P r on y’s 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 6ka iser


Ka iser win dow.

Syntax w = kaiser(n,beta)

Description w = kaiser(n,beta) r et u r n s a n n-poin t Ka iser ( I 0 - sin h ) win dow in t h e


colu m n vect or w. beta is t h e Ka iser win dow β pa r a m et er t h a t a ffect s t h e
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 ≥ α ≥ 21
⎪
⎩ 0 , α < 21

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 bartlett Ba r t let t win dow.


blackman Bla ck m a n win dow.
boxcar Rect a n gu la r win dow.
chebwin Ch ebysh ev win dow.
hamming H a m m in g win dow.
hanning H a n n in g win dow.
kaiserord E st im a t e pa r a m et er s for fir1 wit h Ka iser win dow.
triang 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 6ka iser or d


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.

Syntax [n,Wn,beta,ftype] = kaiserord(f,a,dev)


[n,Wn,beta,ftype] = kaiserord(f,a,dev,Fs)
c = kaiserord(f,a,dev,Fs,'cell')

Description kaiserord r et u r n s a filt er or der n a n d beta pa r a m et er t o specify a Ka iser


win dow for u se wit h t h e fir1 fu n ct ion . Given a set of specifica t ion s in t h e
fr equ en cy dom a in , kaiserord est im a t es t h e m in im u m F IR filt er or der t h a t will
a ppr oxim a t ely m eet t h e specifica t ion s. kaiserord con ver t s t h e given filt er
specifica t ion s in t o pa ssba n d a n d st opba n d r ipples a n d con ver t s cu t off
fr equ en cies in t o t h e for m n eeded for win dowed F IR filt er design .

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 'dc–0' 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 'dc–1' 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 ≥ α ≥ 21
⎪
⎩ 0 , α < 21

wh er e α = -20log 10 δ 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 δp = δs 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)

−50

−100

−150
0 0.2 0.4 0.6 0.8 1
Normalized Angular Frequency (×π rads/sample)

0
Phase (degrees)

−500

−1000

−1500
0 0.2 0.4 0.6 0.8 1
Normalized Angular Frequency (×π rads/sample)

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');

Th is is equ iva len t t o


c = kaiserord([1500 2000],[1 0],[0.01 0.1],8000,'cell');
b = fir1(c{:});

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.

Diagnostics 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.

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.

If t h e ba n d edges a r e n ot st r ict ly in cr ea sin g, kaiserord gives t h e followin g


er r or m essa ge:
Bandedges must be strictly increasing.

See Also fir1 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.
kaiser Ka iser win dow.
remezord 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 6la t c2t f


La t t ice filt er t o t r a n sfer fu n ct ion con ver sion .

Syntax [num,den] = latc2tf(k,v)


[num,den] = latc2tf(k,'iir')
num = latc2tf(k,'fir')
num = latc2tf(k)

Description [num,den] = latc2tf(k,v) fin ds t h e t r a n sfer fu n ct ion n u m er a t or num a n d


den om in a t or den fr om t h e IIR la t t ice coefficien t s k a n d la dder coefficien t s v.

[num,den] = latc2tf(k,'iir') a ssu m es t h a t k is a ssocia t ed wit h a n a ll-pole


IIR la t t ice filt er .

num = latc2tf(k,'fir') a n d

num = latc2tf(k) fin d t h e t r a n sfer fu n ct ion n u m er a t or s fr om t h e F IR la t t ice


coefficien t s specified by k.

See Also latcfilt La t t ice a n d la t t ice-la dder filt er im plem en t a t ion .


tf2latc 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 6la t cfilt


La t t ice a n d la t t ice-la dder filt er im plem en t a t ion .

Syntax [f,g] = latcfilt(k,x)


[f,g] = latcfilt(k,v,x)
[f,g] = latcfilt(k,1,x)
[f,g,zf] = latcfilt(...,'ic',zi)

Description [f,g] = latcfilt(k,x) filt er s x wit h t h e F IR la t t ice coefficien t s in vect or k. f


is t h e for wa r d la t t ice filt er r esu lt a n d g is t h e ba ck wa r d filt er r esu lt .
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 filter 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.
latc2tf La t t ice filt er t o t r a n sfer fu n ct ion con ver sion .
tf2latc 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 6levin son


Levin son -Du r bin r ecu r sion .

Syntax a = levinson(r,p)

Description 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
coefficien t s a r e or der ed in descen din g power s of z:

1 1
H (z ) = ----------- = -------------------------------------------------------------------------
-
A (z ) 1 + a (2 )z + L+ a (p + 1 )z – p
– 1

Algorithm levinson solves t h e sym m et r ic Toeplit z syst em of lin ea r equ a t ion s.

∗ ∗
r (1 ) r (2 ) L r (p ) a (2 ) – r (2 )
r (2 ) r (1 ) L r (p – 1 )
∗ a (3 ) – r (3 )
=
M O O M M M
r (p ) L r (2 ) r (1 ) 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 lpc Lin ea r pr edict ion coefficien t s.


prony P r on y’s m et h od for t im e dom a in IIR filt er design .
rlevinson Rever se Levin son -Du r bin r ecu r sion .
stmcb 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 6lp2bp
Lowpa ss t o ba n dpa ss a n a log filt er t r a n sfor m a t ion .

Syntax [bt,at] = lp2bp(b,a,Wo,Bw)


[At,Bt,Ct,Dt] = lp2bp(A,B,C,D,Wo,Bw)

Description lp2bp t r a n sfor m s a n a log lowpa ss filt er pr ot ot ypes wit h a cu t off fr equ en cy of
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.

Transfer Function Form (Polynomial)

[bt,at] = lp2bp(b,a,Wo,Bw) t r a n sfor m s a n a n a log lowpa ss filt er pr ot ot ype


given by polyn om ia l coefficien t s 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. Row vect or s b a n d a 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 of t h e pr ot ot ype in descen din g power s of s:

b (s ) b (1 )s n b + L+ b (n b )s + b (n b + 1 )
---------- = ------------------------------------------------------------------------------------
a (s ) a (1 )s n a + L+ a (n a )s + a (n a + 1 )
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 = w2–w1.
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 = w2–w1.

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 bilinear 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 .
impinvar 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 .
lp2bs Lowpa ss t o ba n dst op a n a log filt er t r a n sfor m a t ion .
lp2hp Lowpa ss t o h igh pa ss a n a log filt er t r a n sfor m a t ion .
lp2lp 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 6lp2bs
Lowpa ss t o ba n dst op a n a log filt er t r a n sfor m a t ion .

Syntax [bt,at] = lp2bs(b,a,Wo,Bw)


[At,Bt,Ct,Dt] = lp2bs(A,B,C,D,Wo,Bw)

Description lp2bs t r a n sfor m s a n a log lowpa ss filt er pr ot ot ypes wit h a cu t off fr equ en cy of
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.

Transfer Function Form (Polynomial)

[bt,at] = lp2bs(b,a,Wo,Bw) t r a n sfor m s a n a n a log lowpa ss filt er pr ot ot ype


given by polyn om ia l coefficien t s 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. Row vect or s b a n d a 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 of t h e pr ot ot ype in descen din g power s of s:

b (s ) b (1 )s n b + L+ b (n b )s + b (n b + 1 )
---------- = ------------------------------------------------------------------------------------
a (s ) a (1 )s n a + L+ a (n a )s + a (n a + 1 )
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 = w2–w1.
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 = w2–w1.

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 bilinear 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 .
impinvar 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 .
lp2bp Lowpa ss t o ba n dpa ss a n a log filt er t r a n sfor m a t ion .
lp2hp Lowpa ss t o h igh pa ss a n a log filt er t r a n sfor m a t ion .
lp2lp 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 6lp2h p
Lowpa ss t o h igh pa ss a n a log filt er t r a n sfor m a t ion .

Syntax [bt,at] = lp2hp(b,a,Wo)


[At,Bt,Ct,Dt] = lp2hp(A,B,C,D,Wo)

Description lp2hp t r a n sfor m s a n a log lowpa ss filt er pr ot ot ypes wit h a cu t off fr equ en cy of
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.

Transfer Function Form (Polynomial)

[bt,at] = lp2hp(b,a,Wo) t r a n sfor m s a n a n a log lowpa ss filt er pr ot ot ype


given by polyn om ia l coefficien t s in t o a h igh pa ss filt er wit h cu t off fr equ en cy Wo.
Row vect or s b a n d a 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
of t h e pr ot ot ype in descen din g power s of s:

b (s ) b (1 )s n b + L+ b (n b )s + b (n b + 1 )
---------- = ------------------------------------------------------------------------------------
a (s ) a (1 )s n a + L+ a (n a )s + a (n a + 1 )
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 = Wo*inv(A);
Bt = –Wo*(A\B);
Ct = C/A;
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 bilinear 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 .
impinvar 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 .
lp2bp Lowpa ss t o ba n dpa ss a n a log filt er t r a n sfor m a t ion .
lp2bs Lowpa ss t o ba n dst op a n a log filt er t r a n sfor m a t ion .
lp2lp 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 6lp2lp
Lowpa ss t o lowpa ss a n a log filt er t r a n sfor m a t ion .

Syntax [bt,at] = lp2lp(b,a,Wo)


[At,Bt,Ct,Dt] = lp2lp(A,B,C,D,Wo)

Description lp2lp t r a n sfor m s a n a n a log lowpa ss filt er pr ot ot ype wit h a cu t off fr equ en cy of
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.

Transfer Function Form (Polynomial)

[bt,at] = lp2lp(b,a,Wo) t r a n sfor m s a n a n a log lowpa ss filt er pr ot ot ype


given by polyn om ia l coefficien t s in t o a lowpa ss filt er wit h cu t off fr equ en cy Wo.
Row vect or s b a n d a 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
of t h e pr ot ot ype in descen din g power s of s:

b (s ) b (1 )s n b + L+ b (n b )s + b (n b + 1 )
---------- = ------------------------------------------------------------------------------------
a (s ) a (1 )s n a + L+ a (n a )s + a (n a + 1 )
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 = Wo*A;
Bt = Wo*B;
Ct = C;
Dt = 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 bilinear 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 .
impinvar 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 .
lp2bp Lowpa ss t o ba n dpa ss a n a log filt er t r a n sfor m a t ion .
lp2bs Lowpa ss t o ba n dst op a n a log filt er t r a n sfor m a t ion .
lp2hp 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 6lpc
Lin ea r pr edict ion coefficien t s.

Syntax a = lpc(x,p)

Description lpc det er m in es t h e coefficien t s of a for wa r d lin ea r pr edict or by m in im izin g t h e


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:

x̂ (n ) = – a (2 )x (n – 1 ) –a (3 )x (n – 2 ) – L– 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); % Estimated signal


e = x – est_x; % Prediction error
[acs,lags] = xcorr(e,'coeff'); % 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
in pu t sign a l, a n d x̂ ( n ) is t h e pr edict ed sign a l.

Prediction Error Filter

–1 –2 –p x̂ ( n )
x (n ) – a ( 2 )z – a ( 3 )z – L– a ( n e(n )
H (z ) = + 1 )z
– Σ
+

A (z )
Com pa r e t h e pr edict ed sign a l t o t h e or igin a l sign a l.
plot(1:97,x(4001:4097),1:97,est_x(4001:4097),'--');
title('Original Signal vs. LPC Estimate');
xlabel('Samples'); ylabel('Amplitude'); grid;
legend('Original Signal','LPC Estimate')

Original Signal vs. LPC Estimate


3

1
Amplitude

−1

−2

−3
Original Signal
LPC Estimate
−4
0 20 40 60 80 100
Samples

Look a t t h e a u t ocor r ela t ion of t h e pr edict ion er r or .


plot(lags,acs);
title('Autocorrelation of the Prediction Error');
xlabel('Lags'); ylabel('Normalized Value'); grid;

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.8
Normalized Value

0.6

0.4

0.2

−0.2
−5000 0 5000
Lags

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 ≈ b
wh er e

x (1 ) 0 L 0
x (2 ) x (1 ) O M
1 1
M x (2 ) O 0
a (2 ) 0
X = x (m ) M Ox (1 ) , a = , b=
M M
0 x (m ) Ox (2 )
a (p + 1 ) 0
M O O M
0 L 0 x (m )

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 )* L r (p )* a (2 ) – r (2 )
r (2 ) r (1 ) O M a (3 ) – r (3 )
=
M O O r (2 )* M M
r (p ) L 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 aryule 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.
levinson Levin son -Du r bin r ecu r sion .
prony P r on y’s m et h od for t im e dom a in IIR filt er design .
pyulear Power spect r u m est im a t e u sin g Yu le-Wa lker AR
m et h od.
stmcb 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 6m a xfla t
Gen er a lized digit a l Bu t t er wor t h filt er design .

Syntax [b,a,] = maxflat(nb,na,Wn)


b = maxflat(nb,'sym',Wn)
[b,a,b1,b2] = maxflat(nb,na,Wn)
[...] = maxflat(nb,na,Wn,'design_flag')

Description [b,a,] = maxflat(nb,na,Wn) is a lowpa ss Bu t t er wor t h filt er wit h n u m er a t or


a n d den om in a t or coefficien t s b a n d a of or der s nb a n d na r espect ively. Wn is t h e
cu t off 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
(a ppr ox. -3 dB). Wn m u st be 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).

b = maxflat(nb,'sym',Wn) is a sym m et r ic F IR Bu t t er wor t h filt er . nb m u st be


even , a n d Wn is r est r ict ed t o a su bin t er va l of [0,1]. Th e fu n ct ion r a ises a n er r or
if Wn is specified ou t side of t h is su bin t er va l.

[b,a,b1,b2] = maxflat(nb,na,Wn) r et u r n s t wo polyn om ia ls b1 a n d b2 wh ose


pr odu ct is equ a l t o t h e n u m er a t or polyn om ia l b (t h a t is, b = conv(b1,b2)). b1
con t a in s a ll t h e zer os a t z = –1, a n d b2 con t a in s a ll t h e ot h er zer os.

[...] = maxflat(nb,na,Wn,'design_flag') en a bles you t o m on it or t h e filt er


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 nb = 10; na = 2; Wn = 0.2*pi;


[b,a,b1,b2] = maxflat(nb,na,Wn,'plots')
Frequency response
1
Magnitude

0.5

0
0 0.2 0.4 0.6 0.8 1
Pole-zero plot w/p Group delay
5
1
4
0.5 Samples
3
Imag

0 <- deg 4
2
-0.5
1
-1
0
-1 0 1 0 0.5 1
Real w/p

Algorithm 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.

See Also butter Bu t t er wor t h a n a log a n d digit a l filt er design .


filter 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.
freqz 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 6m edfilt 1
On e-dim en sion a l m edia n filt er in g.

Syntax y = medfilt1(x,n)
y = medfilt1(x,n,blksz)

Description y = medfilt1(x,n) a pplies a n or der n, on e-dim en sion a l m edia n filt er t o vect or


x. y is t h e sa m e len gt h a s x; t h e fu n ct ion t r ea t s t h e sign a l a s if it is 0 beyon d
t h e en d poin t s.
F or n odd, y(k) is t h e m edia n of x(k–(n–1)/2:k+(n–1)/2).
F or n even , y(k) is t h e m edia n of x(k–n/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 ((n–1)/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.

If x is a m a t r ix, medfilt1 m edia n filt er s it s colu m n s u sin g


y(:,i) = medfilt1(x(:,i),n,blksz)

in a loop over t h e colu m n s of x.

See Also filter 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.
medfilt2 Two-dim en sion a l m edia n filt er in g (see Im age
Processin g T oolbox User’s Gu id e).
median 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 6m odu la t e
Modu la t ion for com m u n ica t ion s sim u la t ion .

Syntax y = modulate(x,Fc,Fs,'method')
y = modulate(x,Fc,Fs,'method',opt)
[y,t] = modulate(x,Fc,Fs)

Description y = modulate(x,Fc,Fs,'method') a n d

y = modulate(x,Fc,Fs,'method',opt) m odu la t e t h e r ea l m essa ge sign a l x


wit h a ca r r ier fr equ en cy Fc a n d sa m plin g fr equ en cy Fs, u sin g on e of t h e opt ion s
list ed below for method. Not e t h a t som e m et h ods a ccept a n opt ion , opt.
amdsb–sc Am p litu d e m o d u la ti o n , d o u ble s id e ba n d , s u p p re s s e d c a rri e r.
or Mu lt iplies x by a sin u soid of fr equ en cy Fc:
am y = x.*cos(2*pi*Fc*t)
amdsb–tc Am p litu d e m o d u la ti o n , d o u ble s id e ba n d , tra n s m i tte d c a rri e r.
Su bt r a ct s sca la r opt fr om x a n d m u lt iplies t h e r esu lt by a sin u soid
of fr equ en cy Fc:
y = (x–opt).*cos(2*pi*Fc*t)
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 (x–opt) 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)
Th is effect ively r em oves t h e u pper sideba n d.

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)))
so t h e m a xim u m fr equ en cy excu r sion fr om Fc is Fc H z.
pm P h a s e m o d u la t io n . Cr ea t es a sin u soid of fr equ en cy Fc wh ose
ph a se va r ies wit h t h e m essa ge sign a l x:
y = cos(2*pi*Fc*t + opt*x)
modulate u ses opt a s t h e con st a n t of ph a se m odu la t ion . If opt is
n ot pr esen t , modulate u ses a defa u lt of
opt = pi/(max(max(x)))
so t h e m a xim u m ph a se excu r sion is π r a dia n s.
pwm P u ls e -w id th m o d u la tio n . Cr ea t es a pu lse-widt h m odu la t ed
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')
yields pu lses cen t er ed a t t h e begin n in g of ea ch per iod. y is len gt h
length(x)*Fs/Fc.
ptm P u ls e ti m e m o d u la ti o n . Cr ea t es a pu lse t im e m odu la t ed sign a l
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 Qu a d ra tu re a m p litu d e m o d u la tio n . Cr ea t es a qu a dr a t u r e
a m plit u de m odu la t ed sign a l fr om sign a ls x a n d opt:
y = x.*cos(2*pi*Fc*t) + opt.*sin(2*pi*Fc*t)
opt m u st be t h e sa m e size a s x.

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


u ses in it s com pu t a t ion s.

See Also demod Dem odu la t ion for com m u n ica t ion s sim u la t ion .
vco Volt a ge con t r olled oscilla t or.

6-238
pburg

Purpose 6pbu rg
P ower spect r u m est im a t e u sin g t h e Bu r g m et h od.

Syntax Pxx = pburg(x,p,nfft)


[Pxx,freq] = pburg(x,p,nfft)
[Pxx,freq] = pburg(x,p,nfft,Fs)
[Pxx,freq] = pburg(x,p,nfft,Fs,'range')
pburg(...)
pburg(...,'squared')

Description pburg est im a t es t h e power spect r a l den sit y (P SD) of t h e sign a l vect or x[n ]
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 l’s 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 0.2 0.4 0.6 0.8 1
Normalized Angular Frequency (×π rads/sample)

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)); % AR system output
pburg(x,4) % 4th order estimate
Burg Spectral Estimate Pxx(ω)
40

30
Power Spectral Density (dB)

20

10

−10

−20
0 0.2 0.4 0.6 0.8 1
Normalized Angular Frequency (×π rads/sample)

Diagnostics Th e fir st in pu t a r gu m en t m u st be a fu ll vect or ; ot h er wise pburg gen er a t es t h e


followin g er r or m essa ge:
Input signal cannot be sparse.

If you specify a n em pt y m a t r ix for t h e secon d a r gu m en t , pburg gen er a t es t h e


followin g er r or m essa ge:
Model order must be an integer.

6-241
pburg

See Also arburg 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.
lpc Lin ea r pr edict ion coefficien t s.
pcov 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.
pmcov 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.
pmtm 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).
pmusic Power spect r u m est im a t e u sin g MUSIC eigen vect or
m et h od.
prony P r on y’s m et h od for t im e dom a in IIR filt er design .
pwelch 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.
pyulear 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 6pcov
P ower spect r u m est im a t e u sin g t h e cova r ia n ce m et h od.

Syntax Pxx = pcov(x,p,nfft)


[Pxx,freq] = pcov(x,p,nfft)
[Pxx,freq] = pcov(x,p,nfft,Fs)
[Pxx,freq] = pcov(x,p,nfft,Fs,'range')
pcov(...)
pcov(...,'squared')

Description pcov est im a t es t h e power spect r a l den sit y (P SD) of t h e sign a l vect or x[n ] u sin g
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 l’s 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 0.2 0.4 0.6 0.8 1
Normalized Angular Frequency (×π rads/sample)

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)); % AR system output
pcov(x,4) % 4th order estimate
Covariance Spectral Estimate P (ω)
xx
40

30
Power Spectral Density (dB)

20

10

−10

−20
0 0.2 0.4 0.6 0.8 1
Normalized Angular Frequency (×π rads/sample)

Diagnostics Th e fir st in pu t a r gu m en t m u st be a fu ll vect or ; ot h er wise pcov gen er a t es t h e


followin g er r or m essa ge:
Input signal cannot be sparse.

If you specify a n em pt y m a t r ix for t h e secon d a r gu m en t , pcov gen er a t es t h e


followin g er r or m essa ge:
Model order must be an integer.

6-245
pcov

See Also arcov 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.
lpc Lin ea r pr edict ion coefficien t s.
pburg Power spect r u m est im a t e u sin g t h e Bu r g m et h od.
pmcov 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.
pmtm 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).
pmusic Power spect r u m est im a t e u sin g MUSIC eigen vect or
m et h od.
prony P r on y’s m et h od for t im e dom a in IIR filt er design .
pwelch 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.
pyulear 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 6pm cov


P ower 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.

Syntax Pxx = pmcov(x,p,nfft)


[Pxx,freq] = pmcov(x,p,nfft)
[Pxx,freq] = pmcov(x,p,nfft,Fs)
[Pxx,freq] = pmcov(x,p,nfft,Fs,'range')
pmcov(...)
pmcov(...,'squared')

Description pmcov est im a t es t h e power spect r a l den sit y (P SD) of t h e sign a l vect or x[n ]
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 l’s 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 0.2 0.4 0.6 0.8 1
Normalized Angular Frequency (×π rads/sample)

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)); % AR system output
pmcov(x,4) % 4th order estimate
Modified Covariance Spectral Estimate P (ω)
xx
40

30
Power Spectral Density (dB)

20

10

−10

−20

−30
0 0.2 0.4 0.6 0.8 1
Normalized Angular Frequency (×π rads/sample)

Diagnostics Th e fir st in pu t a r gu m en t m u st be a fu ll vect or ; ot h er wise pmcov gen er a t es t h e


followin g er r or m essa ge:
Input signal cannot be sparse.

If you specify a n em pt y m a t r ix for t h e secon d a r gu m en t , pmcov gen er a t es t h e


followin g er r or m essa ge:
Model order must be an integer.

6-249
pmcov

See Also armcov 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.
lpc Lin ea r pr edict ion coefficien t s.
pburg Power spect r u m est im a t e u sin g t h e Bu r g m et h od.
pcov 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.
pmtm 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).
pmusic Power spect r u m est im a t e u sin g MUSIC eigen vect or
m et h od.
prony P r on y’s m et h od for t im e dom a in IIR filt er design .
pwelch 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.
pyulear 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 6pm t m
P ower 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).

Syntax Pxx = pmtm(x,nw)


Pxx = pmtm(x,nw,nfft)
[Pxx,f] = pmtm(x,nw,nfft,Fs)
[Pxx,f] = pmtm(x,nw,nfft,Fs,'method')
[Pxx,Pxxc,f] = pmtm(x,nw,nfft,Fs,'method')
[Pxx,Pxxc,f] = pmtm(x,nw,nfft,Fs,'method',p)
[Pxx,Pxxc,f] = pmtm(x,e,v,nfft,Fs,'method',p)
[Pxx,Pxxc,f] = pmtm(x,dpss_params,nfft,Fs,'method',p)

Description pmtm est im a t es t h e power spect r a l den sit y (P SD) of t h e r ea l t im e ser ies x u sin g
t h e m u lt it a per m et h od (MTM), descr ibed in [1].

Pxx = pmtm(x,nw) est im a t es t h e P SD u sin g nw a s t h e t im e-ba n dwidt h pr odu ct


for t h e discr et e pr ola t e sph er oida l sequ en ces (Slepia n sequ en ces) t h a t a r e u sed
a s da t a win dows. Th e defa u lt for nw is 4; ot h er t ypica l ch oices a r e
2, 5/2, 3, 7/2. Th e n u m ber of sequ en ces u sed t o for m Pxx is 2*nw–1.

Pxx = pmtm(x,nw,nfft) defin es t h e fr equ en cy gr id a s len gt h nfft. Wh en x is


r ea l, Pxx is len gt h (nfft/2+1) for nfft even a n d (nfft+1)/2 for nfft odd;
wh en x is com plex, Pxx is len gt h nfft. Th e defa u lt for nfft is 256 or t h e n ext
power of 2 gr ea t er t h a n t h e len gt h of x, wh ich ever is la r ger .

[Pxx,f] = pmtm(x,nw,nfft,Fs) r et u r n s f, t h e vect or of fr equ en cies a t wh ich


t h e P SD is est im a t ed, for t h e sa m plin g fr equ en cy Fs. Th e defa u lt for Fs is 1 H z.

[Pxx,f] = pmtm(x,nw,nfft,Fs,'method') specifies t h e a lgor it h m u sed for


com bin in g t h e in dividu a l spect r a l est im a t es, wh er e m et h od is:

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


con fiden ce in t er va l for Pxx, a n d

[Pxx,Pxxc,f] = pmtm(x,nw,nfft,Fs,'method',p) r et u r n s Pxxc, t h e p*100%


con fiden ce in t er va l for Pxx, wh er e p is a sca la r bet ween 0 a n d 1. Con fiden ce

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 Th is exa m ple a n a lyzes a sin u soid in wh it e n oise:


Fs = 1000; t = 0:1/Fs:0.3;
x = cos(2*pi*t*200) + randn(size(t));
[Pxx,Pxxc,f] = pmtm(x,3.5,512,Fs,[],0.99);
plot(f,10*log10([Pxx Pxxc]))

20

15

10

-5

-10
0 100 200 300 400 500

See Also dpss Discr et e pr ola t e sph er oida l sequ en ces (Slepia n
sequ en ces).
pburg Power spect r u m est im a t e u sin g t h e Bu r g m et h od.
pcov 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.
pmcov 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.
pmusic Power spect r u m est im a t e u sin g MUSIC eigen vect or
m et h od.
pwelch 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.
pyulear 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 6pm u sic


P ower spect r u m est im a t e u sin g MUSIC eigen vect or m et h od.

Syntax [Pxx,f] = pmusic(x,p)


[Pxx,f] = pmusic(x,[p thresh])
[Pxx,f] = pmusic(x,[p thresh],nfft,Fs,window,noverlap)
[Pxx,f] = pmusic(x,...,'corr')
[Pxx,f] = pmusic(x,...,'ev')
[Pxx,f,evects,svals] = pmusic(x,...)

Description pmusic est im a t es t h e power spect r a l den sit y (P SD) of a sign a l or cor r ela t ion
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 l’s 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 ≤ 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 ≥ 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 ≤ ( thresh )m in (λ k ) ⇒ {λ 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 ≥ 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)

Assu m e t h a t RR is a squ a r e cor r ela t ion m a t r ix (for exa m ple, 7-by-7):


RR = toeplitz(cos(0.1*pi*[0:6])) + 0.1*eye(7);
[PP,ff] = pmusic(RR,4,'corr');

Ma ke a n obser va t ion m a t r ix xx t h a t is r ect a n gu la r (100-by-7):


xx = reshape(cos(0.257*pi*(0:699)),7,100) + 0.1*randn(7,100);
[PP,ff] = pmusic(xx,4);

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 Th e MUSIC est im a t e is given by t h e for m u la

1 1
P music(f ) = ---------------------------------------------------------------
N
- = ------------------------------------------
N -
⎛ ⎞
e H (f ) ⎜ ∑ v k v kH ⎟ e (f ) ∑ v kH e (f ) 2
⎜ ⎟
⎝ k = p + 1 ⎠ k = p +1

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

v kH e (f )

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
-
⎛ ⎞
⎜ v kH e (f ) 2⎟ ⁄ λ k
⎜ ∑ ⎟
⎝ k = p + 1 ⎠

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 Th er e m u st be a t lea st on e ou t pu t a r gu m en t a n d a t lea st t wo in pu t s; ot h er wise,


pmusic st ops a n d gives on e of t h e followin g er r or m essa ges:

Must have at least 1 output argument.


Must have at least 2 input arguments.

Th e fir st a r gu m en t m u st be a fu ll m a t r ix, ot h er wise pmusic gives t h e followin g


er r or m essa ge:
Input signal or correlation cannot be sparse.

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 lpc Lin ea r pr edict ion coefficien t s.


pburg Power spect r u m est im a t e u sin g t h e Bu r g m et h od.
pcov 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.
pmcov 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.
pmtm 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).
prony P r on y’s m et h od for t im e dom a in IIR filt er design .
pwelch 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.
pyulear 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 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.

Syntax r = poly2ac(a,efinal)

Description 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.

See Also ac2poly Con ver sion of a u t ocor r ela t ion sequ en ce t o pr edict ion
polyn om ia l.
poly2rc Con ver sion of pr edict ion polyn om ia l t o r eflect ion
coefficien t s.
rc2ac 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 6poly2r c
Con ver sion of pr edict ion polyn om ia l t o r eflect ion coefficien t s.

Syntax k = poly2rc(a)
[k,r0] = poly2rc(a,efinal)

Description k = poly2rc(a) fin ds t h e r eflect ion coefficien t s of t h e AR la t t ice st r u ct u r e


cor r espon din g t o pr edict ion polyn om ia l a. a m u st be r ea l, a n d a(1) ca n n ot be 0.
If a (1) is n ot equ a l t o 1, poly2rc n or m a lizes t h e pr edict ion polyn om ia l by a(1).
k is a r ow vect or of size length(a)–1.

[k,r0] = poly2rc(a,efinal) r et u r n s t h e zer o-la g a u t ocor r ela t ion , r0, ba sed


on t h e fin a l pr edict ion er r or , efinal.
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 Con sider a n IIR filt er given by


a = [1.0000 0.6149 0.9899 0.0000 0.0031 –0.0082];

It s r eflect ion coefficien t r epr esen t a t ion is


k = poly2rc(a)

k =
0.3090
0.9801
0.0031
0.0081
–0.0082

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.

Algorithm poly2rc im plem en t s t h e r ecu r sive r ela t ion sh ip:

6-263
poly2rc

k (n ) = a n (n )

a n (m ) – k (n )a n (n – m )
a n – 1 (m ) = ---------------------------------------------------------- , m = 1 , 2 , …, n – 1
1 – k (n ) 2
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 = (a–k(i)*fliplr(a))/(1–k(i)^2);

See Also ac2rc Con ver sion of a u t ocor r ela t ion sequ en ce t o r eflect ion
coefficien t s.
latc2tf La t t ice filt er t o t r a n sfer fu n ct ion con ver sion .
latcfilt La t t ice a n d la t t ice-la dder filt er im plem en t a t ion .
poly2ac Con ver sion of pr edict ion polyn om ia l t o
a u t ocor r ela t ion sequ en ce.
rc2poly Con ver sion of r eflect ion coefficien t s t o pr edict ion
polyn om ia l.
tf2latc 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 6polyst a b
St a bilize polyn om ia l.

Syntax b = polystab(a)

Description 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
wit h m a gn it u des gr ea t er t h a n 1 in side t h e u n it cir cle.

b = polystab(a) wh er e a is a vect or of polyn om ia l coefficien t s n or m a lly in t h e


z-dom a in :

a (z ) = a (1 ) + a (2 )z – 1 + L+ a (n a + 1 )z – n a
r et u r n s a r ow vect or con t a in in g t h e st a bilized polyn om ia l.

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 = (1–vs).*v + vs./conj(v);
b = a(1)*poly(v);

See Also roots Polyn om ia l r oot s (see t h e on lin e M AT L AB Fu n ction


R eferen ce).

6-265
prony

Purpose 6pr on y
P r on y’s m et h od for t im e dom a in IIR filt er design .

Syntax [b,a] = prony(h,nb,na)

Description P r on y’s 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 ) = ----------- = ----------------------------------------------------------------------------------------
-
A (z ) a (1 ) + a (2 )z – 1 + L+ a (n a + 1 )z –n a

Example Recover 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,0.2)

b =
0.0048 0.0193 0.0289 0.0193 0.0048

a =
1.0000 –2.3695 2.3140 –1.0547 0.1874

h = filter(b,a,[1 zeros(1,25)]);
[bb,aa] = prony(h,4,4)

bb =
0.0048 0.0193 0.0289 0.0193 0.0048

ab =
1.0000 –2.3695 2.3140 –1.0547 0.1874

Algorithm prony im plem en t s t h e m et h od descr ibed in r efer en ce [1]. 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 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 butter Bu t t er wor t h a n a log a n d digit a l filt er design .


cheby1 Ch ebysh ev t ype I filt er design (pa ssba n d r ipple).
cheby2 Ch ebysh ev t ype II filt er design (st opba n d r ipple).
ellip E llipt ic (Ca u er ) filt er design .
invfreqz Discr et e-t im e filt er iden t ifica t ion fr om fr equ en cy
da t a .
levinson Levin son -Du r bin r ecu r sion .
lpc Lin ea r pr edict ion coefficien t s.
stmcb 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


6psd

su per seded by pwelch.


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 6pu lst r a n


P u lse t r a in gen er a t or .

Syntax y = pulstran(t,d,'func')
y = pulstran(t,d,'func',p1,p2,...)
y = pulstran(t,d,p,Fs)
y = 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(t–d(1)) + func(t–d(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


t o 'func' a s n ecessa r y. F or exa m ple,
func(t–d(1),p1,p2,...) + func(t–d(2),p1,p2,...) + ...

pulstran(t,d,p,Fs) gen er a t es a pu lse t r a in t h a t is t h e su m of m u lt iple


dela yed in t er pola t ion s of t h e pr ot ot ype pu lse in vect or p, sa m pled a t t h e r a t e
Fs, wh er e p spa n s t h e t im e in t er va l [0,(length(p)–1)/Fs], a n d it s sa m ples
a r e iden t ica lly 0 ou t side t h is in t er va l. By defa u lt , lin ea r in t er pola t ion is u sed
for gen er a t in g dela ys.

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)

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

pu lse t r a in len gt h is 10 m sec. Th e r epet it ion a m plit u de sh ou ld a t t en u a t e by 0.8


ea ch t im e:
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)

0.8

0.6

0.4

0.2

-0.2

-0.4

-0.6

-0.8
0 0.002 0.004 0.006 0.008 0.01

6-271
pulstran

Th is exa m ple gen er a t es a t r a in of 10 H a m m in g win dows:


p = hamming(32);
t = 0:320; d = (0:9)'*32;
y = pulstran(t,d,p);
plot(t,y)

0.9

0.8

0.7

0.6

0.5

0.4

0.3

0.2

0.1

0
0 50 100 150 200 250 300 350

See Also chirp Swept -fr equ en cy cosin e gen er a t or.


cos 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).
diric Dir ich let or per iodic sin c fu n ct ion .
gauspuls Ga u ssia n -m odu la t ed sin u soida l pu lse gen er a t or.
rectpuls Sa m pled a per iodic r ect a n gle gen er a t or.
sawtooth Sawt oot h or t r ia n gle wave gen er a t or.
sin 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).
sinc Sin c or sin (πt )/πt fu n ct ion .
square Squ a r e wa ve gen er a t or.
tripuls Sa m pled a per iodic t r ia n gle gen er a t or.

6-272
pwelch

Purpose 6pwelch
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.

Syntax Pxx = pwelch(x)


Pxx = pwelch(x,nfft)
[Pxx,w] = pwelch(x,nfft)
[Pxx,f] = pwelch(x,nfft,Fs)
[Pxx,f] = pwelch(x,nfft,Fs,window)
[Pxx,f] = pwelch(x,nfft,Fs,window,noverlap)
[Pxx,Pxxc,f] = pwelch(x,nfft,Fs,window,noverlap,p)
[Pxx,Pxxc,f] = pwelch(...,'range')
pwelch(...)
pwelch(...,'magunits')

Description Pxx = pwelch(x) est im a t es t h e power spect r u m of t h e sequ en ce x u sin g t h e


Welch m et h od of spect r a l est im a t ion . If x is r ea l, pwelch est im a t es t h e
spect r u m a t posit ive fr equ en cies on ly; in t h is ca se, ou t pu t Pxx 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 is
com plex, pwelch est im a t es t h e spect r u m a t bot h posit ive a n d n ega t ive
fr equ en cies a n d Pxx h a s len gt h nfft.

Pxx = pwelch(x,nfft) u ses t h e specified F F T len gt h nfft in est im a t in g t h e


power spect r u m for x. Th is va lu e det er m in es t h e n u m ber of differ en t
fr equ en cies a t wh ich t h e power spect r u m is est im a t ed. Specify nfft a s a power
of 2 for fa st est execu t ion . Specify a n em pt y m a t r ix for nfft, [], t o u se t h e
defa u lt va lu e of min(256,length(x)).

[Pxx,w] = pwelch(x,nfft) r et u r n s a vect or w of n or m a lized a n gu la r


fr equ en cies (in r a ds/sa m ple) a t wh ich t h e fu n ct ion eva lu a t es t h e P SD. Th e
r a n ge of w is [0,π) for r ea l x a n d [0,2π) for com plex x. Sin ce t h e fr equ en cy vect or
w is t h e sa m e size a s Pxx, plot(w,Pxx) plot s t h e power spect r u m ver su s t h e
n or m a lized a n gu la r fr equ en cy.

[Pxx,f] = pwelch(x,nfft,Fs) r et u r n s a vect or f of lin ea r fr equ en cies (in H z)


a t wh ich t h e fu n ct ion eva lu a t es t h e P SD. Fs is a sca la r t h a t specifies t h e
sa m plin g fr equ en cy of x, a n d Pxx is sca led by 1/Fs. Th e r a n ge of f is [0,Fs/2)
for r ea l x a n d [0,Fs) for com plex x. Sin ce t h e fr equ en cy vect or f is t h e sa m e
size a s Pxx, plot(f,Pxx) plot s t h e power spect r u m ver su s t h e lin ea r fr equ en cy.
Specify a n em pt y m a t r ix for Fs, [], t o u se t h e defa u lt va lu e of 1 H z.

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


m a gn it u de a xis of t h e P SD plot . Th e opt ion s a r 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)

Welch’s Spectral Estimate Pxx(f) / fs


−30

−40

−50
Power Spectral Density (dB)

−60

−70

−80

−90

−100

−110
0 1000 2000 3000 4000 5000
Frequency (Hz)

Algorithm pwelch ca lcu la t es t h e power spect r a l den sit y u sin g Welch ’s m et h od (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


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
of ea ch t r a n sfor m ed sect ion .

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.

Th e n u m ber of sect ion s t h a t pwelch a ver a ges is


k = fix((length(x)–noverlap)/(length(window)–noverlap))

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 window’s length to be no greater than FFT length.


Requires NOVERLAP to be strictly less than the window length.
Requires positive integer values for NFFT and NOVERLAP.
Requires confidence parameter to be a scalar between 0 and 1.
Requires vector input.

See Also cohere 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.
csd 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.
pburg Power spect r u m est im a t e u sin g t h e Bu r g m et h od.
pcov 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.
pmcov 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.
pmtm 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).
pmusic Power spect r u m est im a t e u sin g MUSIC eigen vect or
m et h od.
pyulear Power spect r u m est im a t e u sin g Yu le-Wa lker AR
m et h od.
specgram Tim e-depen den t fr equ en cy a n a lysis (spect r ogr a m ).
tfe 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 6pyu lea r


P ower spect r u m est im a t e u sin g Yu le-Wa lker AR m et h od.

Syntax Pxx = pyulear(x,p,nfft)


[Pxx,freq] = pyulear(x,p,nfft)
[Pxx,freq] = pyulear(x,p,nfft,Fs)
[Pxx,freq] = pyulear(x,p,nfft,Fs,'range')
pyulear(...)
pyulear(...,'squared')

Description pyulear est im a t es t h e power spect r a l den sit y (P SD) of t h e sign a l vect or x[n ]
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 l’s 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 0.2 0.4 0.6 0.8 1
Normalized Angular Frequency (×π rads/sample)

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)); % AR system output
pyulear(x,4) % 4th order estimate
Yule−Walker Spectral Estimate P (ω)
xx
25

20
Power Spectral Density (dB)

15

10

−5

−10
0 0.2 0.4 0.6 0.8 1
Normalized Angular Frequency (×π rads/sample)

Diagnostics Th e fir st in pu t a r gu m en t m u st be a fu ll vect or ; ot h er wise pyulear gen er a t es


t h e followin g er r or m essa ge:
Input signal cannot be sparse.

If you specify a n em pt y m a t r ix for t h e secon d a r gu m en t , pyulear gen er a t es t h e


followin g er r or m essa ge:
Model order must be an integer.

6-280
pyulear

See Also aryule 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.
lpc Lin ea r pr edict ion coefficien t s.
pburg Power spect r u m est im a t e u sin g t h e Bu r g m et h od.
pcov 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.
pmcov 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.
pmtm 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).
pmusic Power spect r u m est im a t e u sin g MUSIC eigen vect or
m et h od.
prony P r on y’s m et h od for t im e dom a in IIR filt er design .
pwelch 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 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.

Syntax r = rc2ac(k,r0)

Description 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.

See Also ac2rc Con ver sion of a u t ocor r ela t ion sequ en ce t o r eflect ion
coefficien t s.
poly2ac Con ver sion of pr edict ion polyn om ia l t o
a u t ocor r ela t ion sequ en ce.
rc2poly 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 6rc2poly
Con ver sion of r eflect ion coefficien t s t o pr edict ion polyn om ia l.

Syntax a = rc2poly(k)
[a,efinal] = rc2poly(k,r0)

Description a = rc2poly(k) fin ds t h e pr edict ion polyn om ia l a, wit h a(1) = 1, fr om t h e


r eflect ion coefficien t s k of t h e cor r espon din g la t t ice st r u ct u r e. Ou t pu t a is r ow
vect or of len gt h k + 1.

[a,efinal] = rc2poly(k,r0) r et u r n s t h e fin a l pr edict ion er r or , efinal,


ba sed on t h e zer o-la g a u t ocor r ela t ion , r0.

Example Con sider a n IIR filt er given by r eflect ion coefficien t s k:


k = [0.3090 0.9800 0.0031 0.0082 –0.0082];

It s polyn om ia l r epr esen t a t ion is


a = rc2poly(k)

a =

1.0000 0.6148 0.9899 0.0000 0.0032 –0.0082

Algorithm rc2poly com pu t es ou t pu t a u sin g Levin son ’s r ecu r sion [1]. Th e fu n ct ion :

1 Set s t h e ou t pu t vect or a t o t h e fir st elem en t of k


2 Loops t h r ou gh t h e r em a in in g elem en t s of k
F or ea ch loop it er a t ion i, a = [a + a(i–1:–1:1)*k(i) k(i)].
3 Im plem en t s a = [1 a]

6-283
rc2poly

See Also ac2poly Con ver sion of a u t ocor r ela t ion sequ en ce t o pr edict ion
polyn om ia l.
latc2tf La t t ice filt er t o t r a n sfer fu n ct ion con ver sion .
latcfilt La t t ice a n d la t t ice-la dder filt er im plem en t a t ion .
poly2rc Con ver sion of pr edict ion polyn om ia l t o r eflect ion
coefficien t s.
rc2ac Con ver sion of r eflect ion coefficien t s t o
a u t ocor r ela t ion sequ en ce.
tf2latc 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 6rceps
Rea l cepst r u m a n d m in im u m ph a se r econ st r u ct ion .

Syntax y = rceps(x)
[y,ym] = rceps(x)

Description 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 rceps is a n M-file im plem en t a t ion of a lgor it h m 7.2 in [2], t h a t is:

y = real(ifft(log(abs(fft(x)))));

Appr opr ia t e win dowin g in t h e cepst r a l dom a in for m s t h e r econ st r u ct ed


m in im u m ph a se sign a l:
w = [1; 2*ones(n/2–1,1); ones(1 – rem(n,2),1); zeros(n/2–1,1)];
ym = real(ifft(exp(fft(w.*y))));

See Also cceps Com plex cepst r a l a n a lysis.


fft On e-dim en sion a l fa st Fou r ier t r a n sfor m .
hilbert H ilber t t r a n sfor m .
icceps In ver se com plex cepst r u m .
unwrap 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 6rect pu ls
Sa m pled a per iodic r ect a n gle gen er a t or .

Syntax y = rectpuls(t)
y = rectpuls(t,w)

Description y = rectpuls(t) r et u r n s a con t in u ou s, a per iodic, u n it y-h eigh t r ect a n gu la r


pu lse a t t h e sa m ple t im es in dica t ed in a r r a y t, cen t er ed a bou t t = 0 a n d wit h
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 Swept -fr equ en cy cosin e gen er a t or.


cos 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).
diric Dir ich let or per iodic sin c fu n ct ion .
gauspuls Ga u ssia n -m odu la t ed sin u soida l pu lse gen er a t or.
pulstran P u lse t r a in gen er a t or.
sawtooth Sawt oot h or t r ia n gle wave gen er a t or.
sin 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).
sinc Sin c or sin (πt )/πt fu n ct ion .
square Squ a r e wa ve gen er a t or.
tripuls Sa m pled a per iodic t r ia n gle gen er a t or.

6-286
remez

Purpose 6rem ez
P a r ks-McClella n opt im a l F IR filt er design .

Syntax b = remez(n,f,a)
b = remez(n,f,a,w)
b = remez(n,f,a,'ftype')
b = remez(n,f,a,w,'ftype')
b = remez(...,{lgrid})
b = remez(n,f,'fresp',w)
b = remez(n,f,'fresp',w,'ftype')
b = remez(n,f,{'fresp',p1,p2,...},w)
b = remez(n,f,{'fresp',p1,p2,...},w,'ftype')
[b,delta] = remez(...)
[b,delta,opt] = remez(...)

Description remez design s a lin ea r -ph a se F IR filt er u sin g t h e P a r ks-McClella n


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.
Th e ou t pu t filt er coefficien t s (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
Vect or s f a n d a specify t h e fr equ en cy-m a gn it u de ch a r a ct er ist ics of t h e filt er :

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]

Desired amplitude
response (a) 1.0

0.5

Normalized
0.0 frequency (f)
0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 (Nyquist)

"Don't care"/transition regions

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

[b,delta,opt] = remez(...) r et u r n s a st r u ct u r e, opt, of opt ion a l r esu lt s


wit h t h e followin g fields.

opt.fgrid F r equ en cy gr id vect or u sed for t h e filt er design opt im iza t ion
opt.des Desir ed fr equ en cy r espon se for ea ch poin t in opt.fgrid
opt.wt Weigh t in g for ea ch poin t in opt.fgrid
opt.H Act u a l fr equ en cy r espon se for ea ch poin t in opt.fgrid
opt.error E r r or a t ea ch poin t in opt.fgrid (opt.des–opt.H)
opt.iextr Vect or of in dices in t o opt.fgrid for ext r em a l fr equ en cies
opt.fextr 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 1

6-291
remez

Algorithm remez is a ME X-file ver sion of t h e or igin a l F or t r a n code fr om [1], a lt er ed t o


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 Response H(f), Response H(f),
Filter Type Order n Symmetry of Coefficients f=0 f = 1 (Nyquist)

Type I E ven even : No r est r ict ion No r est r ict ion


b (k ) = b (n + 2 – k ), k = 1 , …, n + 1
Type II Odd No r est r ict ion H (1) = 0

Type III E ven odd: H (0) = 0 H (1) = 0


b (k ) = – b (n + 2 – k ), k = 1 , …, n + 1
Type IV Odd H (0) = 0 No r est r ict ion

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.

A m or e ser iou s wa r n in g m essa ge is


–– Failure to Converge ––
Probable cause is machine rounding error.

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 Bu t t er wor t h a n a log a n d digit a l filt er design .


cheby1 Ch ebysh ev t ype I filt er design (pa ssba n d r ipple).
cheby2 Ch ebysh ev t ype II filt er design (st opba n d r ipple).
cremez Com plex a n d n on lin ea r-ph a se equ ir ipple F IR filt er
design .
ellip E llipt ic (Ca u er ) filt er design .
fir1 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.
fir2 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.
fircls 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.
fircls1 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.
firls Lea st squ a r e lin ea r-ph a se F IR filt er design .
firrcos Ra ised cosin e F IR filt er design .
remezord Pa r ks-McClella n opt im a l F IR filt er or der est im a t ion .
yulewalk 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 6rem ezor d


P a r ks-McClella n opt im a l F IR filt er or der est im a t ion .

Syntax [n,fo,ao,w] = remezord(f,a,dev)


[n,fo,ao,w] = remezord(f,a,dev,Fs)
c = remezord(f,a,dev,Fs,'cell')

Description [n,fo,ao,w] = remezord(f,a,dev) fin ds t h e a ppr oxim a t e or der , n or m a lized


fr equ en cy ba n d edges, fr equ en cy ba n d a m plit u des, 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, t o u se wit h t h e remez com m a n d.

• 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

2000 H z), a t lea st 40 dB a t t en u a t ion in t h e st opba n d, a n d less t h a n 3 dB of


r ipple in t h e pa ssba n d:
rp = 3; % passband ripple
rs = 40; % stopband ripple
Fs = 2000; % sampling frequency
f = [500 600]; % cutoff frequencies
a = [1 0]; % desired amplitudes

% compute deviations
dev = [(10^(rp/20)–1)/(10^(rp/20)+1) 10^(–rs/20)];

[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)));

title('Lowpass Filter Designed to Specifications');


xlabel('Frequency (Hz)'); ylabel('Magnitude (dB)'); grid;
Lowpass Filter Designed to Specifications
10

-10
Magnitude (dB)

-20

-30

-40

-50

-60
0 100 200 300 400 500 600 700 800 900 1000
Frequency (Hz)

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

Th is is equ iva len t t o


c = remezord( [1500 2000], [1 0], [0.01 0.1], 8000, 'cell');
b = remez(c{:});

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 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).

Diagnostics If t h e in pu t pa r a m et er len gt h s a r e n ot con sist en t , remezord gives t h e followin g


er r or m essa ges:
Requires M and DEV to be the same length.
Length of F must be length(M)–2.

See Also buttord Bu t t er wor t h filt er or der select ion .


cheb1ord Ch ebysh ev t ype I filt er or der select ion .
cheb2ord Ch ebysh ev t ype II filt er or der select ion .
ellipord E llipt ic filt er or der select ion .
kaiserord 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.
remez 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 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 .

Syntax 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)

Description 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
per for m s a n ea r est -n eigh bor in t er pola t ion :
y(k) = x(round((k-1)*q/p)+1)

wh er e y(k) = 0 if t h e in dex t o x is gr ea t er t h a n length(x).

y = resample(x,p,q,n,beta) u ses beta a s t h e design pa r a m et er for t h e


Ka iser win dow t h a t resample em ploys in design in g t h e lowpa ss filt er . Th e
defa u lt for beta is 5.

y = resample(x,p,q,b) filt er s x wit h b, a vect or of filt er coefficien t s.

[y,b] = resample(x,p,q) r et u r n s t h e vect or b, wh ich con t a in s t h e


coefficien t s of t h e filt er a pplied t o x du r in g t h e r esa m plin g pr ocess.

6-298
resample

Examples Resa m ple a sim ple lin ea r sequ en ce a t 3/2 t h e or igin a l r a t e:


Fs1 = 10; % original sampling frequency in Hz
t1 = 0:1/Fs1:1; % time vector
x = t1; % define a linear sequence
y = resample(x,3,2); % now resample it

t2 = (0:(length(y)–1))*2/(3*Fs1); % new time vector


plot(t1,x,'*',t2,y,'o',–0.5:0.01:1.5,–0.5:0.01:1.5,':')
legend('original','resampled'); xlabel('Time')

1.5
original
resampled

0.5

−0.5
−0.5 0 0.5 1 1.5
Time

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
original
8 resampled

0
0 5 10 15 20
Edge Effects Very Noticeable
15

10

5
original
resampled
0
0 5 10 15 20

Diagnostics If p or q a r e n ot posit ive in t eger s, resample gives t h e a ppr opr ia t e er r or


m essa ge:
P must be a positive integer.
Q must be a positive integer.

If x is n ot a vect or , resample gives t h e followin g er r or m essa ge:


Input X must be a vector.

6-300
resample

See Also decimate Decr ea se t h e sa m plin g r a t e for a sequ en ce


(decim a t ion ).
firls Lea st squ a r e lin ea r-ph a se F IR filt er design .
interp 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 ).
interp1 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).
intfilt In t er pola t ion F IR filt er design .
kaiser Ka iser win dow.
spline 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).
upfirdn Upsa m ple, a pply a n F IR filt er, a n d down sa m ple.

6-301
residuez

Purpose 6residu ez
z-t r a n sfor m pa r t ia l-fr a ct ion expa n sion .

Syntax [r,p,k] = residuez(b,a)


[b,a] = residuez(r,p,k)

Description residuez con ver t s a discr et e t im e syst em , expr essed a s t h e r a t io of t wo


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 (z ) = a 0 + a 1 z – 1 + a 2 z – 2 + L+ a n z – n

If t h er e a r e n o m u lt iple r oot s a n d a > n–1,

b (z ) r (1 ) r (n )
---------- = ----------------------------
– 1
- + k (1 ) + k (2 )z – 1 + L+ k (m – n + 1 )z – ( m
+ L+ ---------------------------- – n)
a (z ) 1 – p (1 )z 1 – p (n )z – 1
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)

Th e dir ect t er m coefficien t vect or k is em pt y if length(b) < length(a);


ot h er wise
length(k) = length(b) – length(a) + 1

If p(j) = ... = p(j+s–1) 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 ) r (j + 1 ) r (j + s r – 1 )
--------------------------
– 1 2
- + L+ -----------------------------------
- + ---------------------------------- -
1 – p (j )z ( 1 – p (j )z ) – 1
( 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
poles a ccor din g t o t h eir m u lt iplicit ies.
3 Th e r esidu e for ea ch n on r epea t in g pole p i by m u lt iplyin g b(z)/ a(z) by
1/(1-p iz -1 ) a n d eva lu a t in g t h e r esu lt in g r a t ion a l fu n ct ion a t z = p i.
4 Th e r esidu es for t h e r epea t ed poles by solvin g
S2*r2 = h – S1*r1

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

-, ------------------------------
----------------------
1
-, L
2
, -------------------------------
-
1 – p jz ( 1 – p jz ) – 1
( 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 Con volu t ion m a t r ix.


deconv 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).
poly 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).
prony P r on y’s m et h od for t im e dom a in IIR filt er design .
residue 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).
roots Polyn om ia l r oot s (see t h e on lin e M AT L AB Fu n ction
R eferen ce).
ss2tf Con ver sion of st a t e-spa ce t o zer o-pole-ga in .
tf2ss Con ver sion of t r a n sfer fu n ct ion t o st a t e-spa ce.
tf2zp Con ver sion of t r a n sfer fu n ct ion t o zer o-pole-ga in .
zp2ss 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 6rlevin son


Rever se Levin son -Du r bin r ecu r sion .

Syntax r = rlevinson(a,efinal)
[r,u] = rlevinson(a,efinal)
[r,u,k] = rlevinson(a,efinal)
[r,u,k,e] = rlevinson(a,efinal)

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 ) L r (p ) a (2 ) – r (2 )
r (2 ) r (1 ) L r (p – 1 )
∗ a (3 ) – r (3 )
=
M O O M M M
r (p ) L r (2 ) r (1 ) 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
sign a l, x̂ ( 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 .

Prediction Error Filter

–1 –2 –p x̂ ( n )
x (n ) – a ( 2 )z – a ( 3 )z – L– a ( n + 1 )z e(n )
H (z ) =
– Σ
+

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 (z ) = 1 + a (2 )z –1 + L+ a (n + 1 )z – p

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, σ2 (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


UDU * decom posit ion
–1 –1 ∗
R = UE U
wh er e

∗ ∗
r (1 ) r (2 ) L 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 a 2 (1 ) O a p + 1 (p )
U = ∗
0 0 Oa p + 1 ( p – 1 )
M O O M

0 L 0 a p + 1 (1 )

wh er e a i (j) is t h e jt h coefficien t of t h e it 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)'

Not e t h a t u(p+1:-1:1,p+1)' is t h e in pu t polyn om ia l coefficien t vect or a.

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 ,
–1 –1 ∗
R = UE U .

See Also levinson Levin son -Du r bin r ecu r sion .


lpc Lin ea r pr edict ion coefficien t s.
prony P r on y’s m et h od for t im e dom a in IIR filt er design .
stmcb Lin ea r m odel u sin g St eiglit z-McBr ide it er a t ion .

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 6sa wt oot h


Sa wt oot h or t r ia n gle wa ve gen er a t or .

Syntax x = sawtooth(t)
x = sawtooth(t,width)

Description sawtooth(t) gen er a t es a sa wt oot h wa ve wit h per iod 2π for t h e elem en t s of


t im e vect or t. sawtooth(t) is sim ila r t o sin(t), bu t it cr ea t es a sa wt oot h wa ve
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 If t h e width pa r a m et er is n ot a sca la r , sawtooth gives t h e followin g er r or


m essa ge:
Requires WIDTH parameter to be a scalar.

See Also chirp Swept -fr equ en cy cosin e gen er a t or.


cos 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).
diric Dir ich let or per iodic sin c fu n ct ion .
gauspuls Ga u ssia n -m odu la t ed sin u soida l pu lse gen er a t or.
pulstran P u lse t r a in gen er a t or.
rectpuls Sa m pled a per iodic r ect a n gle gen er a t or.
sin 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).
sinc Sin c or sin (πt )/πt fu n ct ion .
square Squ a r e wa ve gen er a t or.
tripuls Sa m pled a per iodic t r ia n gle gen er a t or.

6-308
sgolay

Purpose 6sgola y
Sa vit zk y-Gola y filt er design .

Syntax b = sgolay(k,f)
b = sgolay(k,f,w)

Description b = sgolay(k,f) design s a Sa vit zk y-Gola y F IR sm oot h in g filt er b. Th e


polyn om ia l or der k m u st be less t h a n t h e fr a m e size, f, wh ich m u st be odd. If
k = f–1, t h e design ed filt er pr odu ces n o sm oot h in g. Th e ou t pu t , b, is a n f-by-f
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 (f–1)/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 (f–1)/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 l’s 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 fir1 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.
firls Lea st squ a r e lin ea r-ph a se F IR filt er design .
filter 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.
sgolayfilt 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 6sgola yfilt


Sa vit zk y-Gola y filt er in g.

Syntax y = sgolayfilt(x,k,f)
y = sgolayfilt(x,k,f,w)

Description y = sgolayfilt(x,k,f) a pplies a Sa vit zky-Gola y F IR sm oot h in g filt er t o t h e


da t a in vect or x. If x is a m a t r ix, sgolayfilt oper a t es on ea ch colu m n . Th e
polyn om ia l or der k m u st be less t h a n t h e fr a m e size, f, wh ich m u st be odd. If
k = f–1, t h e filt er pr odu ces n o sm oot h in g.

y = sgolayfilt(x,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 l’s 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

−4
0 500 1000 1500 2000

smtlb
4

−2

−4
0 500 1000 1500 2000

See Also medfilt1 On e-dim en sion a l m edia n filt er in g.


filter 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.
sgolay Savit zky-Gola y filt er design .
sosfilt 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 6sin c
Sin c fu n ct ion .

Syntax y = sinc(x)

Description 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


fu n ct ion is

⎧ 1 , t =0
⎪
sin c(t ) = ⎨ sin ( πt )
⎪ -------------------, t ≠0
⎩ πt

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π ∫–π e j ωt d ω
y = sinc(x) r et u r n s a n a r r a y y t h e sa m e size a s x, wh ose elem en t s a r e t h e
sinc fu n ct ion of t h e elem en t s of x.

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 ω ∈ [– π,π] 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 ) = ∑ g(n )sin c(t – n )


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)

1.5

0.5

-0.5

-1
-5 0 5 10 15

6-314
sinc

See Also chirp Swept -fr equ en cy cosin e gen er a t or.


cos 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).
diric Dir ich let or per iodic sin c fu n ct ion .
gauspuls Ga u ssia n -m odu la t ed sin u soida l pu lse gen er a t or.
pulstran P u lse t r a in gen er a t or.
rectpuls Sa m pled a per iodic r ect a n gle gen er a t or.
sawtooth Sawt oot h or t r ia n gle wave gen er a t or.
sin 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).
square Squ a r e wa ve gen er a t or.
tripuls Sa m pled a per iodic t r ia n gle gen er a t or.

6-315
sos2ss

Purpose 6sos2ss
Con ver sion of secon d-or der sect ion s t o st a t e-spa ce.

Syntax [A,B,C,D] = sos2ss(sos)


[A,B,C,D] = sos2ss(sos,g)

Description 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
equ iva len t st a t e-spa ce r epr esen t a t ion .

[A,B,C,D] = sos2ss(sos) con ver t s t h e syst em sos, in secon d-or der sect ion
for m , t o a sin gle-in pu t , sin gle-ou t pu t st a t e-spa ce r epr esen t a t ion :

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
b 0 k + b 1 k z –1 + b 2 k z –2
H (z ) = ∏ H k (z ) = ∏ ---------------------------------------------------------
1 + a 1 k z – 1 + a 2 k z –2
-
k =1 k =1

sos is a L -by-6 m a t r ix or ga n ized a s

b 01 b 11 b 21 1 a 11 a 21
b 02 b 12 b 22 1 a 12 a 22
s os =
M M M M M M
b0L b1 L b2L 1 a1L a2L

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 = 2L -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 ∏ 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 3 1 1 10 1];
[A,B,C,D] = sos2ss(sos)

A =
–10 0 10 1
1 0 0 0
0 1 0 0
0 0 1 0

B =
1
0
0
0

C =
21 2 –16 –1

D =
–2

Algorithm 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.

See Also sos2tf Con ver sion of secon d-or der sect ion s t o t r a n sfer
fu n ct ion .
sos2zp Con ver sion of secon d-or der sect ion s t o zer o-pole-ga in .
ss2sos Con ver sion of st a t e-spa ce t o secon d-or der sect ion s.
tf2ss Con ver sion of t r a n sfer fu n ct ion t o st a t e-spa ce.
zp2ss Con ver sion of zer o-pole-ga in t o st a t e-spa ce.

6-317
sos2tf

Purpose 6sos2t f
Con ver sion of secon d-or der sect ion s t o t r a n sfer fu n ct ion .

Syntax [b,a] = sos2tf(sos)


[b,a] = sos2tf(sos,g)

Description 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
equ iva len t t r a n sfer fu n ct ion r epr esen t a t ion .

[b,a] = sos2tf(sos) r et u r n s t h e n u m er a t or coefficien t s b a n d den om in a t or


coefficien t s a of 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 . Th e secon d-or der sect ion for m a t of
H (z) is given by
L L
b 0 k + b 1 k z –1 + b 2 k z –2
H (z ) = ∏ H k (z ) = ∏ ---------------------------------------------------------
1 + a 1 k z – 1 + a 2 k z –2
-
k =1 k =1

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:

b 01 b 11 b 21 1 a 11 a 21
b 02 b 12 b 22 1 a 12 a 22
s os =
M M M M M M
b0L b1 L b2L 1 a1L a2L

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 (z ) b 1 + b 2 z – 1 + L+ b n + 1 z – n
H (z ) = ----------- = --------------------------------------------------------------------
-
A (z ) a 1 + a 2 z – 1 + L+ a m + 1 z – m

[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 ∏ H k (z )
k =1

6-318
sos2tf

Algorithm 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 .

Example 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 3 1 1 10 1];
[b,a] = sos2tf(sos)

b =
–2 1 2 4 1

a =
1 10 0 –10 –1

See Also latc2tf La t t ice filt er t o t r a n sfer fu n ct ion con ver sion .
sos2ss Con ver sion of secon d-or der sect ion s t o st a t e-spa ce.
sos2zp Con ver sion of secon d-or der sect ion s t o zer o-pole-ga in .
ss2tf Con ver sion of st a t e-spa ce t o t r a n sfer fu n ct ion .
tf2sos Con ver sion of t r a n sfer fu n ct ion t o secon d-or der
sect ion s.
zp2tf Con ver sion of zer o-pole-ga in t o t r a n sfer fu n ct ion .

6-319
sos2zp

Purpose 6sos2zp
Con ver sion of secon d-or der sect ion s t o zer o-pole-ga in .

Syntax [z,p,k] = sos2zp(sos)


[z,p,k] = sos2zp(sos,g)

Description 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
equ iva len t zer o-pole-ga in r epr esen t a t ion .

[z,p,k] = sos2zp(sos) 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 . Th e secon d-or der sect ion for m a t of
H (z) is given by
L L
b 0 k + b 1 k z –1 + b 2 k z –2
H (z ) = ∏ H k (z ) = ∏ ---------------------------------------------------------
1 + a 1 k z – 1 + a 2 k z –2
-
k =1 k =1

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:

b 01 b 11 b 21 1 a 11 a 21
b 02 b 12 b 22 1 a 12 a 22
s os =
M M M M M M
b0L b1 L b2L 1 a1L a2L

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 )Lz ( – zn )
H (z ) = k -------------------------------------------------------------------
( p – p 1 ) ( p – p 2 )Lp ( – pm )

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 ∏ 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 3 1 1 10 1];
[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

Algorithm 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.

See Also sos2ss Con ver sion of secon d-or der sect ion s t o st a t e-spa ce.
sos2tf Con ver sion of secon d-or der sect ion s t o t r a n sfer
fu n ct ion .
ss2zp Con ver sion of st a t e-spa ce t o zer o-pole-ga in .
tf2zp Con ver sion of t r a n sfer fu n ct ion t o zer o-pole-ga in .
zp2sos Con ver sion of zer o-pole-ga in t o secon d-or der sect ion s.

6-321
sosfilt

Purpose 6sosfilt
Secon d-or der (biqu a dr a t ic) IIR filt er in g.

Syntax y = sosfilt(sos,x)

Description y = sosfilt(sos,x) a pplies t h e secon d-or der sect ion filt er sos t o vect or x.
Th e ou t pu t , y, is t h e sa m e len gt h a s x.
sos r epr esen t s t h e secon d-or der sect ion filt er H (z)

L L
b 0 k + b 1 k z –1 + b 2 k z –2
H (z ) = ∏ H k (z ) = ∏ ---------------------------------------------------------
1 + a 1 k z – 1 + a 2 k z –2
-
k =1 k =1

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
b 02 b 12 b 22 1 a 12 a 22
s os =
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 filter 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.
medfilt1 On e-dim en sion a l m edia n filt er in g.
sgolayfilt 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 6specgr a m
Tim e-depen den t fr equ en cy a n a lysis (spect r ogr a m ).

Syntax B = specgram(a)
B = specgram(a,nfft)
[B,f] = specgram(a,nfft,Fs)
[B,f,t] = specgram(a,nfft,Fs)
B = specgram(a,nfft,Fs,window)
B = specgram(a,nfft,Fs,window,noverlap)
specgram(a)
B = specgram(a,f,Fs,window,noverlap)

Description specgram com pu t es t h e win dowed discr et e-t im e F ou r ier t r a n sfor m of a sign a l
u sin g a slidin g win dow. Th e spect r ogr a m is t h e m a gn it u de of t h is fu n ct ion .

B = specgram(a) ca lcu la t es t h e spect r ogr a m for t h e sign a l in vect or a. Th is


syn t a x u ses t h e defa u lt va lu es:
• nfft = min(256,length(a))
• Fs = 2
• window = hanning(nfft)
• noverlap = length(window)/2

nfft specifies t h e F F T len gt h t h a t specgram 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 discr et e-t im e F ou r ier t r a n sfor m is com pu 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 specgram u ses in it s sect ion in g of vect or a.
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 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((n–noverlap)/(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.

You ca n u se t h e em pt y m a t r ix [] t o specify t h e defa u lt va lu e for a n y in pu t


a r gu m en t . F or exa m ple,
B = specgram(x,[],10000)

is equ iva len t t o


B = specgram(x)

bu t wit h a sa m plin g fr equ en cy of 10,000 H z in st ea d of t h e defa u lt 2 H z.

specgram wit h n o ou t pu t a r gu m en t s displa ys t h e sca led loga r it h m of t h e


spect r ogr a m in t h e cu r r en t figu r e win dow u sin g
imagesc(t,f,20*log10(abs(b))),axis xy,colormap(jet)

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 specgram ca lcu la t es t h e spect r ogr a m for a given sign a l a s follows:

1 It split s t h e sign a l in t o over la ppin g sect ion s a n d a pplies t h e win dow


specified by t h e window pa r a m et er t o ea ch sect ion .
2 It com pu t es t h e discr et e-t im e F ou r ier t r a n sfor m of ea ch sect ion wit h a
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
poin t s for nfft even a n d (nfft + 1)/2 for nfft odd.

6-325
specgram

Example P lot t h e spect r ogr a m of a digit ized speech sign a l:


load mtlb
specgram(mtlb,512,Fs,kaiser(500,5),475)
title('Spectrogram')
Spectrogram

3500

3000

2500
Frequency

2000

1500

1000

500

0
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45
Time

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 window's length to be no greater than the FFT length.
Requires NOVERLAP to be strictly less than the window length.
Requires positive integer values for NFFT and NOVERLAP.
Requires vector input.

See Also cohere 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.
csd 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.
pwelch 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.
tfe 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 6spt ool


In t er a ct ive digit a l sign a l pr ocessin g t ool (SP Tool).

Syntax sptool

Description 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.

See Ch a pt er 5, “In t er a ct ive Tools” for a fu ll discu ssion of h ow t o u se SP Tool.

6-331
square

Purpose 6squ a re
Squ a r e wa ve gen er a t or .

Syntax x = square(t)
x = square(t,duty)

Description 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
pea ks of ±1 in st ea d of a sin e wa ve.

x = square(t,duty) gen er a t es a squ a r e wa ve wit h specified du t y cycle, duty.


Th e d u ty cycle is t h e per cen t of t h e per iod in wh ich t h e sign a l is posit ive.

See Also chirp Swept -fr equ en cy cosin e gen er a t or.


cos 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).
diric Dir ich let or per iodic sin c fu n ct ion .
gauspuls Ga u ssia n -m odu la t ed sin u soida l pu lse gen er a t or.
pulstran P u lse t r a in gen er a t or.
rectpuls Sa m pled a per iodic r ect a n gle gen er a t or.
sawtooth Sawt oot h or t r ia n gle wave gen er a t or.
sin 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).
sinc Sin c or sin (πt )/πt fu n ct ion .
tripuls Sa m pled a per iodic t r ia n gle gen er a t or.

6-332
ss2sos

Purpose 6ss2sos
Con ver sion of st a t e-spa ce t o secon d-or der sect ion s.

Syntax [sos,g] = ss2sos(A,B,C,D)


[sos,g] = ss2sos(A,B,C,D,iu)
[sos,g] = ss2sos(A,B,C,D,'order')
[sos,g] = ss2sos(A,B,C,D,iu,'order')
[sos,g] = ss2sos(A,B,C,D,iu,'order','scale')
sos = ss2sos(...)

Description ss2sos con ver t s a st a t e-spa ce r epr esen t a t ion of a given syst em t o a n
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

b 01 b 11 b 21 1 a 11 a 21
b 02 b 12 b 22 1 a 12 a 22
s os =
M M M M M M
b0L b1L b2L 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
b 0 k + b 1 k z –1 + b 2 k z – 2
H (z ) = g ∏ H k (z ) = g ∏ ---------------------------------------------------------
1 + a 1 k z –1 + a 2 k z –2
-
k =1 k =1

[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 ) = ∏ H k (z )
k =1

Example F in d a secon d-or der sect ion for m of a Bu t t er wor t h lowpa ss filt er :
[A,B,C,D] = butter(5,0.2);
sos = ss2sos(A,B,C,D)

sos =
0.0013 0.0013 0 1.0000 –0.5095 0
1.0000 2.0008 1.0008 1.0000 –1.0966 0.3554
1.0000 1.9979 0.9979 1.0000 –1.3693 0.6926

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
r epr esen t a t ion for a n in pu t st a t e-spa ce syst em :

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 Con t in u e u n t il a ll of t h e poles a n d zer os a r e m a t ch ed.
ss2sos gr ou ps r ea l poles in t o sect ion s wit h t h e r ea l poles closest t o t h em in
a bsolu t e va lu e. Th e sa m e r u le h olds for r ea l zer os.
3 It or der s t h e sect ion s a ccor din g t o t h e pr oxim it y of t h e pole pa ir s t o t h e u n it
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 .
F or a r bit r a r y H (ω), t h e sca lin g is defin ed by:
1
2π ---
p
1 p
H p = ------
2π ∫ H (ω) d ω
0

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 If t h er e is m or e t h a n on e in pu t t o t h e syst em , ss2sos gives t h e followin g er r or


m essa ge:
State–space system must have only one input.

6-335
ss2sos

See Also cplxpair Gr ou p com plex n u m ber s in t o com plex con ju ga t e


pa ir s.
sos2ss Con ver sion of secon d-or der sect ion s t o st a t e-spa ce.
ss2tf Con ver sion of st a t e-spa ce t o t r a n sfer fu n ct ion .
ss2zp Con ver sion of st a t e-spa ce t o zer o-pole-ga in .
tf2sos Con ver sion of t r a n sfer fu n ct ion t o secon d-or der
sect ion s.
zp2sos 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 6ss2t f
Con ver sion of st a t e-spa ce t o t r a n sfer fu n ct ion .

Syntax [b,a] = ss2tf(A,B,C,D,iu)

Description ss2tf con ver t s a st a t e-spa ce r epr esen t a t ion of a given syst em t o a n equ iva len t
t r a n sfer fu n ct ion r epr esen t a t ion .

[b,a] = ss2tf(A,B,C,D,iu) r et u r n s t h e t r a n sfer fu n ct ion

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 latc2tf La t t ice filt er t o t r a n sfer fu n ct ion con ver sion .
sos2tf Con ver sion of secon d-or der sect ion s t o t r a n sfer
fu n ct ion .
ss2sos Con ver sion of st a t e-spa ce t o secon d-or der sect ion s.
ss2zp Con ver sion of st a t e-spa ce t o zer o-pole-ga in .
tf2ss Con ver sion of t r a n sfer fu n ct ion t o st a t e-spa ce.
zp2tf Con ver sion of zer o-pole-ga in t o t r a n sfer fu n ct ion .

6-337
ss2zp

Purpose 6ss2zp
Con ver sion of st a t e-spa ce t o zer o-pole-ga in .

Syntax [z,p,k] = ss2zp(A,B,C,D,iu)

Description ss2zp con ver t s a st a t e-spa ce r epr esen t a t ion of a given syst em t o a n equ iva len t
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

Z (s ) ( s – z 1 ) ( s – z 2 )Ls ( – zn )
H (s ) = ---------- = k ---------------------------------------------------------------
P (s ) ( s – p 1 ) ( s – p 2 )Ls ( – pn )

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 H er e a r e t wo wa ys of fin din g t h e zer os, poles, a n d ga in s of a syst em :


b = [2 3];
a = [1 0.4 1];
[z,p,k] = tf2zp(b,a)

z =
–1.5000

p =
–0.2000 + 0.9798i
–0.2000 – 0.9798i

k =
2

[A,B,C,D] = tf2ss(b,a);
[z,p,k] = ss2zp(A,B,C,D,1)

z =
–1.5000

p =
–0.2000 + 0.9798i
–0.2000 – 0.9798i

k =
2

Algorithm ss2zp fin ds t h e poles fr om t h e eigen va lu es of t h e A a r r a y. Th e zer os a r e t h e


fin it e solu t ion s t o a gen er a lized eigen va lu e pr oblem :
z = eig([A B;C D], diag([ones(1,n) 0]);

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 Pole-zer o m a p of LTI syst em (Con trol S ystem T oolbox
User’s Gu id e).
sos2zp Con ver sion of secon d-or der sect ion s t o zer o-pole-ga in .
ss2sos Con ver sion of st a t e-spa ce t o secon d-or der sect ion s.
ss2tf Con ver sion of st a t e-spa ce t o t r a n sfer fu n ct ion .
tf2zp Con ver sion of t r a n sfer fu n ct ion t o zer o-pole-ga in .
zp2ss 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 6st m cb
Lin ea r m odel u sin g St eiglit z-McBr ide it er a t ion .

Syntax [b,a] = stmcb(x,nb,na)


[b,a] = stmcb(x,u,nb,na)
[b,a] = stmcb(x,nb,na,niter)
[b,a] = stmcb(x,u,nb,na,niter)
[b,a] = stmcb(x,nb,na,niter,ai)
[b,a] = stmcb(x,u,nb,na,niter,ai)

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 (1 ) + a (2 )z – 1 + L+ a (n a + 1 )z – n a

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

−300
0 0.2 0.4 0.6 0.8 1
Normalized Angular Frequency (×π rads/sample)

0
Phase (degrees)

−200

−400

−600
0 0.2 0.4 0.6 0.8 1
Normalized Angular Frequency (×π rads/sample)

[bb,aa] = stmcb(h,4,4);
freqz(bb,aa,128)

20
Magnitude (dB)

−20

−40

−60
0 0.2 0.4 0.6 0.8 1
Normalized Angular Frequency (×π rads/sample)

0
Phase (degrees)

−200

−400

−600

−800
0 0.2 0.4 0.6 0.8 1
Normalized Angular Frequency (×π rads/sample)

6-342
stmcb

Algorithm stmcb a t t em pt s t o m in im ize t h e squ a r ed er r or bet ween t h e im pu lse r espon se x'


of b(z)/ a(z) a n d t h e in pu t sign a l x:

2
m in
a, b
∑ x (i ) – x'(i )
i =0

stmcb it er a t es u sin g t wo st eps:

1 It pr efilt er s x a n d u u sin g 1/a(z).


2 It solves a syst em of lin ea r equ a t ion s for b a n d a u sin g \ .

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 If x a n d u h a ve differ en t len gt h s, stmcb gives t h e followin g er r or m essa ge:


X and U must have same length.

See Also levinson Levin son -Du r bin r ecu r sion .


lpc Lin ea r pr edict ion coefficien t s.
aryule 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.
prony P r on y’s 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 6st r ips


St r ip plot .

Syntax strips(x)
strips(x,n)
strips(x,sd,Fs)
strips(x,sd,Fs,scale)

Description 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
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.

If x is a m a t r ix, strips(x,n), strips(x,sd,Fs), a n d strips(x,sd,Fs,scale)


plot t h e differ en t colu m n s of x on t h e sa m e st r ip plot .
strips ign or es t h e im a gin a r y pa r t of x if it is com plex.

6-344
strips

Example P lot t wo secon ds of a fr equ en cy m odu la t ed sin u soid in 0.25 secon d st r ips:
Fs = 1000; % sampling frequency
t = 0:1/Fs:2; % time vector
x = vco(sin(2*pi*t),[10 490],Fs); % FM waveform
strips(x,0.25,Fs)

0.25

0.5

0.75

1.25

1.5

1.75

0 0.05 0.1 0.15 0.2 0.25

See Also plot 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).
stem 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 6t f2la t c
Con ver sion of t r a n sfer fu n ct ion t o la t t ice filt er .

Syntax [k,v] = tf2latc(b,a)


k = tf2latc(1,a)
[k,v] = tf2latc(1,a)
k = tf2latc(b)

Description [k,v] = tf2latc(b,a) fin ds t h e la t t ice pa r a m et er s k a n d t h e la dder


pa r a m et er s v for a n IIR (ARMA) la t t ice-la dder filt er , n or m a lized by a(1). Not e
t h a t a n er r or is gen er a t ed if on e or m or e of t h e la t t ice pa r a m et er s a r e exa ct ly
equ a l t o 1.

k = tf2latc(1,a) fin ds t h e la t t ice pa r a m et er s k for a n IIR a ll-pole (AR) la t t ice


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 latc2tf La t t ice filt er t o t r a n sfer fu n ct ion con ver sion .
latcfilt La t t ice a n d la t t ice-la dder filt er im plem en t a t ion .
tf2sos Con ver sion of t r a n sfer fu n ct ion t o secon d-or der
sect ion s.
tf2ss Con ver sion of t r a n sfer fu n ct ion t o st a t e-spa ce.
tf2zp Con ver sion of t r a n sfer fu n ct ion t o zer o-pole-ga in .

6-346
tf2sos

Purpose 6tf2sos
Con ver sion of t r a n sfer fu n ct ion t o secon d-or der sect ion s.

Syntax [sos,g] = tf2sos(b,a)


[sos,g] = tf2sos(b,a,'order')
[sos,g] = tf2sos(b,a,'order','scale')
sos = tf2sos(...)

Description 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
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 (z ) b 1 + b 2 z – 1 + L+ b n b + 1 z – n b
H (z ) = ----------- = ------------------------------------------------------------------------
-
A (z ) a 1 + a 2 z – 1 + L+ a n a + 1 z – n a

sos is a n L -by-6 m a t r ix

b 01 b 11 b 21 1 a 11 a 21
b 02 b 12 b 22 1 a 12 a 22
s os =
M M M M M M
b0L b1L b2L 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
b 0 k + b 1 k z –1 + b 2 k z – 2
H (z ) = g ∏ H k (z ) = g ∏ ---------------------------------------------------------
1 + a 1 k z –1 + a 2 k z –2
-
k =1 k =1

[sos,g] = tf2sos(b,a,'order') specifies t h e or der of t h e r ows in sos, wh er e


order is:

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 ) = ∏ H k (z )
k =1

See Also cplxpair Gr ou p com plex n u m ber s in t o com plex con ju ga t e


pa ir s.
sos2tf Con ver sion of secon d-or der sect ion s t o t r a n sfer
fu n ct ion .
ss2sos Con ver sion of st a t e-spa ce t o secon d-or der sect ion s.
tf2ss Con ver sion of t r a n sfer fu n ct ion t o st a t e-spa ce.
tf2zp Con ver sion of t r a n sfer fu n ct ion t o zer o-pole-ga in .
zp2sos 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 6t f2ss
Con ver sion of t r a n sfer fu n ct ion t o st a t e-spa ce.

Syntax [A,B,C,D] = tf2ss(b,a)

Description tf2ss 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
equ iva len t st a t e-spa ce r epr esen t a t ion .

[A,B,C,D] = tf2ss(b,a) fin ds a st a t e-spa ce r epr esen t a t ion :

·
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
t r a ilin g zer os t o m a ke it t h e sa m e len gt h a s t h e den om in a t or .
Th e tf2ss 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 Con sider t h e syst em

2s + 3
s2
+ 2s + 1
H (s ) = --------------------------------
2
-
s + 0.4 s + 1

6-350
tf2ss

To con ver t t h is syst em t o st a t e-spa ce:


b = [0 2 3; 1 2 1];
a = [1 0.4 1];
[A,B,C,D] = tf2ss(b,a)

A =
–0.4000 –1.0000
1.0000 0

B =
1
0

C =
2.0000 3.0000
1.6000 0

D =
0
1

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;

Algorithm 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 .

See Also sos2ss Con ver sion of secon d-or der sect ion s t o st a t e-spa ce.
ss2tf Con ver sion of st a t e-spa ce t o t r a n sfer fu n ct ion .
tf2sos Con ver sion of t r a n sfer fu n ct ion t o secon d-or der
sect ion s.
tf2zp Con ver sion of t r a n sfer fu n ct ion t o zer o-pole-ga in .
zp2ss Con ver sion of zer o-pole-ga in t o st a t e-spa ce.

6-351
tf2zp

Purpose 6t f2zp
Con ver sion of t r a n sfer fu n ct ion t o zer o-pole-ga in .

Syntax [z,p,k] = tf2zp(b,a)

Description tf2zp fin ds t h e zer os, poles, a n d ga in s of a syst em in polyn om ia l t r a n sfer


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 :

Z (s ) ( s – Z 1 ) ( s – Z 2 )Ls ( – Zm )
H (s ) = ---------- = k ------------------------------------------------------------------
P (s ) ( s – p 1 ) ( s – p 2 )Ls ( – pn )

given a SIMO syst em in polyn om ia l t r a n sfer fu n ct ion for m :

B (s ) b 1 s ( n b – 1 ) + L+ b ( n b – 1 ) s + b ( n b )
----------- = --------------------------------------------------------------------------------------
-
A (s ) a 1 s ( n a – 1 ) + L+ a ( n a – 1 ) s + a ( n a )

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 F in d t h e zer os, poles, a n d ga in s of t h e syst em

2s + 3
H (s ) = --------------------------------
-
s 2 + 0.4 s + 1
b = [2 3];
a = [1 0.4 1];
[z,p,k] = tf2zp(b,a)

z =

–1.5000

p =

–0.2000 + 0.9798i
–0.2000 – 0.9798i

k =

Algorithm 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.

See Also sos2zp Con ver sion of secon d-or der sect ion s t o zer o-pole-ga in .
ss2zp Con ver sion of st a t e-spa ce t o zer o-pole-ga in .
tf2sos Con ver sion of t r a n sfer fu n ct ion t o secon d-or der
sect ion s.
tf2ss Con ver sion of t r a n sfer fu n ct ion t o st a t e-spa ce.
zp2tf Con ver sion of zer o-pole-ga in t o t r a n sfer fu n ct ion .

6-353
tfe

Purpose 6t fe
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 .

Syntax Txy = tfe(x,y)


Txy = tfe(x,y,nfft)
[Txy,f] = tfe(x,y,nfft,Fs)
Txy = tfe(x,y,nfft,Fs,window)
Txy = tfe(x,y,nfft,Fs,window,noverlap)
Txy = tfe(x,y,...,'dflag')
tfe(x,y)

Description Txy = tfe(x,y) fin ds a t r a n sfer fu n ct ion est im a t e Txy given in pu t sign a l
vect or x a n d ou t pu t sign a l vect or y. Th e tran sfer fu n ction is t h e qu ot ien t of t h e
cr oss spect r u m of x a n d y a n d t h e power spect r u m of x:

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.

You ca n u se t h e em pt y m a t r ix [] t o specify t h e defa u lt va lu e for a n y in pu t


a r gu m en t except x or y. F or exa m ple,
Txy = tfe(x,y,[],[],kaiser(128,5))

u ses 256 a s t h e va lu e for nfft a n d 2 a s t h e va lu e for Fs.

Txy = tfe(x,y,...,'dflag') specifies a det r en d opt ion , wh er e dflag is:

• 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

-5
Tranfer Function Estimate (dB)

-10

-15

-20

-25

-30

-35

-40

-45
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Frequency

Algorithm tfe u ses a fou r -st ep a lgor it h m :

1 It m u lt iplies t h e det r en ded sect ion s by window.


2 It t a kes t h e len gt h nfft F F T of ea ch sect ion .
3 It a ver a ges t h e squ a r es of t h e spect r a of t h e x sect ion s t o for m Pxx 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.
4 It ca lcu la t es Txy:
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 window's length to be no greater than the FFT length.
Requires NOVERLAP to be strictly less than the window length.
Requires positive integer values for NFFT and NOVERLAP.
Requires vector (either row or column) input.
Requires 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
User’s Gu id e).
cohere 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.
csd 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.
pwelch 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.
spa 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 User’s Gu id e).

6-357
triang

Purpose 6t ria n g
Tr ia n gu la r win dow.

Syntax w = triang(n)

Description 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
-, 1 ≤ k ≤ -------------
⎪ n + 1 2
w [ k ] = ⎨
⎪ 2------------------------------
(n – k + 1 )
-,
n +1
------------- ≤ k ≤ n
⎩ n +1 2

F or n even :

⎧ 2---------------
k –1
-,
n
1 ≤ k ≤ ---
⎪ n 2
w [ k ] = ⎨
⎪ 2------------------------------
(n – k + 1 )
-,
n
--- + 1 ≤ k ≤ n
⎩ n 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 n–2 poin t s of
triang(n–2) a r e equ iva len t t o bartlett(n).

See Also bartlett Ba r t let t win dow.


blackman Bla ck m a n win dow.
boxcar Rect a n gu la r win dow.
chebwin Ch ebysh ev win dow.
hamming H a m m in g win dow.
hanning H a n n in g win dow.
kaiser 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 6tr ipu ls


Sa m pled a per iodic t r ia n gle gen er a t or .

Syntax y = tripuls(T)
y = tripuls(T,w)
y = tripuls(T,w,s)

Description y = tripuls(T) r et u r n s a con t in u ou s, a per iodic, sym m et r ic, u n it y-h eigh t


t r ia n gu la r pu lse a t t h e t im es in dica t ed in a r r a y T, cen t er ed a bou t T=0 a n d wit h
a defa u lt widt h of 1.

y = tripuls(T,w) gen er a t es a t r ia n gu la r pu lse of widt h w.

y = tripuls(T,w,s) gen er a t es a t r ia n gu la r pu lse wit h skew s, wh er e –1<s<1.


Wh en s is 0, a sym m et r ic t r ia n gu la r pu lse is gen er a t ed.

See Also chirp Swept -fr equ en cy cosin e gen er a t or.


cos 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).
diric Dir ich let or per iodic sin c fu n ct ion .
gauspuls Ga u ssia n -m odu la t ed sin u soida l pu lse gen er a t or.
pulstran P u lse t r a in gen er a t or.
rectpuls Sa m pled a per iodic r ect a n gle gen er a t or.
sawtooth Sawt oot h or t r ia n gle wave gen er a t or.
sin 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).
sinc Sin c or sin (πt )/πt fu n ct ion .
square Squ a r e wa ve gen er a t or.

6-359
unwrap

Purpose 6u n wr a p
Un wr a p ph a se a n gles.

Syntax p = unwrap(p)

Description 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
be in r a dia n s.
Th e unwrap fu n ct ion is pa r t of t h e st a n da r d MATLAB la n gu a ge.

Limitations unwrap t r ies t o det ect br a n ch cu t cr ossin gs, bu t it ca n be fooled by spa r se,
r a pidly ch a n gin g ph a se va lu es.

See Also abs Absolu t e va lu e (m a gn it u de).


angle P h a se a n gle.

6-360
upfirdn

Purpose 6u pfird n
Upsa m ple, a pply a n F IR filt er , a n d down sa m ple.

Syntax yout = upfirdn(xin,h)


yout = upfirdn(xin,h,p)
yout = upfirdn(xin,h,p,q)

Description upfirdn per for m s a ca sca de of t h r ee oper a t ion s:

1 Upsa m plin g by p (zer o in ser t in g)


2 F IR filt er in g wit h t h e im pu lse r espon se given in h
3 Down sa m plin g by q (t h r owin g a wa y sa m ples)

upfirdn h a s been im plem en t ed a s a ME X-file for m a xim u m speed, so on ly t h e


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


in t eger wit h a defa u lt of 1.

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 upfirdn u ses a polyph a se in t er pola t ion st r u ct u r e. Th e n u m ber of m u lt iply-a dd


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.

If t h e a r r a ys a r e spa r se, upfirdn gives t h e er r or m essa ge


H must be full numeric matrix.

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.

Th e a r gu m en t s p a n d q m u st be in t eger s. If t h ey a r e n ot , upfirdn gives t h e


er r or m essa ge
P and/or Q must be greater than zero

If t h e a r gu m en t s p a n d q a r e n ot r ela t ively pr im e, upfirdn gives t h e wa r n in g


m essa ge
WARNING (upfirdn) p & q have common factor

6-363
upfirdn

See Also conv Con volu t ion a n d polyn om ia l m u lt iplica t ion .


decimate Decr ea se t h e sa m plin g r a t e for a sequ en ce
(decim a t ion ).
filter 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.
interp 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 ).
intfilt In t er pola t ion F IR filt er design .
resample 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 6vco
Volt a ge con t r olled oscilla t or .

Syntax y = vco(x,Fc,Fs)
y = vco(x,[Fmin Fmax],Fs)

Description y = vco(x,Fc,Fs) 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 r ea l in pu t vect or or a r r a y x wit h sa m plin g fr equ en cy Fs. Fc is t h e ca r r ier
or r efer en ce fr equ en cy; wh en x is 0, y is a n Fc H z cosin e wit h a m plit u de 1
sa m pled a t Fs H z. x r a n ges fr om -1 t o 1, wh er e -1 cor r espon ds t o a 0 fr equ en cy
ou t pu t , 0 t o Fc, a n d 1 t o 2*Fc. y is t h e sa m e size a s x.

y = vco(x,[Fmin Fmax],Fs) sca les t h e fr equ en cy m odu la t ion r a n ge so t h a t -1


a n d 1 va lu es of x yield oscilla t ion s of Fmin H z a n d Fmax H z r espect ively. F or
best r esu lt s, Fmin a n d Fmax sh ou ld be in t h e r a n ge 0 t o Fs/2.
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

P lot t h e spect r ogr a m of t h e gen er a t ed sign a l.


specgram(x,512,Fs,kaiser(256,5),220)

5000

4500

4000

3500

3000
Frequency

2500

2000

1500

1000

500

0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8
Time

Algorithm vco per for m s F M m odu la t ion u sin g t h e modulate fu n ct ion .

Diagnostics If a n y va lu es of x lie ou t side [-1,1], vco gives t h e followin g er r or m essa ge:


X outside of range [–1,1].

See Also demod Dem odu la t ion for com m u n ica t ion s sim u la t ion .
modulate Modu la t ion for com m u n ica t ion s sim u la t ion .

6-366
xcorr

Purpose 6xcor r
Cr oss-cor r ela t ion fu n ct ion est im a t e.

Syntax c = xcorr(x,y)
c = xcorr(x)
c = xcorr(x,y,'option')
c = xcorr(x,'option')
c = xcorr(x,y,maxlags)
c = xcorr(x,maxlags)
c = xcorr(x,y,maxlags,'option')
c = xcorr(x,maxlags,'option')
[c,lags] = xcorr(...)

Description xcorr est im a t es t h e cr oss-cor r ela t ion sequ en ce of a r a n dom pr ocess.


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

γ 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 2N -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
⎪ x n y n* + m
⎪ ∑ m ≥0
c x y (m ) = ⎨
⎪ n = 0
⎪ *
⎩ c y x (– m ) 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, ..., 2N -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 2N -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 x y , u n biased (m ) = ------------------- c x y (m )
N – m
• 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


t h e a u t ocor r ela t ion .

c = xcorr(x,y,maxlags) r et u r n s t h e cr oss-cor r ela t ion sequ en ce over t h e la g


r a n ge [–maxlags:maxlags]. Ou t pu t c h a s len gt h 2*maxlags+1.

c = xcorr(x,maxlags) r et u r n s t h e a u t ocor r ela t ion sequ en ce over t h e la g


r a n ge [–maxlags:maxlags]. Ou t pu t c h a s len gt h 2*maxlags+1. If x is a n
N -by-P m a t r ix, c is a m a t r ix wit h 2*maxlags+1 r ows wh ose P 2 colu m n s con t a in
t h e a u t ocor 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,maxlags,'option') specifies bot h a m a xim u m n u m ber of la gs


a n d a sca lin g opt ion for t h e cr oss-cor r ela t ion .

c = xcorr(x,maxlags,'option') specifies bot h a m a xim u m n u m ber of la gs


a n d a sca lin g opt ion for t h e a u t ocor r ela t ion .

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:N–1].
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 ≤ m ≤ 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 =

[12–i*8.9e–016 15–i*8 22–i*10 5–i*12 6+i*8.9e–016]

lags =

–2 –1 0 1 2

c2 = conj(fliplr(xcorr(y,x)));
c2 = mat2str(c2,2)

c2 =

[12–i*8.9e–016 15–i*8 22–i*10 5–i*12 6+i*8.9e–016]

F or t h e ca se wh er e in pu t a r gu m en t x is a m a t r ix, t h e ou t pu t colu m n s a r e
a r r a n ged so t h a t ext r a ct in g a r ow a n d r ea r r a n gin g it in t o a squ a r e a r r a y

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,:) % Extract zero-lag row

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 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].

Diagnostics 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.

Th e st r in g 'option' m u st be t h e la st a r gu m en t ; ot h er wise, xcorr gives t h e


followin g er r or m essa ge:
Argument list not in correct order.

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

a sca la r or a st r in g. If t h ey a r e n ot , xcorr gives t h e a ppr opr ia t e er r or


m essa ge(s):
3rd arg is maxlag, 2nd arg cannot be scalar.
When b is a vector, a must be a vector.
Maxlag must be a scalar.

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 conv Con volu t ion a n d polyn om ia l m u lt iplica t ion .


corrcoef Cor r ela t ion coefficien t m a t r ix.
cov Cova r ia n ce m a t r ix.
xcorr2 Two-dim en sion a l cr oss-cor r ela t ion .
xcov 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 6xcor r 2
Two-dim en sion a l cr oss-cor r ela t ion .

Syntax C = xcorr2(A)
C = xcorr2(A,B)

Description C = xcorr2(A,B) r et u r n s t h e cr oss-cor r ela t ion of m a t r ices A a n d B wit h n o


sca lin g. xcorr2 is t h e t wo-dim en sion a l ver sion of xcorr. It h a s it s m a xim u m
va lu e wh en t h e t wo m a t r ices a r e a lign ed so t h a t t h ey a r e sh a ped a s sim ila r ly
a s possible.

xcorr2(A) is t h e a u t ocor r ela t ion m a t r ix of in pu t m a t r ix A. It is iden t ica l t o


xcorr2(A,A).

See Also conv2 Two-dim en sion a l con volu t ion .


filter2 Two-dim en sion a l digit a l filt er in g.
xcorr Cr oss-cor r ela t ion fu n ct ion est im a t e.

6-372
xcov

Purpose 6xcov
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 ).

Syntax v = xcov(x,y)
v = xcov(x)
v = xcov(x,'option')
[c,lags] = xcov(x,y,maxlags)
[c,lags] = xcov(x,maxlags)
[c,lags] = xcov(x,y,maxlags,'option')

Description xcov est im a t es t h e cr oss-cova r ia n ce sequ en ce of r a n dom pr ocesses.


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

φ 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 2N -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 2N -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 – m – 1 ⎛ N –1
⎞ ⎛

⎞
⎪ 1
⎜ x (n ) – ---- ⎟ ⎜ * 1
⎪ ∑ ∑ x i⎟ ⎜ y n + m – ---- ∑ y i*⎟ m ≥0
⎜ N N ⎟
c x y (m ) = ⎨ ⎝ i = 0 ⎠ ⎝ ⎠
⎪ n = 0 =
⎪
⎩ c y*x (– m ) 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,...,2N -1.

6-373
xcov

Th e cova r ia n ce fu n ct ion r equ ir es n or m a liza t ion t o est im a t e t h e fu n ct ion


pr oper ly.

v = xcov(x,'option') specifies a sca lin g opt ion , wh er e option is:

• 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 ≤ m ≤ 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
fu n ct ion s, see [1] a n d [2].

Diagnostics 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.

See Also conv Con volu t ion a n d polyn om ia l m u lt iplica t ion .


corrcoef Cor r ela t ion coefficien t m a t r ix.
cov Cova r ia n ce m a t r ix.
xcorr Cr oss-cor r ela t ion fu n ct ion est im a t e.
xcorr2 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 6yu lewa lk


Recu r sive digit a l filt er design .

Syntax [b,a] = yulewalk(n,f,m)

Description yulewalk design s r ecu r sive IIR digit a l filt er s u sin g a lea st -squ a r es fit t o a
specified fr equ en cy r espon se.

[b,a] = yulewalk(n,f,m) 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


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 ely m a t ch 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, 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
----------- = ---------------------------------------------------------------------------------
-
A (z ) a (1 ) + a (2 )z –1 + L+ a (n + 1 )z – n
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);
[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 1

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


decom posit ion of t h e power fr equ en cy r espon se.
2 E va lu a t es t h e com plet e fr equ en cy r espon se cor r espon din g t o t h e n u m er a t or
a n d den om in a t or polyn om ia ls.
3 Uses a spect r a l fa ct or iza t ion t ech n iqu e t o obt a in t h e im pu lse r espon se of t h e
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 Bu t t er wor t h a n a log a n d digit a l filt er design .


cheby1 Ch ebysh ev t ype I filt er design (pa ssba n d r ipple).
cheby2 Ch ebysh ev t ype II filt er design (st opba n d r ipple).
ellip E llipt ic (Ca u er ) filt er design .
fir2 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.
firls Lea st squ a r e lin ea r-ph a se F IR filt er design .
maxflat Gen er a lized digit a l Bu t t er wor t h filt er design .
remez 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 6zp2sos
Con ver sion of zer o-pole-ga in t o secon d-or der sect ion s.

Syntax [sos,g] = zp2sos(z,p,k)


[sos,g] = zp2sos(z,p,k,'order')
[sos,g] = zp2sos(z,p,k,'order','scale')
sos = zp2sos(...)

Description 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
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 )Lz ( – zn )
H (z ) = k -----------------------------------------------------------------
( z – p 1 ) ( z – p 2 )Lz ( – pm )

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
b 02 b 12 b 22 1 a 12 a 22
s os =
M M M M M M
b0L b1L b2L 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
b 0 k + b 1 k z –1 + b 2 k z – 2
H (z ) = g ∏ H k (z ) = g ∏ ---------------------------------------------------------
1 + a 1 k z –1 + a 2 k z –2
-
k =1 k =1

Th e n u m ber of r ows L of m a t r ix sos is t h e m a xim u m of t h e ceilin g of n /2 a n d


t h e ceilin g of m /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 ) = ∏ H k (z )
k =1

Example F in d a secon d-or der sect ion for m of a Bu t t er wor t h lowpa ss filt er :
[z,p,k] = butter(5,0.2);
sos = zp2sos(z,p,k);

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
r epr esen t a t ion for a n in pu t zer o-pole-ga in syst em :

1 It 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 .
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
a ccor din g t o t h e followin g r u les:

6-380
zp2sos

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 Con t in u e u n t il a ll of t h e poles a n d zer os a r e m a t ch ed.
zp2sos gr ou ps r ea l poles in t o sect ion s wit h t h e r ea l poles closest t o t h em in
a bsolu t e va lu e. Th e sa m e r u le h olds for r ea l zer os.
3 It or der s t h e sect ion s a ccor din g t o t h e pr oxim it y of t h e pole pa ir s t o t h e u n it
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 .
F or a r bit r a r y H (ω), t h e sca lin g is defin ed by:
1
2π ---
p
1 p
H p = ------
2π ∫ H (ω) d ω
0

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 cplxpair Gr ou p com plex n u m ber s in t o com plex con ju ga t e


pa ir s.
sos2zp Con ver sion of secon d-or der sect ion s t o zer o-pole-ga in .
ss2sos Con ver sion of st a t e-spa ce t o secon d-or der sect ion s.
tf2sos Con ver sion of t r a n sfer fu n ct ion t o secon d-or der
sect ion s.
zp2ss Con ver sion of zer o-pole-ga in t o st a t e-spa ce.
zp2tf 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 6zp2ss
Con ver sion of zer o-pole-ga in t o st a t e-spa ce.

Syntax [A,B,C,D] = zp2ss(z,p,k)

Description zp2ss 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
equ iva len t st a t e-spa ce r epr esen t a t ion .

[A,B,C,D] = zp2ss(z,p,k) fin ds a sin gle in pu t , m u lt iple ou t pu t , st a t e-spa ce


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

Z (s ) ( s – z 1 ) ( s – z 2 )Ls ( – zn )
H (s ) = ---------- = k ---------------------------------------------------------------
P (s ) ( s – p 1 ) ( s – p 2 )Ls ( – pn )

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.

See Also sos2ss Con ver sion of secon d-or der sect ion s t o st a t e-spa ce.
ss2zp Con ver sion of st a t e-spa ce t o zer o-pole-ga in .
tf2ss Con ver sion of t r a n sfer fu n ct ion t o st a t e-spa ce.
zp2sos Con ver sion of zer o-pole-ga in t o secon d-or der sect ion s.
zp2tf Con ver sion of zer o-pole-ga in t o t r a n sfer fu n ct ion .

6-383
zp2tf

Purpose 6zp2t f
Con ver sion of zer o-pole-ga in t o t r a n sfer fu n ct ion .

Syntax [b,a] = zp2tf(z,p,k)

Description zp2tf for m s t r a n sfer fu n ct ion polyn om ia ls fr om t h e zer os, poles, a n d ga in s of a


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 (s ) b 1 s ( n b – 1 ) + L+ b ( n b – 1 ) s + b n b
----------- = ----------------------------------------------------------------------------------
-
A (s ) a 1 s ( n a – 1 ) + L+ a ( n a – 1 ) s + a n a

given a syst em in fa ct or ed t r a n sfer fu n ct ion for m :

Z (s ) ( s – z 1 ) ( s – z 2 )Ls ( – zm )
H (s ) = ---------- = k ---------------------------------------------------------------
P (s ) ( s – p 1 ) ( s – p 2 )Ls ( – pn )

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.

Algorithm 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.

See Also sos2tf Con ver sion of secon d-or der sect ion s t o t r a n sfer
fu n ct ion .
ss2tf Con ver sion of st a t e-spa ce t o t r a n sfer fu n ct ion .
tf2zp Con ver sion of t r a n sfer fu n ct ion t o zer o-pole-ga in .
zp2sos Con ver sion of zer o-pole-ga in t o secon d-or der sect ion s.
zp2ss Con ver sion of zer o-pole-ga in t o st a t e-spa ce.

6-384
zplane

Purpose 6zpla n e
Zer o-pole plot .

Syntax zplane(z,p)
zplane(b,a)
[hz,hp,ht] = zplane(z,p)

Description Th is fu n ct ion displa ys t h e poles a n d zer os of discr et e-t im e syst em s.

zplane(z,p) plot s t h e zer os specified in colu m n vect or z a n d t h e poles specified


in colu m n vect or p in t h e cu r r en t figu r e win dow. Th e sym bol 'o' r epr esen t s a
zer o a n d t h e sym bol 'x' r epr esen t s a pole. Th e plot in clu des t h e u n it cir cle for
r efer en ce. If z a n d p a r e a r r a ys, zplane plot s t h e poles a n d zer os in t h e colu m n s
of z a n d p, r espect ively, in differ en t color s.
You ca n over r ide t h e a u t om a t ic sca lin g of zplane u sin g
axis([xmin xmax ymin ymax])

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

0.8

0.6

0.4
Imaginary Part

0.2
5
0

−0.2

−0.4

−0.6

−0.8

−1
−1 −0.5 0 0.5 1
Real Part

To gen er a t e t h e sa m e plot wit h a t r a n sfer fu n ct ion r epr esen t a t ion of t h e filt er :


[b,a] = butter(5,0.2); % transfer function
zplane(b,a)

See Also freqz F r equ en cy r espon se of digit a l filt er s.

6-386
Index

A
abs 6-2, 6-12 design 2-7
ac2poly 6-3, 6-13 Bessel 2-11, 6-22
ac2rc 6-3, 6-14 Bu t t er wor t h 6-43
a lgor it h m , filt er in g in SP Tool 5-18 Ch ebysh ev t ype I 6-65
a lia sed sin c fu n ct ion . S ee Dir ich let fu n ct ion Ch ebysh ev t ype II 6-71
a lia sin g ellipt ic 6-125, 6-126
a n d im pu lse in va r ia n ce 2-42 in ver se 6-203
pr even t in g du r in g r esa m plin g 4-21 fr equ en cy r espon se 1-26, 6-173
r edu cin g wit h a n a lyt ic sign a l 4-38 or der est im a t ion
a ll-pole filt er . S ee IIR filt er Bu t t er wor t h 6-49
a ll-zer o filt er . S ee F IR filt er Ch ebysh ev t ype I 6-56
am 4-29 Ch ebysh ev t ype II 6-61
AM. S ee a m plit u de m odu la t ion ellipt ic 6-133
amdsb–sc 4-29, 6-236 r epr esen t a t ion a l m odels 1-40
amdsb–tc 4-29, 6-236 a n a log fr equ en cy xvii
a m plit u de dem odu la t ion a n a log pr ot ot ype 2-38
dou ble side-ba n d, su ppr essed ca r r ier 6-114 Bessel filt er 2-11, 6-21
dou ble side-ba n d, t r a n sm it t ed ca r r ier 6-114 Bu t t er wor t h filt er 2-8, 6-42
sin gle side-ba n d 6-114 Ch ebysh ev t ype I filt er 2-9, 6-54
a m plit u de m odu la t ion 4-29 Ch ebysh ev t ype II filt er 2-10, 6-59
dou ble side-ba n d, su ppr essed ca r r ier 6-236 con ver sion t o ba n dpa ss 6-220
dou ble side-ba n d, t r a n sm it t ed ca r r ier 6-236 con ver sion t o ba n dst op 6-223
sin gle side-ba n d 6-236 con ver sion t o h igh pa ss 6-225
amssb 4-30, 6-236 con ver sion t o lowpa ss 6-227
a n a log filt er ellipt ic filt er 6-131
Bessel 6-22 fr equ en cy r espon se 2-12
Bu t t er wor t h 6-44 plot t in g 2-12
Ch ebysh ev t ype I 6-66 a n a log pr ot ot ype design
Ch ebysh ev t ype II 6-71 Bessel 2-38
con ver t in g t o digit a l 2-41, 6-194 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 u t or egr essive (AR) filt er 1-15


a n a log sign a l. S ee sign a l S ee also IIR filt er
a n a lyt ic sign a l 2-26, 6-187 a u t or egr essive (AR) m odel
a pplica t ion s 4-38 via Bu r g m et h od 6-16, 6-239
pr oper t ies 4-38 via cova r ia n ce m et h od 6-17, 6-243
angle 6-2, 6-15 via m odified cova r ia n ce m et h od 6-18, 6-247
a n t i-sym m et r ic filt er 2-25 via Yu le-Wa lker AR m et h od 6-19, 6-278
Apply bu t t on , Spect r u m Viewer 5-97 a u t or egr essive m ovin g a ver a ge (ARMA) filt er 1-15
Apply F ilt er bu t t on 5-18 S ee also IIR filt er
a pplyin g pa r a m et er s wit h Apply bu t t on 5-100 a u t o-spect r u m , in SP Tool 5-15
arburg 4-11, 6-16 a ver a gin g filt er 1-14
arcov 4-11, 6-17 a xis la bels, in Sign a l Br owser 5-20, 5-23
ARMA filt er 1-15 a xis pa r a m et er s
S ee also IIR filt er in F ilt er Viewer 5-20
ARMA m odel 4-13, 4-15 in Spect r u m Viewer 5-20
P r on y’s m et h od 4-13 a xis sca lin g r an ge
St eiglit z-McBr ide m et h od 4-15 in F ilt er Viewer 5-25, 5-87
armcov 4-11, 6-18 in Spect r u m Viewer 5-24, 5-100, 5-102
array a xis sca lin g u n it s
displa y in Sign a l Br owser 5-47, 5-51 in F ilt er Viewer 5-25, 5-87
in SP Tool 5-14 in Spect r u m Viewer 5-24, 5-100, 5-102
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 B
ASCII file, im por t in g 1-13 ba n d edges, pr ewa r pin g 2-44
a t t en u a t ion , st opba n d 5-70 ba n dlim it ed in t er pola t ion 6-314
a t t r ibu t es, in st a n t a n eou s 6-187 ba n dpa ss filt er
a u t ocor r ela t ion 6-368 a n a log pr ot ot ype design 2-6
m u lt iple ch a n n els 3-4 a n d im pu lse in va r ia n ce 2-42
t wo-dim en sion a l 6-372 Bessel 6-22
a u t ocor r ela t ion sequ en ce Bu t t er wor t h 6-43, 6-44
con ver t in g fr om filt er coefficien t s 6-262 Ch ebysh ev t ype I 6-65, 6-66
con ver t in g fr om r eflect ion coefficien t s 6-282 Ch ebysh ev t ype II 6-70, 6-71
con ver t in g t o filt er coefficien t s 6-13 ellipt ic 6-125, 6-126
con ver t in g t o r eflect ion coefficien t s 6-14 exa m ple, Ch ebysh ev t ype I 2-40
a u t ocova r ia n ce 6-373 F IR design , wit h win dow m et h od 2-21, 6-154
m u lt iple ch a n n els 3-4 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 pr ewa r pin g 2-44, 6-25


a n a log pr ot ot ype design 2-6 blackman 4-2, 6-8, 6-30
Bessel 6-22 Bla ckm a n win dow 4-4, 6-30
Bu t t er wor t h 6-44, 6-45 defin ed 4-4
Ch ebysh ev t ype I 6-66, 6-67 boxcar 4-2, 6-8, 6-32
Ch ebysh ev t ype II 6-71, 6-72 exa m ple 4-2
ellipt ic 6-126, 6-127 boxca r win dow. S ee r ect a n gu la r win dow
F IR design , wit h win dow m et h od 2-21, 6-153 br a cket s, in dica t in g closed in t er va l xvii
t r a n sfor m a t ion fr om lowpa ss t o 6-223 bu ffer in g 6-33
ba n dwidt h 2-40 Bu r g m et h od 3-5, 3-6, 3-20
bartlett 4-2, 6-8, 6-20 com pa r ed t o Welch ’s m et h od 3-22
com pa r ed t o triang 6-20 defin ed 3-20
exa m ple 4-2 exa m ple 3-21
Ba r t let t win dow 4-2 in Spect r u m Viewer 5-104
coefficien t s 6-20 buttap 2-5, 6-10, 6-42
Bessel filt er exa m ple 2-8
a n a log 6-22 butter 2-5, 2-6, 6-5, 6-43
a n a log pr ot ot ype 2-11, 2-38, 6-21 Bu t t er wor t h filt er
ba n dpa ss con figu r a t ion , a n a log 6-22 a n a log 6-44
ba n dst op con figu r a t ion , a n a log 6-22 a n a log pr ot ot ype 2-8, 2-38, 6-42
ch a r a ct er ist ics 2-11 ba n dpa ss con figu r a t ion
h igh pa ss con figu r a t ion , a n a log 6-22 a n a log 6-44
lim it a t ion s 6-24 digit a l 6-43
lowpa ss con figu r a t ion , a n a log 6-22 ba n dst op con figu r a t ion
besselap 2-5, 6-10, 6-21 a n a log 6-45
exa m ple 2-11 digit a l 6-44
besself 2-5, 2-6, 6-5, 6-22 ch a r a ct er ist ics 2-8
bet a pa r a m et er , of Ka iser win dow 5-75 design 6-43
bia s digit a l 6-43
cor r ela t ion 3-3, 4-12 gen er a lized 2-14
power spect r a l den sit y 3-12 h igh pa ss con figu r a t ion
spect r a l den sit y 3-12 a n a log 6-45
va r ia n ce t r ade-off 3-4 digit a l 6-44
bilinear 2-5, 2-42, 2-43, 6-11, 6-25 lim it a t ion s 6-47
bilin ea r t r a n sfor m a t ion 2-43, 6-25 lowpa ss con figu r a t ion
defin ed 2-43 a n a log 6-44
ou t pu t r epr esen t a t ion 6-26 digit a l 6-43

I-3
Index

or der est im a t ion 2-7, 6-48 ba n dpa ss con figu r a t ion


buttord 2-5, 6-5, 6-48 a n a log 6-66
digit a l 6-65
ba n dst op con figu r a t ion
C a n a log 6-67
ca n on ica l for m s 1-17, 6-351 digit a l 6-66
ca r r ier fr equ en cy 4-29, 6-236, 6-365 ch a r a ct er ist ics 2-9
ca r r ier sign a l 4-29, 6-114 design 6-65
ca scade, digit a l filt er 1-37 digit a l 6-65
Ca u er filt er . S ee ellipt ic filt er h igh pa ss con figu r a t ion
cceps 4-23, 6-9, 6-52 a n a log 6-67
exa m ple 4-23 digit a l 6-66
cen t er fr equ en cy 2-40 lowpa ss con figu r a t ion
cen t r a l fea t u r es 1-2 a n a log 6-66
cepst r u m digit a l 6-65
a pplica t ion s 4-23 or der est im a t ion 2-7, 6-55
com plex 4-23 Ch ebysh ev t ype II filt er
in ver se 4-23, 4-25 a n a log 6-71
over view 4-23 a n a log pr ot ot ype 2-38, 6-59
r ea l 4-23 ba n dpa ss con figu r a t ion
S ee also r ea l cepst r u m , com plex cepst r u m a n a log 6-71
cepst r u m a n a lysis 4-23 digit a l 6-70
cheb1ap 2-5, 6-10, 6-54 ba n dst op con figu r a t ion
exa m ple 2-9, 2-40 a n a log 6-72
cheb1ord 2-5, 6-5, 6-55 digit a l 6-71
cheb2ap 2-5, 6-10, 6-59 ch a r a ct er ist ics 2-10
exa m ple 2-10 design 6-70
cheb2ord 2-5, 6-5, 6-60 digit a l 6-70
chebwin 4-2, 6-8, 6-64 h igh pa ss con figu r a t ion
cheby1 2-5, 2-6, 6-5, 6-65 a n a log 6-72
exa m ple 2-45 digit a l 6-71
cheby2 2-5, 2-6, 6-5, 6-70 lim it a t ion s 6-69
Ch ebysh ev er r or m in im iza t ion 2-22, 6-287 lowpa ss con figu r a t ion
Ch ebysh ev t ype I filt er a n a log 6-71
a n a log 6-66 digit a l 6-70
a n a log pr ot ot ype 2-9, 2-38, 6-54 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 com plex n u m ber s, gr ou pin g by con ju ga t e 6-90


chirp 1-9, 6-2, 6-75 com plex sign a ls, in Sign a l Br owser 5-47
ch ir p sign a l 1-9 com pu t a t ion pa r a m et er s, in Spect r u m Viewer
ch ir p z -t r a n sfor m (CZT) 4-34, 6-105 5-103, 5-104
com pa r ed t o discr et e F ou r ier t r a n sfor m 4-34 Con f. In t . ch eck box 5-107
execu t ion t im e 4-35 con fiden ce in t er va l
for n a r r owba n d fr equ en cy a n a lysis 6-105 for cr oss spect r a l den sit y 3-14
cla ssica l IIR filt er design 2-8 for power spect r a l den sit y 3-14, 5-107
click-a n d-dr a g pa n n in g, in Sign a l Br owser 5-48 set t in g in Spect r u m Viewer 5-107
coefficien t s con ser va t ion of t ot a l power , u sin g pmtm 3-19
cor r ela t ion 6-88 con t ext sen sit ive h elp in SP Tool 5-7
filt er 1-15, 5-79, 6-13, 6-262, 6-263, 6-283 con t in u ou s sign a l. S ee sign a l
lin ea r pr edict ion 6-229 con t in u ou s-t im e filt er . S ee a n a log filt er
r eflect ion 1-37, 6-14, 6-263, 6-282, 6-283 con t r ol syst em s 1-35
sequ en ce 6-282 Con t r ol Syst em s Toolbox 1-35, 6-198
cohere 3-6, 3-16, 6-7, 6-79 conv 1-14, 1-20, 6-2, 6-83
coh er en ce 3-15, 6-79 conv2 1-14, 6-2, 6-84
defin ed 3-15 con ver sion
coh er en ce fu n ct ion 3-15 a u t ocor r ela t ion sequ en ce t o filt er coefficien t s
Color bu t t on 5-35 6-13
color or der a u t ocor r ela t ion sequ en ce t o r eflect ion
in Sign a l Br owser 5-22 coefficien t s 6-14
in Spect r u m Viewer 5-22 filt er coefficien t s t o a u t ocor r ela t ion sequ en ce
Color Or der t ext box 5-22 6-262
color , cu st om izin g in SP Tool 5-20 filt er coefficien t s t o r eflect ion coefficien t s 6-263,
colu m n in dex vect or , en t er in g in Sign a l Br owser 6-283
5-47 r eflect ion coefficien t s t o a u t ocor r ela t ion
colu m n , a r r a y 5-47 sequ en ce 6-282
com m u n ica t ion s 4-10 secon d-or der sect ion s t o st a t e-spa ce 6-316
com m u n ica t ion s sim u la t ion 4-29, 6-114, 6-236 secon d-or der sect ion s t o t r a n sfer fu n ct ion
S ee also m odu lat ion , dem odu la t ion , volt a ge 6-318
con t r olled oscilla t ion secon d-or der sect ion s t o zer o-pole-ga in 6-320
Com pa ct Disc st a n da r d 4-20 st a t e-spa ce t o secon d-or der sect ion s 6-333
com plex cepst r u m , defin ed 4-23 st a t e-spa ce t o zer o-pole-ga in 6-338
com plex con ju ga t e 6-90 t r a n sfer fu n ct ion t o la t t ice 6-346
Com plex Displa y m ode 5-47 t r a n sfer fu n ct ion t o secon d-or der sect ion s
com plex en velope 4-38 6-347

I-5
Index

t r a n sfer fu n ct ion t o st a t e-spa ce 6-350 n or m a liza t ion 3-4


zer o-pole-ga in t o secon d-or der sect ion 6-379 t wo-dim en sion a l 6-372
zer o-pole-ga in t o st a t e-spa ce 6-383 u n bia sed 3-3
convmtx 1-39, 1-42, 6-3, 6-86 cr oss-cova r ia n ce 6-373
con volu t ion m u lt iple ch a n n els 3-4
a n d cr oss-cor r ela t ion 3-3 csd 3-6, 3-14, 6-7, 6-100
a n d filt er in g 1-14, 6-148 CSD. S ee cr oss spect r a l den sit y
con volu t ion m a t r ix 1-39, 6-86 cu t off fr equ en cy 2-38
defin ed 6-83 defin ed 6-22
exa m ple 1-14 for Ka iser win dow filt er 5-75
t wo-dim en sion a l 6-84 czt 4-35, 6-6, 6-105
obt a in in g su bsect ion 6-84 CZT. S ee ch ir p z -t r a n sfor m
con volu t ion m a t r ix 1-42, 6-86
defin ed 1-39
exa m ple 6-86 D
corrcoef 6-7, 6-88 da t a
cor r ela t ion 3-2 du plica t in g in SP Tool 5-16
coefficien t m a t r ix 6-88 edit in g in SP Tool 5-13, 5-15
S ee also a u t ocor r ela t ion , cr oss-cor r ela t ion en t er in g 1-13
cosin e win dow 4-4 expor t in g fr om SP Tool 5-6
cov 6-7, 6-89 im por t in g 1-13
cova r ia n ce 3-2 im por t in g in t o SP Tool 5-3, 5-6, 5-7
m a t r ix 6-89 m ea su r in g in SP Tool 5-31
S ee also au t ocova r ia n ce, cr oss-cova r ia n ce m u lt ich a n n el 1-4, 1-7
cova r ia n ce m et h od 3-6, 3-22 viewin g in SP Tool 5-31
defin ed 3-22 da t a com pr ession 4-10
exa m ple 3-23 da t a m at r ix 1-4, 1-7
cova r ia n ce m et h od, in Spect r u m Viewer 5-105 da t a vect or 1-4
cplxpair 6-9, 6-90 dct 4-36, 6-6, 6-108
Cr ea t e bu t t on , in Spect r a pa n el 5-19, 5-97 exa m ple 4-37
cremez 2-17, 6-5, 6-91 decimate 6-9, 6-110
cr oss spect r a l den sit y 3-14, 6-100 decim a t ion 6-110
con fiden ce in t er va l 3-14 F IR filt er for 6-201
defin ed 3-5 deconv 4-33, 6-9, 6-113
cr oss-cor r ela t ion 6-367 exa m ple 4-33
bia sed 3-3 decon volu t ion 4-33, 6-113
m u lt iple ch a n n els 3-4 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 iden t ifica t ion fr om fr equ en cy da t a 6-207
box 5-28 IIR 2-4
Defa u lt SP Tool session file 5-20, 5-28 com pa r ed t o F IR 2-4
defa u lt va lu es, u sin g em pt y m a t r ix 3-11 im plem en t a t ion 1-14, 6-142, 6-145
dela y F F T-ba sed (F IR) 6-142
a ddin g t o sign a l 2-25 over la p-a dd m et h od 1-22
gr ou p 1-28 u sin g con volu t ion 1-14
n on in t eger 2-26 u sin g filter fu n ct ion 1-16
ph a se 1-28 im pu lse r espon se 1-14, 1-23, 6-196
demod 4-29, 4-30, 6-9, 6-114 in it ia l con dit ion s 1-17
exa m ple 4-30 lin ea r syst em m odels 1-32
dem odu la t ion 4-30, 6-114 n a m es 1-15
exa m ple 4-30 or der 1-15
m et h ods 4-30, 6-114 in st a t e-spa ce r epr esen t a t ion 1-34
design , gen er a lized filt er 2-5 or der est im a t ion
design ed filt er , in SP Tool 5-14 Bu t t er wor t h 6-48
DF T. S ee discr et e F ou r ier t r a n sfor m Ch ebysh ev t ype I 6-55
dftmtx 6-6, 6-117 Ch ebysh ev t ype II 6-60
differ en ce equ a t ion , r ela t ion t o t r a n sfer fu n ct ion ellipt ic 6-132
1-32 equ ir ipple F IR 6-294
differ en t ia t or 2-26, 6-167, 6-289 ph a se dela y 1-28, 6-182
Digit a l Au dio Ta pe st a n da r d 4-20 poles 1-30, 1-33
digit a l filt er r epr esen t a t ion a l m odels 1-32
a n t i-ca u sa l 1-20 r epr esen t in g in MATLAB 1-32
a s con volu t ion m a t r ix 1-40 secon d-or der sect ion s 1-37
Bu t t er wor t h 6-43 specifica t ion s 2-7
ca sca de 1-37 st a r t u p t r a n sien t s 1-21, 1-22
Ch ebysh ev t ype I 6-65 st r u ct u r e
Ch ebysh ev t ype II 6-70 la t t ice 1-37
coefficien t s 1-15 t r a n sposed dir ect for m II 1-17
design 2-2 t im e-dom a in r epr esen t a t ion 1-16
ellipt ic 6-125 t r a n sfer fu n ct ion r epr esen t a t ion 1-15
F IR 2-16 t wo-dim en sion a l 6-148
com pa r ed t o IIR 2-16 zer o-ph a se 1-20, 6-149
fixed-poin t im plem en t a t ion 1-37 zer os 1-30, 1-33
fr equ en cy r espon se 1-24 zer os a n d poles 1-33
gr ou p dela y 1-28, 6-182 S ee also F IR filt er , IIR filt er

I-7
Index

digit a l filt er design bilin ea r t r a n sfor m a t ion 2-43


F IR 2-16 pr ewa r pin g 2-44
IIR 2-4 im pu lse in va r ia n ce 2-42
digit a l fr equ en cy xvii disk, loa din g va r ia bles fr om 5-8
dir ect design 2-13 dpss 6-9, 6-119
descr ibed 2-13 dpss.mat 3-19
su m m a r y 2-5 dpssclear 3-19, 6-9, 6-121
diric 6-2, 6-118 dpssdir 3-19, 6-9, 6-122
Dir ich let fu n ct ion 1-11, 6-118 dpssload 3-19, 6-9, 6-123
defin ed 1-11 DP SSs. S ee discr et e pr ola t e sph er oida l sequ en ces
exa m ple 1-12 dpsssave 3-19, 6-9, 6-124
discr et e cosin e t r a n sfor m (DCT) 6-108 du t y cycle, specifyin g 1-8
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 E
in ver se 4-36, 6-190 ech o det ect ion 4-23
r econ st r u ct in g sign a l fr om few coefficien t s edge effect s 1-22
4-37 edge fr equ en cies, set t in g in F ilt er Design er 5-70
discr et e F ou r ier t r a n sfor m (DF T) 1-2, 1-43 E dit Design bu t t on 5-18, 5-59
a lgor it h m s 1-45 eig, in pmusic fu n ct ion 3-25
a n d IIR filt er im plem en t a t ion 1-22 eigen a n a lysis
a n d spect r a l a n a lysis 3-6 defin ed 3-24
a pplica t ion s 6-137 fr equ en cy est im a t or fu n ct ion s 3-24
depen den ce on sign a l len gt h 1-45 eigen vect or m et h od 3-5, 3-23
exa m ple 1-44 S ee also m u lt iple sign a l cla ssifica t ion m et h od
execu t ion t im e, u sin g ch ir p z -t r a n sfor m 4-35 ellip 2-5, 2-6, 6-5, 6-125
in ver se 1-43, 6-192 ellipap 2-5, 6-10, 6-131
m a t r ix 6-117 exa m ple 2-10
t wo-dim en sion a l 1-45, 6-193 ellipord 2-5, 6-5, 6-132
m a t r ix 6-117 ellipt ic filt er
t wo-dim en sion a l 1-45, 6-141 a n a log 6-126
S ee also fa st F ou r ier t r a n sfor m (F F T), fft a n a log pr ot ot ype 2-38, 6-131
discr et e pr ola t e sph er oida l sequ en ces (DP SSs) ba n dpa ss con figu r a t ion
3-19 a n a log 6-126
discr et e-t im e F ou r ier t r a n sfor m 3-5 digit a l 6-125
discr et iza t ion 2-41, 6-194

I-8
Index

ba n dst op con figu r a t ion n on pa r a m et r ic


a n a log 6-127 F F T m et h od 5-105
digit a l 6-126 m u lt iple sign a l cla ssifica t ion m et h od
ch a r a ct er ist ics 2-10 (MUSIC) 3-5, 5-106
design 6-125 m u lt it a per m et h od (MTM) 3-5, 5-105
digit a l 6-125 Welch ’s m et h od 3-5, 5-106
h igh pa ss con figu r a t ion pa r a m et r ic 3-5
a n a log 6-127 Bu r g m et h od 5-104, 6-16
digit a l 6-126 cova r ia n ce m et h od 6-17
lim it a t ion s 6-129 m odified cova r ia n ce m et h od 6-18
lowpa ss con figu r a t ion Yu le-Wa lker AR m et h od 5-107
a n a log 6-126 Yu le-Wa lker m et h od 6-19
digit a l 6-125 E xpor t F ilt er s a s TF object s ch eck box, in
or der est im a t ion 2-7, 6-132 P r efer en ces dia log box 5-29
en er gy com pa ct ion 4-37 E xpor t m en u it em 5-6
equ ir ipple ch a r a ct er ist ics E xpor t in g Com pon en t s ch eck box, in P r efer en ces
Ch ebysh ev t ype I filt er (pa ssba n d) 2-9 dia log box 5-29
Ch ebysh ev t ype II filt er (st opba n d) 2-10 expor t in g da t a fr om MATLAB 1-13
Ch ebysh ev win dow 4-9 ext en sion s t o SP Tool 5-30
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 F
er r or m in im iza t ion F a ct or y Set t in gs bu t t on , in P r efer en ces dia log box
bet ween desir ed a n d a ct u a l r espon se 2-22 5-30
for equ ir ipple filt er 5-75 fa st F ou r ier t r a n sfor m (F F T) 1-22, 1-43
for lea st squ a r es filt er 5-75 a n d fr equ en cy r espon se 1-24
in t egr a l of squ a r e 2-22 fft 1-22
m in im a x 2-22 pr im e fa ct or a lgor it h m 1-45, 6-139
weigh t in g in fr equ en cy ba n ds 2-24 r a dix-2 a lgor it h m 1-45, 6-139
est im a t ion r ole in sign a l pr ocessin g 1-43
cr oss spect r u m 3-14 t wo-dim en sion a l 6-141
power spect r u m 3-6 fft 1-2, 1-22, 1-43, 6-6, 6-137
t r a n sfer fu n ct ion 3-14 com plex in pu t s 1-45
S ee also pa r am et r ic m odelin g exa m ple 1-44
est im a t ion m et h ods execu t ion t im e 1-45, 6-140
in Spect r u m Viewer 5-103, 5-104 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 expor t in g a s TF object s for Con t r ol Syst em


r ea r r a n gin g ou t pu t 1-45, 6-144 Toolbox 5-29
specifyin g n u m ber of poin t s 1-44 gr ou p dela y 5-17
F F T len gt h iden t ifica t ion fr om fr equ en cy da t a 6-203
in F ilt er Design er 5-20, 5-27 im plem en t a t ion 1-22, 6-142, 6-145
in F ilt er Viewer 5-25 im por t in g in t o SP Tool 5-7, 5-8, 5-11
F F T Len gt h edit box, in P r efer en ces dia log box im pu lse r espon se 5-17
5-25, 5-27 lin ea r t im e-in va r ia n t digit a l 1-2
F F T m et h od, in Spect r u m Viewer 5-105 m a gn it u de r espon se 5-17
F F T. S ee fa st F ou r ier t r a n sfor m m ea su r em en t s 5-37
fft2 1-45, 6-6, 6-141 m edia n 4-28, 6-235
r ea r r a n gin g ou t pu t 1-45 m in im a x 2-22
F F T-ba sed filt er in g 1-22 m in im u m ph a se 6-265
fftfilt 1-19, 6-2, 6-142 m u lt iba n d F IR 2-22
com pa r ed t o filter 6-142 n a m es 1-15
fftshift 1-45, 6-6, 6-144 n a m in g in SP Tool 5-16
F ile Con t en t s list 5-8 or der 1-15, 2-7, 6-48, 6-55, 6-60, 6-132
filt er or der select ion 2-7
a n a log pr ot ot ype 2-8, 2-11, 6-21, 6-42, 6-54, ph a se r espon se 5-17
6-59, 6-131 pr in cipa l su ppor t ed 1-2
a n a lyzin g in F ilt er Viewer 5-17 Sa vit zky-Gola y 6-309, 6-311
a pplyin g t o a sign a l 5-18 secon d-or der sect ion s 6-322
Bu t t er wor t h 2-7, 6-43 sin gle ba n d F IR 2-20
gen er a lized 2-14 specifica t ion s 2-7
Ch ebysh ev 2-7 st ep r espon se 5-17
Ch ebysh ev t ype I 6-65 t r a n sposed dir ect for m II st r u ct u r e 1-17
Ch ebysh ev t ype II 6-70 t wo-dim en sion a l 6-148
coefficien t s 1-15, 2-17, 5-79 t ypes 2-17
design viewin g in F ilt er Viewer 5-17
F IR 6-287 zer os a n d poles 5-17
gen er a lized 2-5 S ee also F IR filt er , IIR filt er , digit a l filt er ,
IIR 2-5 a n a log filt er
in ver se 6-203, 6-207 filter 1-2, 1-16, 1-20, 6-2, 6-145
discr et iza t ion 2-41 com pa r ed t o fftfilt 6-142
ellipt ic 2-7, 6-125 com pa r ed t o filtfilt 1-21
equ ir ipple 2-22 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 set t in gs 5-86


in it ia l con dit ion s 6-150 su bplot s 5-86
filt er coefficien t s viewin g fr equ en cy r espon se 5-82
con ver t in g fr om a u t ocor r ela t ion sequ en ce viewin g gr ou p dela y 5-93
6-13 viewin g im pu lse r espon se 5-94
con ver t in g t o a u t ocor r ela t ion sequ en ce 6-262 viewin g m a gn it u de r espon se 5-89
con ver t in g t o r eflect ion coefficien t s 6-263, viewin g ph a se r espon se 5-91
6-283 viewin g st ep r espon se 5-95
filt er design viewin g zer o-pole plot 5-94
in F ilt er Design er 5-59, 5-73, 5-76 win dow 5-85
st a n da r d ba n d con figu r a t ion s 5-59 filter2 6-3, 6-148
u sin g specifica t ion lin es 5-70 filt er in g
F ilt er Design er 5-2, 5-17, 5-59, 6-329 a n d con volu t ion 1-14
a ct iva t in g 5-17, 5-59 a n t i-ca u sa l 1-20
ch a n gin g plot pr oper t ies 5-27 fr equ en cy dom a in 1-22
cla ssica l IIR filt er design 5-76 in it ia l con dit ion s 1-17
closin g 5-60 gen er a t in g 1-18
cu st om izin g 5-20 zer o-ph a se 1-20
m a gn it u de plot 5-63, 5-69, 5-78 filt er in g a lgor it h m 5-18
m ea su r in g r espon se ch a r a ct er ist ics 5-70 filtfilt 1-19, 1-20, 2-4, 6-3, 6-149
sa vin g da t a t o wor kspa ce 5-79, 5-110 com pa r ed t o filter 1-21
set t in g edge fr equ en cies 5-70 exa m ple 1-20
set t in g pa ssba n d r ipple 5-70 in it ia l con dit ion s 1-21
set t in g st opba n d a t t en u a t ion 5-70 filtic 1-18, 6-3, 6-150
sin gle ba n d F IR filt er design 5-73 F IR filt er
win dow 5-60 a r bit r a r y fr equ en cy r espon se 6-157
filt er pa r a m et er s, in F ilt er Viewer 5-20 com pa r ed t o IIR 2-16
filt er r espon se, pea ks a n d va lleys 5-37 design 2-16
filt er t ype decim a t ion 6-201
design 5-14 in t er pola t ion 6-201
im por t ed 5-14, 5-18 lea st squ a r es m et h od 6-166
F ilt er Viewer 5-2, 5-17, 5-84, 6-330 lin ea r ph a se 6-166
a ct iva t in g 5-17, 5-84 m u lt iba n d fr equ en cy r espon se 6-157
cu st om izin g 5-20 P a r ks-McClella n m et h od 6-287
defa u lt plot 5-85 win dow m et h od 6-152
plot s 5-86 differ en t ia t or 2-26, 6-167, 6-289
pr efer en ces 5-86 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 fircls 2-16, 6-5, 6-160


F F T-ba sed 1-22, 6-142 fircls1 2-16, 6-6, 6-163
over la p-a dd m et h od 1-22, 6-142 firls 2-16, 2-22, 6-6, 6-166
lin ea r ph a se 2-17, 6-287 a ccessin g fr om F ilt er Design er 5-73, 5-75
or der est im a t ion , remez fu n ct ion 6-294 com pa r ed t o remez 2-23
t ypes 6-169, 6-292 filt er ch a r a ct er ist ics 6-169
F IR filt er design 2-16 for differ en t ia t or design 2-26
a n t i-sym m et r ic 2-25 weigh t vect or 2-24
a r bit r a r y r espon ses 2-31 firrcos 2-17, 6-6, 6-171
com plex filt er s 2-17, 6-91 fixed-poin t im plem en t a t ion , digit a l filt er 1-37
n on lin ea r ph a se 2-17, 6-91 fm 4-30
r edu ced dela y 2-34 F M. S ee fr equ en cy m odu la t ion
con st r a in ed lea st squ a r es 2-16, 2-27 fopen 1-13
lin ea r ph a se 2-28 F ou r ier t r a n sfor m , eigen vect or equ iva len t 3-24
m u lt iba n d 2-28, 2-29 F ou r ier t r a n sfor m , t im e depen den t . S ee
weigh t ed 2-30 t im e-depen den t F ou r ier t r a n sfor m
equ ir ipple 2-16, 2-22, 2-23, 5-73, 5-75 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 ,
exa m ple 5-73, 5-113 fa st F ou r ier t r a n sfor m
in F ilt er Design er 5-59, 5-73 fread 1-13
Ka iser win dow 5-73, 5-75 freqs 1-26, 6-3, 6-173
lea st squ a r es 2-16, 2-22, 2-23, 5-73, 5-75 freqspace 6-176
lea st squ a r es com pa r ed t o equ ir ipple 2-23 fr equ en cy 6-287
lin ea r ph a se filt er s 2-17, 2-22 a n a log xvii
m u lt iba n d 2-16, 2-21, 2-22 a n gu la r 2-2
or der select ion 5-75 ca r r ier 4-29, 6-236, 6-365
pa r a m et er s in F ilt er Design er 5-75 cen t er 2-40
P a r ks-McClella n m et h od 2-22 cu t off 2-38
r a ised cosin e m et h od 2-17 digit a l xvii
r ole of Ka iser win dow 4-7 n or m a liza t ion 2-2
st a n da r d ba n d 2-20 N yqu ist xvii, 2-2
win dowin g m et h od 2-16, 2-18 pr ewa r pin g 6-25
F IR filt er in g, in fr equ en cy dom a in 1-19 t r a n sfor m a t ion 6-220, 6-223, 6-225, 6-227
F IR la t t ice filt er , im plem en t a t ion 1-38 vect or 2-24, 6-157, 6-160, 6-376
fir1 2-16, 2-20, 6-5, 6-152 fr equ en cy a n a lysis
a ccessin g fr om F ilt er Design er 5-73, 5-75 in F ilt er Viewer 5-84
fir2 2-16, 2-20, 6-5, 6-157 t im e-depen den t 6-323
exa m ple 2-21

I-12
Index

F r equ en cy Axis Ra n ge pop-u p m en u , in of Bessel pr ot ot ype 2-11


P r efer en ces dia log box 5-24, 5-25 of Bu t t er wor t h pr ot ot ype 2-8
F r equ en cy Axis Sca lin g pop-u p m en u , in of Ch ebysh ev t ype I pr ot ot ype 2-9
P r efer en ces dia log box 5-24, 5-25 of Ch ebysh ev t ype II pr ot ot ype 2-10
fr equ en cy a xis sca lin g, in Spect r u m Viewer 5-100 of Ch ebysh ev win dow 4-9
fr equ en cy dem odu la t ion 6-115 of ellipt ic pr ot ot ype 2-10
fr equ en cy dom a in ph a se 1-26
du a lit y wit h t im e dom a in 1-22 u n wr a ppin g 1-27
F IR filt er in g 1-19 plot t in g 1-25
for filt er im plem en t a t ion 1-22 poin t s a t wh ich eva lu a t ed 1-24
fr equ en cy dom a in ba sed m odelin g. S ee pa r a m et r ic spa cin g 6-176
m odelin g specifyin g sa m plin g fr equ en cy 1-24
fr equ en cy est im a t or fu n ct ion s, in eigen a n a lysis F r equ en cy Sca le pop-u p m en u , Spect r u m Viewer
3-24 5-100
fr equ en cy est im a t or t ech n iqu es fr equ en cy t r a n sfor m a t ion 2-38
eigen vect or (E V) m et h od 3-23 exa m ple 2-40
m u lt iple sign a l classifica t ion (MUSIC) m et h od lowpa ss t o ba n dpa ss 6-220
3-23 lowpa ss t o ba n dst op 6-223
fr equ en cy m odu la t ion 6-237 lowpa ss t o h igh pa ss 6-225
fr equ en cy poin t s lowpa ss t o lowpa ss 6-227
freqz 1-24, 1-26 fr equ en cy vect or 6-287
r a n ge 1-26 freqz 1-24, 6-3, 6-177
spa cin g 1-26 fr equ en cy poin t s 1-24
F r equ en cy Ra n ge pop-u p m en u , Spect r u m Viewer sa m plin g fr equ en cy 1-24
5-100 spa cin g 6-176
fr equ en cy r espon se 1-24 F r om Disk r a dio bu t t on , in Im por t dia log box 5-8
a r bit r a r y 2-13, 6-157 F r om Wor kspa ce r a dio bu t t on , in Im por t dia log
exa m ple 1-25 box 5-8
in F ilt er Viewer 5-82, 5-84, 5-89 fscanf 1-13
in ver se 6-203 F u ll View bu t t on 5-32
Ka iser win dow 4-6
lin ea r ph a se 2-17
m a gn it u de 1-26 G
m in im ized er r or bet ween desir ed a n d a ct u a l gauspuls 1-8, 1-10, 6-2, 6-180
2-22 Ga u ss-N ewt on m et h od 6-205, 6-209
m on ot on ic 2-9 gen er a lized Bu t t er wor t h filt er 2-14
m u lt iba n d 2-13 gen er a lized cosin e win dow 4-4

I-13
Index

Gibbs effect 2-19 a n d in st a n t a n eou s a t t r ibu t es 4-39


r edu ced by win dow 4-2 exa m ple 4-39
gr a ph ica l u ser in t er fa ce (GUI) xii, 1-3 H ilber t t r a n sfor m er 6-167, 6-289
gr id lin es, in F ilt er Design er 5-20, 5-27 h om om or ph ic syst em s 4-23
gr ou p dela y 1-28, 5-17, 6-182 H or izon t a l bu t t on , for r u ler s 5-36, 5-38, 5-39
defin ed 1-28
exa m ple 1-29
of lin ea r r espon se filt er 2-17 I
pa ssba n d 2-11 icceps 4-23, 4-25, 6-9, 6-189
viewin g in F ilt er Viewer 5-93 exa m ple 4-26
Gr ou p Dela y ch eck box, F ilt er Viewer 5-86 idct 4-36, 6-6, 6-190
gr ou p dela y plot 5-86, 5-93 idea l lowpa ss filt er 2-18
grpdelay 1-28, 6-3, 6-182 ifft 1-43, 6-6, 6-192
GU I. S ee gr a ph ica l u ser in t er fa ce specifyin g n u m ber of poin t s 1-45
GU I-ba sed t ools. S ee in t er a ct ive t ools 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
H Bessel 2-11
hamming 4-2, 6-8, 6-185 Bu t t er wor t h 2-8
H a m m in g win dow 2-20, 4-4, 6-185 Ch ebysh ev t ype I 2-9
HandleVisibility pr oper t y 5-57, 5-110 Ch ebysh ev t ype II 2-10
hanning 4-2, 6-8, 6-186 com pa r ed t o F IR 2-4
H a n n in g win dow 4-4, 6-186 design 2-4
h igh pa ss filt er dir ect 2-13
a n a log pr ot ot ype design 2-6 Levin son -Du r bin r ecu r sion 6-218
Bessel 6-22 m u lt iba n d 2-13
Bu t t er wor t h 6-44, 6-45 P r on y’s m et h od 6-266
Ch ebysh ev t ype I 6-66, 6-67 St eiglit z-McBr ide it er a t ion 6-341
Ch ebysh ev t ype II 6-71, 6-72 Yu le-Wa lker 6-376
ellipt ic 6-126, 6-127 ellipt ic 2-10
F IR design im plem en t a t ion 6-145
wit h win dow m et h od 2-21, 6-154 fr equ en cy dom a in 1-22
t r a n sfor m a t ion fr om lowpa ss t o 6-225 zer o-ph a se 1-20
hilbert 2-26, 4-38, 6-6, 6-187 IIR filt er design 2-4, 2-5
exa m ple 4-39 a n a log pr ot ot ype 2-5
H ilber t t r a n sfor m 4-34, 4-38, 6-187 Bu t t er wor t h 2-7, 2-8, 5-76, 5-77
a n d a n a lyt ic sign a l 2-26 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 Im pu lse Respon se ch eck box, F ilt er Viewer 5-86
com pa r ison of filt er t ypes 2-8 im pu lse r espon se plot 5-86, 5-94
gen er a l st eps 2-37 impz 6-3, 6-196
illu st r a t ion 2-37 exa m ple 1-23
in F ilt er Design er 5-76 in dexin g, of vect or s 1-15
or der est im a t ion 2-7 In h er it fr om pop-u p m en u , Spect r u m Viewer
plot t in g pr ot ot ypes 2-12 5-100
sin gle st ep 2-6 in h er it in g pa r a m et er s 5-100
sin gle st ep or der est im a t ion 2-7 in it ia l con dit ion s 1-17, 1-21, 6-150
syst em m odel 2-7 gen er a t in g 1-18
dir ect m et h ods 2-13 In it ia l Type pop-u p m en u , in P r efer en ces dia log
Yu le-Wa lker 2-13 box 5-21
ellipt ic 2-7, 2-10, 5-76, 5-77 in st a n t a n eou s a t t r ibu t es 4-39, 6-187
exa m ple 5-76, 5-77 in t er a ct ive t ools 5-2
gen er a lized Bu t t er wor t h 2-14 ext en ded exa m ple 5-113
in F ilt er Design er 5-59, 5-76 F ilt er Design er 5-2, 5-59, 6-329
m a xim a lly fla t 2-14 F ilt er Viewer 5-2, 5-84, 6-330
pa r a m et er s in F ilt er Design er 5-77 Sign a l Br owser 5-2, 5-43, 6-328
t o specifica t ion s 2-7 Spect r u m Viewer 5-2, 5-97, 6-331
S ee also dir ect design , pa r a m et r ic m odelin g SP Tool 5-2, 6-328
IIR la t t ice filt er , im plem en t a t ion 1-38 interp 6-9, 6-199
im a ge pr ocessin g 6-84 in t er pola t ion 6-199
wit h fft2 a n d ifft2 1-45 F IR filt er design 6-201
impinvar 2-5, 2-42, 6-11, 6-194 in t er va l n ot a t ion xvii
Im por t As pop-u p m en u , in Im por t dia log box 5-9 intfilt 6-6, 6-201
Im por t m en u it em 5-4, 5-6 in ver se com plex cepst r u m 4-25
im por t ed filt er , in SP Tool 5-14 in ver se discr et e cosin e t r a n sfor m 6-190
im pu lse in va r ia n ce 2-42, 6-194 a ccu r a cy of sign a l r econ st r u ct ion 4-38
lim it a t ion s 2-42 in ver se discr et e F ou r ier t r a n sfor m 1-43, 6-192
im pu lse r espon se 1-23, 5-17, 6-196 ifft 1-43
a n d im pu lse in va r ia n ce 2-42 m a t r ix 6-117
com pu t in g wit h filter 1-23 t wo-dim en sion a l 1-45, 6-193
com pu t in g wit h impz 1-23 in ver se filt er design 6-207, 6-266
defin ed 1-23 a n a log 6-203
exa m ple 1-23 digit a l 6-207
of idea l lowpa ss filt er 2-18 in ver se F ou r ier t r a n sfor m , con t in u ou s. S ee sinc
viewin g in F ilt er Viewer 5-94 fu n ct ion

I-15
Index

invfreqs 2-5, 4-11, 4-16, 6-8, 6-203 a n d pa r a m et r ic m odelin g 4-12


invfreqz 2-5, 4-11, 4-16, 6-8, 6-207 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
K in Sign a l Br owser 5-35
kaiser 4-2, 6-8, 6-210 in Spect r u m Viewer 5-35
a ccessin g fr om F ilt er Design er 5-73 lin e select ion
exa m ple 4-5 in F ilt er Viewer 5-34, 5-35
Ka iser win dow 4-4, 6-210 in Sign a l Br owser 5-34, 5-35
a n d F IR filt er design 4-7, 5-73 in Spect r u m Viewer 5-34, 5-35
bet a pa r a m et er 4-4, 6-210 lin e st yle
exa m ple 4-5 cu st om izin g in SP Tool 5-20
fr equ en cy r espon se 4-6 in F ilt er Viewer 5-22, 5-35
kaiserord 2-16, 6-6, 6-211 in Sign a l Br owser 5-22, 5-35
a ccessin g fr om F ilt er Design er 5-75 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
L lin ea r ph a se 2-16, 2-17, 6-166
la dder coefficien t s 1-38 filt er design 6-287
La gr a n ge in t er pola t ion filt er 6-201 r ela t ed ch a r a ct er ist ics 2-17
La pla ce t r a n sfor m 1-41 lin ea r pr edict ion coefficien t s 6-229
equ iva len t t o st a t e-spa ce r epr esen t a t ion 1-41 lin ea r pr edict ion m odelin g 4-12
latc2tf 1-39, 1-42, 6-3, 6-216 lin ea r pr edict ive codin g
latcfilt 1-19, 1-39, 6-3, 6-217 lin ea r swept -fr equ en cy cosin e. S ee ch ir p
la t t ice coefficien t s 1-38 lin ea r syst em m odels 1-32
la t t ice filt er 1-42 lin ea r syst em t r a n sfor m a t ion s 1-41
im plem en t a t ion 1-38 con ver sion ch a r t 1-41
im plem en t a t ion wit h latcfilt 1-39 lin ea r t im e-in va r ia n t differ en t ia l equ a t ion s,
la t t ice for m r epr esen t ed in st a t e-spa ce for m 1-40
con ver t in g fr om t r a n sfer fu n ct ion 6-346 load 1-13
la t t ice st r u ct u r e 1-37 lowpa ss filt er
la t t ice/la dder filt er a n a log pr ot ot ype design 2-6
im plem en t a t ion 1-38 a n d im pu lse in va r ia n ce 2-42
im plem en t a t ion wit h latcfilt 1-39 Bessel 6-22
lea st squ a r es m et h od, F IR filt er design 6-166 Bu t t er wor t h 6-43, 6-44
filt er ch a r a ct er ist ics 6-169 Ch ebysh ev t ype I 6-65, 6-66
levinson 4-11, 6-8, 6-218 , 6-305 Ch ebysh ev t ype II 6-70, 6-71

I-16
Index

ellipt ic 6-125, 6-126 Ma r ker Size edit box, in P r efer en ces dia log box
F IR design , wit h win dow m et h od 2-21 5-21
for decim a t ion 6-110 m a t ch fr equ en cy (for pr ewa r pin g) 6-25
for in t er pola t ion 6-199 MAT-file
idea l im pu lse r espon se 2-18 dpss.mat 3-19
t r a n sla t ion of cu t off fr equ en cy 6-227 im por t in g 1-13
lp2bp 2-5, 2-39, 6-10, 6-220 im por t in g in t o SP Tool 5-4, 5-6
exa m ple 2-40 loa din g in t o SP Tool 5-8
lp2bs 2-5, 2-39, 6-10, 6-223 MAT-file for m a t , con ver t in g t o 1-13
lp2hp 2-5, 2-39, 6-10, 6-225 m a t r ices
lp2lp 2-5, 2-39, 6-10, 6-227 con volu t ion 1-39, 6-86
lpc 2-5, 4-11, 6-8, 6-229 cor r ela t ion coefficien t 6-88
S ee also lin ea r pr edict ive codin g, P r on y’s cova r ia n ce 6-89
m et h od da t a 1-4, 1-7
LP C. S ee lin ea r pr edict ion coefficien t s 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 m a t r ix for m . S ee st a t e-spa ce for m
m a gn it u de maxflat 2-5, 2-14, 6-5, 6-233
of F ou r ier t r a n sfor m of sequ en ce 1-44 m a xim a , loca l 5-37
of fr equ en cy r espon se 1-26 m a xim a lly fla t 2-14
viewin g in F ilt er Viewer 5-89 m ea su r em en t lin es 5-70
of t r a n sfer fu n ct ion est im a t e 3-15 m ea su r em en t s
vect or 2-24, 6-157, 6-160, 6-376 in F ilt er Viewer 5-37
Ma gn it u de Axis Sca lin g pop-u p m en u , in in Sign a l Br owser 5-37
P r efer en ces dia log box 5-24, 5-25 in Spect r u m Viewer 5-37, 5-101
Ma gn it u de ch eck box, F ilt er Viewer 5-86 sa vin g in F ilt er Viewer 5-37
m a gn it u de plot 5-78 sa vin g in Sign al Br owser 5-37
m a gn it u de plot , in F ilt er Design er 5-69, 5-78 sa vin g in Spect r u m Viewer 5-37
m a gn it u de r espon se 5-17 medfilt1 4-28, 6-9, 6-235
m a gn it u de r espon se plot 5-86, 5-89 m edia n filt er 4-28, 6-235
in F ilt er Design er 5-63 m essa ge sign a l 4-29, 6-236
Ma gn it u de Sca le pop-u p m en u , Spect r u m Viewer Met h od pop-u p m en u , Spect r u m Viewer 5-103
5-100 ME X-file 1-13
m a gn it u de sca le, in Spect r u m Viewer 5-100 M-files 1-3
m a n u fa ct u r in g 4-10 cr ea t in g xii, 1-3
m odifyin g xii

I-17
Index

viewin g xii S ee also F IR filt er


m in im a , loca l 5-37 MTM. S ee m u lt it a per m et h od
m in im a x m et h od, F IR filt er design 2-22 m u lt iba n d filt er
S ee also P a r ks-McClella n m et h od F IR 2-21
m in im u m ph a se filt er 6-265 F IR, wit h t r a n sit ion ba n ds 2-22
m odels IIR 2-13
a u t or egr essive 6-16, 6-17, 6-18, 6-19 m u lt ich a n n el da t a 1-4, 1-7
via Bu r g m et h od 6-239 m u lt ich a n n el sign a l 3-4
via cova r ia n ce m et h od 6-243 m u lt iple sign a l cla ssifica t ion m et h od (MUSIC) 3-5,
via m odified cova r ia n ce m et h od 6-247 3-6, 3-23
via Yu le-Wa lker AR m et h od 6-278 defin ed 3-23
m odels, syst em r epr esen t a t ion 1-32 in Spect r u m Viewer 5-106
m odified cova r ia n ce m et h od 3-6, 3-22 m u lt iplicit y, of zer os a n d poles 5-71
defin ed 3-22 m u lt ir a t e filt er ba n k, im plem en t at ion 1-19
exa m ple 3-23 m u lt ir a t e filt er in g 1-19
m odified per iodogr a m 3-9 m u lt it a per m et h od (MTM) 3-5, 3-6, 3-16
modulate 4-29, 6-9 com pa r ed t o Welch ’s m et h od 3-19
exa m ple 4-30 defin ed 3-16
m et h od fla gs 4-29 exa m ple 3-17
m odu la t ion 6-236 in Spect r u m Viewer 5-105
a m plit u de MUSIC. S ee m u lt iple sign a l cla ssifica t ion m et h od
defin ed 4-29
exa m ple 4-30
fr equ en cy N
m et h ods 4-29, 6-236 N ew Design bu t t on 5-17, 5-59
ph a se 4-30 n on in t eger dela y 2-26
pu lse t im e 4-30 n on r ecu r sive filt er . S ee F IR filt er
pu lse widt h 4-30 n or m a liza t ion 3-3
qu a dr a t u r e a m plit u de 4-30 cor r ela t ion 3-4, 6-367, 6-368
m ou se zoom 5-32 power spect r a l den sit y 3-12
in F ilt er Design er 5-20 N yqu ist fr equ en cy xvii, 2-2
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 O
t u r n in g off 5-33 object s, edit in g in SP Tool 5-15
Mou se Zoom bu t t on 5-32 on e-t im e m ou se zoom in g 5-32
m ovin g a ver a ge (MA) filt er 1-15 Open Session m en u it em 5-6

I-18
Index

or der est im a t ion 2-7, 6-294 P a r ks-McClella n m et h od, F IR filt er design 2-22,
Bu t t er wor t h 6-48 6-287
Ch ebysh ev t ype I 6-55 pa r t ia l fr a ct ion 1-42
Ch ebysh ev t ype II 6-60 pa r t ia l fr a ct ion expa n sion 1-40
ellipt ic 6-132 defin ed 1-35
in F ilt er Design er 5-75, 5-78 det er m in in g wit h residue 1-41
or der select ion 2-7 exa m ple 1-35
in F ilt er Design er 5-75, 5-78 pa r t ia l fr a ct ion for m 1-35, 6-302
or der , of filt er 1-15, 2-7 pa ssba n d
or t h ogon a l win dows, in P SD est im a t es 3-16 equ ir ipple 2-9, 2-10
oscilla t or , volt a ge con t r olled 6-365 gr ou p dela y 2-11
over la p-a dd m et h od, F IR filt er im plem en t a t ion pa ssba n d r ipple, set t in g in F ilt er Design er 5-70
1-22, 6-142 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
P exa m ple 3-21
P a ge Set u p dia log box 5-45, 5-99 pcov 3-6, 3-22, 6-7, 6-243
pa n n er 5-52 exa m ple 3-23
in Sign a l Br owser 5-20, 5-23, 5-48 P ea ks bu t t on , Sign a l Br owser 5-37
P a n n er ch eck box, in P r efer en ces dia log box 5-23 per iodic sin c fu n ct ion 6-118
pa r a m et er s S ee also Dir ich let fu n ct ion
in Spect r u m Viewer 5-99, 5-100, 5-103 per iodogr a m 3-7
in h er it in g in Spect r u m Viewer 5-100 m odified 3-9
pa r a m et r ic m odelin g 4-10, 6-207 per sist en t m ou se zoom in g 5-32
a pplica t ion s 4-10 ph a se
fr equ en cy dom a in ba sed 4-16 com pu t in g wit h angle 6-15
su m m a r y 2-5 of F ou r ier t r a n sfor m of sequ en ce 1-44
t ech n iqu es 4-10 of fr equ en cy r espon se 1-26
t im e dom a in ba sed viewin g in F ilt er Viewer 5-91
lin ea r pr edict ive codin g 4-12, 4-13 of t r a n sfer fu n ct ion est im a t e 3-15
St eiglit z-McBr ide m et h od 4-15 u n wr a ppin g 1-27, 6-360
t im e-dom a in based 4-11 P h a se ch eck box, F ilt er Viewer 5-86
Bu r g m et h od 6-16 ph a se dela y 1-28, 6-182
cova r ia n ce m et h od 6-17 defin ed 1-28
m odified cova r ia n ce m et h od 6-18 exa m ple 1-29
Yu le-Wa lker m et h od 6-19 of lin ea r r espon se filt er 2-17
pa r en t h eses, in dica t in g open in t er va l xvii ph a se dem odu la t ion 6-115

I-19
Index

ph a se dist or t ion st ep r espon se 5-86, 5-95


elim in a t in g st r ip plot 6-344
du r in g filt er in g 1-19 t ilin g in F ilt er Viewer 5-88
exa m ple 1-20 t r a n sfer fu n ct ion 3-15
u sin g filtfilt 1-20 zer o-pole 1-30, 5-86, 5-94, 6-385
in F IR filt er s 1-20 plu g-in s 5-20, 5-30
n on lin ea r pm 4-30
in IIR filt er s 1-20 pmcov 3-6, 3-22, 6-7, 6-247
ph a se m odifica t ion exa m ple 3-23
da t a depen den t , u sin g >cceps 4-25 p-m odel. S ee pa r a m et r ic m odelin g
ph a se m odu la t ion 4-30, 6-237 pmtm 3-6, 6-7, 6-251
ph a se r espon se 5-17 exa m ple 3-17
ph a se r espon se plot 5-86, 5-91 pmusic 3-6, 3-23, 6-7, 6-255
P h a se Un it s pop-u p m en u , in P r efer en ces dia log pole-zer o filt er . S ee IIR filt er
box 5-25 poly 1-33, 1-42
ph a se u n it s, in F ilt er Viewer 5-25 poly2ac 6-4, 6-262
P la y m en u it em , Sign a l Br owser 5-46 poly2rc 6-4, 6-263
pla yin g a sign a l 5-46 polyn om ia l
plot division 4-33, 6-113
a n a log pr ot ot ypes 2-12 m u lt iplica t ion 6-83
coh er en ce fu n ct ion 3-16 r oot s 1-33
com plex cepst r u m 4-24 st a biliza t ion 6-265
DF T 1-44 polyph a se filt er in g t ech n iqu es 1-19
fr equ en cy r espon se 1-25 polystab 6-9, 6-265
m a gn it u de 1-26 power spect r a l den sit y 6-273
ph a se 1-26 bia s 3-12
gr ou p dela y 1-29, 5-86, 5-93 com pu t a t ion pa r a m et er s 5-103, 5-104
im pu lse r espon se 5-86, 5-94 con fiden ce in t er va l 3-14
in F ilt er Viewer 5-84, 5-86, 5-88, 5-89 defa u lt plot 5-102
m a gn it u de r espon se 5-78, 5-86, 5-89 defin ed 3-5
m odified per iodogr a m 3-10 est im a t ion by Bu r g m et h od 3-6, 3-20, 5-104,
m u lt it a per est im a t e 3-17, 3-18 6-239
per iodogr a m 3-7 est im a t ion by cova r ia n ce m et h od 3-6, 3-22,
ph a se dela y 1-29 5-105, 6-243
ph a se r espon se 5-86, 5-91 est im a t ion by F F T m et h od 5-105
power spect r a l den sit y 3-11 est im a t ion by m odified cova r ia n ce m et h od 3-6,
spect r a l den sit y 5-101 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, pr ot ot ype


5-105 Bessel filt er 2-11, 6-21
est im a t ion by MUSIC m et h od 3-6, 3-23, 5-106 Bu t t er wor t h filt er 2-8, 6-42
est im a t ion by Welch ’s m et h od 3-6, 3-10, 5-106 Ch ebysh ev t ype I filt er 6-54
est im a t ion by Yu le-Wa lker AR m et h od 3-6, Ch ebysh ev t ype II filt er 6-59
3-19, 5-107, 6-278 ellipt ic filt er 6-131
est im a t ion m et h ods 5-103, 5-104 P SD. S ee power spect r a l den sit y
in SP Tool 5-13 psd. S ee pwelch 6-268
n or m a liza t ion 3-12 ptm 4-30
u n it s of 3-11 pu lse t im e dem odu la t ion 6-115
viewin g in Spect r u m Viewer 5-97, 5-102, pu lse t im e m odu la t ion 4-30, 6-237
5-104 pu lse t r a in gen er a t or 6-269
pr efer en ces pu lse t r a in s
r u ler s 5-21 gen er a t in g 1-9
sa vin g in Sign a l Br owser 5-45 pulstran 1-9
pr efer en ces file pu lse widt h dem odu la t ion 6-115
in SP Tool 5-31 pu lse widt h m odu la t ion 4-30, 6-237
sigprefs.mat 5-31 pulstran 1-9, 6-2, 6-75, 6-119, 6-121, 6-122, 6-123,
P r efer en ces m en u it em 5-6, 5-20, 5-30 6-124, 6-269 , 6-286, 6-346, 6-359
pr ewa r pin g 6-25 pwelch 3-6, 3-10, 6-7, 6-273
P r in t dia log box 5-45, 5-55, 5-99, 5-108, 5-120, exa m ple 3-12
5-124 pwm 4-30
P r in t P r eview win dow pyulear 3-6, 3-20, 6-7, 6-278
H a n dle Gr a ph ics 5-57, 5-110 exa m ple 3-20, 3-21
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 Q
pr efer en ces 5-109 qam 4-30
pr in t in g qu a dr a t u r e a m plit u de dem odu la t ion 6-115
fr om Sign a l Br owser 5-2, 5-21, 5-22, 5-31, 5-33, qu a dr a t u r e a m plit u de m odu la t ion 4-30, 6-237
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 R
pr ola t e-sph er oida l win dow 4-4 r a da r a pplica t ion s 4-27
prony 2-5, 4-11, 4-13, 6-8, 6-266 r a dix-2 a lgor it h m 1-45
P r on y’s m et h od 4-13, 6-266 r a ised cosin e filt er design 6-171
m odelin g 4-13 randn xiv

I-21
Index

r a n dom n u m ber , gen er a t ion xiv Rever t pa n el 5-31


r a n ge n ot a t ion xvii r ipple, pa ssba n d 5-70
Ra n ge pop-u p m en u , F ilt er Viewer 5-87 rlevinson 6-9, 6-305
rc2poly 6-4, 6-283 r oot s
rceps 4-23, 4-25, 6-9, 6-285 of Bessel filt er 6-21
r ea l cepst r u m 6-285 polyn om ia l 1-33
defin ed 4-24 roots 1-33, 1-42
r econ st r u ct in g sign a l (m in im u m -ph a se) 4-25 r u ler color 5-21
r ebu ffer in g 6-33 Ru ler Color edit box, in P r efer en ces dia log box
r ect a n gu la r win dow 2-18, 4-2, 6-32 5-21
rectpuls 6-2, 6-286 Ru ler Ma r ker pop-u p m en u , in P r efer en ces dia log
r ecu r sive filt er . S ee IIR filt er box 5-21
r efer en ces 1-46, 3-27, 4-40 r u ler m a r ker s 5-21, 5-36
r eflect ion coefficien t s 1-37, 1-39 r u ler t ype
con ver t in g fr om a u t ocor r ela t ion sequ en ce in Sign a l Br owser 5-21
6-14 in Spect r u m Viewer 5-21
con ver t in g fr om filt er coefficien t s 6-263, r u ler s
6-283 br in gin g t o cen t er 5-35
con ver t in g t o a u t ocor r ela t ion sequ en ce 6-282 cu st om izin g in SP Tool 5-20
remez 2-16, 2-22, 6-6, 6-287 dr a ggin g 5-36
a ccessin g fr om F ilt er Design er 5-73, 5-75 fin d r u ler bu t t on s 5-35
com pa r ed t o firls 2-23 h or izon t a l 5-36
filt er ch a r a ct er ist ics 6-292 h or izon t a l m ode 5-40
for differ en t ia t or design 2-26 in F ilt er Viewer 5-26, 5-33
for H ilber t t r a n sfor m er design 2-25 in Sign a l Br owser 5-20, 5-21, 5-23, 5-33
or der est im a t ion 6-294 in Spect r u m Viewer 5-20, 5-21, 5-24, 5-33
weigh t vect or 2-24 pa r a m et er s 5-36
Rem ez exch a n ge a lgor it h m 2-22, 6-287 posit ion in g 5-38
remezord 2-16, 6-6, 6-294 pr efer en ces 5-21
a ccessin g fr om F ilt er Design er 5-75 sa vin g m ea su r em en t s 5-37
resample 6-10, 6-298 slope 5-36
r esa m plin g 4-20, 6-298 slope m ode 5-42
in F IR filt er in g 1-19 t r a ck 5-36
S ee also decim a t ion , in t er pola t ion t r a ck m ode 5-41
residue 1-41, 1-42 ver t ica l 5-36
r esidu e for m . S ee pa r t ia l fr a ct ion for m ver t ica l m ode 5-39
residuez 1-42, 6-4, 6-302

I-22
Index

Ru ler s ch eck box, in P r efer en ces dia log box 5-23, secon d-or der sect ion for m
5-24, 5-26 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
S secon d-or der sect ion s for m 1-36
sa m plin g fr equ en cy con ver t in g fr om st a t e-spa ce for m 6-333
ch a n gin g in SP Tool 5-9 con ver t in g t o st a t e-spa ce 6-316
in SP Tool 5-16 con ver t in g t o t r a n sfer fu n ct ion 6-318
Sa m plin g F r equ en cy edit box, in Im por t dia log box con ver t in g t o zer o-pole-ga in 6-320
5-4, 5-9 defin ed 1-36
Sa m plin g F r equ en cy m en u it em 5-16 filt er in g 6-322
sa m plin g r a t e specifyin g in SP Tool 5-12
ch a n gin g by n on in t eger fa ct or 4-20, 6-298 select in g da t a object s in SP Tool 5-15
ch a n gin g for ir r egu lar ly spa ced da t a 4-22 sequ en ce
ch a n gin g wit h upfirdn 1-19 a u t ocor r ela t ion 6-13, 6-14, 6-262
decr ea sin g by in t eger fa ct or 6-110 set t in gs
in cr ea sin g by in t eger fa ct or 6-199 r est or in g in SP Tool 5-30
Sa ve Ru ler s bu t t on 5-37 r u ler s 5-21
Sa ve Session m en u it em 5-6 sa vin g in Sign al Br owser 5-45
sa vin g ch a n ges in SP Tool 5-30 sa vin g in SP Tool 5-31
sa vin g da t a sgolay 6-309 , 6-311
fr om F ilt er Design er 5-79, 5-110 sgolayfilt 6-311
fr om Sign a l Br owser 5-57 sign a l
sa vin g da t a , fr om F ilt er Design er 5-79, 5-110 a ddin g n oise 1-6
sa vin g da t a , fr om Sign a l Br owser 5-57 a n a lyt ic 4-38, 6-187
sa vin g set t in gs, in F ilt er Viewer 5-86 bu ffer in g 6-33
Sa vit zky-Gola y ca r r ier 4-29, 6-114
filt er design 6-309 com plex 5-47
filt er in g 6-311 con t in u ou s (a n a log) 1-2
sawtooth 1-8, 6-2, 6-308 differ en t ia t ion 2-26
sa wt oot h wa ve 1-8 discr et e (digit a l) 1-2
sca la r gen er a t in g 1-7
for st a t e-spa ce for m 1-34 im por t in g in t o SP Tool 5-3, 5-7, 5-8, 5-10
r epr esen t in g ga in 1-33 lin kin g t o spect r u m 5-100
Sca le pop-u p m en u , F ilt er Viewer 5-87 m ea su r em en t s 5-37
Sea r ch for P lu g-In s a t st a r t -u p ch eck box, in m ea su r em en t s in Sign a l Br owser 5-36
P r efer en ces dia log box 5-30 m essa ge 4-29, 6-236

I-23
Index

m u lt ich a n n el 3-4 Slope bu t t on , for r u ler s 5-36


n a m in g in SP Tool 5-16 Slope con t r ol 5-38, 5-41
pea ks 5-37 son a r a pplica t ion s 4-27
pla yin g 5-46 sos2ss 1-42, 6-4, 6-316
plot t in g 1-6 sos2tf 1-42, 6-4, 6-318
r ebu ffer in g 6-33 sos2zp 1-42, 6-4, 6-320
r econ st r u ct ion specgram 4-27, 6-10, 6-323
fr om DCT coefficien t s 4-37 exa m ple 4-27, 6-365
m in im u m ph a se 4-25, 6-285 specifica t ion lin es 5-78
r epr esen t in g dr a ggin g t o edit filt er 5-70
in MATLAB 1-4 specifica t ion s for filt er design 2-7
m u lt ich a n n el 1-4 spect r a l a n a lysis 3-5
sin gle ch a n n el 1-4 cr oss spect r a l den sit y 3-14
select in g in Sign a l Br owser 5-48 defin ed 3-5
va lleys 5-37 power spect r a l den sit y 3-5
viewin g in Sign a l Br owser 5-17, 5-48 u sin g Spect r u m Viewer 5-97
S ee also wa vefor m spect r a l den sit y 3-5
Sign a l Br owser 5-2, 5-17, 5-43, 6-328 S ee also power spect r a l den sit y, cr oss spect r a l
a ct iva t in g 5-17, 5-43 den sit y
cu st om izin g 5-20 spect r a l den sit y plot
pr in t in g fr om 5-23, 5-43, 5-44, 5-54 in Spect r u m Viewer 5-101
sa vin g da t a t o wor kspa ce 5-57 spect r ogr a m 4-27, 6-323
win dow 5-44 exa m ple 4-27, 6-365
Sign a l P r ocessin g Toolbox 1-2 spect r u m
sign a l t ype com pu t in g in SP Tool 5-19
a r r a y 5-14 im por t in g in t o SP Tool 5-7, 5-8, 5-13
vect or 5-14 lin kin g t o sign a l 5-100
sigprefs.mat 5-31 m ea su r em en t s 5-37
sinc 1-10, 6-2, 6-313 m ea su r em en t s in Spect r u m Viewer 5-36, 5-101
ba n dlim it ed in t er pola t ion exa m ple 6-314 n a m in g in SP Tool 5-16
sin c fu n ct ion 1-10, 6-313 pea ks 5-37
a n d ba n dlim it ed in t er pola t ion 6-314 u pda t in g in SP Tool 5-19
ba sic exa m ple 1-10 va lleys 5-37
defin ed 1-10 viewin g in Spect r u m Viewer 5-97
sin u soida l wa ve 1-8 viewin g in SP Tool 5-19
Slepia n sequ en ces. S ee discr et e pr ola t e spect r u m t ype, a u t o 5-15
sph er oida l sequ en ces 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 r epr esen t in g in MATLAB 1-34


ch a n gin g plot pr oper t ies 5-102 specifyin g in SP Tool 5-11
cu st om izin g 5-20 st a t ist ica l oper a t ion s 3-2
defa u lt plot 5-102 St a y in Zoom -m ode Aft er Zoom ch eck box, in
pr in t in g fr om 5-24, 5-97, 5-98, 5-107, 5-108 P r efer en ces dia log box 5-23, 5-24, 5-26,
set t in g con fiden ce in t er va ls 5-107 5-27
viewin g power spect r a l den sit y plot s 5-102 St eiglit z-McBr ide m et h od 4-15, 6-341
win dow 5-98 st ep r espon se 5-17
speech pr ocessin g 4-10, 4-21 viewin g in F ilt er Viewer 5-95
spline 4-22 St ep Respon se ch eck box, F ilt er Viewer 5-86
spt ext en sion 5-6 st ep r espon se plot 5-86, 5-95
SP Tool 5-2, 6-328 stmcb 2-5, 4-11, 4-15, 6-9, 6-341
a ct iva t in g fr om Sign a l Br owser 5-54 st opba n d
closin g 5-6 a t t en u a t ion , set t in g in F ilt er Design er 5-70
cu st om izin g 5-6, 5-20 equ ir ipple 2-10
loa din g 5-3 st r ip plot 6-344
pr efer en ces 5-6 defin ed 6-344
win dow 5-5 strips 6-2, 6-344
sptool com m a n d 6-11, 6-328 st r u ct u r e, digit a l filt er
square 1-8, 6-2, 6-332 la t t ice 1-37
squ a r e wa ve 1-8 t r a n sposed dir ect for m II 1-17
ss2sos 1-42, 6-4, 6-333 su bplot s 5-84
ss2tf 1-42, 6-337 in F ilt er Viewer 5-86
ss2zp 1-42, 6-4, 6-338 su bspa ce t h r esh olds, con t r ollin g in pmusic
st a biliza t ion , polyn om ia l 6-265 fu n ct ion 3-25
st a n da r ds svd, in pmusic fu n ct ion 3-25
Com pa ct Disc 4-20 swept -fr equ en cy cosin e gen er a t or . S ee ch ir p
Digit a l Au dio Ta pe 4-20 syst em iden t ifica t ion 4-13
st a r t u p t r a n sien t s 1-22 syst em m odels 1-32
r edu cin g 1-21, 6-149 a n d bilin ea r t r a n sfor m a t ion 2-44
st a t e-spa ce for m 1-40, 1-42 a n d filt er design fu n ct ion s 2-7
con ver t in g fr om secon d-or der sect ion s 6-316 a n d fr equ en cy t r a n sfor m a t ion fu n ct ion s 2-39
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 T
con ver t in g t o zer o-pole-ga in 6-338 t a per s, in P SD est im a t es 3-16
defin ed 1-34 t a ps 2-17

I-25
Index

t ext s, r ela t ed 1-46 con ver t in g fr om secon d-or der sect ion s 6-318
tf2latc 1-39, 1-42, 6-4, 6-346 con ver t in g t o la t t ice 6-346
tf2ss 1-42, 6-4, 6-350 con ver t in g t o secon d-or der sect ion s 6-347
tf2zp 1-42, 6-339, 6-352 con ver t in g t o st a t e-spa ce 6-350
tfe 3-6, 3-14, 6-7, 6-354 specifyin g in SP Tool 5-11
thresh 3-25 t r a n sfor m 4-34
t ilin g 5-88 ch ir p z -t r a n sfor m (CZT) 4-34, 6-105
t ilin g displa y, in F ilt er Viewer 5-26 discr et e cosin e 6-108
t ilin g pr efer en ces, in F ilt er Viewer 5-20 discr et e F ou r ier 1-43
Tim e Respon se Len gt h edit box, in P r efer en ces H ilber t 4-38, 6-187
dia log box 5-25 in ver se discr et e cosin e 4-36, 6-190
t im e r espon se len gt h , in F ilt er Viewer 5-25 in ver se discr et e F ou r ier 6-192
t im e vect or 1-6 t r a n sfor m a t ion s
r et u r n ed by modulate 4-30 bet ween syst em m odels 1-41
t im e-depen den t F ou r ier t r a n sfor m 4-27 bilin ea r 2-43, 6-25
t im e-dom a in a n a lysis, in F ilt er Viewer 5-84 fr equ en cy 2-38, 6-220, 6-223, 6-225, 6-227
t im e-dom a in ba sed m odelin g. S ee pa r a m et r ic t r a n sit ion ba n d 2-23
m odelin g t r a n sposed dir ect for m II 6-145
t oolbox in it ia l con dit ion s 6-150
Con t r ol Syst em s Toolbox 1-35, 6-198, 6-340 triang 4-2, 6-8, 6-358
Im a ge P r ocessin g Toolbox 6-109, 6-190, 6-235 com pa r ed t o bartlett 6-20
Sign a l P r ocessin g Toolbox 1-2 exa m ple 4-2
Sym bolic Ma t h Toolbox 6-21 t r ia n gu la r win dow 6-358
Syst em Iden t ifica t ion Toolbox 6-357 tripuls 6-2, 6-359
Tr a ck bu t t on , for r u ler s 5-36, 5-38, 5-40 t wo-dim en sion a l oper a t ion s
t r a n sfer fu n ct ion 1-32, 1-35, 1-40, 1-42 a u t ocor r ela t ion 6-372
coefficien t s 1-15, 5-79 con volu t ion 6-84
defin ed 1-15 obt a in in g su bsect ion 6-84
der iva t ion 1-15 cr oss-cor r ela t ion 6-372
est im a t e fr om in pu t a n d ou t pu t 6-354 discr et e F ou r ier t r a n sfor m 1-45, 6-141
est im a t in g u sin g Welch ’s m et h od 3-14 filt er in g 6-148
expor t in g fr om SP Tool 5-79 in ver se discr et e F ou r ier t r a n sfor m 1-45, 6-193
fa ct or ed for m 1-33 t wo-dim en sion a l sign a l pr ocessin g, wit h fft2 a n d
for a n a log filt er 1-41 ifft2 1-45
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

I-26
Index

U ch ir p 1-9
u n it cir cle 6-265 ch ir p, exa m ple 1-9
u n it im pu lse fu n ct ion 1-7 fr om sin u soids 1-6
u n it r a m p fu n ct ion 1-7 gen er a t in g wit h diric fu n ct ion 1-11
u n it sa m ple, m u lt ich a n n el r epr esen t a t ion 1-7 gen er a t in g wit h pulstran 1-9
u n it st ep fu n ct ion 1-7 gen er a t in g wit h sinc fu n ct ion 1-10
u n it s of power spect r a l den sit y (P SD) fu n ct ion lin ea r swept -fr equ en cy cosin e. S ee ch ir p
3-11 per iodic 1-7
unwrap 1-27, 6-3, 6-360 sa wt oot h 1-8, 6-308
U pda t e bu t t on 5-19, 5-97 exa m ple 1-8
upfirdn 1-19, 4-22, 6-10, 6-361 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
V Welch ’s m et h od 3-6
Va lleys bu t t on , Sign a l Br owser 5-37 bia s 3-12
va r ia n ce com pa r ed t o t h e Bu r g m et h od 3-22
of cor r ela t ion sequ en ce est im a t e 3-4 com pa r ed t o t h e MTM m et h od 3-19
of power spect r u m est im a t e 3-8 com pa r ed t o t h e Yu le-Wa lker AR m et h od 3-20
vco 4-29, 4-31, 6-10, 6-365 for cr oss spect r a l den sit y est im a t ion 3-14,
vect or 6-102
da t a 1-4 for n on pa r a m et r ic syst em iden t ifica t ion 3-14
displa y, in Sign a l Br owser 5-50 for power spect r a l den sit y est im a t ion 3-5, 3-10,
for filt er coefficien t s 1-16, 1-32 6-81, 6-275
fr equ en cy 2-24, 6-157, 6-160, 6-287, 6-376 in Spect r u m Viewer 5-106
in SP Tool 5-14 n or m a liza t ion 3-12
in dexin g xvii, 1-15 wh it e n oise 1-6
m a gn it u de 2-24, 6-157, 6-160, 6-376 win dow
t im e 1-6 a pplied t o per iodogr a m 3-9
weigh t in g 2-24, 6-167, 6-288 Ba r t let t 4-2, 6-20
Ver t ica l bu t t on , for r u ler s 5-36, 5-38 Bla ckm a n 4-4, 6-30
View bu t t on 5-17, 5-19 boxca r 2-18
volt a ge con t r olled oscilla t or 4-31, 6-365 Ch ebysh ev 4-9, 6-64
for filt er design 2-18
gen er a lized cosin e 4-4
W H a m m in g 2-20, 4-4, 6-185
wa vefor m H a n n in g 4-4, 6-186
a per iodic 1-8 Ka iser 4-4, 6-210

I-27
Index

r ect a n gu la r 2-18, 6-32 Yu le-Wa lker filt er design 6-376


sh a pes, over view 4-2
specifyin g for fir1 2-21
t r ia n gu la r 6-358 Z
win dow m et h od zer o fr equ en cy com pon en t , cen t er in g wit h fftshift
F IR filt er design 2-18 1-45
m u lt iba n d design 2-21 zer o-or der h old. S ee a ver a gin g filt er
sin gle ba n d design 2-20 zer o-ph a se filt er in g 6-149
win dow m et h od, F IR filt er design zer o-pole a n a lysis
ba n dpa ss con figu r a t ion 6-152 exa m ple 1-30
ba n dst op con figu r a t ion 6-152 zer o-pole plot s 6-385
h igh pa ss con figu r a t ion 6-152 zer o-pole ga in 1-42
lowpa ss con figu r a t ion 6-152 zer o-pole plot 5-86, 5-94
Wor kspa ce Con t en t s list , in Im por t dia log box viewin g in F ilt er Viewer 5-94
5-7 zer o-pole-ga in for m 1-40
wor kspa ce, loa din g va r ia bles fr om 5-7 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
X con ver t in g t o st a t e-spa ce 6-383
X La bel edit box, in P r efer en ces dia log box 5-23 defin ed 1-33
xcorr 3-2, 6-7, 6-367 r epr esen t in g in MATLAB 1-33
a n d pa r a m et r ic m odelin g 4-12 specifyin g in SP Tool 5-11
xcorr2 6-7, 6-372 zer os a n d poles 5-17
xcov 3-2, 6-7, 6-373 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
Y zoom con t r ols
Y La bel edit box, in P r efer en ces dia log box 5-23 in F ilt er Design er 5-31
yulewalk 2-5, 2-13, 6-5, 6-376 in F ilt er Viewer 5-31
exa m ple 2-14 in Sign a l Br owser 5-31
Yu le-Wa lker AR m et h od 3-5, 3-6, 3-19 in Spect r u m Viewer 5-31
com pa r ed t o Welch ’s m et h od 3-20 in SP Tool 5-31
defin ed 3-19 Zoom In -X bu t t on 5-32
exa m ple 3-20, 3-21 Zoom In -Y bu t t on 5-32
Yu le-Wa lker AR m et h od, in Spect r u m Viewer Zoom Ou t -X bu t t on 5-32
5-107 Zoom Ou t -Y bu t t on 5-32
Yu le-Wa lker equ a t ion s 2-13 zoom per sist en ce 5-32

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

You might also like