Sie sind auf Seite 1von 720

Computation

Visualization
Programming
For Use with MATLAB

Users Guide
Version 4.2
Signal Processing
Toolbox
How to Contact The MathWorks:
508-647-7000 Phone
508-647-7001 Fax
The MathWorks, I nc. Mai l
24 Pri me Park Way
Nati ck, MA 01760-1500
http://www.mathworks.com Web
ftp.mathworks.com Anonymous FTP server
comp.soft-sys.matlab Newsgroup
support@mathworks.com Techni cal support
suggest@mathworks.com Product enhancement suggesti ons
bugs@mathworks.com Bug reports
doc@mathworks.com Documentati on error reports
subscribe@mathworks.com Subscri bi ng user regi strati on
service@mathworks.com Order status, l i cense renewal s, passcodes
info@mathworks.com Sal es, pri ci ng, and general i nformati on
Signal ProcessingToolbox Users Guide
COPYRI GHT 1988 - 1999 by The MathWor ks, I nc. Al l Ri ghts Reser ved.
The softwar e descr i bed i n thi s document i s fur ni shed under a l i cense agreement. The software may be used
or copi ed onl y under the terms of the l i cense agr eement. No par t of thi s manual may be photocopi ed or r epr o-
duced i n any form wi thout pr i or wr i tten consent from The MathWor ks, I nc.
U.S. GOVERNMENT: I f Li censee i s acqui r i ng the Progr ams on behal f of any uni t or agency of the U.S.
Gover nment, the fol l owi ng shal l appl y: (a) For uni ts of the Depar tment of Defense: the Gover nment shal l
have onl y the ri ghts speci fi ed i n the l i cense under whi ch the commerci al computer softwar e or commer ci al
softwar e documentati on was obtai ned, as set for th i n subpar agr aph (a) of the Ri ghts i n Commer ci al
Computer Softwar e or Commer ci al Softwar e Documentati on Cl ause at DFARS 227.7202-3, ther efor e the
ri ghts set for th her ei n shal l appl y; and (b) For any other uni t or agency: NOTI CE: Notwi thstandi ng any
other l ease or l i cense agr eement that may per tai n to, or accompany the del i ver y of, the computer software
and accompanyi ng documentati on, the ri ghts of the Gover nment regar di ng i ts use, r epr oducti on, and di scl o-
sure are as set for th i n Cl ause 52.227-19 (c)(2) of the FAR.
MATLAB, Si mul i nk, Statefl ow, Handl e Gr aphi cs, and Real -Ti me Workshop ar e r egi stered trademar ks, and
Tar get Language Compi l er i s a trademar k of The MathWor ks, I nc.
Other pr oduct or br and names are tr ademar ks or r egi stered tr ademar ks of thei r respecti ve hol der s.
Pri nti ng Hi story: December 1996 Fi r st pr i nti ng New for MATLAB 5.0
Januar y 1998 Second pri nti ng Revi sed for MATLAB 5.2
Januar y 1999 (Onl i ne onl y) Revi sed for Versi on 4.2 (Rel ease 11)

PHO NE
FAX
u
M AI L
I NTERNET
@
i
Contents
BeforeYou Begin
What Is theSignal ProcessingToolbox? . . . . . . . . . . . . . . . . . . . xii
Howto UseThis Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
Typographical Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi
Techni cal Notati ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
1
Signal ProcessingBasics
Signal ProcessingToolbox Central Features . . . . . . . . . . . . . . 1-2
Fi l teri ng and FFTs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
Si gnal s and Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
Key Areas: Fi l ter Desi gn and Spectral Anal ysi s . . . . . . . . . . . . 1-3
Graphi cal User I nterface (GUI ) . . . . . . . . . . . . . . . . . . . . . . . . . 1-3
Extensi bi l i ty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3
RepresentingSignals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4
Vector Representati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4
WaveformGeneration: TimeVectors and Sinusoids . . . . . . . 1-6
Common Sequences: Uni t I mpul se, Uni t Step, and Uni t Ramp 1-7
Mul ti channel Si gnal s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7
Common Peri odi c Waveforms . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7
Common Aperi odi c Waveforms . . . . . . . . . . . . . . . . . . . . . . . . . . 1-8
The pul stran Functi on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9
The Si nc Functi on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-10
The Di ri chl et Functi on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-11
ii Contents
Workingwith Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13
Filter Implementation and Analysis . . . . . . . . . . . . . . . . . . . . . . 1-14
Convol uti on and Fi l teri ng . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-14
Fi l ters and Transfer Functi ons . . . . . . . . . . . . . . . . . . . . . . . . . 1-15
Fi l ter Coeffi ci ents and Fi l ter Names . . . . . . . . . . . . . . . . . . 1-15
Fi l teri ng wi th the fi l ter Functi on . . . . . . . . . . . . . . . . . . . . . . . 1-16
filter Function Implementation and Initial Conditions . . . 1-17
Other Functions for Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-19
Mul ti rate Fi l ter Bank I mpl ementati on . . . . . . . . . . . . . . . . . . 1-19
Anti -Causal , Zero-Phase Fi l ter I mpl ementati on . . . . . . . . . . . 1-20
Frequency Domai n Fi l ter I mpl ementati on . . . . . . . . . . . . . . . . 1-22
ImpulseResponse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-23
Frequency Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-24
Di gi tal Domai n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-24
Anal og Domai n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-26
Magni tude and Phase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-26
Del ay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-28
Zero-PoleAnalysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-30
Linear SystemModels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-32
Di screte-Ti me System Model s . . . . . . . . . . . . . . . . . . . . . . . . . . 1-32
Transfer Functi on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-32
Zero-Pol e-Gai n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-33
State-Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-34
Parti al Fracti on Expansi on (Resi due Form) . . . . . . . . . . . . 1-35
Second-Order Secti ons (SOS) . . . . . . . . . . . . . . . . . . . . . . . . 1-36
Latti ce Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-37
Convol uti on Matri x . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-39
Conti nuous-Ti me System Model s . . . . . . . . . . . . . . . . . . . . . . . 1-40
Li near System Transformati ons . . . . . . . . . . . . . . . . . . . . . . . . 1-41
iii
DiscreteFourier Transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-43
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-46
2
Filter Design
Filter Requirements and Specification . . . . . . . . . . . . . . . . . . . . 2-2
IIR Filter Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
Cl assi cal I I R Fi l ter Desi gn Usi ng Anal og Prototypi ng . . . . . . . 2-6
Compl ete Cl assi cal I I R Fi l ter Desi gn . . . . . . . . . . . . . . . . . . . 2-6
Desi gni ng I I R Fi l ters to Frequency Domai n Speci fi cati ons . 2-7
Compari son of Cl assi cal I I R Fi l ter Types . . . . . . . . . . . . . . . . . . 2-8
Butterworth Fi l ter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8
Chebyshev Type I Fi l ter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9
Chebyshev Type I I Fi l ter . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10
El l i pti c Fi l ter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10
Bessel Fi l ter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-11
Di rect I I R Fi l ter Desi gn . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-13
General i zed Butterworth Fi l ter Desi gn . . . . . . . . . . . . . . . . 2-14
FIR Filter Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-16
Li near Phase Fi l ters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-17
Wi ndowi ng Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-18
Standard Band FI R Fi l ter Desi gn: fi r1 . . . . . . . . . . . . . . . . 2-20
Mul ti band FI R Fi l ter Desi gn: fi r2 . . . . . . . . . . . . . . . . . . . . 2-21
Mul ti band FI R Fi l ter Desi gn wi th Transi ti on Bands . . . . . . . 2-22
Basi c Confi gurati ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-22
The Wei ght Vector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-24
Anti -Symmetri c Fi l ters /Hi l bert Transformers . . . . . . . . . . 2-25
Di fferenti ators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-26
Constrai ned Least Squares FI R Fi l ter Desi gn . . . . . . . . . . . . . 2-27
Basi c Lowpass and Hi ghpass CLS Fi l ter Desi gn . . . . . . . . . 2-28
Mul ti band CLS Fi l ter Desi gn . . . . . . . . . . . . . . . . . . . . . . . . 2-29
Wei ghted CLS Fi l ter Desi gn . . . . . . . . . . . . . . . . . . . . . . . . . 2-30
iv Contents
Arbi trary-Response Fi l ter Desi gn . . . . . . . . . . . . . . . . . . . . . . . 2-31
Mul ti band Fi l ter Desi gn . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-32
Fi l ter Desi gn wi th Reduced Del ay . . . . . . . . . . . . . . . . . . . . 2-34
Special Topics in IIR Filter Design . . . . . . . . . . . . . . . . . . . . . . . 2-37
Anal og Prototype Desi gn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-38
Frequency Transformati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-38
Fi l ter Di screti zati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-41
I mpul se I nvari ance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-42
Bi l i near Transformati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-43
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-46
3
Statistical Signal Processing
Correlation and Covariance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2
Bi as and Normal i zati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3
Mul ti pl e Channel s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4
Spectral Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5
Wel chs Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6
Power Spectral Densi ty Functi on . . . . . . . . . . . . . . . . . . . . . 3-10
Bi as and Normal i zati on i n Wel chs Method . . . . . . . . . . . . . 3-12
Cross-Spectral Densi ty Functi on . . . . . . . . . . . . . . . . . . . . . 3-14
Confi dence I nterval s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-14
Transfer Functi on Esti mate . . . . . . . . . . . . . . . . . . . . . . . . . 3-14
Coherence Functi on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-15
Mul ti taper Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-16
Yul e-Wal ker AR Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-19
Burg Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-20
Covari ance and Modi fi ed Covari ance Methods . . . . . . . . . . . . 3-22
MUSI C and Ei genvector Anal ysi s Methods . . . . . . . . . . . . . . . 3-23
Ei genanal ysi s Overvi ew . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-24
Control l i ng Subspace Threshol ds . . . . . . . . . . . . . . . . . . . . . 3-25
v
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-27
4
Special Topics
Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
Basi c Shapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
General i zed Cosi ne Wi ndows . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4
Kai ser Wi ndow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4
Kai ser Wi ndows i n FI R Desi gn . . . . . . . . . . . . . . . . . . . . . . . . 4-7
Chebyshev Wi ndow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-9
Parametric Modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10
Ti me-Domai n Based Model i ng . . . . . . . . . . . . . . . . . . . . . . . . . 4-11
Li near Predi cti on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12
Pronys Method (ARMA Model i ng) . . . . . . . . . . . . . . . . . . . . 4-13
Stei gl i tz-McBri de Method (ARMA Model i ng) . . . . . . . . . . . 4-15
Frequency-Domai n Based Model i ng . . . . . . . . . . . . . . . . . . . . . 4-16
Resampling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-20
CepstrumAnalysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-23
I nverse Compl ex Cepstrum . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-25
FFT-Based Time-Frequency Analysis . . . . . . . . . . . . . . . . . . . . . 4-27
Median Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-28
Communications Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-29
Deconvolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-33
Specialized Transforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-34
Chi rp z-Transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-34
Di screte Cosi ne Transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-36
Hi l bert Transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-38
vi Contents
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-40
5
InteractiveTools
SPTool: An InteractiveSignal ProcessingEnvironment . . . 5-2
Overvi ew . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
UsingSPTool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3
Openi ng SPTool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3
Qui ck Start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3
Exampl e: I mporti ng Si gnal Data from a MAT-Fi l e . . . . . . . . 5-3
Basi c SPTool Functi ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-5
Fi l e Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-6
Hel p Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-6
I mporti ng Si gnal s, Fi l ters, and Spectra . . . . . . . . . . . . . . . . . . . 5-7
Loadi ng Vari abl es from the MATLAB Workspace . . . . . . . . 5-7
Loadi ng Vari abl es from Di sk . . . . . . . . . . . . . . . . . . . . . . . . . 5-8
I mporti ng Workspace Contents and Fi l e Contents . . . . . . . . 5-8
Worki ng wi th Si gnal s, Fi l ters, and Spectra . . . . . . . . . . . . . . . 5-13
Component Li sts i n SPTool . . . . . . . . . . . . . . . . . . . . . . . . . . 5-14
Sel ecti ng Data Objects i n SPTool . . . . . . . . . . . . . . . . . . . . . 5-15
Edi ti ng Data Objects i n SPTool . . . . . . . . . . . . . . . . . . . . . . 5-15
Vi ewi ng a Si gnal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17
Vi ewi ng a Fi l ter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17
Desi gni ng a Fi l ter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17
Appl yi ng a Fi l ter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18
Creati ng a Spectrum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19
Vi ewi ng a Spectrum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19
Updati ng a Spectrum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19
vii
Customi zi ng Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20
Rul er Setti ngs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-21
Col or Setti ngs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-22
Si gnal Browser Setti ngs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-23
Spectrum Vi ewer Setti ngs . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-24
Fi l ter Vi ewer Setti ngs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-25
Fi l ter Vi ewer Ti l i ng Setti ngs . . . . . . . . . . . . . . . . . . . . . . . . 5-26
Fi l ter Desi gner Setti ngs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-27
Defaul t Sessi on Setti ng . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-28
Exporti ng Components Setti ng . . . . . . . . . . . . . . . . . . . . . . . 5-29
Pl ug-I ns Setti ng . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-30
Savi ng and Di scardi ng Changes to Preferences Setti ngs . . 5-30
Control s for Vi ewi ng and Measuri ng . . . . . . . . . . . . . . . . . . . . 5-31
Zoom Control s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-31
Rul er Control s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-33
Maki ng Si gnal Measurements . . . . . . . . . . . . . . . . . . . . . . . 5-37
UsingtheSignal Browser: InteractiveSignal Analysis . . . 5-43
Openi ng the Si gnal Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-43
Basi c Si gnal Browser Functi ons . . . . . . . . . . . . . . . . . . . . . . . . 5-44
Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-45
Zoom Control s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-46
Rul er and Li ne Di spl ay Control s . . . . . . . . . . . . . . . . . . . . . 5-46
Hel p Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-46
Di spl ay Management Control s . . . . . . . . . . . . . . . . . . . . . . . 5-47
Mai n Axes Di spl ay Area . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-47
Panner . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-48
Maki ng Si gnal Measurements . . . . . . . . . . . . . . . . . . . . . . . 5-49
Vi ewi ng and Expl ori ng Si gnal s . . . . . . . . . . . . . . . . . . . . . . . . . 5-49
Sel ecti ng and Di spl ayi ng a Si gnal . . . . . . . . . . . . . . . . . . . . 5-49
Panner Di spl ay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-52
Mani pul ati ng Di spl ays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-53
Worki ng wi th Si gnal s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-54
Pri nti ng Si gnal Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-54
Savi ng Si gnal Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-57
UsingtheFilter Designer: InteractiveFilter Design . . . . . . 5-59
Openi ng the Fi l ter Desi gner . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-59
viii Contents
Basi c Fi l ter Desi gner Functi ons . . . . . . . . . . . . . . . . . . . . . . . . 5-60
Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-60
Fi l ter Pop-Up Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-60
Zoom Control s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-61
Hel p Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-61
General Control s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-62
Fi l ter Speci fi cati ons Panel Desi gn Methods . . . . . . . . . . . 5-63
Fi l ter Measurements Panel Desi gn Methods . . . . . . . . . . 5-65
Fi l ter Speci fi cati ons Panel Pol e/Zero Edi tor . . . . . . . . . . . 5-66
Fi l ter Measurements Panel Pol e/Zero Edi tor . . . . . . . . . . 5-68
Magni tude Pl ot (Di spl ay) AreaDesi gn Methods . . . . . . . . 5-69
Magni tude Pl ot (Di spl ay) AreaPol e/Zero Edi tor . . . . . . . . 5-71
Desi gni ng Fi ni te I mpul se Response (FI R) Fi l ters . . . . . . . . . . 5-73
Exampl e: FI R Fi l ter Desi gn, Standard Band Confi gurati on 5-73
Fi l ter Desi gn Opti ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-75
Order Sel ecti on for FI R Fi l ter Desi gn . . . . . . . . . . . . . . . . . 5-75
Desi gni ng I nfi ni te I mpul se Response (I I R) Fi l ters . . . . . . . . . 5-76
Exampl e: Cl assi cal I I R Fi l ter Desi gn . . . . . . . . . . . . . . . . . . 5-76
Fi l ter Desi gn Opti ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-77
Order Sel ecti on for I I R Fi l ter Desi gn . . . . . . . . . . . . . . . . . . 5-78
Redesi gni ng a Fi l ter Usi ng the Magni tude Pl ot . . . . . . . . . . . . 5-78
Savi ng Fi l ter Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-79
Vi ewi ng Frequency Response Pl ots . . . . . . . . . . . . . . . . . . . . . . 5-82
UsingtheFilter Viewer: InteractiveFilter Analysis . . . . . . 5-84
Openi ng the Fi l ter Vi ewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-84
Basi c Fi l ter Vi ewer Functi ons . . . . . . . . . . . . . . . . . . . . . . . . . . 5-84
Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-86
Fi l ter I denti fi cati on Panel . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-86
Pl ots Panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-86
Frequency Axi s Setti ngs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-87
Zoom Control s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-87
Hel p Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-87
Mai n Pl ots Area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-88
ix
Vi ewi ng Fi l ter Pl ots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-89
Vi ewi ng Magni tude Response . . . . . . . . . . . . . . . . . . . . . . . . 5-89
Vi ewi ng Phase Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-91
Vi ewi ng Group Del ay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-93
Vi ewi ng a Zero-Pol e Pl ot . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-94
Vi ewi ng I mpul se Response . . . . . . . . . . . . . . . . . . . . . . . . . . 5-94
Vi ewi ng Step Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-95
UsingtheSpectrumViewer: InteractivePSD Analysis . . . 5-97
Openi ng the Spectrum Vi ewer . . . . . . . . . . . . . . . . . . . . . . . . . 5-97
Basi c Spectrum Vi ewer Functi ons . . . . . . . . . . . . . . . . . . . . . . 5-98
Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-99
Si gnal I D Panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-100
Spectrum Management Buttons . . . . . . . . . . . . . . . . . . . . . 5-100
Zoom Control s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-101
Rul er and Li ne Di spl ay Control s . . . . . . . . . . . . . . . . . . . . 5-101
Hel p Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-101
Mai n Axes Di spl ay Area . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-101
Maki ng Spectrum Measurements . . . . . . . . . . . . . . . . . . . . 5-102
Vi ewi ng Spectral Densi ty Pl ots . . . . . . . . . . . . . . . . . . . . . . . . 5-102
Control l i ng and Mani pul ati ng Pl ots . . . . . . . . . . . . . . . . . . . . 5-102
Changi ng Pl ot Properti es . . . . . . . . . . . . . . . . . . . . . . . . . . 5-102
Choosi ng Computati on Parameters . . . . . . . . . . . . . . . . . . 5-103
Computati on Methods and Parameters . . . . . . . . . . . . . . . 5-104
Setti ng Confi dence I nterval s . . . . . . . . . . . . . . . . . . . . . . . . 5-107
Pri nti ng Spectrum Data . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-107
Savi ng Spectrum Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-110
Example: Generation of Bandlimited Noise. . . . . . . . . . . . . . 5-113
Create, I mport, and Name a Si gnal . . . . . . . . . . . . . . . . . . . . 5-113
Desi gn a Fi l ter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-115
Appl y the Fi l ter to a Si gnal . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-116
Vi ew, Pl ay, and Pri nt the Si gnal s . . . . . . . . . . . . . . . . . . . . . . 5-117
Compare Spectra of Both Si gnal s . . . . . . . . . . . . . . . . . . . . . . 5-120
6
Reference
x Contents
Before You Begi n
What Is theSignal ProcessingToolbox? . . . . . . . . . . . . . . . .xi i
Howto UseThis Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi i i
Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
Typographical Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . xvi
Techni cal Notati ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xvi i
Before You Begin
xii
What Is the Signal Processing Toolbox?
Thi s secti on descri bes how to begi n usi ng the Si gnal Processi ng Tool box. I t
expl ai ns how to use thi s manual and poi nts you to addi ti onal books for tool box
i nstal l ati on i nformati on.
The Si gnal Processi ng Tool box i s a col l ecti on of tool s bui l t on the MATLAB

numeri c computi ng envi ronment. The tool box supports a wi de range of si gnal
processi ng operati ons, from waveform generati on to fi l ter desi gn and
i mpl ementati on, parametri c model i ng, and spectral anal ysi s. The tool box
provi des two categori es of tool s:
Si gnal processi ng functi ons
Graphi cal , i nteracti ve tool s
The fi rst category of tool s i s made up of functi ons that you can cal l from the
command l i ne or from your own appl i cati ons. Many of these functi ons are
MATLAB M-fi l es, seri es of MATLAB statements that i mpl ement speci al i zed
si gnal processi ng al gori thms. You can vi ew the MATLAB code for these
functi ons usi ng the statement
type function_name
or by openi ng the M-fi l e i n the MATLAB Edi tor/Debugger. You can change the
way any tool box functi on works by copyi ng and renami ng the M-fi l e, then
modi fyi ng your copy. You can al so extend the tool box by addi ng your own
M-fi l es.
Second, the tool box provi des a number of i nteracti ve tool s that l et you access
many of the functi ons through a graphical user interface(GUI ). The GUI -based
tool s provi de an i ntegrated envi ronment for fi l ter desi gn, anal ysi s, and
i mpl ementati on, as wel l as si gnal expl orati on and edi ti ng. For exampl e, wi th
the graphi cal user i nterface tool s you can:
Use the mouse to graphi cal l y edi t the magni tude response of a fi l ter or
measure the sl ope of a si gnal wi th onscreen rul ers.
Pl ay a si gnal on your systems audi o hardware by sel ecti ng a menu i tem or
pressi ng a correspondi ng keystroke combi nati on.
Customi ze the parameters and method of computi ng the spectrum of a
si gnal .
How to Use This Manual
xiii
How to Use This Manual
If you are a new user. Begi n wi th Chapter 1, Si gnal Processi ng Basi cs. Thi s
chapter i ntroduces the MATLAB si gnal processi ng envi ronment through the
tool box functi ons. I t descri bes the basi c functi ons of the Si gnal Processi ng
Tool box, revi ewi ng i ts use i n basi c waveform generati on, fi l ter i mpl ementati on
and anal ysi s, i mpul se and frequency response, zero-pol e anal ysi s, l i near
system model s, and the di screte Fouri er transform.
When you feel comfortabl e wi th the basi c functi ons, move on to Chapter 2 and
Chapter 3 for a more i n-depth i ntroducti on to usi ng the Si gnal Processi ng
Tool box:
Chapter 2, Fi l ter Desi gn, for a detai l ed expl anati on of usi ng the Si gnal
Processi ng Tool box i n i nfi ni te i mpul se response (I I R) and fi ni te i mpul se
response (FI R) fi l ter desi gn and i mpl ementati on, i ncl udi ng speci al topi cs i n
I I R fi l ter desi gn.
Chapter 3, Stati sti cal Si gnal Processi ng, for how to use the correl ati on,
covari ance, and spectral anal ysi s tool s to esti mate i mportant functi ons of
di screte random si gnal s.
Once you understand the general pri nci pl es and appl i cati ons of the tool box,
l earn how to use the i nteracti ve tool s.
Chapter 5, I nter acti ve Tool s, for an over vi ew of the i nteracti ve GUI
envi ronment and exampl es of how to use i t for si gnal expl orati on, fi l ter
desi gn and i mpl ementati on, and spectral anal ysi s.
Fi nal l y, see the fol l owi ng chapter for a di scussi on of speci al i zed tool box
functi ons.
Chapter 4, Speci al Topi cs, for speci al i zed functi ons, i ncl udi ng fi l ter
wi ndows, parametri c model i ng, resampl i ng, cepstrum anal ysi s,
ti me-dependent Fouri er transforms and spectrograms, medi an fi l teri ng,
communi cati ons appl i cati ons, deconvol uti on, and speci al i zed transforms.
If you are an experienced toolbox user. See Chapter 5, I nter acti ve Tool s, for an
overvi ew of the i nteracti ve GUI envi ronment and exampl es of how to use i t for
si gnal vi ewi ng, fi l ter desi gn and i mpl ementati on, and spectral anal ysi s.
Before You Begin
xiv
All toolbox users. Use Chapter 6, Reference, for l ocati ng i nformati on on speci fi c
functi ons. Reference descri pti ons i ncl ude a synopsi s of the functi ons syntax, as
wel l as a compl ete expl anati on of opti ons and operati ons. Many reference
descri pti ons al so i ncl ude hel pful exampl es, a descri pti on of the functi ons
al gori thm, and references to addi ti onal readi ng materi al .
Use thi s manual i n conjuncti on wi th the software to l earn about the powerful
features that MATLAB provi des. Each chapter provi des numerous exampl es
that appl y the tool box to representati ve si gnal processi ng tasks.
Some exampl es use MATLABs random number generati on functi on randn. I n
these cases, to dupl i cate the resul ts i n the exampl e, type
randn('seed',0)
before runni ng the exampl e.
Installation
xv
Installation
To i nstal l thi s tool box on a wor kstati on, see the MATLAB I nstallation Guide
for UNI X. To i nstal l the tool box on a PC, see the MATLAB PC I nstallation
Guide.
To determi ne i f the Si gnal Processi ng Tool box i s al ready i nstal l ed on your
system, check for a subdi rectory named signal wi thi n the mai n tool box
di rectory or fol der.
Before You Begin
xvi
Typographical Conventions
To Indicate This Manual Uses Example
Exampl e code Monospace type. To assi gn the val ue 5 to
A, enter
A = 5
MATLAB
output
Monospace type. MATLAB responds wi th
A =
5
Functi on names Monospace type. The cos functi on fi nds
the cosi ne of each array
el ement.
New terms I talics. An array i s an ordered
col l ecti on of
i nformati on.
Keys Boldfacewi th an
i ni ti al capi tal l etter.
Press the Return key.
Menu names,
i tems, and GUI
control s
Boldfacewi th an
i ni ti al capi tal l etter.
Choose the Filemenu.
Mathemati cal
expressi ons
Vari abl es i n italics.
Functi ons,
oper ators, and
constants i n
standard type.
Thi s vector represents
the pol ynomi al
p =x
2
+ 2x + 3
Typographical Conventions
xvii
Technical Notations
Thi s manual and the Si gnal Processi ng Tool box functi ons use the fol l owi ng
techni cal notati ons:
Nyqui st frequency One-hal f the sampl i ng frequency. Most
tool box functi ons normal i ze thi s val ue to 1.
x(1) The fi rst el ement of a data sequence or
fi l ter, correspondi ng to zero l ag.
Anal og frequency i n radi ans per second.
or w Di gi tal frequency i n radi ans per second.
f Di gi tal frequency i n Hertz.
[x, y) The i nterval from xto y, i ncl udi ng xbut not
i ncl udi ng y
Before You Begin
xviii
1
Si gnal Processi ng Basi cs
Signal ProcessingToolbox Central Features . . . . . . . . . . . 1-2
RepresentingSignals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4
WaveformGeneration: TimeVectors and Sinusoids . . . . 1-6
Workingwith Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13
Filter Implementation and Analysis . . . . . . . . . . . . . . . . . . 1-14
filter Function Implementation and Initial Conditions . 1-17
Other Functions for Filtering. . . . . . . . . . . . . . . . . . . . . . . . 1-19
ImpulseResponse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-23
Frequency Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-24
Zero-PoleAnalysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-30
Linear SystemModels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-32
DiscreteFourier Transform . . . . . . . . . . . . . . . . . . . . . . . . . 1-43
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-46
1 Signal Processing Basics
1-2
Signal Processing Toolbox Central Features
Thi s chapter descri bes how to begi n usi ng MATLAB and the Si gnal Processi ng
Tool box for your si gnal processi ng appl i cati ons. I t assumes a basi c knowl edge
and understandi ng of si gnal s and systems, i ncl udi ng such topi cs as fi l ter and
l i near system theory and basi c Fouri er anal ysi s.
Many exampl es throughout the chapter demonstrate how to appl y tool box
functi ons. I f you are not al ready fami l i ar wi th MATLABs si gnal processi ng
capabi l i ti es, use thi s chapter i n conjuncti on wi th the software to try exampl es
and l earn about the powerful features avai l abl e to you.
The Si gnal Processi ng Tool box functi ons are al gori thms, expressed mostl y i n
M-fi l es, that i mpl ement a vari ety of si gnal processi ng tasks. These tool box
functi ons are a speci al i zed extensi on of the MATLAB computati onal and
graphi cal envi ronment.
Filtering and FFTs
Two of the most i mportant functi ons for si gnal processi ng are not i n the Si gnal
Processi ng Tool box at al l , but are bui l t-i n MATLAB functi ons:
filter appl i es a di gi tal fi l ter to a data sequence.
fft cal cul ates the di screte Fouri er transform of a sequence.
The operati ons these functi ons perform are the mai n computati onal
workhorses of cl assi cal si gnal processi ng. Both are descri bed i n thi s chapter.
The Si gnal Processi ng Tool box uses many other standard MATLAB functi ons
and l anguage features, i ncl udi ng pol ynomi al root fi ndi ng, compl ex ari thmeti c,
matri x i nversi on and mani pul ati on, and graphi cs tool s.
Signals and Systems
The basi c enti ti es that tool box functi ons work wi th are si gnal s and systems.
The functi ons emphasi ze di gi tal , or di screte, si gnal s and fi l ters, as opposed to
anal og, or conti nuous, si gnal s. The pri nci pal fi l ter type the tool box supports i s
the l i near, ti me-i nvari ant di gi tal fi l ter wi th a si ngl e i nput and a si ngl e output.
You can represent l i near ti me-i nvari ant systems usi ng one of several model s
(such as transfer functi on, state-space, zero-pol e-gai n, and second-order
secti on) and convert between representati ons.
Signal Processing Toolbox Central Features
1-3
Key Areas: Filter Design and Spectral Analysis
I n addi ti on to i ts core functi ons, the tool box provi des ri ch, customi zabl e support
for the key areas of fi l ter desi gn and spectral anal ysi s. I t i s easy to i mpl ement
a desi gn techni que that sui ts your appl i cati on, desi gn di gi tal fi l ters di rectl y, or
create anal og prototypes and di screti ze them. Tool box functi ons al so esti mate
power spectral densi ty and cross spectral densi ty, usi ng ei ther parametri c or
nonparametri c techni ques. Chapters 2 and 3, respecti vel y, detai l tool box
functi ons for fi l ter desi gn and spectral anal ysi s.
There are functi ons for computati on and graphi cal di spl ay of frequency
response, as wel l as functi ons for system i denti fi cati on; generati ng si gnal s;
di screte cosi ne, chi rp-z, and Hi l bert transforms; l atti ce fi l ters; resampl i ng;
ti me-frequency anal ysi s; and basi c communi cati on systems si mul ati on.
Graphical User Interface (GUI)
The power of the Si gnal Processi ng Tool box i s greatl y enhanced by i ts
easy-to-use graphi cal user i nterface. The GUI provi des an i ntegrated set of
i nteracti ve tool s for performi ng a wi de vari ety of si gnal processi ng tasks. These
tool s enabl e you to use the mouse and menus to mani pul ate a ri ch graphi cal
envi ronment for si gnal vi ewi ng, fi l ter desi gn and i mpl ementati on, and spectral
anal ysi s.
Extensibility
Perhaps the most i mportant feature of the MATLAB envi ronment i s that i t i s
extensi bl e: MATLAB l ets you create your own M-fi l es to meet numeri c
computati on needs for research, desi gn, or engi neeri ng of si gnal processi ng
systems. Si mpl y copy the M-fi l es provi ded wi th the Si gnal Processi ng Tool box
and modi fy them as needed, or create new functi ons to expand the functi onal i ty
of the tool box.
1 Signal Processing Basics
1-4
Representing Signals
The central data construct i n MATLAB i s the numeric array, an ordered
col l ecti on of real or compl ex numeri c data wi th two or more di mensi ons. The
basi c data objects of si gnal processi ng (one-di mensi onal si gnal s or sequences,
mul ti channel si gnal s, and two-di mensi onal si gnal s) are al l natural l y sui ted to
array representati on.
Vector Representation
MATLAB represents ordi nary one-di mensi onal sampl ed data si gnal s, or
sequences, as vectors. Vectors are 1-by-n or n-by-1 arrays, where n i s the
number of sampl es i n the sequence. One way to i ntroduce a sequence i nto
MATLAB i s to enter i t as a l i st of el ements at the command prompt. The
statement
x = [4 3 7 9 1]
creates a si mpl e fi ve-el ement real sequence i n a row vector. Transposi ti on
turns the sequence i nto a col umn vector
x = x'
resul ti ng i n
x =
4
3
7
9
1
Col umn ori entati on i s preferabl e for si ngl e channel si gnal s because i t extends
natural l y to the mul ti channel case. For mul ti channel data, each col umn of a
matri x represents one channel . Each row of such a matri x then corresponds to
a sampl e poi nt. A three-channel si gnal that consi sts of x, 2x, and x/ i s
y = [x 2*x x/pi]
Representing Signals
1-5
Thi s resul ts i n
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 Signal Processing Basics
1-6
Waveform Generation: Time Vectors and Sinusoids
A vari ety of tool box functi ons generate waveforms. Most requi re you to begi n
wi th a vector representi ng a ti me base. Consi der generati ng data wi th a 1000
Hz sampl e frequency, for exampl e. An appropri ate ti me vector i s
t = (0:0.001:1)';
where MATLABs col on operator creates a 1001-el ement row vector that
represents ti me runni ng from zero to one second i n steps of one mi l l i second.
The transpose operator (') changes the row vector i nto a col umn; the
semi col on (;) tel l s MATLAB to compute but not di spl ay the resul t.
Gi ven t you can create a sampl e si gnal y consi sti ng of two si nusoi ds, one at 50
Hz and one at 120 Hz wi th twi ce the ampl i tude:
y = sin(2*pi*50*t) + 2*sin(2*pi*120*t);
The new vari abl e y, formed from vector t, i s al so 1001 el ements l ong. You can
add normal l y di stri buted whi te noi se to the si gnal and graph the fi rst fi fty
poi nts usi ng
yn = y + 0.5*randn(size(t));
plot(t(1:50),yn(1:50))
0 0.01 0.02 0.03 0.04 0.05
-4
-3
-2
-1
0
1
2
3
4
Waveform Generation: Time Vectors and Sinusoids
1-7
Common Sequences: Unit Impulse, Unit Step, and
Unit Ramp
Si nce MATLAB i s a programmi ng l anguage, an endl ess vari ety of di fferent
si gnal s i s possi bl e. Here are some statements that generate several commonl y
used sequences, i ncl udi ng the uni t i mpul se, uni t step, and uni t ramp functi ons:
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);
Al l of these sequences are col umn vectors the l ast three i nheri t thei r shapes
from t.
Multichannel Signals
Use standard MATLAB array syntax to work wi th mul ti channel si gnal s. For
exampl e, a mul ti channel si gnal consi sti ng of the l ast three si gnal s generated
above i s
z = [t t.^2 square(4*t)];
You can generate a mul ti channel uni t sampl e functi on usi ng the outer product
operator. For exampl e, a si x-el ement col umn vector whose fi rst el ement i s one,
and whose remai ni ng fi ve el ements are zeros, i s
a = [1 zeros(1,5)]';
To dupl i cate col umn vector a i nto a matri x wi thout performi ng any
mul ti pl i cati on, use MATLABs col on operator and the ones functi on.
c = a(:,ones(1,3));
Common Periodic Waveforms
The tool box provi des functi ons for generati ng wi del y used peri odi c waveforms:
1 Signal Processing Basics
1-8
sawtooth generates a sawtooth wave wi th peaks at t1 and a peri od of 2. An
opti onal width parameter speci fi es a fracti onal mul ti pl e of 2 at whi ch the
si gnal s maxi mum occurs.
square generates a square wave wi th a peri od of 2. An opti onal parameter
speci fi es dutycycle, the percent of the peri od for whi ch the si gnal i s posi ti ve.
To generate 1.5 seconds of a 50 Hz sawtooth wave wi th a sampl e rate of 10 kHz
and pl ot 0.2 seconds of the generated waveform, use
Fs = 10000;
t = 0:1/Fs:1.5;
x = sawtooth(2*pi*50*t);
plot(t,x), axis([0 0.2 1 1])
Common Aperiodic Waveforms
The tool box al so provi des functi ons for generati ng several wi del y used
aperi odi c waveforms:
gauspuls generates a Gaussi an-modul ated si nusoi dal pul se wi th a speci fi ed
ti me, center frequency, and fracti onal bandwi dth. Opti onal parameters
0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2
-1
-0.5
0
0.5
1
Waveform Generation: Time Vectors and Sinusoids
1-9
return i n-phase and quadrature pul ses, the RF si gnal envel ope, and the
cutoff ti me for the trai l i ng pul se envel ope.
chirp generates a l i near swept-frequency cosi ne si gnal . An opti onal
parameter speci fi es al ternati ve sweep methods. An opti onal parameter phi
al l ows i ni ti al phase to be speci fi ed i n degrees.
To compute 2 seconds of a l i near chi rp si gnal wi th a sampl e rate of 1 kHz, that
starts at DC and crosses 150 Hz at 1 second, use
t = 0:1/1000:2;
y = chirp(t,0,1,150);
To pl ot the spectrogram, use
specgram(y,256,1000,256,250)
The pulstran Function
The pulstran functi on generates pul se trai ns from ei ther conti nuous or
sampl ed prototype pul ses. The fol l owi ng exampl e generates a pul se trai n
consi sti ng of the sum of mul ti pl e del ayed i nterpol ati ons of a Gaussi an pul se.
The pul se trai n i s defi ned to have a sampl e rate of 50 kHz, a pul se trai n l ength
Time
F
r
e
q
u
e
n
c
y
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6
0
50
100
150
200
250
300
350
400
450
500
1 Signal Processing Basics
1-10
of 10 ms, and a pul se repeti ti on rate of 1 kHz; D speci fi es the del ay to each pul se
repeti ti on i n col umn 1 and an opti onal attenuati on for each repeti ti on i n
col umn 2. The pul se trai n i s constructed by passi ng the name of the gauspuls
functi on to pulstran, al ong wi th addi ti onal parameters that speci fy a 10 kHz
Gaussi an pul se wi th 50% bandwi dth:
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)
The Sinc Function
The sinc functi on computes the mathemati cal si nc functi on for an i nput vector
or matri x x. The si nc functi on i s the conti nuous i nverse Fouri er transform of
the rectangul ar pul se of wi dth 2 and hei ght 1:
The si nc functi on has a val ue of 1 where x i s zero, and a val ue of
for al l other el ements of x.
0 0.001 0.002 0.003 0.004 0.005 0.006 0.007 0.008 0.009 0.01
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
x ( ) si n
x
--------------------
Waveform Generation: Time Vectors and Sinusoids
1-11
To pl ot the si nc functi on for a l i nearl y spaced vector wi th val ues rangi ng from
5 to 5,
x = linspace(5,5);
y = sinc(x);
plot(x,y)
The Dirichlet Function
The tool box functi on diric computes the Di ri chl et functi on, someti mes cal l ed
the periodic sinc or aliased sinc functi on, for an i nput vector or matri x x. The
Di ri chl et functi on i s
where n i s a user-speci fi ed posi ti ve i nteger. For n odd, the Di ri chl et functi on
has a peri od of 2; for n even, i ts peri od i s 4. The magni tude of thi s functi on i s
(1/n) ti mes the magni tude of the di screte-ti me Fouri er transform of the n-poi nt
rectangul ar wi ndow.
-5 -4 -3 -2 -1 0 1 2 3 4 5
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
di ri c x ( )
1
k n 1 ( )
x 2k k 0 1 t 2 t , , , = , =
nx 2 ( ) si n
n x 2 ( ) si n
----------------------------
otherwise

'

=
1 Signal Processing Basics
1-12
To pl ot the Di ri chl et functi on over the range 0 to 4 for n = 7 and n = 8, use
x = linspace(0,4*pi,300);
plot(x,diric(x,7))
plot(x,diric(x,8))
0 5 10 15
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
n = 7
0 5 10 15
-1
-0.5
0
0.5
1
n = 8
Working with Data
1-13
Working with Data
The exampl es i n the pr ecedi ng secti ons obtai n data i n one of two ways:
By di rect i nput, that i s, enteri ng the data manual l y at the keyboard
By usi ng a MATLAB or tool box functi on, such as sin, cos, sawtooth, square,
or sinc
Some appl i cati ons, however, may need to i mport data from outsi de MATLAB.
Dependi ng on your data format, you can do thi s i n the fol l owi ng ways:
Load data from an ASCI I fi l e or MAT-fi l e wi th MATLABs load command
Read the data i nto MATLAB wi th a l ow-l evel fi l e I /Ofuncti on, such as fopen,
fread, and fscanf
Devel op a MEX-fi l e to read the data
Other resources are al so useful , such as a hi gh-l evel l anguage program (i n
Fortran or C, for exampl e) that converts your data i nto MAT-fi l e formatsee
the MATLAB ApplicationProgrammingI nterfacereference manual for detai l s.
MATLAB reads such fi l es usi ng the load command.
Si mi l ar techni ques are avai l abl e for exporti ng data generated wi thi n
MATLAB. See UsingMATLAB for more detai l s on i mporti ng and exporti ng
data, and see the onl i ne MATLAB Function Referencefor descri pti ons of fi l e
l oadi ng and I /O routi nes.
1 Signal Processing Basics
1-14
Filter Implementation and Analysis
Thi s secti on descri bes how to fi l ter di screte si gnal s usi ng MATLABs filter
functi on and other functi ons i n the Si gnal Processi ng Tool box. I t al so di scusses
how to use the tool box functi ons to anal yze fi l ter characteri sti cs, i ncl udi ng
i mpul se response, magni tude and phase response, group del ay, and zero-pol e
l ocati ons.
Convolution and Filtering
The mathemati cal foundati on of fi l teri ng i s convol uti on. MATLABs conv
functi on performs standard one-di mensi onal convol uti on, convol vi ng one
vector wi th another.
conv([1 1 1],[1 1 1])
ans =
1 2 3 2 1
NOTE Convol ve rectangul ar matri ces for two-di mensi onal si gnal processi ng
usi ng the conv2 functi on.
A di gi tal fi l ters output y(n) i s rel ated to i ts i nput x(n) by convol uti on wi th i ts
i mpul se response h(n).
I f a di gi tal fi l ters i mpul se response h(n) i s fi ni te l ength, and the i nput x(n) i s
al so fi ni te l ength, you can i mpl ement the fi l ter usi ng conv. Store x(n)i n a vector
x, h(n) i n a vector h, and convol ve the two.
x = randn(5,1); % a random vector of length 5
h = [1 1 1 1]/4; % length 4 averaging filter
y = conv(h,x);
y n ( ) h n ( ) x n ( ) h n m ( )x m ( )
m =

= =
Filter Implementation and Analysis
1-15
Filters and Transfer Functions
I n general , the z-transform Y(z) of a di gi tal fi l ters output y(n) i s rel ated to the
z-transform X(z) of the i nput by
where H(z) i s the fi l ters transfer function. Her e, the constants b(i) and a(i) are
the fi l ter coeffi ci ents and the order of the fi l ter i s the maxi mum of na and nb.
NOTE The fi l ter coeffi ci ents start wi th subscri pt 1, rather than 0. Thi s
refl ects MATLABs standard i ndexi ng scheme for vectors.
MATLAB stores the coeffi ci ents i n two vectors, one for the numerator and one
for the denomi nator. By conventi on, MATLAB uses row vectors for fi l ter
coeffi ci ents.
Filter Coefficients and Filter Names
Many standard names for fi l ters refl ect the number of a and b coeffi ci ents
present:
When nb = 0 (that i s, b i s a scal ar), the fi l ter i s an I nfi ni te I mpul se Response
(I I R), al l -pol e, recursi ve, or autoregressi ve (AR) fi l ter.
When na = 0 (that i s, a i s a scal ar), the fi l ter i s a Fi ni te I mpul se Response
(FI R), al l -zero, nonrecursi ve, or movi ng average (MA) fi l ter.
I f both na and nb are greater than zero, the fi l ter i s an I I R, pol e-zero,
recursi ve, or autoregressi ve movi ng average (ARMA) fi l ter.
The acronyms AR, MA, and ARMA are usual l y appl i ed to fi l ters associ ated
wi th fi l tered stochasti c processes.
Y z ( ) H z ( )X z ( )
b 1 ( ) b 2 ( )z
1
L b nb 1 + ( )z
nb
+ + +
a 1 ( ) a 2 ( )z
1
L a na 1 + ( )z
na
+ + +
-----------------------------------------------------------------------------------------X z ( ) = =
1 Signal Processing Basics
1-16
Filtering with the filter Function
I t i s si mpl e to work back to a di fference equati on from the z-transform rel ati on
shown earl i er. Assume that a(1) = 1. Move the denomi nator to the l eft-hand
si de and take the i nverse z-transform.
I n terms of current and past i nputs, and past outputs, y(n) i s
Thi s i s the standard ti me-domai n representati on of a di gi tal fi l ter, computed
starti ng wi th y(1) and assumi ng zero i ni ti al condi ti ons. Thi s representati ons
progressi on i s
A fi l ter i n thi s form i s easy to i mpl ement wi th the filter functi on. For
exampl e, a si mpl e si ngl e-pol e fi l ter (l owpass) i s
b = 1; % numerator
a = [1 0.9]; % denominator
where the vectors b and a represent the coeffi ci ents of a fi l ter i n transfer
functi on form. To appl y thi s fi l ter to your data
y = filter(b,a,x);
filter gi ves you as many output sampl es as there are i nput sampl es, that i s,
the l ength of y i s the same as the l ength of x. I f the fi rst el ement of a i s not 1,
filter di vi des the coeffi ci ents by a(1) before i mpl ementi ng the di fference
equati on.
y n ( ) a 2 ( )y n 1 ( ) L a na 1 + ( )y n na ( ) + + + b 1 ( )x n ( ) b 2 ( )x n 1 ( ) L b nb 1 + ( )x n nb ( ) + + + =
y n ( ) b 1 ( )x n ( ) b 2 ( )x n 1 ( ) L b nb 1 + ( )x n nb ( ) a 2 ( )y n 1 ( ) L a na 1 + ( ) y n na ( ) + + + =
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 =
filter Function Implementation and Initial Conditions
1-17
filter Function Implementation and Initial Conditions
filter i s i mpl emented as a transposed di rect form I I structure
where n-1 i s the fi l ter order. Thi s i s a canoni cal form that has the mi ni mum
number of del ay el ements.
At sampl e m, filter computes the di fference equati ons
I n i ts most basi c form, filter i ni ti al i zes the del ay outputs z
i
(1), i = 1, ..., n-1
to 0. Thi s i s equi val ent to assumi ng both past i nputs and outputs are zero. Set
the i ni ti al del ay outputs usi ng a fourth i nput parameter to filter, or access
the fi nal del ay outputs usi ng a second output parameter.
[y,zf] = filter(b,a,x,zi)
Access to i ni ti al and fi nal condi ti ons i s useful for fi l teri ng data i n secti ons,
especi al l y i f memory l i mi tati ons are a consi derati on. Suppose you have
col l ected data i n two segments of 5000 poi nts each.
x1 = randn(5000,1); % two random sequences to
x2 = randn(5000,1); % serve as simulated data
Perhaps the fi rst sequence, x1, corresponds to the fi rst 10 mi nutes of data and
the second, x2, to an addi ti onal 10 mi nutes. The whol e sequence i s
x = [x1; x2]. I f there i s not suffi ci ent memory to hol d the combi ned sequence,
z
-1
z
-1
x(m)
y(m)
b( 3) b( 2) b(1)
a( 3) a( 2)
z
1
(m) z
2
(m)
z
-1
b(n)
a(n)
z
n-1
(m)
...
...
...
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 =
z
n 2
m ( ) b n 1 ( )x m ( ) z
n 1
m 1 ( ) a n 1 ( )y m ( ) + =
z
n 1
m ( ) b n ( )x m ( ) a n ( )y m ( ) =
1 Signal Processing Basics
1-18
fi l ter the subsequences x1 and x2 one at a ti me. To ensure conti nui ty of the
fi l tered sequences, use the fi nal condi ti ons from x1 as i ni ti al condi ti ons to fi l ter
x2.
[y1,zf] = filter(b,a,x1);
y2 = filter(b,a,x2,zf);
The filtic functi on generates i ni ti al condi ti ons for filter. filtic computes
the del ay vector to make the behavi or of the fi l ter refl ect past i nputs and
outputs that you speci fy. To obtai n the same output del ay val ues zf as above
usi ng filtic
zf = filtic(b,a,flipud(y1),flipud(x1));
Thi s can be useful when fi l teri ng short data sequences, as appropri ate i ni ti al
condi ti ons hel p reduce transi ent startup effects.
Other Functions for Filtering
1-19
Other Functions for Filtering
I n addi ti on to filter, several other functi ons i n the Si gnal Processi ng Tool box
perform the basi c fi l teri ng operati on. These functi ons i ncl ude upfirdn, whi ch
performs FI R fi l teri ng wi th resampl i ng, filtfilt, whi ch el i mi nates phase
di storti on i n the fi l teri ng process, fftfilt, whi ch performs the FI R fi l teri ng
operati on i n the frequency domai n, and latcfilt, whi ch fi l ters usi ng a l atti ce
i mpl ementati on.
Multirate Filter Bank Implementation
The functi on upfirdn al ters the sampl i ng rate of a si gnal by an i nteger rati o
P/Q. I t computes the resul t of the cascade of three systems: (1) upsampl i ng
(zero i nserti on) by i nteger factor p, (2) fi l teri ng by FI R fi l ter h, and (3)
downsampl i ng by i nteger factor q.
For exampl e, to change the sampl e rate of a si gnal from 44.1 kHz to 48 kHz,
we fi rst fi nd the smal l est i nteger conversi on rati o p/q.
d = gcd(48000,44100);
p = 48000/d;
q = 44100/d;
where we fi nd that p = 160 and q = 147. Sampl e rate conversi on i s then
accompl i shed by y = upfirdn(x,h,p,q). Thi s cascade of operati ons i s
i mpl emented i n an effi ci ent manner usi ng pol yphase fi l teri ng techni ques, and
i t i s a central concept of mul ti rate fi l teri ng (see reference [1] for detai l s on
mul ti rate fi l ter theory). Note that the qual i ty of the resampl i ng resul t rel i es on
the qual i ty of the FI R fi l ter h.
Fi l ter banks may be i mpl emented usi ng upfirdn by al l owi ng the fi l ter h to be
a matri x, wi th one FI R fi l ter per col umn. A si gnal vector i s passed
i ndependentl y through each FI R fi l ter, resul ti ng i n a matri x of output si gnal s.
Other functi ons that perform mul ti rate fi l teri ng (wi th fi xed fi l ter) i ncl ude
resample, interp, and decimate.
P
x(n) y(n)
FIR
H
Q
1 Signal Processing Basics
1-20
Anti-Causal, Zero-Phase Filter Implementation
I n the case of FI R fi l ters, i t i s possi bl e to desi gn l i near phase fi l ters that, when
appl i ed to data (usi ng filter or conv), si mpl y del ay the output by a fi xed
number of sampl es. For I I R fi l ters, however, the phase di storti on i s usual l y
hi ghl y nonl i near. The filtfilt functi on uses the i nformati on i n the si gnal at
poi nts before and after the current poi nt, i n essence l ooki ng i nto the future,
to el i mi nate phase di storti on.
To see how filtfilt does thi s, recal l that i f the z-transform of a real sequence
x(n) i s X(z), the z-transform of the ti me reversed sequence x(n) i s X(1/z).
Consi der the processi ng scheme
When | z| = 1, that i s z =e
j
, the output reduces to X(e
j
)| H(e
j
)|
2
. Gi ven al l
the sampl es of the sequence x(n), a doubl y fi l ter ed ver si on of x that has
zero-phase di storti on i s possi bl e.
For exampl e, a one-second durati on si gnal sampl ed at 100 Hz, composed of two
si nusoi dal components at 3 Hz and 40 Hz, i s
Fs = 100;
t = 0:1/Fs:1;
x = sin(2*pi*t*3)+.25*sin(2*pi*t*40);
H(z) X(z)
X(z)H(z) X(1/z)H(1/z) X(1/z)H(1/z)H(z)
X(z)H(1/z)H(z) H(z)
Time
Reverse
Time
Reverse
Other Functions for Filtering
1-21
Now create a 10-poi nt averagi ng FI R fi l ter, and fi l ter x usi ng both filter and
filtfilt for compari son:
b = ones(1,10)/10; % 10 point averaging filter
y = filtfilt(b,1,x); % noncausal filtering
yy = filter(b,1,x); % normal filtering
plot(t,x,t,y,'--',t,yy,':')
Both fi l tered versi ons el i mi nate the 40 Hz si nusoi d evi dent i n the ori gi nal ,
sol i d l i ne. The pl ot al so shows how filter and filtfilt di ffer; the dashed
(filtfilt) l i ne i s i n phase wi th the ori gi nal 3 Hz si nusoi d, whi l e the dotted
(filter) l i ne i s del ayed by about fi ve sampl es. Al so, the ampl i tude of the
dashed l i ne i s smal l er due to the magni tude squared effects of filtfilt.
filtfilt reduces fi l ter startup transi ents by careful l y choosi ng i ni ti al
condi ti ons, and by prependi ng onto the i nput sequence a short, refl ected pi ece
of the i nput sequence. For best r esul ts, make sur e the sequence you are
fi l teri ng has l ength at l east three ti mes the fi l ter order and tapers to zero on
both edges.
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-1.5
-1
-0.5
0
0.5
1
1.5
1 Signal Processing Basics
1-22
Frequency Domain Filter Implementation
Dual i ty between the ti me domai n and the frequency domai n makes i t possi bl e
to perform any operati on i n ei ther domai n. Usual l y one domai n or the other i s
more conveni ent for a parti cul ar operati on, but you can al ways accompl i sh a
gi ven oper ati on i n ei ther domai n.
To i mpl ement general I I R fi l teri ng i n the frequency domai n, mul ti pl y the
di screte Fouri er transform (DFT) of the i nput sequence wi th the quoti ent of the
DFT of the fi l ter,
n = length(x);
y = ifft(fft(x).*fft(b,n)./fft(a,n));
Thi s computes resul ts that are i denti cal to filter, but wi th di fferent startup
transi ents (edge effects). For l ong sequences, thi s computati on i s very
i neffi ci ent because of the l arge zero-padded FFT operati ons on the fi l ter
coeffi ci ents, and because the FFT al gori thm becomes l ess effi ci ent as the
number of poi nts n i ncreases.
For FI R fi l ters, however, i t i s possi bl e to break l onger sequences i nto shorter,
computati onal l y effi ci ent FFT l engths. The functi on
y = fftfilt(b,x)
uses the overl ap add method (see reference [1] at the end of thi s chapter) to
fi l ter a l ong sequence wi th mul ti pl e medi um-l ength FFTs. I ts output i s
equi val ent to filter(b,1,x).
Impulse Response
1-23
Impulse Response
The i mpul se response of a di gi tal fi l ter i s the output ari si ng from the i nput
sequence
I n MATLAB, you can generate an i mpul se sequence a number of ways; one
strai ghtforward way i s
imp = [1; zeros(49,1)];
The i mpul se response of the si mpl e fi l ter b = 1 and a = [1 0.9] i s
h = filter(b,a,imp);
The impz functi on i n the tool box si mpl i fi es thi s operati on, choosi ng the number
of poi nts to generate and then maki ng a stem pl ot (usi ng the stem functi on).
impz(b,a)
The pl ot shows the exponenti al decay h(n) = 0.9n of the si ngl e pol e system.
x n ( )
1 n 1 = ,
0 n 1 ,

'

=
0 10 20 30 40 50 60 70 80 90
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
1 Signal Processing Basics
1-24
Frequency Response
The Si gnal Processi ng Tool box enabl es you to perform frequency domai n
anal ysi s of both anal og and di gi tal fi l ters.
Digital Domain
freqz uses an FFT-based al gori thm to cal cul ate the z-transform frequency
response of a di gi tal fi l ter. Speci fi cal l y, the statement
[h,w] = freqz(b,a,n)
returns the n-poi nt compl ex frequency response, H(e
j
), of the di gi tal fi l ter.
I n i ts si mpl est form, freqz accepts the fi l ter coeffi ci ent vectors b and a, and an
i nteger n speci fyi ng the number of poi nts at whi ch to cal cul ate the frequency
response. freqz returns the compl ex frequency response i n vector h, and the
actual frequency poi nts i n vector w i n radi ans/second.
freqz can accept other parameters, such as a sampl i ng frequency or a vector of
arbi trary frequency poi nts. The exampl e bel ow fi nds the 256-poi nt frequency
response for a 12th-or der Chebyshev type I fi l ter . The cal l to freqz speci fi es a
sampl i ng frequency Fs of 1000 Hz.
[b,a] = cheby1(12,0.5,200/500);
[h,f] = freqz(b,a,256,1000);
Because the parameter l i st i ncl udes a sampl i ng frequency, freqz returns a
vector f that contai ns the 256 frequency poi nts between 0 and Fs/2 used i n the
frequency response cal cul ati on.
H e
j
( )
b 1 ( ) b 2 ( )e
j
L b nb 1 + ( )e
j nb ( )
+ + +
a 1 ( ) a 2 ( )e
j
L a na 1 + ( )e
j na ( )
+ + +
---------------------------------------------------------------------------------------------------- =
Frequency Response
1-25
Frequency Normalization Thi s tool box uses the conventi on that uni t
frequency i s the Nyqui st frequency, defi ned as hal f the sampl i ng frequency.
The cutoff frequency parameter for al l basi c fi l ter desi gn functi ons i s
normal i zed by the Nyqui st frequency. For a system wi th a 1000 Hz sampl i ng
frequency, for exampl e, 300 Hz i s 300/500 = 0.6. To convert normal i zed
frequency to angul ar frequency around the uni t ci rcl e, mul ti pl y by . To
convert normal i zed frequency back to Hertz, mul ti pl y by hal f the sampl e
frequency.
I f you cal l freqz wi th no output arguments, i t automati cal l y pl ots both
magni tude versus frequency and phase versus frequency. For exampl e, a
ni nth-order Butterworth l owpass fi l ter wi th a cutoff frequency of 400 Hz, based
on a 2000 Hz sampl i ng frequency, i s
[b,a] = butter(9,400/1000);
Now cal cul ate the 256-poi nt compl ex frequency response for thi s fi l ter, and pl ot
the magni tude and phase wi th a cal l to freqz.
freqz(b,a,256,2000)
0 100 200 300 400 500 600 700 800 900 1000
-1000
-800
-600
-400
-200
0
Frequency (Hertz)
P
h
a
s
e

(
d
e
g
r
e
e
s
)
0 100 200 300 400 500 600 700 800 900 1000
-400
-300
-200
-100
0
100
Frequency (Hertz)
M
a
g
n
i
t
u
d
e

R
e
s
p
o
n
s
e

(
d
B
)
1 Signal Processing Basics
1-26
freqz can al so accept a vector of arbi trary frequency poi nts for use i n the
frequency response cal cul ati on. For exampl e,
w = linspace(0,pi);
h = freqz(b,a,w);
cal cul ates the compl ex frequency response at the frequency poi nts i n w for the
fi l ter defi ned by vectors b and a. The frequency poi nts can range from 0 to 2.
To speci fy a frequency vector that ranges from zero to your sampl i ng frequency,
i ncl ude both the frequency vector and the sampl i ng frequency val ue i n the
parameter l i st.
Analog Domain
freqs eval uates frequency response for an anal og fi l ter defi ned by two i nput
coeffi ci ent vectors b and a. I ts operati on i s si mi l ar to that of freqz; you can
speci fy a number of frequency poi nts to use (by defaul t, the functi on uses 200),
suppl y a vector of arbi trary frequency poi nts, and pl ot the magni tude and
phase response of the fi l ter.
Magnitude and Phase
MATLAB provi des functi ons to extract magni tude and phase from a frequency
response vector h. The functi on abs returns the magni tude of the response;
angle returns the phase angl e i n radi ans. To extract and pl ot the magni tude
and phase of a Butterwor th fi l ter .
[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 100 200 300 400
10
-15
10
-10
10
-5
10
0
0 100 200 300 400
-200
-100
0
100
200
Frequency Response
1-27
The unwrap functi on i s al so useful i n frequency anal ysi s. unwrap unwraps the
phase to make i t conti nuous across 360 phase di sconti nui ti es by addi ng
mul ti pl es of t360, as needed. To see how unwrap i s useful , desi gn a 25th-order
l owpass FI R fi l ter.
h = fir1(25,0.4);
Obtai n the fi l ters frequency response wi th freqz, and pl ot the phase i n
degrees.
[H,f] = freqz(h,1,512,2);
plot(f,angle(H)*180/pi); grid
I t i s di ffi cul t to di sti ngui sh the 360 jumps (an arti fact of the arctangent
functi on i nsi de angle) from the 180 jumps that si gni fy zeros i n the frequency
response.
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-200
-150
-100
-50
0
50
100
150
200
1 Signal Processing Basics
1-28
Use unwrap to el i mi nate the 360 jumps.
plot(f,unwrap(angle(H))*180/pi); grid
Delay
The group delay of a fi l ter i s a measure of the average del ay of the fi l ter as a
functi on of frequency. I t i s defi ned as the negati ve fi rst deri vati ve of a fi l ters
phase response. I f the compl ex frequency response of a fi l ter i s H(e
j
), then the
group del ay i s
where i s the phase angl e of H(e
j
). Compute group del ay wi th
[gd,w] = grpdelay(b,a,n)
whi ch returns the n-poi nt group del ay, , of the di gi tal fi l ter speci fi ed by b
and a, eval uated at the frequenci es i n vector w.
The phasedelay of a fi l ter i s the negati ve of phase di vi ded by frequency
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-1400
-1200
-1000
-800
-600
-400
-200
0

g
( )
d ( )
d
--------------- =

g
( )

p
( )
( )

----------- =
Frequency Response
1-29
To pl ot both the group and phase del ays of a system on the same graph.
[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')
0 200 400 600 800 1000
30
20
10
0
10
20
30
Group Delay
Phase Delay
1 Signal Processing Basics
1-30
Zero-Pole Analysis
The zplane functi on pl ots pol es and zeros of a l i near system. For exampl e, a
si mpl e fi l ter wi th a 0 at -1/2 and a compl ex pol e pai r at and
i s
zer = 0.5;
pol = .9*exp(j*2*pi*[0.3 .3]');
The zero-pol e pl ot for the fi l ter i s
zplane(zer,pol)
For a system i n zero-pol e form, suppl y col umn vector arguments z and p to
zplane.
zplane(z,p)
For a system i n transfer functi on form, suppl y row vectors b and a as
arguments to zplane.
zplane(b,a)
I n thi s case zplane fi nds the roots of b and a usi ng the roots functi on and pl ots
the resul ti ng zeros and pol es.
0.9e
j 2 0.3 ( )
0.9e
j 2 0.3 ( )
-1 -0.5 0 0.5 1
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
Real part
I
m
a
g
i
n
a
r
y

p
a
r
t
Zero-Pole Analysis
1-31
See Li near System Model s on page 1-32 for detai l s on zero-pol e and transfer
functi on representati on of systems.
1 Signal Processing Basics
1-32
Linear System Models
The Si gnal Processi ng Tool box provi des several model s for representi ng l i near
ti me-i nvari ant systems. Thi s fl exi bi l i ty l ets you choose the representati onal
scheme that best sui ts your appl i cati on and, wi thi n the bounds of numeri c
stabi l i ty, convert freel y to and from most other model s. Thi s secti on provi des a
bri ef overvi ew of supported l i near system model s and descri bes how to work
wi th these model s i n MATLAB.
Discrete-Time System Models
The di screte-ti me system model s are representati onal schemes for di gi tal
fi l ters. MATLAB supports several di screte-ti me system model s:
Transfer functi on
Zero-pol e-gai n form
State-space form
Parti al fracti on expansi on
Second-order secti on form
Latti ce structure form
Convol uti on matri ces
Transfer Function
The transfer function i s a basi c z-domai n representati on of a di gi tal fi l ter,
expressi ng the fi l ter as a rati o of two pol ynomi al s. I t i s the pri nci pal
di screte-ti me model for thi s tool box. The transfer functi on model descri pti on
for the z-transform of a di gi tal fi l ters di fference equati on i s
Here, the constants b(i) and a(i) are the fi l ter coeffi ci ents, and the order of the
fi l ter i s the maxi mum of na and nb. I n MATLAB, you store these coeffi ci ents i n
two vectors (row vectors by conventi on), one row vector for the numerator and
one for the denomi nator. See Fi l ters and Transfer Functi ons on page 1-15 for
more detai l s on the transfer functi on form.
Y z ( )
b 1 ( ) b 2 ( )z
1
L b nb 1 + ( )z
nb
+ + +
a 1 ( ) a 2 ( )z
1
L a na 1 + ( )z
na
+ + +
---------------------------------------------------------------------------------------- -X z ( ) =
Linear System Models
1-33
Zero-Pole-Gain
The factored or zero-pole-gain form of a transfer functi on i s
By conventi on, MATLAB stores pol ynomi al coeffi ci ents i n row vectors and
pol ynomi al roots i n col umn vectors. I n zero-pol e-gai n form, therefore, the zero
and pol e l ocati ons for the numerator and denomi nator of a transfer functi on
resi de i n col umn vectors. The factored transfer functi on gai n k i s a MATLAB
scal ar.
The poly and roots functi ons convert between pol ynomi al and zero-pol e-gai n
representati ons. For exampl e, a si mpl e I I R fi l ter i s
b = [2 3 4];
a = [1 3 3 1];
The zer os and pol es of thi s fi l ter are
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 =
2
H z ( )
q z ( )
p z ( )
---------- k
z q 1 ( ) ( ) z q 2 ( ) ( )Lz q n ( ) ( )
z p 1 ( ) ( ) z p 2 ( ) ( )Lz p n ( ) ( )
----------------------------------------------------------------------------- = =
1 Signal Processing Basics
1-34
Returni ng to the ori gi nal pol ynomi al s,
bb = k*poly(q)
bb =
2.0000 3.0000 4.0000
aa = poly(p)
aa =
1.0000 3.0000 3.0000 1.0000
Note that b and a i n thi s case represent the transfer functi on
For b = [2 3 4], the roots functi on mi sses the zero for z equal to 0. I n fact, i t
mi sses pol es and zeros for zequal to 0 whenever the i nput transfer functi on has
more pol es than zeros, or vi ce versa. Thi s i s acceptabl e i n most cases. To
ci rcumvent the probl em, however, si mpl y append zeros to make the vectors the
same l ength before usi ng the roots functi on, for exampl e, b = [b 0].
State-Space
I t i s al ways possi bl e to represent a di gi tal fi l ter, or a system of di fference
equati ons, as a set of fi rst-order di fference equati ons. I n matri x or state-space
form, you can wri te the equati ons as
where u i s the i nput, x i s the state vector, and y i s the output. For
si ngl e-channel systems, A i s an m-by-m matri x where m i s the or der of the fi l ter,
B i s a col umn vector, C i s a row vector, and D i s a scal ar. State-space notati on i s
especi al l y conveni ent for mul ti channel systems where i nput u and output y
become vectors, and B, C, and D become matri ces.
State-space representati on extends easi l y to the MATLAB envi ronment. I n
MATLAB, A, B, C, and D are rectangul ar arrays; MATLAB treats them as
i ndi vi dual vari abl es.
H z ( )
2 3z
1
4z
2
+ +
1 3z
1
3z
2
z
3
+ + +
------------------------------------------------------
2z
3
3z
2
4z + +
z
3
3z
2
3z 1 + + +
-------------------------------------------- = =
x n 1 + ( ) Ax n ( ) Bu n ( ) + =
y n ( ) Cx n ( ) Du n ( ) + =
Linear System Models
1-35
Taki ng the z-transform of the state-space equati ons and combi ni ng them shows
the equi val ence of state-space and transfer functi on forms.
Dont be concerned i f you are not fami l i ar wi th the state-space representati on
of l i near systems. Some of the fi l ter desi gn al gori thms use state-space form
i nternal l y but do not requi re any knowl edge of state-space concepts to use them
successful l y. I f your appl i cati ons use state-space based si gnal pr ocessi ng
extensi vel y, however, consul t the Control System Tool box for a comprehensi ve
l i brary of state-space tool s.
Partial Fraction Expansion (Residue Form)
Each transfer functi on al so has a correspondi ng partial fraction expansion or
residueform representati on, gi ven by
provi ded H(z) has no repeated pol es. Here, n i s the degree of the denomi nator
pol ynomi al of the rati onal transfer functi on b(z)/a(z). I f r i s a pol e of mul ti pl i ci ty
s
r
, then H(z) has terms of the form
The residuez functi on i n the Si gnal Processi ng Tool box converts transfer
functi ons to and from the parti al fracti on expansi on form. The z on the end of
residuez stands for z-domai n, or di screte domai n. residuez returns the pol es
i n a col umn vector p, the resi dues correspondi ng to the pol es i n a col umn vector
r, and any i mproper part of the ori gi nal transfer functi on i n a row vector k.
residuez determi nes that two pol es are the same i f the magni tude of thei r
di fference i s smal l er than 0.1 percent of ei ther of the pol es magni tudes.
Parti al fracti on expansi on ari ses i n si gnal processi ng as one method of fi ndi ng
the i nverse z-transform of a transfer functi on. For exampl e, the parti al fracti on
expansi on of
Y z ( ) H z ( )U z ( ) = where H z ( ) C zI A ( )
1
B D + = ,
b z ( )
a z ( )
----------
r 1 ( )
1 p 1 ( )z
1

---------------------------- L
r n ( )
1 p n ( )z
1

----------------------------- k 1 ( ) k 2 ( )z
1
L k m n 1 + ( )z
m n ( )
+ + + + + + =
r j ( )
1 p j ( )z
1

---------------------------
r j 1 + ( )
1 p j ( )z
1
( )
2
----------------------------------- L
r j s
r
1 + ( )
1 p j ( )z
1
( )
s
r
------------------------------------ + + +
H z ( )
4 8z
1
+
1 6z
1
8z
2
+ +
---------------------------------------- =
1 Signal Processing Basics
1-36
i s
b = [4 8];
a = [1 6 8];
[r,p,k] = residuez(b,a)
r =
12
8
p =
4
2
k =
[]
correspondi ng to
To fi nd the i nverse z-transform of H(z), fi nd the sum of the i nverse z-transforms
of the two addends of H(z), gi vi ng the causal i mpul se response
To veri fy thi s i n 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)
Any transfer functi on H(z) has a second-order secti ons representati on
H z ( )
12
1 4z
1
+
---------------------
8
1 2z
1
+
--------------------- + =
h n ( ) 12 4 ( )
n
8 2 ( )
n
+ n 0 1 2 , , , = , =
Linear System Models
1-37
where L i s the number of second-order secti ons that descri be the system.
MATLAB represents the second-order secti on form of a di screte-ti me system as
an L-by-6 array sos. Each row of sos contai ns a si ngl e second-order secti on,
where the row el ements are the three numerator and three denomi nator
coeffi ci ents that descri be the second-order secti on.
There are an uncountabl e number of ways to represent a fi l ter i n second-order
secti on form. Through careful pai ri ng of the pol e and zero pai rs, orderi ng of the
secti ons i n the cascade, and mul ti pl i cati ve scal i ng of the secti ons, i t i s possi bl e
to reduce quanti zati on noi se gai n and avoi d overfl ow i n some fi xed-poi nt fi l ter
i mpl ementati ons. The functi ons zp2sos and ss2sos, descri bed l ater i n Li near
System Transformati ons, perform pol e-zero pai ri ng, secti on scal i ng, and
secti on orderi ng.
Lattice Structure
For a di screte Nth order al l -pol e or al l -zero fi l ter descri bed by the pol ynomi al
coeffi ci ents a(n), n =1,2,,N+1, there are N correspondi ng l atti ce structure
coeffi ci ents k(n), n =1,2,,N. The parameters k(n) are al so cal l ed the reflection
H z ( ) H
k
z ( )
k 1 =
L

b
0k
b
1k
z
1
b
2k
z
2
+ +
a
0k
a
1k
z
1
a
2k
z
2
+ +
----------------------------------------------------------
k 1 =
L

= =
sos
b
01
b
11
b
21
a
01
a
11
a
21
b
02
b
12
b
22
a
02
a
12
a
22
M M M M M M
b
0L
b
1L
b
2L
a
0L
a
1L
a
2L
=
1 Signal Processing Basics
1-38
coefficients of the fi l ter . Gi ven these refl ecti on coeffi ci ents, you can i mpl ement
a di screte fi l ter as
For a general pol e-zero I I R fi l ter descri bed by pol ynomi al coeffi ci ents a and b,
there are both l atti ce coeffi ci ents k(n) for the denomi nator a and l adder
coeffi ci ents v(n) for the numerator b. The l atti ce/l adder fi l ter may be
i mpl emented as

z
-1
y(m)
k(1)
k(1)

k(n)
k(n)
. . .
. . .
z
-1
FI R Latti ce Fi l ter
x(m)
x(m)

y(m)
k(1)
k(1)

k(n)
k(n)
. . .
. . .
z
-1
z
-1
I I R Latti ce Fi l ter
z
-1
+
+
x(m)
g(m)
+
k(N)
k(N)
z
-1
+
+
k(2)
k(2)
z
-1
+
+
k(1)
k(1)
+ + +
v(N+1) v(N) v(3) v(2) v(1)
f(m)
Linear System Models
1-39
The tool box functi on tf2latc accepts an FI R or I I R fi l ter i n pol ynomi al form
and returns the correspondi ng refl ecti on coeffi ci ents. An exampl e I I R fi l ter i n
pol ynomi al form i s
a = [1.0000 0.6149 0.9899 0.0000 0.0031 0.0082];
Thi s fi l ters l atti ce (refl ecti on coeffi ci ent) representati on i s
k = tf2latc(a)
k =
0.3090
0.9800
0.0031
0.0081
0.0082
The magni tude of the refl ecti on coeffi ci ents provi des an easy stabi l i ty check for
a fi l ter. I f al l the refl ecti on coeffi ci ents correspondi ng to a pol ynomi al have
magni tude l ess than 1, al l of that pol ynomi al s roots are i nsi de the uni t ci rcl e.
The functi on latc2tf cal cul ates the pol ynomi al coeffi ci ents for a fi l ter from i ts
l atti ce (refl ecti on) coeffi ci ents. Gi ven the refl ecti on coeffi ci ent vector k(above),
the correspondi ng pol ynomi al form i s
a = latc2tf(k)
a =
1.0000 0.6149 0.9899 0.0000 0.0031 0.0082
The l atti ce or l atti ce/l adder coeffi ci ents can be used to i mpl ement the fi l ter
usi ng the functi on latcfilt.
Convolution Matrix
I n si gnal processi ng, convol vi ng two vectors or matri ces i s equi val ent to
fi l teri ng one of the i nput operands by the other. Thi s rel ati onshi p permi ts the
representati on of a di gi tal fi l ter as a convolution matrix.
Gi ven any vector, the tool box convmtx functi on generates a matri x whose i nner
product wi th another vector i s equi val ent to the convol uti on of the two vectors.
The generated matri x represents a di gi tal fi l ter that you can appl y to any
1 Signal Processing Basics
1-40
vector of appropri ate l ength; the i nner di mensi on of the operands must agree
to compute the i nner product.
The convol uti on matri x for a vector b, representi ng the numerator coeffi ci ents
for a di gi tal fi l ter, i s
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 ways to convol ve b wi th x are
y1 = C*x;
y2 = conv(b,x);
Type thi s exampl e i nto MATLAB; the resul ts for y1 and y2 are equal .
Continuous-Time System Models
The conti nuous-ti me system model s are representati onal schemes for anal og
fi l ters. Many of the di screte-ti me system model s descri bed earl i er are al so
appropri ate for the representati on of conti nuous-ti me systems:
State-space form
Parti al fracti on expansi on
Transfer functi on
Zero-pol e-gai n form
I t i s possi bl e to represent any system of l i near ti me-i nvari ant di fferenti al
equati ons as a set of fi rst-or der di ffer enti al equati ons. I n matri x or state-space
form, you can express the equati ons as
x

Ax Bu + =
y Cx Du + =
Linear System Models
1-41
where ui s a vector of nui nputs, xi s an nx-el ement state vector, and yi s a vector
of ny outputs. I n MATLAB, store A, B, C, and D i n separate rectangul ar arrays.
An equi val ent representati on of the state-space system i s the Lapl ace
transform transfer functi on descri pti on
where
For si ngl e-i nput, si ngl e-output systems, thi s form i s gi ven by
Gi ven the coeffi ci ents of a Lapl ace transform transfer functi on, residue
determi nes the parti al fracti on expansi on of the system. See the descri pti on of
residue i n the MATLAB LanguageReferenceManual for detai l s.
The factored zero-pol e-gai n form i s
As i n the di screte-ti me case, MATLAB stores pol ynomi al coeffi ci ents i n row
vectors i n descendi ng powers of s. MATLAB stores pol ynomi al roots, or zeros
and pol es, i n col umn vectors.
Linear System Transformations
The Si gnal Processi ng Tool box provi des a number of functi ons that convert
between the vari ous l i near system model s; see the reference descri pti on i n
Chapter 6 for a compl ete descri pti on of each. You can use the fol l owi ng chart to
fi nd an appropri ate transfer functi on: fi nd the row of the model to convert from
on the l eft si de of the chart and the col umn of the model to convert toon the top
of the chart and read the functi on name(s) at the i ntersecti on of the row and
col umn.
Y s ( ) H s ( )U s ( ) =
H s ( ) C sI A ( )
1
B D + =
H s ( )
b s ( )
a s ( )
----------
b 1 ( )s
nb
b 2 ( )s
nb 1
L b nb 1 + ( ) + + +
a 1 ( )s
na
a 2 ( )s
na 1
L a na 1 + ( ) + + +
---------------------------------------------------------------------------------------------- = =
H s ( )
z s ( )
p s ( )
---------- k
s z 1 ( ) ( ) s z 2 ( ) ( )Ls z n ( ) ( )
s p 1 ( ) ( ) s p 2 ( ) ( )Ls p n ( ) ( )
----------------------------------------------------------------------------- = =
1 Signal Processing Basics
1-42
Many of the tool box fi l ter desi gn functi ons use these functi ons i nternal l y. For
exampl e, the zp2ss functi on converts the pol es and zeros of an anal og
prototype i nto the state-space form requi red for creati on of a Butterworth,
Chebyshev, or el l i pti c fi l ter. Once i n state-space form, the fi l ter desi gn functi on
performs any requi red frequency transformati on, that i s, i t transforms the
i ni ti al l owpass desi gn i nto a bandpass, hi ghpass, or bandstop fi l ter, or a
l owpass fi l ter wi th the desi red cutoff frequency. See Chapter 6 and the
reference descri pti ons of the i ndi vi dual fi l ter desi gn functi ons for more detai l s.
Transfer
function
State-
space
Zero-
pole
gain
Partial
fraction
Lattice
filter
Second-
order
sections
Convolution
matrix
Transfer
function
tf2ss tf2zp
roots
residuez
residue
tf2latc convmtx
State-space ss2tf ss2zp ss2sos
Zero-pole
gain
zp2tf
poly
zp2ss zp2sos
Partial
fraction
residuez
residue
Lattice filter latc2tf
Second-
order
sections
sos2tf sos2ss sos2zp
Convolution
matrix
Discrete Fourier Transform
1-43
Discrete Fourier Transform
The di screte Fouri er transform, or DFT, i s the pri mary tool of di gi tal si gnal
processi ng. The foundati on of the Si gnal Processi ng Tool box i s the Fast Fouri er
Transform (FFT), a method for computi ng the DFT wi th reduced executi on
ti me. Many of the tool box functi ons (i ncl udi ng z-domai n frequency response,
spectrum and cepstrum anal ysi s, and some fi l ter desi gn and i mpl ementati on
functi ons) i ncorporate the FFT.
MATLAB provi des the functi ons fft and ifft to compute the di screte Fouri er
transform and i ts i nverse, respecti vel y. For the i nput sequence xand i ts
transformed versi on X (the di screte-ti me Fouri er transform at equal l y spaced
frequenci es around the uni t ci rcl e), the two functi ons i mpl ement the
rel ati onshi ps
I n these equati ons, the seri es subscri pts begi n wi th 1 i nstead of 0 because of
MATLABs vector i ndexi ng scheme, and
NOTE MATLAB uses a negati ve j for the fft functi on. Thi s i s an engi neeri ng
conventi on; physi cs and pure mathemati cs typi cal l y use a posi ti ve j.
fft, wi th a si ngl e i nput argument x, computes the DFT of the i nput vector or
matri x. I f x i s a vector, fft computes the DFTof the vector; i f x i s a rectangul ar
array, fft computes the DFT of each array col umn.
X k 1 + ( ) x n 1 + ( )W
n
kn
n 0 =
N 1

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

=
W
N
e
j
2
N
-------
,
_
=
1 Signal Processing Basics
1-44
For exampl e, create a ti me vector and si gnal .
t = (0:1/99:1); % time vector
x = sin(2*pi*15*t) + sin(2*pi*40*t);% signal
The DFT of the si gnal , and the magni tude and phase of the transformed
sequence, are then
y = fft(x); % Compute DFT of x.
m = abs(y); p = unwrap(angle(y)); % mag. and phase
To pl ot the magni tude and phase
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]);
A second argument to fft speci fi es a number of poi nts n for the transform,
representi ng DFT l ength.
y = fft(x,n);
I n thi s case, fft pads the i nput sequence wi th zeros i f i t i s shorter than n, or
truncates the sequence i f i t i s l onger than n. I f n i s not speci fi ed, i t defaul ts to
the l ength of the i nput sequence.
15 40 60 85
0
10
20
30
40
50
15 40 60 85
-1500
-1000
-500
0
Discrete Fourier Transform
1-45
Executi on ti me for fft depends on the l ength n of the DFT i t performs:
For any n that i s a power of two, fft uses the hi gh-speed radi x-2 al gori thm.
Thi s resul ts i n the fastest executi on ti me. Addi ti onal l y, the al gori thm for
power of two n i s hi ghl y opti mi zed for real x, provi di ng a 40% speed-up over
the compl ex case.
For any composi te number n that i s not a power of two, fft uses a pri me
factor al gori thm. The speed of thi s al gori thm depends on both the si ze of n
and number of pri me factors i t has. Al though 1013 and 1000 are cl ose i n
magni tude, fft transforms a sequence of l ength 1000 much more qui ckl y
than a sequence of l ength 1013.
For a pri me number n, fft cannot use an FFT al gori thm, and i nstead
performs the sl ower, computati on-i ntensi ve DFT di rectl y.
The i nverse di screte Fouri er transform functi on ifft al so accepts an i nput
sequence and, opti onal l y, the number of desi red poi nts for the transform. Try
the exampl e bel ow; the ori gi nal sequence x and the reconstructed sequence are
i denti cal (wi thi n roundi ng error).
t = (0:1/255:1);
x = sin(2*pi*120*t);
y = real(ifft(fft(x)));
Thi s tool box al so i ncl udes functi ons for the two-di mensi onal FFT and i ts
i nverse, fft2 and ifft2. These functi ons are useful for two-di mensi onal si gnal
or i mage processi ng; see the reference descri pti ons i n Chapter 6 for detai l s.
I t i s someti mes conveni ent to rearrange the output of the fft or fft2 functi on
so the zero frequency component i s at the center of the sequence. The MATLAB
functi on fftshift moves the zero frequency component to the center of a vector
or matri x.
1 Signal Processing Basics
1-46
References
Al gori thm devel opment for the Si gnal Processi ng Tool box has drawn heavi l y
upon the references l i sted bel ow. Al l are recommended to the i nterested reader
who needs to know more about si gnal processi ng than i s covered i n thi s
manual .
1 Crochi ere, R.E., and L.R. Rabi ner. Multi-RateSignal Processing. Engl ewood
Cl i ffs, NJ: Prenti ce Hal l , 1983. Pgs. 88-91.
2 I EEE. Programsfor Digital Signal Processing. I EEE Press. New York: John
Wi l ey & Sons, 1979.
3 Jackson, L.B. Digital Filters and Signal Processing. Thi rd Ed. Boston:
Kl uwer Academi c Publ i shers, 1989.
4 Kay, S.M. Modern Spectral Estimation. Engl ewood Cl i ffs, NJ: Prenti ce Hal l ,
1988.
5 Oppenhei m, A.V., and R.W. Schafer. Discrete-TimeSignal Processing.
Engl ewood Cl i ffs, NJ: Prenti ce Hal l , 1989.
6 Parks, T.W., and C.S. Burrus. Digital Filter Design. New York: John Wi l ey
& Sons, 1987.
7 Pratt,W.K. Digital I mageProcessing. New York: John Wi l ey & Sons, 1991.
8 Perci val , D.B., and A.T. Wal den. Spectral Analysisfor Physical Applications:
Multitaper and Conventional UnivariateTechniques. Cambri dge:
Cambri dge Uni versi ty Press, 1993.
9 Proaki s, J.G., and D.G. Manol aki s. Digital Signal Processing: Principles,
Algorithms, and Applications. Upper Saddl e Ri ver, NJ: Prenti ce Hal l , 1996.
10 Rabi ner, L.R., and B. Gol d. Theory and Application of Digital Signal
Processing. Engl ewood Cl i ffs, NJ: Prenti ce Hal l , 1975.
11 Wel ch, P.D. The Use of Fast Fouri er Transform for the Esti mati on of Power
Spectra: A Method Based on Ti me Aver agi ng Over Shor t, Modi fi ed
Peri odograms. I EEE Trans. AudioElectroacoust. Vol . AU-15 (June 1967).
Pgs. 70-73.
2
Fi l ter Desi gn
Filter Requirements and Specification . . . . . . . . . . . . . . . . 2-2
IIR Filter Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
Cl assi cal I I R Fi l ter Desi gn Usi ng Anal og Prototypi ng . . . . . . . . 2-6
Compari son of Cl assi cal I I R Fi l ter Types . . . . . . . . . . . . . . . . . . 2-8
FIR Filter Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-16
Li near Phase Fi l ters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-17
Wi ndowi ng Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-18
Mul ti band FI R Fi l ter Desi gn wi th Transi ti on Bands . . . . . . . . 2-22
Constrai ned Least Squares FI R Fi l ter Desi gn . . . . . . . . . . . . . 2-27
Arbi trary-Response Fi l ter Desi gn . . . . . . . . . . . . . . . . . . . . . . . 2-31
Special Topics in IIR Filter Design . . . . . . . . . . . . . . . . . . . 2-37
Anal og Prototype Desi gn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-38
Frequency Transformati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-38
Fi l ter Di screti zati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-41
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-45
2 Filter Design
2-2
Filter Requirements and Specification
The Si gnal Processi ng Tool box provi des functi ons that support a range of fi l ter
desi gn methodol ogi es. Thi s chapter expl ai ns how to appl y the fi l ter desi gn tool s
to I nfiniteI mpulseResponse(I I R) and FiniteI mpulseResponse(FI R) fi l ter
desi gn probl ems.
The goal of fi l ter desi gn i s to perform frequency dependent al terati on of a data
sequence. A possi bl e requi rement mi ght be to remove noi se above 30 Hz from
a data sequence sampl ed at 100 Hz. A more ri gorous speci fi cati on mi ght cal l for
a speci fi c amount of passband ri ppl e, stopband attenuati on, or transi ti on
wi dth. A very preci se speci fi cati on coul d ask to achi eve the performance goal s
wi th the mi ni mum fi l ter order, or i t coul d cal l for an arbi trary magni tude
shape, or i t mi ght requi re an FI R fi l ter.
Fi l ter desi gn methods di ffer pri mari l y i n how performance i s speci fi ed. For
l oosel y speci fi ed requi rements, as i n the fi rst case above, a Butterworth I I R
fi l ter i s often suffi ci ent. To desi gn a fi fth-order 30 Hz l owpass Butterworth
fi l ter and appl y i t to the data i n vector x,
[b,a] = butter(5,30/50);
y = filter(b,a,x);
The second i nput argument to butter i ndi cates the cutoff frequency,
normal i zed to hal f the sampl i ng frequency (the Nyqui st frequency).
Frequency Normalization in the Signal Processing Toolbox Al l of the
fi l ter desi gn functi ons operate wi th normal i zed frequenci es, so they do not
requi re the system sampl i ng rate as an extra i nput argument. Thi s tool box
uses the conventi on that uni t frequency i s the Nyqui st frequency, defi ned as
hal f the sampl i ng frequency. The normal i zed frequency, therefore, i s al ways i n
the i nterval 0 f 1. For a system wi th a 1000 Hz sampl i ng frequency, 300 Hz
i s 300/500 = 0.6. To convert normal i zed frequency to angul ar frequency
around the uni t ci rcl e, mul ti pl y by . To convert normal i zed frequency back to
Hertz, mul ti pl y by hal f the sampl e frequency.
Filter Requirements and Specification
2-3
More ri gorous fi l ter requi rements tradi ti onal l y i ncl ude passband ri ppl e (Rp, i n
deci bel s), stopband attenuati on (Rs, i n deci bel s), and transi ti on wi dth (WsWp,
i n Hertz).
You can desi gn Butterworth, Chebyshev type I , Chebyshev type I I , and el l i pti c
fi l ters that meet thi s type of performance speci fi cati on. The tool box order
sel ecti on functi ons esti mate the mi ni mum fi l ter order that meets a gi ven set of
requi rements.
To meet speci fi cati ons wi th more ri gi d constrai nts l i ke l i near phase or
arbi trary fi l ter shape, use the FI R and di rect I I R fi l ter desi gn routi nes.
10
-1
10
0
10
1
0
0.2
0.4
0.6
0.8
1
Frequency(rad/sec)
M
a
g
n
i
t
u
d
e
2 Filter Design
2-4
IIR Filter Design
The pri mary advantage of I I R fi l ters over FI R fi l ters i s that they typi cal l y meet
a gi ven set of speci fi cati ons wi th a much l ower fi l ter order than a correspondi ng
FI R fi l ter. Al though I I R fi l ters have nonl i near phase, data processi ng wi thi n
MATLAB i s commonl y performed off-l i ne, that i s, the enti re data sequence i s
avai l abl e pri or to fi l teri ng. Thi s al l ows for a noncausal , zero-phase fi l teri ng
approach (vi a the filtfilt functi on), whi ch el i mi nates the nonl i near phase
di storti on of an I I R fi l ter.
The cl assi cal I I R fi l ters, Butterworth, Chebyshev types I and I I , el l i pti c, and
Bessel , al l approxi mate the i deal bri ckwal l fi l ter i n di fferent ways. Thi s
tool box provi des functi ons to create al l these types of cl assi cal I I R fi l ters i n both
the anal og and di gi tal domai ns (except Bessel , for whi ch onl y the anal og case
i s supported), and i n l owpass, hi ghpass, bandpass, and bandstop
confi gurati ons. For most fi l ter types, you can al so fi nd the l owest fi l ter order
that fi ts a gi ven fi l ter speci fi cati on i n terms of passband and stopband
attenuati on, and transi ti on wi dth(s).
The di rect fi l ter desi gn functi on yulewalk fi nds a fi l ter wi th magni tude
response approxi mati ng a desi red functi on. Thi s i s one way to create a
mul ti band bandpass fi l ter.
You can al so use the parametri c model i ng or system i denti fi cati on functi ons to
desi gn I I R fi l ters. These functi ons are di scussed i n the Parametri c Model i ng
secti on of Chapter 4.
The general i zed Butterworth desi gn functi on maxflat i s di scussed i n the
secti on General i zed Butterworth Fi l ter Desi gn on page 2-14.
The fol l owi ng tabl e summari zes the vari ous fi l ter methods i n the tool box and
l i sts the functi ons avai l abl e to i mpl ement these methods.
IIR Filter Design
2-5
* See the System Identification Toolbox for an extensive collection of parametric modeling tools.
Method Description Functions
Anal og
Prototypi ng
Usi ng the pol es and zeros of
a cl assi cal l owpass
prototype fi l ter i n the
conti nuous (Lapl ace)
domai n, obtai n a di gi tal
fi l ter through frequency
transformati on and fi l ter
di screti zati on.
Compl ete desi gn functi ons:
besself, butter, cheby1, cheby2, ellip
Order esti mati on functi ons:
buttord, cheb1ord, cheb2ord, ellipord
Lowpass anal og prototype functi ons:
besselap, buttap, cheb1ap, cheb2ap,
ellipap
Frequency transformati on functi ons:
lp2bp, lp2bs, lp2hp, lp2lp
Fi l ter di screti zati on functi ons:
bilinear, impinvar
Di rect Desi gn Desi gn di gi tal fi l ter
di rectl y i n the di screte
domai n by approxi mati ng a
pi ecewi se l i near magni tude
response.
yulewalk
Parametri c
Model i ng*
Fi nd a di gi tal fi l ter that
approxi mates a prescri bed
ti me or frequency domai n
response.
Ti me-domai n model i ng functi ons:
lpc, prony, stmcb
Frequency-domai n model i ng functi ons:
invfreqs, invfreqz
General i zed
Butterworth
Desi gn
Desi gn l owpass
Butterworth fi l ters wi th
more zeros than pol es.
maxflat
2 Filter Design
2-6
Classical IIR Filter Design Using Analog Prototyping
The pri nci pal I I R di gi tal fi l ter desi gn techni que thi s tool box provi des i s based
on the conversi on of cl assi cal l owpass anal og fi l ters to thei r di gi tal equi val ents.
The fol l owi ng secti ons descri be how to desi gn fi l ters and summari ze the
characteri sti cs of the supported fi l ter types. See Speci al Topi cs i n I I R Fi l ter
Desi gn on page 2-37 for detai l ed steps on the fi l ter desi gn process.
Complete Classical IIR Filter Design
You can easi l y create a fi l ter of any order wi th a l owpass, hi ghpass, bandpass,
or bandstop confi gurati on usi ng the fi l ter desi gn functi ons.
By defaul t, each of these functi ons returns a l owpass fi l ter; you need onl y
speci fy the desi red cutoff frequency Wn i n normal i zed frequency (Nyqui st
frequency = 1 Hz). For a hi ghpass fi l ter, append the stri ng 'high' to the
functi ons parameter l i st. For a bandpass or bandstop fi l ter, speci fy Wn as a
two-el ement vector contai ni ng the passband edge frequenci es, appendi ng the
stri ng 'stop' for the bandstop confi gurati on.
Filter Type Design Function
Butterworth [b,a] = butter(n,Wn,options)
[z,p,k] = butter(n,Wn,options)
[A,B,C,D] = butter(n,Wn,options)
Chebyshev type 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)
Chebyshev type I I [b,a] = cheby2(n,Rs,Wn,options)
[z,p,k] = cheby2(n,Rs,Wn,options)
[A,B,C,D] = cheby2(n,Rs,Wn,options)
El l i pti c [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 (anal og onl y) [b,a] = besself(n,Wn,options)
[z,p,k] = besself(n,Wn,options)
[A,B,C,D] = besself(n,Wn,options)
IIR Filter Design
2-7
Here are some exampl e di gi tal fi l ters.
[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 desi gn an anal og fi l ter, perhaps for si mul ati on, use a trai l i ng 's' and
speci fy cutoff frequenci es i n radi ans/second.
[b,a] = butter(5,.4,'s'); % analog Butterworth filter
Al l fi l ter desi gn functi ons return a fi l ter i n the transfer functi on,
zero-pol e-gai n, or state-space l i near system model representati on, dependi ng
on how many output arguments are present.
NOTE Al l cl assi cal I I R l owpass fi l ters are i l l -condi ti oned for extremel y l ow
cut-off frequenci es. Therefore, i nstead of desi gni ng a l owpass I I R fi l ter wi th a
very narrow passband, i t can be better to desi gn a wi der passband and
deci mate the i nput si gnal .
Designing IIR Filters to Frequency Domain Specifications
Thi s tool box provi des order sel ecti on functi ons that cal cul ate the mi ni mum
fi l ter order that meets a gi ven set of requi rements.
These are useful i n conjuncti on wi th the fi l ter desi gn functi ons. Suppose you
want a bandpass fi l ter wi th a passband from 1000 to 2000 Hz, stopbands
starti ng 500 Hz away on ei ther si de, a 10 kHz sampl i ng frequency, at most 1 dB
Filter Type Order Estimation Function
Butterworth [n,Wn] = buttord(Wp,Ws,Rp,Rs)
Chebyshev type I [n,Wn] = cheb1ord(Wp, Ws, Rp, Rs)
Chebyshev type I I [n,Wn] = cheb2ord(Wp, Ws, Rp, Rs)
El l i pti c [n,Wn] = ellipord(Wp, Ws, Rp, Rs)
2 Filter Design
2-8
of passband ri ppl e, and at l east 60 dB of stopband attenuati on. To meet these
speci fi cati ons wi th the butter functi on.
[n,Wn] = buttord([1000 2000]/5000,[500 2500]/5000,1,60)
n =
12
Wn =
0.1951 0.4080
[b,a] = butter(n,Wn);
An el l i pti c fi l ter that meets the same requi rements i s gi ven 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);
These functi ons al so work wi th the other standard band confi gurati ons, as wel l
as for anal og fi l ters; see Chapter 6 for detai l s.
Comparison of Classical IIR Filter Types
The tool box provi des fi ve di fferent types of cl assi cal I I R fi l ters, each opti mal i n
some way. Thi s secti on shows the basi c anal og prototype form for each and
summari zes major characteri sti cs.
Butterworth Filter
The Butterworth fi l ter provi des the best Tayl or Seri es approxi mati on to the
i deal l owpass fi l ter r esponse at =0 and =; for any order N, the magni tude
squared response has 2N1 zero deri vati ves at these l ocati ons (maximallyflat
IIR Filter Design
2-9
at = 0 and = ). Response i s monotoni c overal l , decreasi ng smoothl y from
= 0 to = . | H(j)| = sqrt(1/2) at = 1.
Chebyshev Type I Filter
The Chebyshev type I fi l ter mi ni mi zes the absol ute di fference between the
i deal and actual frequency response over the enti re passband by i ncorporati ng
an equal ri ppl e of Rp dB i n the passband. Stopband response i s maxi mal l y fl at.
The transi ti on from passband to stopband i s more rapi d than for the
Butterworth fi l ter. | H(j)| = 10
-Rp/20
at = 1.
10
-1
10
0
10
1
0
0.2
0.4
0.6
0.8
1
Frequency(rad/sec)
M
a
g
n
i
t
u
d
e
10
-1
10
0
10
1
0
0.2
0.4
0.6
0.8
1
Frequency(rad/sec)
M
a
g
n
i
t
u
d
e
2 Filter Design
2-10
Chebyshev Type II Filter
The Chebyshev type I I fi l ter mi ni mi zes the absol ute di fference between the
i deal and actual frequency response over the enti re stopband, by i ncorporati ng
an equal ri ppl e of Rs dB i n the stopband. Passband response i s maxi mal l y fl at.
The stopband does not approach zero as qui ckl y as the type I fi l ter (and does
not approach zero at al l for even-val ued n). The absence of ri ppl e i n the
passband, however, i s often an i mportant advantage. | H(j)| = 10
-Rs/20
at
= 1.
Elliptic Filter
El l i pti c fi l ters are equi ri ppl e i n both the passband and stopband. They
general l y meet fi l ter requi rements wi th the l owest order of any supported fi l ter
type. Gi ven a fi l ter order n, passband ri ppl e Rp i n deci bel s, and stopband ri ppl e
10
-1
10
0
10
1
0
0.2
0.4
0.6
0.8
1
Frequency(rad/sec)
M
a
g
n
i
t
u
d
e
IIR Filter Design
2-11
Rs i n deci bel s, el l i pti c fi l ters mi ni mi ze transi ti on wi dth. | H(j)| = 10
-Rp/20
at
= 1.
Bessel Filter
Anal og Bessel l owpass fi l ters have maxi mal l y fl at group del ay at zero
frequency and retai n nearl y constant group del ay across the enti re passband.
Fi l tered si gnal s therefore mai ntai n thei r waveshapes i n the passband
frequency range. Frequency mapped and di gi tal Bessel fi l ters, however, do not
have thi s maxi mal l y fl at property; thi s tool box supports onl y the anal og case
for the compl ete Bessel fi l ter desi gn functi on.
10
-1
10
0
10
1
0
0.2
0.4
0.6
0.8
1
Frequency(rad/sec)
M
a
g
n
i
t
u
d
e
2 Filter Design
2-12
Bessel fi l ters general l y requi re a hi gher fi l ter order than other fi l ters for
sati sfactory stopband attenuati on. | H(j)| < at =1 and decreases as n
i ncreases.
NOTE The l owpass fi l ter s shown above wer e cr eated wi th the anal og
prototype functi ons besselap, buttap, cheb1ap, cheb2ap, and ellipap. These
functi ons fi nd the zeros, pol es, and gai n of an order n anal og fi l ter of the
appropri ate type wi th cutoff frequency of 1 rad/sec. The compl ete fi l ter desi gn
functi ons (besself, butter, cheby1, cheby2, and ellip) cal l the pr ototypi ng
functi ons as a fi rst step i n the desi gn process. See Speci al Topi cs i n I I R Fi l ter
Desi gn on page 2-37 for detai l s.
To create si mi l ar pl ots, use n = 5 and, as needed, Rp = 0.5 and Rs = 20. For
exampl e, to create the el l i pti c fi l ter pl ot:
[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
1 2
10
-1
10
0
10
1
0
0.2
0.4
0.6
0.8
1
Frequency(rad/sec)
M
a
g
n
i
t
u
d
e
IIR Filter Design
2-13
Direct IIR Filter Design
Thi s tool box uses the term direct methods to descri be techni ques for I I R desi gn
that fi nd a fi l ter based on speci fi cati ons i n the di screte domai n. Unl i ke the
anal og prototypi ng method, di rect desi gn methods are not constrai ned to the
standard l owpass, hi ghpass, bandpass, or bandstop confi gurati ons. Rather,
these functi ons desi gn fi l ters wi th an arbi trary, perhaps mul ti band, frequency
response. Thi s secti on di scusses the yulewalk functi on, whi ch i s i ntended
speci fi cal l y for fi l ter desi gn; Parametri c Model i ng i n Chapter 4 di scusses
other methods that may al so be consi dered di rect, such as Pronys method,
Li near Predi cti on, the Stei gl i tz-McBri de method, and i nverse frequency
desi gn.
yulewalk desi gns recursi ve I I R di gi tal fi l ters by fi tti ng a speci fi ed frequency
response. yulewalks name refl ects i ts method for fi ndi ng the fi l ters
denomi nator coeffi ci ents: i t fi nds the i nverse FFT of the i deal desi red power
spectrum and sol ves the modi fi ed Yul e-Wal ker equati ons usi ng the resul ti ng
autocorrel ati on functi on sampl es. The statement
[b,a] = yulewalk(n,f,m)
returns row vectors b and a contai ni ng the n+1 numerator and denomi nator
coeffi ci ents of the order n I I R fi l ter whose frequency-magni tude characteri sti cs
approxi mate those gi ven i n vectors f and m. f i s a vector of frequency poi nts
rangi ng from 0 to 1, where 1 represents the Nyqui st frequency. m i s a vector
contai ni ng the desi red magni tude response at the poi nts i n f. f and m can
descri be any pi ecewi se l i near shape magni tude response, i ncl udi ng a
mul ti band response. The FI R counterpart of thi s functi on i s fir2, whi ch al so
desi gns a fi l ter based on an arbi trary pi ecewi se l i near magni tude response. See
FI R Fi l ter Desi gn on page 2-16 for detai l s.
Note that yulewalk does not accept phase i nformati on, and no statements are
made about the opti mal i ty of the resul ti ng fi l ter.
2 Filter Design
2-14
Desi gn a mul ti band fi l ter wi th yulewalk, and pl ot the desi red and actual
frequency response.
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))
Generalized Butterworth Filter Design
The tool box functi on maxflat enabl es you to desi gn general i zed Butterworth
fi l ters, that i s, Butterworth fi l ters wi th di fferi ng numbers of zeros and pol es.
Thi s i s desi rabl e i n some i mpl ementati ons where pol es are more expensi ve
computati onal l y than zeros. maxflat i s just l i ke the butter functi on, except
that i t you can speci fy twoorders (one for the numerator and one for the
denomi nator) i nstead of just one. These fi l ters are maximallyflat. Thi s means
that the resul ti ng fi l ter i s opti mal for any numerator and denomi nator orders,
wi th the maxi mum number of deri vati ves at 0 and the Nyqui st frequency =
both set to 0.
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
0
0.2
0.4
0.6
0.8
1
1.2
IIR Filter Design
2-15
For exampl e, when the two orders are the same, maxflat i s the same as 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
However, maxflat i s more versati l e, because you can desi gn a fi l ter wi th more
zeros than pol es.
[b,a] = maxflat(3,1,0.25)
b =
0.0950 0.2849 0.2849 0.0950
a =
1.0000 -0.2402
The thi rd i nput to maxfl at i s the half-power frequency, a frequency between
0 and 1 wi th a desi red magni tude response of .
You can al so desi gn l i near phase fi l ters that have the maxi mal l y fl at property
usi ng the 'sym' opti on.
maxflat(4,'sym',0.3)
ans =
0.0331 0.2500 0.4337 0.2500 0.0331
For compl ete detai l s of the maxflat al gori thm, see Sel esni ck and Burrus [2].
1 2
2 Filter Design
2-16
FIR Filter Design
Di gi tal fi l ters wi th fi ni te-durati on i mpul se response (al l -zero, or FI R fi l ters)
have both advantages and di sadvantages compared to i nfi ni te-durati on
i mpul se response (I I R) fi l ters.
FI R fi l ters have the fol l owi ng pri mary advantages:
They can have exactl y l i near phase.
They are al ways stabl e.
The desi gn methods are general l y l i near.
They can be real i zed effi ci entl y i n hardware.
The fi l ter startup transi ents have fi ni te durati on.
The pri mary di sadvantage of FI R fi l ters i s that they often requi re a much
hi gher fi l ter order than I I R fi l ters to achi eve a gi ven l evel of performance.
Correspondi ngl y, the del ay of these fi l ters i s often much greater than for an
equal performance I I R fi l ter.
Method Description Functions
Wi ndowi ng Appl y wi ndow to truncated
i nverse Fouri er transform of
desi red bri ckwal l fi l ter
fir1,fir2,kaiserord
Mul ti band
wi th
Transi ti on
Bands
Equi ri ppl e or l east squares
appr oach over sub-bands of the
frequency range
firls,remez,remezord
Constrai ned
Least
Squares
Mi ni mi ze squared i ntegral
error over enti re frequency
range subject to maxi mum
error constrai nts
fircls,fircls1
FIR Filter Design
2-17
Linear Phase Filters
Except for cremez, al l of the FI R fi l ter desi gn functi ons desi gn l i near phase
fi l ters onl y. The fi l ter coeffi ci ents, or taps, of such fi l ters obey ei ther an even
or odd symmetry rel ati on. Dependi ng on thi s symmetry, and on whether the
order n of the fi l ter i s even or odd, a l i near phase fi l ter (stor ed i n l ength n+1
vector b) has certai n i nherent restri cti ons on i ts frequency response.
The phase del ay and group del ay of l i near phase FI R fi l ters are equal and
constant over the frequency band. For an order n l i near phase FI R fi l ter, the
group del ay i s n/2, and the fi l tered si gnal i s si mpl y del ayed by n/2 ti me steps
(and the magni tude of i ts Fouri er transform i s scal ed by the fi l ters magni tude
response). Thi s property preserves the wave shape of si gnal s i n the passband,
that i s, there i s no phase di storti on.
The functi ons fir1, fir2, firls, remez, fircls, fircls1, and firrcos al l
desi gn type I and I I l i near phase FI R fi l ters by defaul t. Both firls and remez
desi gn type I I I and I V l i near phase FI R fi l ters gi ven a 'hilbert' or
'differentiator' fl ag. cremez can desi gn any type of l i near phase fi l ter, and
nonl i near phase fi l ters as wel l .
Arbi trary
Response
Arbi trary responses, i ncl udi ng
nonl i near phase and compl ex
fi l ters
cremez
Rai sed
Cosi ne
Lowpass response wi th
smooth, si nusoi dal transi ti on
firrcos
Method Description Functions
Linear
Phase
Filter Type
Filter
Order n Symmetry of Coefficients
Response H(f),
f = 0
Response H(f),
f = 1 (Nyquist)
Type I Even even: No restri cti on No restri cti on
Type I I Odd No restri cti on H(1) = 0
Type I I I Even odd: H(0) = 0 H(1) = 0
Type I V Odd H(0) = 0 No restri cti on
b k ( ) b n 2 k + ( ) k 1 = n 1 + , , , =
b k ( ) b n 2 k + ( ) k 1 = n 1 + , , , =
2 Filter Design
2-18
NOTE Because the frequency response of a type I I fi l ter i s zero at the Nyqui st
rate (hi gh frequency), fir1 does not desi gn type I I hi ghpass and bandstop
fi l ters. For odd-val ued n i n these cases, fir1 adds 1 to the order and returns a
type I fi l ter.
Windowing Method
Consi der the i deal , or bri ck-wal l , di gi tal l owpass fi l ter wi th a cutoff frequency
of
0
rad/sec. Thi s fi l ter has magni tude 1 at al l frequenci es wi th magni tude l ess
than
0
, and magni tude 0 at frequenci es wi th magni tude between
0
and . I ts
i mpul se response sequence h(n) i s
Thi s fi l ter i s not i mpl ementabl e si nce i ts i mpul se response i s i nfi ni te and
noncausal . To create a fi ni te-durati on i mpul se response, truncate i t by
appl yi ng a wi ndow. By retai ni ng the central secti on of i mpul se response i n thi s
truncati on, you obtai n a l i near phase FI R fi l ter. For exampl e, a l ength 51 fi l ter
wi th a l owpass cutoff frequency
0
of 0.4 rad/sec i s
b = 0.4*sinc(0.4*(25:25));
The wi ndow appl i ed here i s a si mpl e rectangul ar or boxcar wi ndow. By
Par seval s theor em, thi s i s the l ength 51 fi l ter that best appr oxi mates the i deal
h n ( )
1
2
------ H ( )e
j n
d

1
2
------ e
j n
d

------ -si nc

------ -n ( ) = = =
FIR Filter Design
2-19
l owpass fi l ter, i n the i ntegrated l east squares sense. To vi ew i ts frequency
response:
[H,w] = freqz(b,1,512,2);
plot(w,abs(H)), grid
Note the ri ngi ng and ri ppl es i n the response, especi al l y near the band edge.
Thi s Gi bbs effect does not vani sh as the fi l ter l ength i ncreases, but a
nonrectangul ar wi ndow reduces i ts magni tude. Mul ti pl i cati on by a wi ndow i n
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
0
0.2
0.4
0.6
0.8
1
1.2
Truncated Sinc Lowpass FIR Filter
Normalized Frequency (Nyquist == 1)
M
a
g
n
i
t
u
d
e

R
e
s
p
o
n
s
e
2 Filter Design
2-20
the ti me domai n causes a convol uti on or smoothi ng i n the frequency domai n.
Appl y a l ength 51 Hammi ng wi ndow to the fi l ter.
b = b.*hamming(51)';
[H,w] = freqz(b,1,512,2);
plot(w,abs(H)), grid
As you can see, thi s greatl y reduces the ri ngi ng. Thi s i mprovement i s at the
expense of transi ti on wi dth (the wi ndowed versi on takes l onger to ramp from
passband to stopband) and opti mal i ty (the wi ndowed versi on does not
mi ni mi ze the i ntegrated squared error).
The functi ons fir1 and fir2 are based on thi s wi ndowi ng process. Gi ven a
fi l ter order and descri pti on of an i deal desi red fi l ter, these functi ons return a
wi ndowed i nverse Fouri er transform of that i deal fi l ter. Both use a Hammi ng
wi ndow by defaul t, but they accept any wi ndow functi on. See the Wi ndows
secti on of Chapter 4 for an overvi ew of wi ndows and thei r properti es.
Standard Band FIR Filter Design: fir1
fir1 i mpl ements the cl assi cal method of wi ndowed l i near phase FI R di gi tal
fi l ter desi gn. I t resembl es the I I R fi l ter desi gn functi ons i n that i t i s formul ated
to desi gn fi l ters i n standard band confi gurati ons: l owpass, bandpass, hi ghpass,
and bandstop.
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
0
0.2
0.4
0.6
0.8
1
1.2
Normalized Frequency (Nyquist == 1)
M
a
g
n
i
t
u
d
e

R
e
s
p
o
n
s
e
Hamming Windowed Truncated SINC LP FIR Filter
FIR Filter Design
2-21
The statements
n = 50;
Wn = 0.4;
b = fir1(n,Wn);
create row vector b contai ni ng the coeffi ci ents of the order n
Hammi ng-wi ndowed fi l ter. Thi s i s a l owpass, l i near phase FI R fi l ter wi th cutoff
frequency Wn. Wn i s a number between 0 and 1, where 1 corresponds to the
Nyqui st frequency, hal f the sampl i ng frequency. (Unl i ke other methods, here
Wn corresponds to the 6 dB poi nt.) For a hi ghpass fi l ter, si mpl y append the
stri ng 'high' to the functi ons parameter l i st. For a bandpass or bandstop
fi l ter, speci fy Wn as a two-el ement vector contai ni ng the passband edge
frequenci es; append the stri ng 'stop' for the bandstop confi gurati on.
b = fir1(n,Wn,window) uses the wi ndow speci fi ed i n col umn vector window for
the desi gn. The vector window must be n+1 el ements l ong. I f you do not speci fy
a wi ndow, fir1 appl i es a Hammi ng wi ndow.
Kaiser Window Order Estimation. The kaiserord functi on esti mates the fi l ter
order, cutoff frequency, and Kai ser wi ndow beta parameter needed to meet a
gi ven set of speci fi cati ons. Gi ven a vector of frequency band edges and a
correspondi ng vector of magni tudes, as wel l as maxi mum al l owabl e ri ppl e,
kaiserord returns appropri ate i nput parameters for the fir1 functi on. For
detai l s on kaiserord, see the reference descri pti on i n Chapter 6.
Multiband FIR Filter Design: fir2
The functi on fir2 al so desi gns wi ndowed FI R fi l ters, but wi th an arbi trari l y
shaped pi ecewi se l i near frequency response. Thi s i s i n contrast to fir1, whi ch
onl y desi gns fi l ters i n standard l owpass, hi ghpass, bandpass, and bandstop
confi gurati ons.
The commands
n = 50;
f = [0 .4 .5 1];
m = [1 1 0 0];
b = fir2(n,f,m);
return row vector b contai ni ng the n+1 coeffi ci ents of the order n FI R fi l ter
whose frequency-magni tude characteri sti cs match those gi ven by vectors f and
m. f i s a vector of frequency poi nts rangi ng from 0 to 1, where 1 represents the
2 Filter Design
2-22
Nyqui st frequency. m i s a vector contai ni ng the desi red magni tude response at
the poi nts speci fi ed i n f. (The I I R counterpart of thi s functi on i s yulewalk,
whi ch al so desi gns fi l ters based on arbi trary pi ecewi se l i near magni tude
responses. See I I R Fi l ter Desi gn for detai l s.)
Multiband FIR Filter Design with Transition Bands
The firls and remez functi ons provi de a more general means of speci fyi ng the
i deal desi red fi l ter than the fir1 and fir2 functi ons. These functi ons desi gn
Hi l bert transformers, di fferenti ators, and other fi l ters wi th odd symmetri c
coeffi ci ents (type I I I and type I V l i near phase). They al so l et you i ncl ude
transi ti on or dont care regi ons i n whi ch the error i s not mi ni mi zed, and
perform band dependent wei ghti ng of the mi ni mi zati on.
firls i s an extensi on of the fir1 and fir2 functi ons i n that i t mi ni mi zes the
i ntegral of the square of the error between the desi red frequency response and
the actual frequency response.
remez i mpl ements the Parks-McCl el l an al gori thm, whi ch uses the Remez
exchange al gori thm and Chebyshev approxi mati on theory to desi gn fi l ters wi th
opti mal fi ts between the desi red and actual frequency responses. The fi l ters are
opti mal i n the sense that they mi ni mi ze the maxi mum error between the
desi red frequency response and the actual frequency response; they are
someti mes cal l ed minimax fi l ters. Fi l ters desi gned i n thi s way exhi bi t an
equi ri ppl e behavi or i n thei r frequency response, and hence are al so known as
equiripplefi l ters. The Parks-McCl el l an FI R fi l ter desi gn al gori thm i s perhaps
the most popul ar and wi del y used FI R fi l ter desi gn methodol ogy.
The syntax for firls and remez i s the same; the onl y di fference i s thei r
mi ni mi zati on schemes. The next exampl e shows how fi l ters desi gned wi th
firls and remez refl ect these di fferent schemes.
Basic Configurations
The defaul t mode of oper ati on of firls and remez i s to desi gn type I or type I I
l i near phase fi l ters, dependi ng on whether the order you desi re i s even or odd,
respecti vel y. A l owpass exampl e wi th approxi mate ampl i tude 1 from 0 to 0.4
Hz, and approxi mate ampl i tude 0 from 0.5 to 1.0 Hz i s
n = 20; % filter order
f = [0 .4 .5 1]; % frequency band edges
a = [1 1 0 0]; % desired amplitudes
b = remez(n,f,a);
FIR Filter Design
2-23
From 0.4 to 0.5 Hz, remez performs no error mi ni mi zati on; thi s i s a transi ti on
band or dont care regi on. A transi ti on band mi ni mi zes the error more i n the
bands that you do car e about, at the expense of a sl ower tr ansi ti on rate. I n thi s
way, these types of fi l ter s have an i nher ent tr ade-off si mi l ar to FI R desi gn by
wi ndowi ng.
To compare l east squares to equi ri ppl e fi l ter desi gn, use firls to create a
si mi l ar fi l ter.
bb = firls(n,f,a);
and compare thei r frequency responses:
[H,w]=freqz(b);
[HH,w]=freqz(bb);
plot(w/pi,abs(H),w/pi,abs(HH),'--'), grid
You can see that the fi l ter desi gned wi th remez exhi bi ts equi ri ppl e behavi or.
Al so note that the firls fi l ter has a better r esponse over most of the passband
and stopband, but at the band edges (f = 0.4 and f = 0.5), the response i s
further away from the i deal than the remez fi l ter. Thi s shows that the remez
fi l ters maximumerror over the pass- and stopbands i s smal l er and, i n fact, i t
i s the smal l est possi bl e for thi s band edge confi gurati on and fi l ter l ength.
Thi nk of frequency bands as l i nes over short frequency i nterval s. remez and
firls use thi s scheme to represent any pi ecewi se l i near desi red functi on wi th
10
-1
10
0
10
1
0
0.2
0.4
0.6
0.8
1
Frequency(rad/sec)
M
a
g
n
i
t
u
d
e
2 Filter Design
2-24
any transi ti on bands. firls and remez desi gn l owpass, hi ghpass, bandpass,
and bandstop fi l ters; a bandpass exampl e i s
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
Techni cal l y, these f and a vector s defi ne fi ve bands:
Two stopbands, from 0.0 to 0.3 and from 0.8 to 1.0
A passband from 0.4 to 0.7
Two transi ti on bands, from 0.3 to 0.4 and from 0.7 to 0.8
Exampl e hi ghpass and bandstop fi l ters are
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 exampl e mul ti band bandpass fi l ter i s
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];
Another possi bi l i ty i s a fi l ter that has as a transi ti on regi on the l i ne connecti ng
the passband wi th the stopband; thi s can hel p control runaway magni tude
response i n wi de tr ansi ti on r egi ons:
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
Both firls and remez al l ow you to pl ace more or l ess emphasi s on mi ni mi zi ng
the error i n certai n frequency bands rel ati ve to others. To do thi s, speci fy a
wei ght vector fol l owi ng the frequency and ampl i tude vectors. An exampl e
FIR Filter Design
2-25
l owpass equi ri ppl e fi l ter wi th 10 ti mes l ess ri ppl e i n the stopband than the
passband i s
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 l egal wei ght vector i s al ways hal f the l ength of the f and a vectors; there must
be exactl y one wei ght per band.
Anti-Symmetric Filters / Hilbert Transformers
When cal l ed wi th a trai l i ng 'h' or 'Hilbert' opti on, remez and firls desi gn
FI R fi l ters wi th odd symmetry, that i s, type I I I (for even order) or type I V (for
odd order) l i near phase fi l ters. An i deal Hi l bert transformer has thi s
anti -symmetry property and an ampl i tude of 1 across the enti re frequency
range. Try the fol l owi ng approxi mate Hi l bert transformers:
b = remez(21,[0.05 1],[1 1],'h'); % highpass Hilbert
bb = remez(20,[0.05 0.95],[1 1],'h'); % bandpass Hilbert
You can fi nd the del ayed Hi l bert transform of a si gnal x by passi ng i t through
these fi l ters:
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
0 0.25 0.5 0.75 1
0
0.2
0.4
0.6
0.8
1
Frequency (Normalized)

Bandpass Hilbert
0 0.25 0.5 0.75 1
0
0.2
0.4
0.6
0.8
1
Frequency (Normalized)
Highpass Hilbert
2 Filter Design
2-26
The anal yti c si gnal correspondi ng to x i s the compl ex si gnal that has x as i ts
real part and the Hi l bert transform of x as i ts i magi nary part. For thi s FI R
method (an al ternati ve to the hilbert functi on), you must del ay x by hal f the
fi l ter order to create the anal yti c si gnal .
xd = [zeros(10,1); x(1:length(x)10)]; % delay 10 samples
xa = xd + j*xh; % analytic signal
Thi s method does not work di rectl y for fi l ters of odd order, whi ch requi re a
noni nteger del ay. I n thi s case, the hilbert functi on, descri bed i n the
Speci al i zed Transforms secti on i n Chapter 4, esti mates the anal yti c si gnal .
Al ternati vel y, use the resample functi on to del ay the si gnal by a noni nteger
number of sampl es.
Differentiators
Di fferenti ati on of a si gnal i n the ti me domai n i s equi val ent to mul ti pl i cati on of
the si gnal s Fouri er transform by an i magi nary ramp functi on. That i s, to
di fferenti ate a si gnal , pass i t through a fi l ter that has a response H(w) = jw.
Approxi mate the i deal di fferenti ator (wi th a del ay) usi ng remez or firls wi th
a 'd' or 'differentiator' opti on.
b = remez(21,[0 1],[0 pi*Fs],'d');
To obtai n the correct deri vati ve, scal e by pi*Fs rad/sec, where Fs i s the
sampl i ng frequency i n Hertz. For a type I I I fi l ter, the di fferenti ati on band
shoul d stop short of the Nyqui st frequency, and the ampl i tude vector must
refl ect that change to ensure the correct sl ope.
bb = remez(20,[0 0.9],[0 0.9*pi*Fs],'d');
I n the 'd' mode, remez wei ghts the error by 1/wi n nonzero ampl i tude bands to
mi ni mi ze the maxi mum relativeerror. firls wei ghts the error by (1/w)
2
i n
nonzero ampl i tude bands i n the 'd' mode.
FIR Filter Design
2-27
The magni tude response pl ots for the di fferenti ators shown above are
Constrained Least Squares FIR Filter Design
The Constrai ned Least Squares (CLS) FI R fi l ter desi gn functi ons i mpl ement a
techni que that enabl es you to desi gn FI R fi l ters wi thout expl i ci tl y defi ni ng the
transi ti on bands for the magni tude response. The abi l i ty to omi t the
speci fi cati on of transi ti on bands i s useful i n several si tuati ons. For exampl e, i t
may not be cl ear where a ri gi dl y defi ned transi ti on band shoul d appear i f noi se
and si gnal i nformati on appear together i n the same frequency band. Si mi l arl y,
i t may make sense to omi t the speci fi cati on of transi ti on bands i f they appear
onl y to control the resul ts of Gi bbs phenomena that appear i n the fi l ters
response. See Sel esni ck, Lang, and Burrus [2] for di scussi on of thi s method.
I nstead of defi ni ng passbands, stopbands, and transi ti on regi ons, the CLS
method accepts a cutoff frequency (for the hi ghpass, l owpass, bandpass, or
bandstop cases), or passband and stopband edges (for mul ti band cases), for the
desi red response. I n thi s way, the CLS method defi nes transi ti on regi ons
i mpl i ci tl y, rather than expl i ci tl y.
The key feature of the CLS method i s that i t enabl es you to defi ne upper and
l ower threshol ds that contai n the maxi mum al l owabl e ri ppl e i n the magni tude
response. Gi ven thi s constrai nt, the techni que appl i es the l east square error
mi ni mi zati on techni que over the frequency range of the fi l ters response,
i nstead of over speci fi c bands. The error mi ni mi zati on i ncl udes any areas of
di sconti nui ty i n the i deal , bri ck wal l response. An addi ti onal benefi t i s that
0 100 200 300 400 500
0
500
1000
1500
2000
2500
3000
3500
Differentiator, odd order
Frequency (Normalized)
0 100 200 300 400 500
0
500
1000
1500
2000
2500
3000
3500
Differentiator, even order
Frequency (Normalized)
2 Filter Design
2-28
the techni que enabl es you to speci fy arbi trari l y smal l peaks resul ti ng from
Gi bbs phenomena.
There are two tool box functi ons that i mpl ement thi s desi gn techni que.
For detai l s on the cal l i ng syntax for these functi ons, see thei r reference
descri pti ons i n Chapter 6.
Basic Lowpass and Highpass CLS Filter Design
The most basi c of the CLS desi gn functi ons, fircls1, uses thi s techni que to
desi gn l owpass and hi ghpass FI R fi l ters. As an exampl e, consi der desi gni ng a
fi l ter wi th order 61 i mpul se response and cutoff frequency of 0.3 (normal i zed).
Further, defi ne the upper and l ower bounds that constrai n the desi gn process
as:
Maxi mum passband devi ati on from 1 (passband ri ppl e) of 0.02.
Maxi mum stopband devi ati on from 0 (stopband ri ppl e) of 0.008.
Description Function
Constrai ned l east square mul ti band FI R fi l ter desi gn. fircls
Constrai ned l east square fi l ter desi gn for l owpass and
hi ghpass l i near phase fi l ters
fircls1
0
ds = 0.008
1
dp = 0.02
FIR Filter Design
2-29
To approach thi s desi gn probl em usi ng fircls1
n = 61;
wo = 0.3;
dp = 0.02;
ds = 0.008;
h = fircls1(n,wo,dp,ds,'plot');
Multiband CLS Filter Design
fircls uses the same techni que to desi gn FI R fi l ters wi th a desi red pi ecewi se
constant magni tude response. I n thi s case, you can speci fy a vector of band
edges and a correspondi ng vector of band ampl i tudes. I n addi ti on, you can
speci fy the maxi mum amount of ri ppl e for each band.
For exampl e, assume the speci fi cati ons for a fi l ter cal l for:
From 0 to 0.3 (normal i zed): ampl i tude 0, upper bound 0.005, l ower
bound -0.005
From 0.3 to 0.5: ampl i tude 0.5, upper bound 0.51, l ower bound 0.49
From 0.5 to 0.7: ampl i tude 0, upper bound 0.03, l ower bound -0.03
From 0.7 to 0.9: ampl i tude 1, upper bound 1.02, l ower bound 0.98
From 0.9 to 1: ampl i tude 0, upper bound 0.05, l ower bound -0.05
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-0.2
0
0.2
0.4
0.6
0.8
1
2 Filter Design
2-30
Desi gn a CLS fi l ter wi th i mpul se response or der 129 that meets these
speci fi cati ons.
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');
Weighted CLS Filter Design
Wei ghted CLS fi l ter desi gn l ets you desi gn l owpass or hi ghpass FI R fi l ters wi th
rel ati ve wei ghti ng of the error mi ni mi zati on i n each band. The fircls1
functi on enabl es you to speci fy the passband and stopband edges for the l east
squares wei ghti ng functi on, as wel l as a constant k that speci fi es the rati o of
the stopband to passband wei ghti ng.
For exampl e, consi der speci fi cati ons that cal l for an FI R fi l ter wi th i mpul se
response order of 55 and cutoff frequency of 0.3 (normal i zed). Al so assume
maxi mum al l owabl e passband ri ppl e of 0.02 and maxi mum al l owabl e stopband
ri ppl e of 0.004. I n addi ti on, add wei ghti ng requi rements:
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-0.2
0
0.2
0.4
0.6
0.8
1
1.2
FIR Filter Design
2-31
Passband edge for the wei ght functi on of 0.28 (normal i zed)
Stopband edge for the wei ght functi on of 0.32
Wei ght error mi ni mi zati on 10 ti mes as much i n the stopband as i n the
passband
To approach thi s usi ng 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');
Arbitrary-Response Filter Design
The cremez fi l ter desi gn functi on provi des a tool for desi gni ng FI R fi l ters wi th
arbi trary compl ex responses. I t di ffers from the other fi l ter desi gn functi ons i n
how the frequency response of the fi l ter i s speci fi ed: i t accepts the name of a
functi on whi ch returns the fi l ter response cal cul ated over a gri d of frequenci es.
Thi s capabi l i ty makes cremez a hi ghl y ver sati l e and powerful techni que for
fi l ter desi gn.
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-0.2
0
0.2
0.4
0.6
0.8
1
2 Filter Design
2-32
Thi s desi gn techni que may be used to produce nonl i near-phase FI R fi l ters,
asymmetri c frequency-response fi l ters (wi th compl ex coeffi ci ents), or more
symmetri c fi l ters wi th custom frequency responses.
The desi gn al gori thm opti mi zes the Chebyshev (or mi ni max) error usi ng an
extended Remez-exchange al gori thm for an i ni ti al esti mate. I f thi s exchange
method fai l s to obtai n the opti mal fi l ter, the al gori thm swi tches to an
ascent-descent al gori thm that takes over to fi ni sh the convergence to the
opti mal sol uti on.
For detai l s on the cal l i ng syntax for cremez, see the reference descri pti on i n
Chapter 6.
Multiband Filter Design
Consi der a mul ti band fi l ter wi th the fol l owi ng speci al frequency-domai n
characteri sti cs:
A l i near-phase mul ti band fi l ter may be desi gned usi ng the predefi ned
frequency-response functi on multiband, as fol l ows.
b = cremez(38, [1 0.5 0.4 0.3 0.4 0.8], ...
{multiband, [5 1 2 2 2 1]}, [1 10 5]);
For the speci fi c case of a mul ti band fi l ter, we can use a shorthand fi l ter desi gn
notati on si mi l ar to the syntax 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 wi th remez, a vector of band edges i s passed to cremez. Thi s vector defi nes
the frequency bands over whi ch opti mi zati on i s performed; note that there are
two transi ti on bands, from -0.5 to -0.4 and from 0.3 to 0.4.
Band Amplitude Optimization
Weighting
[-1 -0.5] [5 1] 1
[-0.4 +0.3] [2 2] 10
[+0.4 +0.8] [2 1] 5
FIR Filter Design
2-33
I n ei ther case, the frequency response i s obtai ned and pl otted usi ng l i near
scal e.
[h,w] = freqz(b,1,512,whole);
plot(w/pi1,fftshift(abs(h)));
Note that the frequency response has been cal cul ated over the enti re
normal i zed frequency range [-1 +1] by passi ng the opti on 'whole' to freqz. I n
order to pl ot the negati ve frequency i nformati on i n a natural way, the response
has been wrapped, just as FFT data i s, usi ng fftshift.
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
1
1.5
2
2.5
3
3.5
4
4.5
5
Normalized Frequency
M
a
g
n
i
t
u
d
e

R
e
s
p
o
n
s
e
2 Filter Design
2-34
The fi l ter response for thi s mul ti band fi l ter i s compl ex, whi ch i s expected
because of the asymmetry i n the frequency domai n. The fi l ter response i s
Filter Design with Reduced Delay
Consi der the desi gn of a 62-tap l owpass fi l ter wi th a hal f-Nyqui st cutoff. I f we
speci fy a negati ve offset val ue to the lowpass fi l ter desi gn functi on, the group
del ay offset for the desi gn i s si gni fi cantl y l ess than that obtai ned for a standard
l i near -phase desi gn. Thi s fi l ter desi gn may be computed as fol l ows.
b = cremez(61, [0 0.5 0.55 1], {'lowpass', 16});
0 5 10 15 20 25 30 35 40
-0.5
0
0.5
1
1.5
2
2.5
R
e
a
l

P
a
r
t
0 5 10 15 20 25 30 35 40
-0.2
0
0.2
I
m
a
g

P
a
r
t
FIR Filter Design
2-35
The resul ti ng magni tude response i s
[h,w] = freqz(b,1,512,'whole');
plot(w/pi1,fftshift(abs(h)));
The group del ay of the fi l ter reveal s that the offset has been reduced from
N/2=30.5 to N/216=14.5. Now, however, the group del ay i s no l onger fl at i n
the passband regi on (pl otted over the normal i zed frequency range 0 to 0.5 for
cl ari ty).
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
1.2
1.4
Normalized Frequency
M
a
g
n
i
t
u
d
e

R
e
s
p
o
n
s
e
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5
12
13
14
15
16
17
Normalized frequency (Nyquist == 1)
G
r
o
u
p

d
e
l
a
y

(
i
n

s
a
m
p
l
e
s
)
2 Filter Design
2-36
I f we compare thi s nonl i near-phase fi l ter to a l i near-phase fi l ter that has
exactl y 14.5 sampl es of group del ay, the resul ti ng fi l ter i s of order 2*14.5 or 29.
Usi ng b = cremez(29,[0 0.5 0.55 1],'lowpass'), the passband and
stopband ri ppl e i s much greater for the order 29 fi l ter. These compari sons can
assi st you i n deci di ng whi ch fi l ter i s more appropri ate for a speci fi c appl i cati on.
Special Topics in IIR Filter Design
2-37
Special Topics in IIR Filter Design
The cl assi c I I R fi l ter desi gn techni que fi nds an anal og l owpass fi l ter wi th cutoff
frequency of 1, transl ates thi s prototype fi l ter to the desi red band
confi gurati on, then transforms the fi l ter to the di gi tal domai n. The tool box
provi des functi ons for each step of thi s process.
The butter, cheby1, cheby2, and ellip functi ons are suffi ci ent for many
desi gn probl ems, and the l ower l evel functi ons are general l y not needed. But i f
you do have an appl i cati on where you need to transform the band edges of an
anal og fi l ter, or di screti ze a rati onal transfer functi on, thi s secti on descri bes
tool s to do so.
Classical IIR Filter Design
Analog Lowpass Prototype Creation Frequency Transformation Discretization
buttap
ellipap
cheb1ap
cheb2ap
besselap lp2lp
lp2bp
lp2hp
lp2bs
bilinear
impinvar
butter cheby1 cheby2 ellip besself
Minimum Order Computation for Classical IIR Filter Design
buttord cheb1ord cheb2ord ellipord
Complete Design
2 Filter Design
2-38
Analog Prototype Design
Thi s tool box provi des a number of functi ons to create l owpass anal og prototype
fi l ters wi th cutoff frequency of 1, the fi rst step i n the cl assi cal approach to I I R
fi l ter desi gn. The tabl e bel ow summari zes the anal og prototype desi gn
functi ons for each supported fi l ter type; pl ots for each type are shown i n the
I I R Fi l ter Desi gn secti on above.
Frequency Transformation
The second step i n the anal og prototypi ng desi gn techni que i s the frequency
transfor mati on of a l owpass prototype. The tool box pr ovi des a set of functi ons
to tr ansfor m anal og l owpass prototypes (wi th cutoff fr equency of 1 rad/sec) i nto
bandpass, hi ghpass, bandstop, and l owpass fi l ters of the desi red cutoff
frequency.
Filter Type Analog Prototype Function
Bessel [z,p,k] = besselap(n)
Butterworth [z,p,k] = buttap(n)
Chebyshev type I [z,p,k] = cheb1ap(n,Rp)
Chebyshev type I I [z,p,k] = cheb2ap(n,Rs)
El l i pti c [z,p,k] = ellipap(n,Rp,Rs)
Special Topics in IIR Filter Design
2-39
As shown, al l of the frequency transformati on functi ons can accept two l i near
system model s: transfer functi on and state-space form. For the bandpass and
bandstop cases
and
where
1
i s the l ower band edge and
2
i s the upper band edge.
The frequency transformati on functi ons perform frequency vari abl e
substi tuti on. I n the case of lp2bp and lp2bs, thi s i s a second-order
substi tuti on, so the output fi l ter i s twi ce the order of the i nput. For lp2lp and
lp2hp, the output fi l ter i s the same order as the i nput.
Freq. Transformation Transformation Function
Lowpass to l owpass [numt,dent] = lp2lp(num,den,Wo)
[At,Bt,Ct,Dt] = lp2lp(A,B,C,D,Wo)
Lowpass to hi ghpass [numt,dent] = lp2hp(num,den,Wo)
[At,Bt,Ct,Dt] = lp2hp(A,B,C,D,Wo)
Lowpass to bandpass [numt,dent] = lp2bp(num,den,Wo,Bw)
[At,Bt,Ct,Dt] = lp2bp(A,B,C,D,Wo,Bw)
Lowpass to bandstop [numt,dent] = lp2bs(num,den,Wo,Bw)
[At,Bt,Ct,Dt] = lp2bs(A,B,C,D,Wo,Bw)
s' s
0
=
s'

0
s
------ - =
s'

0
B

-------
s
0
( )
2
1 +
s
0

------------------------------- =
s'
B

0
-------
s
0

s
0
( )
2
1 +
------------------------------- =

0

1

2
=
B


2

1
=
2 Filter Design
2-40
To begi n desi gni ng an order 10 bandpass Chebyshev type I fi l ter wi th a val ue
of 3 dB for passband ri ppl e
[z,p,k] = cheb1ap(5,3);
z, p, and k contai n the pol es, zeros, and gai n of a l owpass anal og fi l ter wi th
cutoff frequency
c
equal to 1 rad/sec. Use the lp2bp functi on to transform thi s
l owpass prototype to a bandpass anal og fi l ter wi th band edges W
1
= /5 and
W
2
= . Fi rst, convert the fi l ter to state-space form so the lp2bp functi on can
accept i t.
[A,B,C,D] = zp2ss(z,p,k); % Convert to statespace form.
Now, fi nd the bandwi dth and center frequency, and cal l lp2bp.
u1 = 0.1*2*pi; u2 = 0.5*2*pi; % in radians per second
Bw = u2u1;
Wo = sqrt(u1*u2);
[At,Bt,Ct,Dt] = lp2bp(A,B,C,D,Wo,Bw);
Special Topics in IIR Filter Design
2-41
Fi nal l y, cal cul ate the frequency response and pl ot i ts magni tude.
[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.
Filter Discretization
The thi rd step i n the anal og prototypi ng techni que i s the transformati on of the
fi l ter to the di screte-ti me domai n. The tool box provi des two methods for thi s:
the i mpul se i nvari ant and bi l i near transformati ons. The fi l ter desi gn functi ons
pi/5 pi
10
-7
10
-6
10
-5
10
-4
10
-3
10
-2
10
-1
10
0
Frequency (rad/sec)
2 Filter Design
2-42
butter, cheby1, cheby2, and ellip use the bi l i near transformati on for
di screti zati on i n thi s step.
Impulse Invariance
The tool box functi on impinvar creates a di gi tal fi l ter whose i mpul se response
i s the sampl es of the conti nuous i mpul se response of an anal og fi l ter. Thi s
functi on works onl y on fi l ters i n transfer functi on form. For best resul ts, the
anal og fi l ter shoul d have negl i gi bl e frequency content above hal f the sampl i ng
frequency, because such hi gh frequency content i s al i ased i nto l ower bands
upon sampl i ng. I mpul se i nvari ance works for some l owpass and bandpass
fi l ters, but i s not appropri ate for hi ghpass and bandstop fi l ters.
Analog to Digital
Transformation
Transformation Function
I mpul se i nvari ance [numd,dend] = impinvar(num,den,Fs)
Bi l i near transform [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)
Special Topics in IIR Filter Design
2-43
Desi gn a Chebyshev type I fi l ter and pl ot i ts frequency response.
[bz,az] = impinvar(b,a,2);
freqz(bz,az)
I mpul se i nvari ance retai ns the cutoff frequenci es of 0.1 Hz and 0.5 Hz.
Bilinear Transformation
The bi l i near transformati on i s a nonl i near mappi ng of the conti nuous domai n
to the di screte domai n; i t maps the s-pl ane i nto the z-pl ane by
Bi l i near transformati on maps the j axi s of the conti nuous domai n to the uni t
ci rcl e of the di screte domai n accordi ng to
The tool box functi on bilinear i mpl ements thi s operati on, where the frequency
warpi ng constant k i s equal to twi ce the sampl i ng frequency (2*Fs) by defaul t
and equal to 2*pi*Fp/tan(pi*Fp/Fs) i f you gi ve bilinear a trai l i ng argument
that represents a match frequency Fp. I f a match frequency Fp (i n Hertz) i s
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-800
-600
-400
-200
0
200
Normalized frequency (Nyquist == 1)
P
h
a
s
e

(
d
e
g
r
e
e
s
)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-150
-100
-50
0
Normalized frequency (Nyquist == 1)
M
a
g
n
i
t
u
d
e

R
e
s
p
o
n
s
e

(
d
B
)
H z ( ) H s ( )
s k
z 1
z 1 +
------------ =
=
2tan
1

k
----
,
_
=
2 Filter Design
2-44
present, bilinear maps the frequency =2f
p
(i n radi ans/second) to the same
frequency i n the di screte domai n, normal i zed to the sampl i ng rate: = 2f
p
/ f
s
(al so i n radi ans/second).
The bilinear functi on can perform thi s transformati on on three di fferent
l i near system representati ons: zero-pol e-gai n, transfer functi on, and
state-space form. Try cal l i ng bilinear wi th the state-space matri ces that
descri be the Chebyshev type I fi l ter from the previ ous secti on, usi ng a sampl i ng
frequency of 2 Hz, and retai ni ng the l ower band edge of 0.1 Hz.
[Ad,Bd,Cd,Dd] = bilinear(At,Bt,Ct,Dt,2,0.1);
The frequency response of the resul ti ng di gi tal fi l ter i s
[bz,az] = ss2tf(Ad,Bd,Cd,Dd); % convert to TF
freqz(bz,az)
The l ower band edge i s at 0.1 Hz as expected. Noti ce, however, that the upper
band edge i s sl i ghtl y l ess than 0.5 Hz, al though i n the anal og domai n i t was
exactl y 0.5 Hz. Thi s i l l ustrates the nonl i near nature of the bi l i near
transformati on. To counteract thi s nonl i neari ty, i t i s necessary to create anal og
domai n fi l ters wi th prewarped band edges, whi ch map to the correct l ocati ons
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-1000
-500
0
500
Normalized frequency (Nyquist == 1)
P
h
a
s
e

(
d
e
g
r
e
e
s
)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-300
-200
-100
0
Normalized frequency (Nyquist == 1)
M
a
g
n
i
t
u
d
e

R
e
s
p
o
n
s
e

(
d
B
)
Special Topics in IIR Filter Design
2-45
upon bi l i near transformati on. Here the prewarped frequenci es u1 and u2
generate Bw and Wo for the lp2bp functi on.
Fs = 2; % sampling frequency (Hertz)
u1 = 2*Fs*tan(.1*(2*pi/Fs)/2); % lower band edge (radians/second)
u2 = 2*Fs*tan(.5*(2*pi/Fs)/2); % upper band edge (radians/second)
Bw = u2u1; % bandwidth
Wo = sqrt(u1*u2); % center frequency
[At,Bt,Ct,Dt] = lp2bp(A,B,C,D,Wo,Bw);
A di gi tal bandpass fi l ter wi th correct band edges 0.1 and 0.5 ti mes the Nyqui st
frequency i s
[Ad,Bd,Cd,Dd] = bilinear(At,Bt,Ct,Dt,Fs);
The exampl e bandpass fi l ters from the l ast two secti ons coul d al so be created
i n one statement usi ng the compl ete I I R desi gn functi on cheby1. For i nstance,
an anal og versi on of the exampl e Chebyshev fi l ter i s
[b,a] = cheby1(5,3,[0.1 0.5]*2*pi,'s');
Note that the band edges are i n radi ans/second for anal og fi l ters, whereas for
the di gi tal case, frequency i s normal i zed (the Nyqui st frequency i s equal to 1
Hz).
[bz,az] = cheby1(5,3,[0.1 0.5]);
Al l of the compl ete desi gn functi ons cal l bilinear i nternal l y. They prewarp the
band edges as needed to obtai n the correct di gi tal fi l ter. See Chapter 6 for more
on these functi ons.
2 Filter Design
2-46
References
1 Karam, L.J., and J.H. McCl el l an. Compl ex Chebyshev Approxi mati on for
FI R Fi l ter Desi gn. I EEE Trans. on Circuits and Systems I I . March 1995.
2 Sel esni ck, I .W., and C.S. Burrus. General i zed Di gi tal Butterworth Fi l ter
Desi gn. Proceedings of theI EEE I nt. Conf. Acoust., Speech, Signal
Processing. Vol . 3 (May 1996).
3 Sel esni ck, I .W., M. Lang, and C.S. Burrus. Constrai ned Least Square
Desi gn of FI R Fi l ters wi thout Speci fi ed Transi ti on Bands. Proceedings of
theI EEE I nt. Conf. Acoust., Speech, Signal Processing. Vol . 2 (May 1995).
Pgs. 1260-1263.
3
Stati sti cal Si gnal
Processi ng
Correlation and Covariance . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2
Bi as and Normal i zati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3
Mul ti pl e Channel s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4
Spectral Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5
Wel chs Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6
Mul ti taper Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-16
Yul e-Wal ker AR Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-19
Burg Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-20
Covari ance and Modi fi ed Covari ance Methods . . . . . . . . . . . . . 3-22
MUSI C and Ei genvector Anal ysi s Methods . . . . . . . . . . . . . . . 3-23
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-27
3 Statistical Signal Processing
3-2
Correlation and Covariance
The Si gnal Processi ng Tool box provi des tool s for esti mati ng i mportant
functi ons of random si gnal s. I n parti cul ar, there are tool s to esti mate
correl ati on and covari ance sequences and spectral densi ty functi ons of di screte
si gnal s. Thi s chapter expl ai ns the correl ati on and covari ance functi ons and
di scusses the mathemati cal l y rel ated functi ons for esti mati ng the power
spectrum.
The functi ons xcorr and xcov esti mate the cross-correl ati on and
cross-covari ance sequences of random processes. They al so handl e
autocorrel ati on and autocovari ance as speci al cases.
The true cross-correl ati on sequence i s a stati sti cal quanti ty defi ned as
where x
n
and y
n
are stati onary random processes, - , and E{}i s the
expected val ue operator. The cross-covari ance sequence i s the mean-removed
cross-correl ati on sequence
or, i n terms of the cross-correl ati on,
I n practi ce, you must esti mate these sequences, because i t i s possi bl e to access
onl y a fi ni te segment of the i nfi ni te-l ength random process. A common esti mate
based on N sampl es of x
n
and y
n
i s the determi ni sti c cross-correl ati on sequence
(al so cal l ed the ti me-ambi gui ty functi on)

xy
m ( ) E{x
n
y
*
n m +
} =
n < <
C
xy
m ( ) E{ x
n

x
( ) y
*
n m +

*
x
( )} =
C
xy
m ( )
xy
m ( )
x

*
y
=
R

xy m ( )
x
n
y
n m +
*
n 0 =
N m 1

m 0
R

yx
*
m ( ) m 0 <

'

=
Correlation and Covariance
3-3
where we assume for thi s di scussi on that x
n
and y
n
are i ndexed from 0 to N-1,
and from -(N-1) to N-1. The xcorr functi on eval uates thi s sum wi th
an effi ci ent FFT-based al gori thm, gi ven i nputs x
n
and y
n
stored i n l ength N
vectors x and y. I ts oper ati on i s equi val ent to convol uti on wi th one of the two
subsequences reversed i n ti me.
For exampl e,
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
Noti ce that the resul ti ng sequence i s twi ce the l ength of the i nput sequence
mi nus 1. Thus, the Nth el ement i s the correl ati on at l ag 0. Al so noti ce the
tri angul ar pul se of the output that resul ts when convol vi ng two square pul ses.
The xcov functi on esti mates autocovari ance and cross-covari ance sequences.
Thi s functi on has the same opti ons and eval uates the same sum as xcorr, but
fi rst removes the means of x and y.
Bias and Normalization
An esti mate of a quanti ty i s biased i f i ts expected val ue i s not equal to the
quanti ty i t esti mates. The expected val ue of the output of xcorr i s
R

yx
*
m ( )
E{R

xy m ( )} E{x
n
y
*
n m +
}
n 0 =
N m 1

N m ( )
xy
m ( ) = =
3 Statistical Signal Processing
3-4
xcorr provi des the unbi ased esti mate, di vi di ng by N-| m| , when you speci fy an
'unbiased' fl ag after the i nput sequences.
xcorr(x,y,'unbiased')
Al though thi s esti mate i s unbi ased, the end poi nts (near -(N-1) and N-1) suffer
from l arge vari ance because xcorr computes them usi ng onl y a few data poi nts.
A possi bl e trade-off i s to si mpl y di vi de by N usi ng the 'biased' fl ag.
xcorr(x,y,'biased')
Wi th thi s scheme, onl y the sampl e of the correl ati on at 0 l ag (the Nth output
el ement) i s unbi ased. Thi s esti mate i s often more desi rabl e than the unbi ased
one because i t avoi ds random l arge vari ati ons at the end poi nts of the
correl ati on sequence.
xcorr pr ovi des one other nor mal i zati on scheme. The syntax
xcorr(x,y,'coeff')
di vi des the output by norm(x)*norm(y) so that, for autocorrel ati ons, the
sampl e at 0 l ag i s 1.
Multiple Channels
For a mul ti channel si gnal , xcorr and xcov esti mate the autocorrel ati on and
cross-correl ati on and covari ance sequences for al l of the channel s at once. I f S
i s an M-by-N si gnal matri x representi ng N channel s i n i ts col umns, xcorr(S)
returns a (2M-1)-by-N
2
matri x wi th the autocorrel ati ons and cross-correl ati ons
of the channel s of S i n i ts N
2
col umns. I f S i s a 3-channel si gnal
S = [s1 s2 s3]
then the resul t of xcorr(S) i s organi zed as
R = [Rs1s1 Rs1s2 Rs1s3 Rs2s1 Rs2s2 Rs2s3 Rs3s1 Rs3s2 Rs3s3]
Two rel ated functi ons, cov and corrcoef, are avai l abl e i n the standard
MATLAB envi ronment. They esti mate covari ance and normal i zed covari ance
respecti vel y between the di fferent channel s at l ag 0 and arrange them i n a
square matri x.
Spectral Analysis
3-5
Spectral Analysis
Spectral anal ysi s seeks to descri be the frequency content of a si gnal , random
process, or system, based on a fi ni te set of data. Esti mati on of power spectra i s
useful i n a vari ety of appl i cati ons, i ncl udi ng the detecti on of si gnal s buri ed i n
wi de-band noi se.
The power spectral density (PSD) of a stati onary random process x
n
i s rel ated
mathemati cal l y to the correl ati on sequence by the di screte-ti me Fouri er
transform,
Thi s functi on of frequency has the property that i ts i ntegral over a frequency
band i s equal to the power of the si gnal x
n
i n that band.
The PSD i s a speci al case of the cross spectral density (CSD) functi on, defi ned
between two si gnal s x
n
and y
n
as
As i s the case for the correl ati on and covari ance sequences, the tool box
estimates the PSD and CSD because si gnal l engths are fi ni te.
The vari ous methods of PSD esti mati on can be i denti fi ed as parametric or
nonparametric. One techni que offered i n the Si gnal Processi ng Tool box i s the
popul ar nonparametri c scheme devel oped by Wel ch [5]. Thi s i s compl emented
by more modern nonparametri c techni ques such as the multitaper method
(MTM) and the multiplesignal classification (MUSI C) or eigenvector (EV)
method, whi ch i s wel l sui ted for l i ne spectra (data made up of si nusoi ds). The
Yule-Walker autoregressive(AR) methodi s a parametri c method that esti mates
the autocorrel ati on functi on to sol ve for the AR model parameters. The Burg
method i s another parametri c spectral esti mati on method that mi ni mi zes the
forward and backward l i near predi cti on errors whi l e sati sfyi ng the
Levi nson-Durbi n recursi on. These methods are l i sted i n the tabl e bel ow wi th
the correspondi ng tool box functi on name. The number bel ow each method
name i ndi cates the page that descri bes the method i n greater detai l . See
P
xx
( )
xx
m ( )e
j m
m =

=
P
xy
( )
xy
m ( )e
j m
m =

=
3 Statistical Signal Processing
3-6
Parametri c Model i ng i n Chapter 4 for detai l s about lpc and other parametri c
esti mati on functi ons.
Welchs Method
One way of esti mati ng the power spectrum of a process i s to si mpl y fi nd the
di screte-ti me Fouri er transform of the sampl es of the process (usual l y done on
Method Description Functions
Burg
(3-20)
Autoregressi ve (AR) spectral
esti mati on of a ti me-ser i es by
mi ni mi zati on of l i near predi cti on
errors
pburg
Covari ance
(3-22)
Autoregressi ve (AR) spectral
esti mati on of a ti me-ser i es by
mi ni mi zati on of the forward
predi cti on errors
pcov
Modi fi ed
Covari ance
(3-22)
Autoregressi ve (AR) spectral
esti mati on of a ti me-ser i es by
mi ni mi zati on of the forward and
backward predi cti on errors
pmcov
Mul ti taper
(3-16)
Spectral esti mate from combi nati on
of mul ti pl e orthogonal wi ndows (or
tapers)
pmtm
MUSI C
(3-23)
Mul ti pl e si gnal cl assi fi cati on or
ei genvector method
pmusic
Wel ch
(3-6)
Averaged peri odograms of
overl apped, wi ndowed si gnal secti ons
pwelch, csd,
tfe, cohere
Yul e-Wal ker AR
(3-19)
Autoregressi ve (AR) spectral
esti mate of a ti me-seri es from i ts
esti mated autocorrel ati on functi on
pyulear
Spectral Analysis
3-7
a gri d wi th an FFT) and take the magni tude squared of the resul t. An exampl e
1001-el ement si gnal xn, whi ch consi sts of two si nusoi ds pl us noi se, i s gi ven 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 crude esti mate of the PSD of xn i s
Pxx = abs(fft(xn,1024)).^2/1001;
Thi s esti mate i s cal l ed the periodogram. Scal e the magni tude squared of the
FFTby the square of the norm of the data wi ndow appl i ed to the si gnal (i n thi s
case, a l ength 1001 rectangul ar wi ndow) to ensure that the esti mate i s
asymptoticallyunbiased. That i s, as the number of sampl es i ncreases, the
expected val ue of the peri odogram approaches the true PSD.
The probl em wi th the peri odogram esti mate i s that i ts vari ance i s l arge (on the
order of the PSD squared) and does not decrease as the number of sampl es
i ncreases. The fol l owi ng two exampl es show thi s; as FFTl ength i ncreases, the
peri odogram does not become smoother.
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))
Reduce the vari ance of the PSD esti mate by breaki ng the si gnal i nto
nonoverl appi ng secti ons and averagi ng the peri odograms of these secti ons.
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))
0 100 200 300 400 500 600 700 800 900 1000
-10
-5
0
5
10
15
20
25
Frequency (Hz)
P
o
w
e
r

S
p
e
c
t
r
u
m

(
d
B
)
Averaged Periodogram (no overlap)
3 Statistical Signal Processing
3-8
Thi s averaged esti mate has one thi rd the vari ance of the l ength 256
peri odogram shown earl i er. The more secti ons you average, the l ower the
vari ance of the resul t. However, the si gnal l ength l i mi ts the number of secti ons
0 100 200 300 400 500 600 700 800 900 1000
-20
-10
0
10
20
30
Frequency (Hz)
P
o
w
e
r

S
p
e
c
t
r
u
m

(
d
B
)
Short Periodogram
0 100 200 300 400 500 600 700 800 900 1000
-30
-20
-10
0
10
20
30
Frequency (Hz)
P
o
w
e
r

S
p
e
c
t
r
u
m

(
d
B
)
Periodogram
Spectral Analysis
3-9
possi bl e (to three secti ons of l ength 256 i n the previ ous exampl e). To obtai n
more secti ons, break the si gnal i nto overl appi ng secti ons.
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))
I n thi s case the secti ons are stati sti cal l y dependent, resul ti ng i n hi gher
vari ance; thus there i s a trade-off between the number of secti ons and the
over l ap rate.
Another way to i mprove the peri odogram esti mate i s to appl y a nonrectangul ar
data wi ndow to the secti ons before computi ng the peri odogram, resul ti ng i n a
modified periodogram. Thi s reduces the effect of secti on dependence due to
overl ap, because the wi ndow i s tapered to 0 on the edges. Al so, a
nonrectangul ar wi ndow di mi ni shes the si de-l obe i nterference or spectral
l eakage whi l e i ncreasi ng the wi dth of spectral peaks. Wi th a sui tabl e wi ndow
(such as Hammi ng, Hanni ng, or Kai ser), overl ap rates of about hal f the secti on
l ength have been found to l ower the vari ance of the esti mate si gni fi cantl y.
0 100 200 300 400 500 600 700 800 900 1000
-10
-5
0
5
10
15
20
25
Frequency (Hz)
P
o
w
e
r

S
p
e
c
t
r
u
m

(
d
B
)
Averaged Periodogram (128 sample overlap)
3 Statistical Signal Processing
3-10
The appl i cati on of a Hanni ng wi ndow resul ts i n
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))
Noti ce i n thi s pl ot that the spectral peaks have wi dened, and the noisefloor, or
l evel of the noi se, seems to be the fl attest of any esti mate so far. Thi s method
of averaged, modi fi ed peri odograms i s Wel chs method of PSD esti mati on.
The functi ons pwelch and csd pr ovi de contr ol over al l the parameter s di scussed
so far (FFTl ength, wi ndow, and amount of overl ap) i n computi ng the PSD and
CSD of si gnal s usi ng Wel chs method.
For a more detai l ed di scussi on of Wel chs method of PSD esti mati on, see
Kay [1] and Wel ch [5].
Power Spectral Density Function
The pwelch functi on averages and scal es the modi fi ed peri odograms of secti ons
of a si gnal . Si mpl y speci fy the parameters that control the al gori thm as
arguments to the functi on.
An esti mate for the PSD of a sequence xn usi ng pwelchs defaul t FFT l ength
(256), wi ndow (Hanni ng of l ength 256), and overl ap sampl es (none) i s
Pxx = pwelch(xn);
0 100 200 300 400 500 600 700 800 900 1000
-10
-5
0
5
10
15
20
25
Frequency (Hz)
P
o
w
e
r

S
p
e
c
t
r
u
m

(
d
B
)
Averaged Modified Periodogram (128 sample overlap, Hanning window)
Spectral Analysis
3-11
Pxx has uni ts of power per uni t frequency i nterval . For exampl e, i f the ori gi nal
sequence xn has uni ts of vol ts, Pxx has uni ts of Watts/Hz.
To recreate the l ast exampl e accuratel y, speci fy 128 as the number of sampl es
to overl ap:
nfft = 256; % length of FFT
window = hanning(256); % window function
noverlap = 128; % number of samples overlap
Pxx = pwelch(xn,nfft,Fs,window,noverlap);
Pxx i s scal ed by the reci procal of the sampl i ng frequency, 1/Fs. pwelch wi thout
any outputs generates a pl ot of the PSD over the frequency range [0,Fs/2):
pwelch(xn,nfft,Fs,window,noverlap)
I f you want to pl ot the PSD yoursel f, obtai n the frequency vector through an
addi ti onal output argument.
[Pxx,f] = pwelch(xn,nfft,Fs,256,noverlap);
plot(f,10*log10(Pxx))
Al l the spectral esti mati on functi ons al l ow you to speci fy an empty matri x, [],
i n pl ace of an i nput argument to use the defaul t val ue of that argument. I n the
command above, because the val ues for nfft and window are actual l y the same
as the defaul ts, you coul d repl ace them both wi th the empty matri x.
[Pxx,f] = pwelch(xn,[],Fs,[],noverlap);
0 50 100 150 200 250 300 350 400 450 500
40
35
30
25
20
15
10
5
Welchs Spectral Estimate P
xx
(f) / f
s
Frequency (Hz)
P
o
w
e
r

S
p
e
c
t
r
a
l

D
e
n
s
i
t
y

(
d
B
)
3 Statistical Signal Processing
3-12
Si nce the si gnal xn i s real , pwelch returns onl y the frequenci es from 0 through
the Nyqui st frequency. I n contrast, the earl i er FFT exampl e generated PSD
esti mates rangi ng from 0 through Fs.
Bias and Normalization in Welchs Method
I n studyi ng the output of pwelch shown earl i er, several reveal i ng
characteri sti cs about the si gnal xn are evi dent. The noi se fl oor i s fl at at 0
deci bel s (dB), i mpl yi ng whi te noi se of vari ance 1. Furthermore, the si gnal
part of xn i s concentrated i n two peaks at 50 and 120 Hz. The rel ati on of the
peak hei ghts i s meani ngful . For i nstance, the 50 Hz peak i s 6 dB bel ow the 120
Hz peak, veri fyi ng that the hi gher frequency si nusoi d has twi ce the magni tude
as the l ower (10
6/20
= 2.0). Unl i ke the rel ati ve hei ghts, the actual hei ght of the
peaks does not tel l us much about the ori gi nal ampl i tude of the si nusoi ds
wi thout addi ti onal anal ysi s.
To obtai n useful i nformati on about the peak ampl i tudes of the underl yi ng
si nusoi ds, note that the expected val ue of the esti mated PSD i s
Because the expected val ue i s not equal to the true PSD, the esti mate i s biased.
Thi s quanti ty i s the convol uti on of the true PSD wi th the squared magni tude
of the wi ndows di screte-ti me Fouri er transform W(), scal ed by the squared
norm of the wi ndow. The scal i ng factor i s the sum of the squares of the wi ndow
functi on:
Thi s says that i f P
xx
() has a peak of hei ght 1 at a parti cul ar frequency
0
, the
esti mate wi l l have approxi mate hei ght at that frequency,
provi ded the wi ndow W() i s narrow wi th respect to the spaci ng between the
peak and other spectral features. So, to obtai n an esti mate whi ch on average
refl ects the hei ght of the ori gi nal peaks, mul ti pl y the resul t of pwelch by
E P

xx ( ) { }
1
2 w
2
------------------- P
xx
( ) W ( ) d

=
w
2
w n ( )
2

=
W 0 ( )
2
w
2

Spectral Analysis
3-13
norm(w)^2/sum(w)^2, where w i s the wi ndow vector. Thi s scal i ng i s
i ndependent of wi ndow l ength and shape. For exampl e:
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
I n both pl ots, whi ch show the spectrum at posi ti ve frequenci es onl y (the
negati ve frequenci es are the same), the hi gher frequency peak has a val ue of 0
dB, and the l ower frequency peak i s at -6 dB. The 120 Hz si nusoi d hei ght of 0
dB corresponds to a squared ampl i tude of 1. Thi s resul ts from the si nusoi d of
ampl i tude 2 havi ng compl ex exponenti al components of ampl i tude 1 at both
posi ti ve and negati ve frequency. Si mi l arl y, the 50 Hz si nusoi d has both
posi ti ve and negati ve frequency components wi th squared ampl i tude of
( )
2
= , or 10*l og10(.25) = -6 dB, as shown i n the pl ot. Al so, note that the
second pl ot refl ects a sl i ghtl y l ower noi se fl oor, whi ch i s the resul t of a l onger
wi ndow l ength.
0 100 200 300 400 500
70
60
50
40
30
20
0 100 200 300 400 500
70
60
50
40
30
20
3 Statistical Signal Processing
3-14
Cross-Spectral Density Function
To esti mate the cross-spectral densi ty of two equal l ength si gnal s x and y usi ng
Wel chs method, the csd functi on forms the peri odogram as the product of the
FFT of x and the conjugate of the FFT of y. Unl i ke the real -val ued PSD, the
CSD i s a compl ex functi on. csd handl es the secti oni ng and wi ndowi ng of x and
y i n the same way as the pwelch functi on.
Pxy = csd(x,y,nfft,Fs,window,noverlap)
Confidence Intervals
Both the pwelch and csd functi ons can compute confi dence i nterval s. Si mpl y
provi de an i nput argument p, whi ch speci fi es the percentage of the confi dence
i nterval .
[Pxx,Pxxc,f] = pwelch(x,nfft,Fs,window,noverlap,p)
[Pxy,Pxyc,f] = csd(x,y,nfft,Fs,window,noverlap,p)
p must be a scal ar between 0 and 1. The functi ons assume chi -squared
di stri buted peri odograms of nonoverl appi ng secti ons i n computi ng the
confi dence i nterval s. (Thi s assumpti on i s val i d when the si gnal i s a Gaussi an
di stri buted random process.) Provi ded these assumpti ons are correct, there i s
a p*100% probabi l i ty that the confi dence i nterval
[PxxPxxc(:,1) Pxx+Pxxc(:,2)]
covers the true PSD. I f the secti ons overl ap, the confi dence i nterval i s not
rel i abl e and the functi ons di spl ay a warni ng message.
Transfer Function Estimate
One appl i cati on of Wel chs method i s nonparametri c system i denti fi cati on.
Assume that H i s a l i near, ti me i nvari ant system, and x(n) and y(n) are the
i nput to and output of H, respecti vel y. Then the PSD of x(n) i s rel ated to the
CSD of x(n) and y(n) by
An esti mate of the transfer functi on between x(n) and y(n) i s
P
xy
( ) H ( )P
xx
( ) =
H

( )
P

xy ( )
P

xx ( )
----------------- =
Spectral Analysis
3-15
Thi s method esti mates both magni tude and phase i nformati on. The tfe
functi on uses Wel chs method to compute the CSD and PSD and then forms
thei r quoti ent for the transfer functi on esti mate. Use tfe the same way that
you use the csd functi on.
Fi l ter the si gnal xn wi th an FI R fi l ter, then pl ot the actual magni tude response
and the esti mated response.
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)');
Coherence Function
The magni tude-squared coherence between two si gnal s x(n) and y(n) i s
0 100 200 300 400 500
0
0.2
0.4
0.6
0.8
1
Actual Transfer Function Magnitude
0 100 200 300 400 500
0
0.2
0.4
0.6
0.8
1
Transfer Function Magnitude Estimate
Frequency (Hz)
C
xy
( )
P
xy
( )
2
P
xx
( )P
yy
( )
----------------------------------- =
3 Statistical Signal Processing
3-16
Thi s quoti ent i s a real number between 0 and 1 that measures the correl ati on
between x(n) and y(n) at the frequency .
The cohere functi on takes sequences x and y, computes thei r PSDs and CSD,
and returns the quoti ent of the magni tude squared of the CSD and the product
of the PSDs. I ts opti ons and operati on are si mi l ar to the csd and tfe functi ons.
The coherence functi on of xn and the fi l ter output yn versus frequency i s
cohere(xn,yn,256,Fs,256,128,'none')
I f the i nput sequence l ength, wi ndow l ength, and overl ap are such that cohere
operates on onl y a si ngl e record, the functi on returns al l ones.
Multitaper Method
The multitaper method (MTM) uses orthogonal wi ndows (or taper s) to obtai n
approxi matel y i ndependent esti mates of the power spectrum and then
combi nes them to yi el d an esti mate. Thi s esti mate exhi bi ts mor e degr ees of
freedom and al l ows for easi er quanti fi cati on of the bi as and vari ance trade-offs,
compared to conventi onal peri odogram methods. Many conventi onal spectral
esti mates use a si ngl e taper (or wi ndow), wi th some i rretri evabl e l oss of
i nformati on at the begi nni ng and the end of the seri es. I n the mul ti taper
method, addi ti onal tapers are used to recover some of the l ost i nformati on.
Thi s bri ef di scussi on of the mul ti taper method provi des an i ntui ti ve l ook at the
al gori thm to assi st i n determi ni ng when to use i t. For a more detai l ed and
thorough expl anati on, see Perci val and Wal den [3].
The si mpl e parameter for the mul ti taper method i s the ti me-bandwi dth
product, NW. Thi s parameter i s a resol uti on parameter di rectl y rel ated to the
number of tapers used to compute the spectrum. There are al ways 2*NW-1
tapers used to form the esti mate. Thi s means that, as NWi ncreases, there are
0 50 100 150 200 250 300 350 400 450 500
0
0.2
0.4
0.6
0.8
1
Frequency
C
o
h
e
r
e
n
c
e

F
u
n
c
t
i
o
n

E
s
t
i
m
a
t
e
Coherence Function
Spectral Analysis
3-17
more esti mates of the power spectrum, and the vari ance of the esti mate
decreases. However, the bandwi dth of each taper i s al so proporti onal to NW, so
as NWi ncreases, each esti mate exhi bi ts more spectral l eakage (i .e., wi der
peaks) and the overal l spectral esti mate i s more bi ased. For each data set,
there i s usual l y a val ue for NWthat al l ows an opti mal trade-off between bi as
and vari ance.
Usi ng pmtm on the data from the previ ous secti on, xn, yi el ds
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])
40 60 80 100 120 140
-20
-15
-10
-5
0
5
10
15
20
25
30
Frequency (Hz)
M
a
g
n
i
t
u
d
e

(
d
B
)
3 Statistical Signal Processing
3-18
By l oweri ng the ti me-bandwi dth product, the peaks become narrower.
[P1,f] = pmtm(xn,3/2,1024,Fs);
plot(f,10*log10(P1)) % plot in decibels
axis([30 150 20 30])
Note that the area under the peaks remai ns about the same, as can be seen
when both ar e pl otted together on a l i near scal e.
plot(f,[P P1])
axis([30 150 0 400])
40 60 80 100 120 140
-20
-15
-10
-5
0
5
10
15
20
25
30
Frequency (Hz)
M
a
g
n
i
t
u
d
e

(
d
B
)
40 60 80 100 120 140
0
50
100
150
200
250
300
350
400
Frequency (Hz)
M
a
g
n
i
t
u
d
e
Spectral Analysis
3-19
Thi s conservati on of total power i s veri fi abl e numeri cal l y.
sum(P)
ans =
1.8447e+03
sum(P1)
ans =
1.8699e+03
Note that total power i s onl y approxi matel y conserved i n thi s case. Thi s i s
because the adapti ve wei ghti ng procedure that i s used to mi ni mi ze l eakage
does not stri ctl y conserve total power.
Thi s method i s more expensi ve computati onal l y than Wel chs method, because
of the cost of computi ng the di screte prol ate spheroi dal sequences (DPSSs, al so
known as Sl epi an sequences). For l ong data seri es (10,000 poi nts or more), i t i s
useful to compute the DPSSs once and save them i n a MAT-fi l e. The M-fi l es
dpsssave, dpssload, dpssdir, and dpssclear are provi ded, to keep a database
of saved DPSSs i n the MAT-fi l e dpss.mat.
Yule-Walker AR Method
The Yule-Walker AR methodi s an autoregressi ve techni que for spectral densi ty
esti mati on (see Marpl e [2], Chapter 7, and Proaki s[4], Secti on 12.3.2). Thi s
method sol ves for the AR model parameters by the autocorrel ati on method.
The Yul e-Wal ker AR esti mate i s obtai ned by sol uti on of the normal equati ons.
Here, a = [1 a(2) ... a(n+1)] i s a vector of autoregressi ve coeffi ci ents, the
el ements of vector r = [r(1) r(2) ... r(n+1)] are correl ati ons, and the l eft-hand
si de autocorrel ati on matri x i s Hermi ti an Toepl i tz and posi ti ve defi ni te.
r 1 ( ) r 2 ( )
*
L r n ( )
*
r 2 ( ) r 1 ( ) L r n 1 ( )
*
M O O M
r n ( ) L r 2 ( ) r 1 ( )
a 2 ( )
a 3 ( )
M
a n 1 + ( )
r 2 ( )
r 3 ( )
M
r n 1 + ( )
=
3 Statistical Signal Processing
3-20
The spectral densi ty esti mate i s
where e(f) i s a compl ex si nusoi d.
The tool box functi on pyulear i mpl ements the Yul e-Wal ker AR method.
For exampl e, compare the spectrum of a speech si gnal usi ng Wel chs method
and the Yul e-Wal ker AR method:
load mtlb
[P1,f] = pwelch(mtlb,1024,Fs,256);
[P2,f] = pyulear(mtlb,14,1024,Fs); % 14th order model
plot(f,10*log10(P1),':',f,10*log10(P2)); grid
ylabel('Magnitude (dB)'); xlabel('Frequency (Hz)');
legend('Welch','YuleWalker AR')
The sol i d Yul e-Wal ker AR spectrum i s smoother than the peri odogram because
of the si mpl e underl yi ng al l -pol e model .
Burg Method
The Burg method for AR spectral esti mati on i s based on mi ni mi zi ng the
forward and backward predi cti on errors whi l e sati sfyi ng the Levi nson-Durbi n
recursi on (see Marpl e[2], Chapter 7, and Proaki s[4], Secti on 12.3.3). I n
contrast to other AR esti mati on methods, the Burg method avoi ds cal cul ati ng
P
YuleAR
f ( )
1
a
H
e f ( )
2
----------------------- =
0 500 1000 1500 2000 2500 3000 3500 4000
90
80
70
60
50
40
30
20
M
a
g
n
i
t
u
d
e

(
d
B
)
Frequency (Hz)
Welch
YuleWalker AR
Spectral Analysis
3-21
the autocorrel ati on functi on, and i nstead esti mates the refl ecti on coeffi ci ents
di rectl y.
The pri mary advantages of the Burg method are resol vi ng cl osel y spaced
si nusoi ds i n si gnal s wi th l ow noi se l evel s, and esti mati ng short data records, i n
whi ch case the AR power spectral densi ty esti mates are very cl ose to the true
val ues. I n addi ti on, the Burg method ensures a stabl e AR model and i s
computati onal l y effi ci ent.
The accuracy of the Burg method i s l ower for hi gh-order model s, l ong data
records, and hi gh si gnal -to-noi se rati os (whi ch can cause linesplitting, or the
generati on of extraneous peaks i n the spectrum esti mate). The spectral densi ty
esti mate computed by the Burg method i s al so suscepti bl e to frequency shi fts
(rel ati ve to the true frequency) resul ti ng from the i ni ti al phase of noi sy
si nusoi dal si gnal s. Thi s effect i s magni fi ed when anal yzi ng short data
sequences.
The tool box functi on pburg i mpl ements the Burg method. Compare the
spectrum of the speech si gnal gener ated by both the Bur g method and the
Yul e-Wal ker AR method. They are very si mi l ar for l arge si gnal l engths.
load mtlb
[P1,f] = pburg(mtlb(1:512),14,1024,Fs); % 14th order model
[P2,f] = pyulear(mtlb(1:512),14,1024,Fs); % 14th order model
plot(f,10*log10(P1),':',f,10*log10(P2)); grid
ylabel('Magnitude (dB)'); xlabel('Frequency (Hz)');
legend('Burg','YuleWalker AR')
0 500 1000 1500 2000 2500 3000 3500 4000
90
80
70
60
50
40
30
20
M
a
g
n
i
t
u
d
e

(
d
B
)
Frequency (Hz)
Burg
YuleWalker AR
3 Statistical Signal Processing
3-22
Compare the spectrum of a noi sy si gnal computed usi ng the Burg method and
the Wel ch method.
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')
Note that, as the model order for the Burg method i s reduced, a frequency shi ft
due to the i ni ti al phase of the si nusoi ds wi l l become apparent.
Covariance and Modified Covariance Methods
The covari ance method for AR spectral esti mati on i s based on mi ni mi zi ng the
forward predi cti on error. The modi fi ed covari ance method i s based on
mi ni mi zi ng the forward and backward predi cti on errors. The tool box functi ons
pcov and pmcov i mpl ement the respecti ve methods.
0 50 100 150 200
50
45
40
35
30
25
20
15
10
5
0
M
a
g
n
i
t
u
d
e

(
d
B
)
Frequency (Hz)
Welch
Burg
Spectral Analysis
3-23
Compare the spectrum of the speech si gnal generated by both the covari ance
method and the modi fi ed covari ance method. They are nearl y i denti cal , even
for a short si gnal l ength.
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')
MUSIC and Eigenvector Analysis Methods
The pmusic functi on pr ovi des two rel ated spectral anal ysi s methods:
The mul ti pl e si gnal cl assi fi cati on method (MUSI C) devel oped by Schmi dt
The ei genvector (EV) method devel oped by Johnson
See Marpl e [2] (pgs. 373-378) for a summary of these methods.
Both of these methods are frequency esti mator techni ques based on
ei genanal ysi s of the autocorrel ati on matri x. Thi s type of spectral anal ysi s
categori zes the i nformati on i n a correl ati on or data matri x, assi gni ng
i nformati on to ei ther a si gnal subspace or a noi se subspace.
0 500 1000 1500 2000 2500 3000 3500 4000
100
90
80
70
60
50
40
M
a
g
n
i
t
u
d
e

(
d
B
)
Frequency (Hz)
Covariance
Modified Covariance
3 Statistical Signal Processing
3-24
Eigenanalysis Overview
Consi der a number of compl ex si nusoi ds embedded i n whi te noi se. You can
wri te the autocorrel ati on matri x R for thi s system as the sum of the si gnal
autocorrel ati on matri x (S) and the noi se autocorrel ati on matri x (W).
There i s a cl ose rel ati onshi p between the ei genvectors of the si gnal
autocorrel ati on matri x and the si gnal and noi se subspaces. The ei genvectors v
of S span the same si gnal subspace as the si gnal vectors. I f the system contai ns
M compl ex si nusoi ds and the order of the autocorrel ati on matri x i s p,
ei genvectors v
M+1
through v
p+1
span the noi se subspace of the autocorrel ati on
matri x.
Frequency Estimator Functions. To generate thei r frequency esti mates,
ei genanal ysi s methods cal cul ate functi ons of the vectors i n the si gnal and noi se
subspaces. Both the MUSI C and EV techni ques choose a functi on that
theoreti cal l y goes to i nfi ni ty at one of the si nusoi dal frequenci es i n the i nput
si gnal . Usi ng di gi tal technol ogy, the resul ti ng esti mate has sharp peaks at the
frequenci es of i nterest; thi s means that there wont be i nfi ni ty val ues i n the
vectors.
The MUSI C esti mate i s gi ven by the formul a
where N i s the si ze of the ei genvectors and e(f) i s a compl ex si nusoi d vector:
v represents the ei genvectors of the i nput si gnal s correl ati on matri x; v
k
i s the
k
th
ei genvector. H i s the conjugate transpose operator. The ei genvectors used
i n the sum correspond to the smal l est ei genval ues and span the noi se subspace
(p i s the si ze of the si gnal subspace).
The expressi on i s equi val ent to a Fouri er transform (the vector e(f)
consi sts of compl ex exponenti al s). Thi s form i s useful for numeri c computati on
because the FFTcan be computed for each v
k
and then the squared magni tudes
can be summed.
R S W + =
P
music
f ( )
1
e
H
f ( ) v
k
v
k
H
k p 1 + =
N

,


_
e f ( )
----------------------------------------------------------------
1
v
k
H
e f ( )
2
k p 1 + =
N

------------------------------------------- = =
e f ( ) 1 exp j 2f ( ) exp j 2f 2 ( ) exp j 2f 4 ( ) exp j 2f n 1 ( ) ( ) [ ]
H
=
v
k
H
e f ( )
Spectral Analysis
3-25
The EV method wei ghts the summati on by the ei genval ues of the correl ati on
matri x:
The pmusic functi on i n thi s tool box uses the svd (si ngul ar val ue decomposi ti on)
functi on i n the si gnal case and the eig functi on for anal yzi ng the correl ati on
matri x and assi gni ng ei genvectors to the si gnal or noi se subspaces. When svd
i s used, pmusic never computes the correl ati on matri x expl i ci tl y, but the
si ngul ar val ues are the ei genval ues.
Controlling Subspace Thresholds
To provi de user control over the assi gnments of ei genvectors to the si gnal and
noi se subspaces, the pmusic functi on accepts a threshol d argument thresh.
thresh i s a two-el ement vector where the fi rst el ement i s the number of
ei genvectors spanni ng the si gnal subspace and the second el ement i s a
threshol d test:
I f thresh(2) 1, then thresh(1) speci fi es the number of ei genvectors
spanni ng the si gnal subspace. I n thi s case the val ues of thresh(1) must be
i n the range [0, N), where N i s:
- The col umn l ength of xR i f xR i s a data matri x
- The matri x si ze i f xR i s a correl ati on matri x
- The wi ndow l ength i f xR i s a si gnal vector
I f thresh(1) N, then thresh(2) i s a val ue greater than or equal to 1 that
speci fi es the absol ute threshol d for spl i tti ng the ei genval ues between the
si gnal and noi se subspaces. That i s, i f a gi ven ei genval ue i s l ess than or equal
to the product thresh(2)mi n{
k
}, then the gi ven ei genvector i s assi gned to
the noi se subspace.
I f thresh(1) < N and thresh(2) 1, thresh(1) sti l l speci fi es the maxi mum
number of ei genvectors i n the si gnal subspace. However, the threshol d test
speci fi ed by thresh(2) can al so assi gn ei genvectors to the noi se subspace.
I f thresh(1) N and thresh(2) < 1, there are no noi se ei genvectors. Thi s i s
an i nval i d case and pmusic generates an error.
P
ev
f ( )
1
v
k
H
e f ( )
2
k p 1 + =
N

,


_

----------------------------------------------------------- =
3 Statistical Signal Processing
3-26
For compl ete detai l s on usi ng the thresh parameter, see the reference
descri pti on of pmusic i n Chapter 6.
References
3-27
References
1 Kay, S.M. ModernSpectral Estimation. Engl ewood Cl i ffs, NJ: Prenti ce Hal l ,
1988.
2 Marpl e, S.L. Digital Spectral Analysis. Engl ewood Cl i ffs, NJ: Prenti ce Hal l ,
1987.
3 Perci val , D.B., and A.T. Wal den. Spectral Analysisfor Physical Applications:
Multitaper and Conventional UnivariateTechniques. Cambri dge:
Cambri dge Uni versi ty Press, 1993.
4 Proaki s, J.G., and D.G. Manol aki s. Digital Signal Processing: Principles,
Algorithms, and Applications. Engl ewood Cl i ffs, NJ: Prenti ce Hal l , 1996.
5 Wel ch, P.D. The Use of Fast Fouri er Transform for the Esti mati on of Power
Spectra: A Method Based on Ti me Averagi ng Over Short, Modi fi ed
Peri odograms. I EEE Trans. AudioElectroacoust. Vol . AU-15 (June 1967).
Pgs. 70-73.
3 Statistical Signal Processing
3-28
4
Speci al Topi cs
Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
Basi c Shapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
General i zed Cosi ne Wi ndows . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4
Kai ser Wi ndow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4
Chebyshev Wi ndow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-9
Parametric Modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10
Ti me-Domai n Based Model i ng . . . . . . . . . . . . . . . . . . . . . . . . . . 4-11
Frequency-Domai n Based Model i ng . . . . . . . . . . . . . . . . . . . . . 4-16
Resampling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-20
CepstrumAnalysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-23
I nverse Compl ex Cepstrum . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-25
FFT-Based Time-Frequency Analysis . . . . . . . . . . . . . . . . . 4-27
Median Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-28
Communications Applications . . . . . . . . . . . . . . . . . . . . . . . 4-29
Deconvolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-33
Specialized Transforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-34
Chi rp z-Transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-34
Di screte Cosi ne Transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-36
Hi l bert Transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-38
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-40
4 Special Topics
4-2
Windows
I n both di gi tal fi l ter desi gn and power spectrum esti mati on, the choi ce of a
wi ndowi ng functi on can pl ay an i mportant rol e i n determi ni ng the qual i ty of
overal l resul ts. The mai n rol e of the wi ndow i s to damp out the effects of the
Gi bbs phenomenon that resul ts from truncati on of an i nfi ni te seri es.
The tool box wi ndow functi ons ar e shown i n the tabl e bel ow.
Basic Shapes
The basi c wi ndow i s the rectangular window, a vector of ones of the appropri ate
l ength. A rectangul ar wi ndow of l ength 50 i s
n = 50;
w = boxcar(n);
Thi s tool box stores wi ndows i n col umn vectors by conventi on, so an equi val ent
expressi on i s
w = ones(50,1);
The Bartlett (or tri angul ar) windowi s the convol uti on of two rectangul ar
wi ndows. The functi ons bartlett and triang compute si mi l ar tri angul ar
wi ndows, wi th three i mportant di fferences. The bartlett functi on al ways
Window Function
Bartl ett wi ndow bartlett
Bl ackman wi ndow blackman
Rectangul ar wi ndow boxcar
Chebyshev wi ndow chebwin
Hammi ng wi ndow hamming
Hanni ng wi ndow hanning
Kai ser wi ndow kaiser
Tri angul ar wi ndow triang
Windows
4-3
returns a wi ndow wi th two zeros on the ends of the sequence, so that for n odd,
the center secti on of bartlett(n+2) i s equi val ent to 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
For n even, bartlett i s sti l l the convol uti on of two rectangul ar sequences.
There i s no standard defi ni ti on for the tri angul ar wi ndow for n even; the sl opes
of the l i ne segments of triangs resul t are sl i ghtl y steeper than those of
bartletts i n thi s case:
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
The fi nal di fference between the Bartl ett and tri angul ar wi ndows i s evi dent i n
the Fouri er transforms of these functi ons. The Fouri er transform of a Bartl ett
4 Special Topics
4-4
wi ndow i s negati ve for n even. The Fouri er transform of a tri angul ar wi ndow,
however, i s al ways nonnegati ve.
Thi s di fference can be i mportant when choosi ng a wi ndow for some spectral
esti mati on techni ques, such as the Bl ackman-Tukey method. Bl ackman-Tukey
forms the spectral esti mate by cal cul ati ng the Fouri er transform of the
autocorrel ati on sequence. The resul ti ng esti mate mi ght be negati ve at some
frequenci es i f the wi ndows Fouri er transform i s negati ve (see Kay [1], pg. 80).
Generalized Cosine Windows
Bl ackman, Hammi ng, Hanni ng, and rectangul ar wi ndows are al l speci al cases
of the generalized cosinewindow. These wi ndows are combi nati ons of
si nusoi dal sequences wi th frequenci es 0, 2/(N-1), and 4/(N-1), where N i s the
wi ndow l ength. One way to generate them i s
ind = (0:n1)'*2*pi/(n1);
w = A B*cos(ind) + C*cos(2*ind);
where A, B, and C are constants you defi ne. The concept behi nd these wi ndows
i s that by summi ng the i ndi vi dual terms to form the wi ndow, the l ow frequency
peaks i n the frequency domai n combi ne i n such a way as to decrease si del obe
hei ght. Thi s has the si de effect of i ncreasi ng the mai nl obe wi dth.
The Hammi ng and Hanni ng wi ndows are two-term general i zed cosi ne
wi ndows, gi ven by A = 0.54, B = 0.46 for Hammi ng and A = 0.5, B = 0.5 for
Hanni ng (C = 0 i n both cases). The hamming and hanning functi ons,
respecti vel y, compute these wi ndows.
Note that the defi ni ti on of the general i zed cosi ne wi ndow shown i n the earl i er
MATLAB code yi el ds zeros at sampl es 1 and n for A = 0.5 and B = 0.5. To
el i mi nate these zeros on the edges of the wi ndow, hanning uses a cosi ne of
frequency 2/(N+1) i nstead of 2/(N-1).
The Bl ackman wi ndow i s a popul ar three-term wi ndow, gi ven by
A = 0.42, B = 0.5, C = 0.08. The blackman functi on computes thi s wi ndow.
Kaiser Window
The Kaiser windowi s an approxi mati on to the prol ate-spheroi dal wi ndow, for
whi ch the rati o of the mai nl obe energy to the si del obe energy i s maxi mi zed. For
a Kai ser wi ndow of a parti cul ar l ength, the parameter control s the si del obe
hei ght. For a gi ven , the si del obe hei ght i s fi xed wi th respect to wi ndow l ength.
Windows
4-5
The statement kaiser(n,beta) computes a l ength n Kai ser wi ndow wi th
parameter beta.
Exampl es of Kai ser wi ndows wi th l ength 50 and vari ous val ues for the beta
parameter are
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])))
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-180
-160
-140
-120
-100
-80
-60
-40
-20
0
Three Kaiser Window Responses
Normalized Frequency (Nyquist == 1)
N
o
r
m
a
l
i
z
e
d

M
a
g
n
i
t
u
d
e

(
d
B
)
beta = 1
beta = 2
beta = 3
4 Special Topics
4-6
As i ncreases, the si del obe hei ght decreases and the mai nl obe wi dth i ncreases.
To see how the si del obe hei ght stays the same for a fi xed parameter as the
l ength i s vari ed, try
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])))
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-120
-100
-80
-60
-40
-20
0
Three Kaiser Window Responses, Beta Fixed
Normalized Frequency (Nyquist == 1)
N
o
r
m
a
l
i
z
e
d

M
a
g
n
i
t
u
d
e

(
d
B
)
length = 50
length = 20
length = 101
Windows
4-7
Kaiser Windows in FIR Design
There are two desi gn formul as that can hel p you desi gn FI R fi l ters to meet a
set of fi l ter speci fi cati ons usi ng a Kai ser wi ndow. To achi eve a si del obe hei ght
of dB, the beta parameter i s
For a transi ti on wi dth of rad/sec, use the l ength
Fi l ters desi gned usi ng these heuri sti cs wi l l meet the speci fi cati ons
approxi matel y, but you shoul d veri fy thi s. To desi gn a l owpass fi l ter wi th cutoff
frequency 0.5 rad/sec, transi ti on wi dth 0.2 rad/sec, and 40 dB of attenuati on
i n the stopband, try
[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');
The kaiserord functi on esti mates the fi l ter order, cutoff frequency, and Kai ser
wi ndow beta par ameter needed to meet a gi ven set of fr equency domai n
speci fi cati ons.

0.1102 8.7 ( ), 50 >


0.5842 21 ( )
0.4
0.07886 21 ( ) + , 50 21
0, 21 <

'

=
n
8
2.285
----------------------- 1 + =
4 Special Topics
4-8
The ri ppl e i n the passband i s roughl y the same as the ri ppl e i n the stopband.
As you can see from the frequency response, thi s fi l ter nearl y meets the
speci fi cati ons.
[H,f] = freqz(h,1,512,2);
plot(f,20*log10(abs(H))), grid
For detai l s on kaiserord, see the reference descri pti on i n Chapter 6.
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-100
-80
-60
-40
-20
0
20
Normalized Frequency (Nyquist == 1)
M
a
g
n
i
t
u
d
e

(
d
B
)
FIR Design using Kaiser Window
0.2
40 dB
Windows
4-9
Chebyshev Window
The Chebyshev wi ndow mi ni mi zes the mai nl obe wi dth, gi ven a parti cul ar
si del obe hei ght. I t i s characteri zed by an equi ri ppl e behavi or, that i s, i ts
si del obes al l have the same hei ght. The chebwin functi on, wi th l ength and
si del obe hei ght parameters, computes a Chebyshev wi ndow.
n = 51;
Rs = 40; % sidelobe height in decibels
w = chebwin(n,Rs);
stem(w)
As shown i n the pl ot, the Chebyshev wi ndow has l arge spi kes at i ts outer
sampl es.
Pl ot the frequency response to see the equi ri ppl es at -40 dB.
[W,f] = freqz(w,1,512,2);
plot(f,20*log10(abs(W)/sum(w))), grid
For a detai l ed di scussi on of the characteri sti cs and appl i cati ons of the vari ous
wi ndow types, see [2] Oppenhei m and Schafer, pgs. 444-462, and [3] Parks and
Burrus, pgs. 71-73.
0 5 10 15 20 25 30 35 40 45 50
0
0.2
0.4
0.6
0.8
1
Sample Number
Length 51 Chebyshev Window
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-80
-60
-40
-20
0
Normalized Frequency (Nyquist == 1)
N
o
r
m
a
i
l
z
e
d

M
a
g
n
i
t
u
d
e

(
d
B
)
Chebyshev Window Magnitude Response
4 Special Topics
4-10
Parametric Modeling
Parametri c model i ng techni ques fi nd the parameters for a mathemati cal model
descri bi ng a si gnal , system, or process. These techni ques use known
i nformati on about the system to determi ne the model . Appl i cati ons for
parametri c model i ng i ncl ude speech and musi c synthesi s, data compressi on,
hi gh-resol uti on spectral esti mati on, communi cati ons, manufacturi ng, and
si mul ati on.
The tool box parametri c model i ng functi ons operate wi th the rati onal transfer
functi on model . Gi ven appropri ate i nformati on about an unknown system
(i mpul se or frequency response data, or i nput and output sequences), these
functi ons fi nd the coeffi ci ents of a l i near system that model s the system.
One i mportant appl i cati on of the parametri c model i ng functi ons i s i n the
desi gn of fi l ters that have a prescri bed ti me or frequency response. These
functi ons provi de a data-ori ented al ternati ve to the I I R and FI R fi l ter desi gn
functi ons di scussed i n Chapter 2.
Here i s a summary of the parametri c model i ng functi ons i n thi s tool box. Note
that the System I denti fi cati on Tool box provi des a more extensi ve col l ecti on of
parametri c model i ng functi ons.
Parametric Modeling
4-11
Because yulewalk i s geared expl i ci tl y toward ARMA fi l ter desi gn, i t i s
di scussed i n Chapter 2. pburg and pyulear are di scussed i n Chapter 3 al ong
wi th the other (nonparametri c) spectral esti mati on methods.
Time-Domain Based Modeling
The lpc, prony, and stmcb functi ons fi nd the coeffi ci ents of a di gi tal rati onal
transfer functi on that approxi mates a gi ven ti me-domai n i mpul se response.
The al gori thms di ffer i n compl exi ty and accuracy of the resul ti ng model .
Domain Functions Description
Ti me arburg Generate al l -pol e fi l ter coeffi ci ents that model an i nput data
sequence usi ng the Levi nson-Durbi n al gori thm.
arcov Generate al l -pol e fi l ter coeffi ci ents that model an i nput data
sequence by mi ni mi zi ng the forward predi cti on error.
armcov Generate al l -pol e fi l ter coeffi ci ents that model an i nput data
sequence by mi ni mi zi ng the forward and backward predi cti on
errors.
aryule Generate al l -pol e fi l ter coeffi ci ents that model an i nput data
sequence usi ng an esti mate of the autocorrel ati on functi on.
lpc,
levinson
Li near Predi cti ve Codi ng. Generate al l -pol e recursi ve fi l ter whose
i mpul se response matches a gi ven sequence.
prony Generate I I R fi l ter whose i mpul se response matches a gi ven
sequence.
stmcb Fi nd I I R fi l ter whose output, gi ven a speci fi ed i nput sequence,
matches a gi ven output sequence.
Frequency invfreqz,
invfreqs
Generate di gi tal or anal og fi l ter coeffi ci ents gi ven compl ex
frequency response data.
4 Special Topics
4-12
Linear Prediction
Li near predi cti on model i ng assumes that each output sampl e of a si gnal , x(k),
i s a l i near combi nati on of the past n outputs (that i s, i t can be l i nearl y
predi cted from these outputs), and that the coeffi ci ents are constant from
sampl e to sampl e.
An nth-order al l -pol e model of a si gnal x i s
a = lpc(x,n)
To i l l ustrate lpc, cr eate a sampl e si gnal that i s the i mpul se r esponse of an
al l -pol e fi l ter wi th addi ti ve whi te noi se.
randn('seed',0)
x = impz(1,[1 0.1 0.1 0.1 0.1],10) + randn(10,1)/10;
The coeffi ci ents for a fourth-order al l -pol e fi l ter that model s the system are
a = lpc(x,4)
a =
1.0000 0.0395 0.0338 0.0668 0.1264
lpc fi rst cal l s xcorr to fi nd a bi ased esti mate of the correl ati on functi on of x,
and then uses the Levi nson-Durbi n recursi on, i mpl emented i n the levinson
functi on, to fi nd the model coeffi ci ents a. The Levi nson-Durbi n recursi on i s a
fast al gori thm for sol vi ng a system of symmetri c Toepl i tz l i near equati ons.
lpcs enti re al gori thm for n = 4 i s
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
x k ( ) a 2 ( )x k 1 ( ) a 3 ( )x k 2 ( ) L a n 1 + ( )x k n ( ) =
Parametric Modeling
4-13
You coul d form the l i near predi cti on coeffi ci ents wi th other assumpti ons by
passi ng a di fferent correl ati on esti mate to levinson, such as the unbi ased
correl ati on esti mate.
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
Pronys Method (ARMA Modeling)
The prony functi on model s a si gnal usi ng a speci fi ed number of pol es and zeros.
Gi ven a sequence x and numerator and denomi nator orders nb and na,
respecti vel y, the statement
[b,a] = prony(x,nb,na)
fi nds the numerator and denomi nator coeffi ci ents of an I I R fi l ter whose
i mpul se response approxi mates the sequence x.
prony i mpl ements the method descri bed i n [3] Parks and Burrus
(pgs. 226-228). Thi s method uses a vari ati on of the covari ance method of AR
model i ng to fi nd the denomi nator coeffi ci ents a, and then fi nds the numerator
coeffi ci ents b for whi ch the resul ti ng fi l ters i mpul se response matches exactl y
the fi rst nb + 1 sampl es of x. The fi l ter i s not necessari l y stabl e, but i t can
potenti al l y recover the coeffi ci ents exactl y i f the data sequence i s trul y an
autoregressi ve movi ng average (ARMA) process of the correct order.
NOTE The functi ons prony and stmcb (descri bed next) are more accuratel y
descri bed as ARX model s i n system i denti fi cati on termi nol ogy. ARMA
model i ng assumes noi se onl y at the i nputs, whi l e ARX assumes an external
i nput. prony and stmcb know the i nput si gnal : i t i s an i mpul se for prony and
i s arbi trary for stmcb.
4 Special Topics
4-14
A model for the test sequence x (from the earl i er lpc exampl e) usi ng a
thi rd-order I I R fi l ter i s
[b,a] = prony(x,3,3)
b =
1.1165 0.2181 0.6084 0.5369
a =
1.0000 0.1619 0.4765 0.4940
The impz command shows how wel l thi s fi l ters i mpul se response matches the
ori gi nal sequence.
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
Noti ce that the fi rst four sampl es match exactl y. For an exampl e of exact
recovery, recover the coeffi ci ents of a Butterworth fi l ter from i ts i mpul se
response.
[b,a] = butter(4,.2);
h = impz(b,a,26);
[bb,aa] = prony(h,4,4);
Try thi s exampl e; youl l see that bb and aa match the ori gi nal fi l ter coeffi ci ents
to wi thi n a tol erance of 10
-13
.
Parametric Modeling
4-15
Steiglitz-McBride Method (ARMA Modeling)
stmcb deter mi nes the coeffi ci ents for the system b(z)/a(z) gi ven an approxi mate
i mpul se response x, as wel l as the desi red number of zeros and pol es. Thi s
functi on i denti fi es an unknown system based on both i nput and output
sequences that descri be the systems behavi or, or just the i mpul se response of
the system. I n i ts defaul t mode, stmcb works l i ke 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 al so fi nds systems that match gi ven i nput and output sequences
y = filter(1,[1 1],x); % Create an output signal.
[b,a] = stmcb(y,x,0,1)
b =
1
a =
1 1
I n thi s exampl e, stmcb correctl y i denti fi es the system used to create y from x.
The Stei gl i tz-McBri de method i s a fast i terati ve al gori thm that sol ves for the
numerator and denomi nator coeffi ci ents si mul taneousl y i n an attempt to
mi ni mi ze the si gnal error between the fi l ter output and the gi ven output
si gnal . Thi s al gori thm usual l y converges rapi dl y, but mi ght not converge i f the
model order i s too l arge. As for prony, stmcbs resul ti ng fi l ter i s not necessari l y
stabl e due to i ts exact model i ng approach.
stmcb provi des control over several i mportant al gori thmi c parameters; modi fy
these parameters i f you are havi ng troubl e model i ng the data. To change the
number of i terati ons from the defaul t of fi ve and provi de an i ni ti al esti mate for
the denomi nator coeffi ci ents
n = 10; % number of iterations
a = lpc(x,3); % initial estimates for denominator
[b,a] = stmcb(x,3,3,n,a);
4 Special Topics
4-16
The functi on uses an al l -pol e model cr eated wi th prony as an i ni ti al esti mate
when you do not provi de one of your own.
To compare the functi ons lpc, prony, and stmcb, compute the si gnal error i n
each case
a1 = lpc(x,3);
[b2,a2] = prony(x,3,3);
[b3,a3] = stmcb(x,3,3);
[ ximpz(1,a1,10) ximpz(b2,a2,10) ximpz(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
I n compari ng model i ng capabi l i ti es for a gi ven order I I R model , the l ast resul t
shows that for thi s exampl e, stmcb performs best, fol l owed by prony, then lpc.
Thi s rel ati ve performance i s typi cal of the model i ng functi ons.
Frequency-Domain Based Modeling
The invfreqs and invfreqz functi ons i mpl ement the i nverse operati ons of
freqs and freqz; they fi nd an anal og or di gi tal transfer functi on of a speci fi ed
order that matches a gi ven compl ex frequency response. Though the fol l owi ng
exampl es demonstrate invfreqz, the di scussi on al so appl i es to invfreqs.
Parametric Modeling
4-17
To recover the ori gi nal fi l ter coeffi ci ents from the frequency response of a
si mpl e di gi tal fi l ter
[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
The vector of fr equenci es w has the uni ts i n rads/sampl e, and the frequenci es
need not be equal l y spaced. invfreqz fi nds a fi l ter of any order to fi t the
frequency data; a thi rd-order exampl e i s
[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
Both invfreqs and invfreqz desi gn fi l ters wi th real coeffi ci ents; for a data
poi nt at posi ti ve frequency f, the functi ons fi t the frequency response at both f
and f.
4 Special Topics
4-18
By defaul t invfreqz uses an equati on error method to i denti fy the best model
from the data. Thi s fi nds b and a i n
by creati ng a system of l i near equati ons and sol vi ng them wi th MATLABs \
operator. Here A(w(k)) and B(w(k)) are the Fouri er transforms of the
pol ynomi al s a and b respecti vel y at the frequency w(k), and n i s the number of
frequency poi nts (the l ength of h and w). wt(k) wei ghts the error rel ati ve to the
error at di fferent frequenci es. The syntax
invfreqz(h,w,nb,na,wt)
i ncl udes a wei ghti ng vector. I n thi s mode, the fi l ter resul ti ng from invfreqz i s
not guaranteed to be stabl e.
invfreqz provi des a superi or (output-error) al gori thm that sol ves the di rect
probl em of mi ni mi zi ng the wei ghted sum of the squared error between the
actual frequency response poi nts and the desi red response
To use thi s al gori thm, speci fy a parameter for the i terati on count after the
wei ght vector parameter
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
mi n
b a ,
wt k ( ) h k ( )A w k ( ) ( ) B w k ( ) ( )
2
k 1 =
n

mi n
b a ,
wt k ( ) h k ( )
B w k ( ) ( )
A w k ( ) ( )
--------------------
2
k 1 =
n

Parametric Modeling
4-19
The resul ti ng fi l ter i s al ways stabl e. Graphi cal l y compare the resul ts of the
fi rst and second al gori thms to the ori gi nal Butterworth fi l ter.
[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
To veri fy the superi ori ty of the fi t numeri cal l y
sum(abs(hfreqz(bb,aa,w)).^2) % total error, algorithm 1
ans =
0.0200
sum(abs(hfreqz(bbb,aaa,w)).^2) % total error, algorithm 2
ans =
0.0096
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
1.2
1.4
Original
First Estimate
Second Estimate
4 Special Topics
4-20
Resampling
The tool box provi des a number of functi ons that resampl e a si gnal at a hi gher
or l ower rate.
The resample functi on changes the sampl i ng rate for a sequence to any rate
that i s a rati o of two i ntegers. The basi c syntax for resample i s
y = resample(x,p,q)
where the functi on resampl es the sequence x at p/q ti mes the ori gi nal
sampl i ng rate. The l ength of the resul t y i s p/q ti mes the l ength of x.
One resampl i ng appl i cati on i s the conversi on of di gi ti zed audi o si gnal s from
one sampl i ng rate to another, such as from 48 kHz (the Di gi tal Audi o Tape
standard) to 44.1 kHz (the Compact Di sc standard). I n the next exampl e, the
sampl i ng rates are di fferent but the i dea i s the same.
Operation Function
Resampl e at new rate resample
Deci mati on decimate
I nterpol ati on interp
Appl y FI R fi l ter wi th resampl i ng upfirdn
Cubi c spl i ne i nterpol ati on spline
Other 1-D i nterpol ati on interp1
Resampling
4-21
The exampl e fi l e contai ns a l ength 4001 vector of speech sampl ed at 7418 Hz.
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 pl ay thi s speech si gnal on a workstati on that can onl y pl ay sound at 8192
Hz, use the rat functi on to fi nd i ntegers p and q that yi el d the correct
resampl i ng factor.
[p,q] = rat(8192/Fs,.0001)
p =
127
q =
115
Si nce p/q*Fs = 8192.05 Hz, the tol erance of 0.0001 i s acceptabl e; to resampl e
the si gnal at very cl ose to 8192 Hz.
y = resample(mtlb,p,q);
resample appl i es a l owpass fi l ter to the i nput sequence to prevent al i asi ng
duri ng resampl i ng. I t desi gns thi s fi l ter usi ng the firls functi on wi th a Kai ser
wi ndow. The syntax
resample(x,p,q,l,beta)
control s the fi l ters l ength and the beta parameter of the Kai ser wi ndow.
Al ternati vel y, use the functi on intfilt to desi gn an i nterpol ati on fi l ter b and
use i t wi th
resample(x,p,q,b)
4 Special Topics
4-22
The decimate and interp functi ons do the same thi ng as resample wi th p = 1
and q = 1, respecti vel y. These functi ons provi de di fferent anti -al i as fi l teri ng
opti ons, and they i ncur a sl i ght si gnal del ay due to fi l teri ng. The interp
functi on i s si gni fi cantl y l ess effi ci ent than the resample functi on wi th q = 1.
The tool box al so contai ns a functi on, upfirdn, that appl i es an FI R fi l ter to an
i nput sequence and outputs the fi l tered sequence at a di fferent sampl e rate
than i ts ori gi nal rate. See Mul ti rate Fi l ter Bank I mpl ementati on on page
1-19 and the reference descri pti on of upfirdn i n Chapter 6 for more detai l s.
The standard MATLAB envi ronment contai ns a functi on, spline, that works
wi th i rregul arl y spaced data. The MATLAB functi on interp1 performs
i nterpol ati on, or tabl e l ookup, usi ng vari ous methods i ncl udi ng l i near and
cubi c i nterpol ati on. See the onl i ne MATLAB Function Referencefor
i nformati on on spline and interp1.
Cepstrum Analysis
4-23
Cepstrum Analysis
Cepstrum anal ysi s i s a nonl i near si gnal processi ng techni que wi th a vari ety of
appl i cati ons i n areas such as speech and i mage processi ng. The Si gnal
Processi ng Tool box provi des three functi ons for cepstrum anal ysi s.
The compl ex cepstrum for a sequence xi s cal cul ated by fi ndi ng the compl ex
natural l ogari thm of the Fouri er transform of x, then the i nverse Fouri er
transform of the resul ti ng sequence.
The tool box functi on cceps performs thi s operati on, esti mati ng the compl ex
cepstrum for an i nput sequence. I t returns a real sequence the same si ze as the
i nput sequence
xhat = cceps(x)
The compl ex cepstrum transformati on i s central to the theory and appl i cati on
of homomorphic systems, that i s, systems that obey certai n general rul es of
superposi ti on. See [2] Oppenhei m and Schafer for a di scussi on of the compl ex
cepstrum and homomorphi c transformati ons, wi th detai l s on speech processi ng
appl i cati ons.
Try usi ng cceps i n an echo detecti on appl i cati on. Fi rst, create a 45 Hz si ne
wave sampl ed at 100 Hz
t = 0:0.01:1.27;
s1 = sin(2*pi*45*t);
Operation Function
Compl ex cepstrum cceps
Real cepstrum rceps
I nverse compl ex cepstrum icceps
x
1
2
------ X e
j
( ) [ ] l og e
j n
d

=
4 Special Topics
4-24
Add an echo of the si gnal , wi th hal f the ampl i tude, 0.2 seconds after the
begi nni ng of the si gnal .
s2 = s1 + 0.5*[zeros(1,20) s1(1:108)];
The compl ex cepstrum of thi s new si gnal i s
c = cceps(s2);
plot(t,c)
Note that the compl ex cepstrum shows a peak at 0.2 seconds, i ndi cati ng the
echo.
The real cepstrumof a si gnal x, someti mes cal l ed si mpl y the cepstrum, i s
cal cul ated by determi ni ng the natural l ogari thm of magni tude of the Fouri er
transform of x, then obtai ni ng the i nverse Fouri er transform of the resul ti ng
sequence
0 0.2 0.4 0.6 0.8 1 1.2 1.4
-1.5
-1
-0.5
0
0.5
1
c
x
1
2
------ X e
j
( ) l og e
j n
d

=
Cepstrum Analysis
4-25
The tool box functi on rceps performs thi s operati on, returni ng the real
cepstrum for a sequence x. The returned sequence i s a real -val ued vector the
same si ze as the i nput vector.
y = rceps(x)
By defi ni ti on, you cannot reconstruct the ori gi nal sequence from i ts real
cepstrum transformati on, as the real cepstrum i s based onl y on the magni tude
of the Fouri er transform for the sequence (see [2]). The rceps functi on,
however, can reconstruct a mi ni mum-phase versi on of the ori gi nal sequence by
appl yi ng a wi ndowi ng functi on i n the cepstral domai n. To obtai n both the real
cepstrum and the mi ni mum phase reconstructi on for a sequence, use
[y,ym] = rceps(x)
where y i s the real cepstrum and ym i s the mi ni mum phase reconstructi on of x.
Inverse Complex Cepstrum
To i nvert the compl ex cepstrum, use the icceps functi on. I nversi on i s
compl i cated by the fact that the cceps functi on performs a data dependent
phase modi fi cati on so that the unwrapped phase of i ts i nput i s conti nuous at
zero frequency. The phase modi fi cati on i s equi val ent to an i nteger del ay. Thi s
del ay term i s returned by cceps i f you ask for a second output. For exampl e,
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 Special Topics
4-26
To i nvert the compl ex cepstrum, use icceps wi th the ori gi nal del ay parameter.
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 Wi th any modi fi cati on of the compl ex cepstrum, the ori gi nal del ay
term may no l onger be val i d. Use the icceps functi on wi th care.
FFT-Based Time-Frequency Analysis
4-27
FFT-Based Time-Frequency Analysis
The Si gnal Processi ng Tool box provi des a functi on, specgram, that returns the
ti me-dependent Fouri er transform for a sequence, or di spl ays thi s i nformati on
as a spectrogram. The time-dependent Fourier transformi s the di screte-ti me
Fouri er transform for a sequence, computed usi ng a sl i di ng wi ndow. Thi s form
of the Fouri er transform, al so known as the short-ti me Fouri er transform
(STFT), has numerous appl i cati ons i n speech, sonar, and radar processi ng. The
spectrogramof a sequence i s the magni tude of the ti me-dependent Fouri er
transform versus ti me.
To di spl ay the spectrogram of a l i near FM si gnal
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)
Note that the spectrogram di spl ay i s an i mage, not a pl ot.
Time
F
r
e
q
u
e
n
c
y
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8
0
500
1000
1500
2000
2500
3000
3500
4000
4500
5000
4 Special Topics
4-28
Median Filtering
The functi on medfilt1 i mpl ements one-di mensi onal medi an fi l teri ng, a
nonl i near techni que that appl i es a sl i di ng wi ndow to a sequence. The medi an
fi l ter repl aces the center val ue i n the wi ndow wi th the medi an val ue of al l the
poi nts wi thi n the wi ndow [4]. I n computi ng thi s medi an, medfilt1 assumes
zeros beyond the i nput poi nts.
When the number of el ements n i n the wi ndow i s even, medfilt1 sorts the
numbers, then takes the average of the ((n1)/2 & ((n1)/2)+1) el ements.
Two si mpl e exampl es wi th fourth- and thi rd-order medi an fi l ters are
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 the I mageProcessingToolbox Users Guidefor i nformati on on
two-di mensi onal medi an fi l teri ng.
Communications Applications
4-29
Communications Applications
The tool box provi des three functi ons for communi cati ons si mul ati on.
Modulation vari es the ampl i tude, phase, or frequency of a carrier signal wi th
reference to a messagesignal. The modulate functi on modul ates a message
si gnal wi th a speci fi ed modul ati on method.
The basi c syntax for the modulate functi on i s
y = modulate(x,Fc,Fs,'method',opt)
where:
x i s the message si gnal .
Fc i s the carri er frequency.
Fs i s the sampl i ng frequency.
method i s a fl ag for the desi red modul ati on method.
opt i s any addi ti onal argument that the method requi res. (Not al l
modul ati on methods requi re an opti on argument.)
The tabl e bel ow summari zes the modul ati on methods provi ded; see Chapter 6
for compl ete detai l s on each.
Operation Function
Modul ati on modulate
Demodul ati on demod
Vol tage control l ed osci l l ati on vco
Method Description
amdsbsc or am Ampl i tude modul ati on, doubl e si de-band, suppressed
carri er
amdsbtc Ampl i tude modul ati on, doubl e si de-band, transmi tted
carri er
4 Special Topics
4-30
I f the i nput x i s an array rather than a vector, modulate modul ates each
col umn of the array.
To obtai n the ti me vector that modulate uses to compute the modul ated si gnal ,
speci fy a second output parameter.
[y,t] = modulate(x,Fc,Fs,'method',opt)
The demod functi on performs demodulation, that i s, i t obtai ns the ori gi nal
message si gnal from the modul ated si gnal .
The syntax for demod i s
x = demod(y, Fc,Fs,'method',opt)
demod uses any of the methods shown for modulate, but the syntax for
quadrature ampl i tude demodul ati on requi res two output parameters.
[X1,X2] = demod(y,Fc,Fs,'qam')
I f the i nput y i s an array, demod demodul ates al l col umns.
Try modul ati ng and demodul ati ng a si gnal . A 50 Hz si ne wave sampl ed at 1000
Hz i s
t = (0:1/1000:2);
x = sin(2*pi*50*t);
amssb Ampl i tude modul ati on, si ngl e si de-band
fm Frequency modul ati on
pm Phase modul ati on
ptm Pul se ti me modul ati on
pwm Pul se wi dth modul ati on
qam Quadrature ampl i tude modul ati on
Method Description
Communications Applications
4-31
Wi th a carri er frequency of 200 Hz, the modul ated and demodul ated versi ons
of thi s si gnal are
y = modulate(x,200,1000,'am');
z = demod(y,200,1000,'am');
To pl ot porti ons of the ori gi nal , modul ated, and demodul ated si gnal
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');
The vol tage control l ed osci l l ator functi on vco creates a si gnal that osci l l ates at
a frequency determi ned by the i nput vector. The basi c syntax for vco i s
y = vco(x,Fc,Fs)
where Fc i s the carri er frequency and Fs i s the sampl i ng frequency.
To scal e the frequency modul ati on range
y = vco(x,[Fmin Fmax],Fs)
0 0.05 0.1 0.15
-1
-0.5
0
0.5
1
Original Signal
0 0.05 0.1 0.15
-2
-1
0
1
2
Modulated Signal
0 0.05 0.1
-1
-0.5
0
0.5
1
Demodulated Signal
4 Special Topics
4-32
I n thi s case, vco scal es the frequency modul ati on range so val ues of x on the
i nterval [1 1] map to osci l l ati ons of frequency on [Fmin Fmax].
I f the i nput x i s an array, vco produces an array whose col umns osci l l ate
accordi ng to the col umns of x.
See FFT-Based Ti me-Frequency Anal ysi s on page 4-27 for an exampl e usi ng
the vco functi on.
Deconvolution
4-33
Deconvolution
Deconvolution, or pol ynomi al di vi si on, i s the i nverse operati on of convol uti on.
Deconvol uti on i s useful i n recoveri ng the i nput to a known fi l ter, gi ven the
fi l tered output. Thi s method i s very sensi ti ve to noi se i n the coeffi ci ents,
however, so use cauti on i n appl yi ng i t.
The syntax for deconv i s
[q,r] = deconv(b,a)
where b i s the pol ynomi al di vi dend, a i s the di vi sor, q i s the quoti ent, and r i s
the remai nder.
To try deconv, fi rst convol ve two si mpl e vectors a and b (see Chapter 1 for a
descri pti on of the convol uti on functi on)
a = [1 2 3];
b = [4 5 6];
c = conv(a,b)
c =
4 13 28 27 18
Now use deconv to deconvol ve b from c
[q,r] = deconv(c,a)
q =
4 5 6
r =
0 0 0 0 0
See the SystemI dentification Toolbox Users Guidefor advanced appl i cati ons
of si gnal deconvol uti on.
4 Special Topics
4-34
Specialized Transforms
I n addi ti on to the di screte Fouri er transform (DFT) descri bed i n Chapter 1, the
Si gnal Processi ng Tool box and the MATLAB envi ronment together provi de the
fol l owi ng transform functi ons:
The chi rp z-transform (CZT), useful i n eval uati ng the z-transform al ong
contours other than the uni t ci rcl e. The chi rp z-transform i s al so more
effi ci ent than the DFT al gori thm for the computati on of pri me-l ength
transforms, and i t i s useful i n computi ng a subset of the DFTfor a sequence.
The di screte cosi ne transform (DCT), cl osel y rel ated to the DFT. The DCTs
energy compacti on properti es are useful for appl i cati ons l i ke si gnal codi ng.
The Hi l bert transform, whi ch faci l i tates the formati on of the anal yti c si gnal .
The anal yti c si gnal i s useful i n the area of communi cati ons, parti cul arl y i n
bandpass si gnal processi ng.
Chirp z-Transform
The chi rp z-transform, or CZT, computes the z-transform al ong spi ral contours
i n the z-pl ane for an i nput sequence. Unl i ke the DFT, the CZT i s not
constrai ned to operate al ong the uni t ci rcl e, but can eval uate the z-transform
al ong contours descri bed by
where A i s the compl ex starti ng poi nt, Wi s a compl ex scal ar descri bi ng the
compl ex rati o between poi nts on the contour, and M i s the l ength of the
transform.
z
l
AW
l
l 0 M 1 , , = , =
Specialized Transforms
4-35
One possi bl e spi r al i s
A = 0.8*exp(j*pi/6);
W = 0.995*exp(j*pi*.05);
M = 91;
z = A*(W.^((0:M1)));
zplane([],z.')
czt(x,M,W,A) computes the z-transform of x on these poi nts.
An i nteresti ng and useful spi ral set i s m evenl y spaced sampl es around the uni t
ci rcl e, parameteri zed by A = 1 and W = exp(j*pi/M). The z-transform on thi s
contour i s si mpl y the DFT, obtai ned by
y = czt(x)
czt i s faster than the fft functi on for computi ng the DFT of sequences wi th
certai n odd l engths, parti cul arl y l ong pri me-l ength sequences. (Try compari ng
the executi on ti me for the fft and czt functi ons for a sequence of l ength 1013.)
-1.5 -1 -0.5 0 0.5 1 1.5
-1
-0.5
0
0.5
1
Real part
I
m
a
g
i
n
a
r
y

p
a
r
t
4 Special Topics
4-36
Discrete Cosine Transform
The tool box functi on dct computes the uni tary di screte cosi ne transform, or
DCT, for an i nput vector or matri x. Mathemati cal l y, the uni tary DCT of an
i nput sequence xi s
where
The DCT i s cl osel y rel ated to the di screte Fouri er transform; the DFT i s
actual l y one step i n the computati on of the DCT for a sequence. The DCT,
however, has better energy compaction properti es, wi th just a few of the
transform coeffi ci ents representi ng the majori ty of the energy i n the sequence.
The energy compacti on properti es of the DCT make i t useful i n appl i cati ons
such as data communi cati ons.
The functi on idct computes the i nverse DCT for an i nput sequence,
reconstructi ng a si gnal from a compl ete or parti al set of DCT coeffi ci ents. The
i nverse di screte cosi ne transform i s
where
y k ( ) w n ( )x n ( )
2n 1 ( ) k 1 ( )
2N
------------------------------------------- cos
n 1 =
N

k 1 N , , = , =
w n ( )
1
N
--------- n 1 = ,
2
N
---- 2 n N ,

'

=
x n ( ) w k ( )y k ( )
2n 1 ( ) k 1 ( )
2N
------------------------------------------- cos
k 1 =
N

n 1 N , , = , =
w k ( )
1
N
--------- k 1 = ,
2
N
---- 2 k N ,

'

=
Specialized Transforms
4-37
Because of the energy compacti on menti oned above, i t i s possi bl e to reconstruct
a si gnal from onl y a fracti on of i ts DCTcoeffi ci ents. For exampl e, generate a 10
Hz si nusoi dal sequence, sampl ed at 1000 Hz.
t = (0:1/999:1);
x = sin(2*pi*25*t);
Compute the DCTof thi s sequence and reconstruct the si gnal usi ng onl y those
components wi th val ue greater than 53 (12 of the ori gi nal 1000 DCT
coeffi ci ents).
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
Pl ot the ori gi nal and reconstructed sequences.
plot(t,x)
plot(t,z), axis([0 1 1 1])
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-1
-0.5
0
0.5
1
Original Signal
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-1
-0.5
0
0.5
1
Reconstructed Signal
4 Special Topics
4-38
One measure of the accuracy of the reconstructi on i s
norm(xz)/norm(x)
that i s, the norm of the di fference between the ori gi nal and reconstructed
si gnal s, di vi ded by the norm of the ori gi nal si gnal . I n thi s case, the rel ati ve
error of reconstructi on i s 0.1778. The reconstructed si gnal retai ns
approxi matel y 82% of the energy i n the ori gi nal si gnal .
Hilbert Transform
The tool box functi on hilbert computes the Hi l bert transform for a real i nput
sequence x and returns a compl ex resul t of the same l ength
y = hilbert(x)
where the real part of y i s the ori gi nal real data and the i magi nary part i s the
actual Hi l bert transform. y i s someti mes cal l ed the analyticsignal, i n reference
to the conti nuous-ti me anal yti c si gnal . A key property of the di screte-ti me
anal yti c si gnal i s that i ts z-transform i s 0 on the l ower hal f of the uni t ci rcl e.
Many appl i cati ons of the anal yti c si gnal are rel ated to thi s property; for
exampl e, the anal yti c si gnal i s useful i n avoi di ng al i asi ng effects for bandpass
sampl i ng operati ons. The magni tude of the anal yti c si gnal i s the compl ex
envel ope of the or i gi nal si gnal .
Specialized Transforms
4-39
The Hi l bert transform i s rel ated to the actual data by a 90 phase shi ft; si nes
become cosi nes and vi ce versa. To pl ot a porti on of data (sol i d l i ne) and i ts
Hi l bert transform (dotted l i ne)
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
The anal yti c si gnal i s useful i n cal cul ati ng instantaneous attributes of a ti me
seri es, the attri butes of the seri es at any poi nt i n ti me. The i nstantaneous
ampl i tude of the i nput sequence i s the ampl i tude of the anal yti c si gnal . The
i nstantaneous phase angl e of the i nput sequence i s the (unwrapped) angle of
the anal yti c si gnal ; the i nstantaneous frequency i s the ti me rate of change of
the i nstantaneous phase angl e. You can cal cul ate the i nstantaneous frequency
usi ng diff, as descri bed i n the onl i ne MATLAB Function Reference.
0 0.01 0.02 0.03 0.04 0.05
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
4 Special Topics
4-40
References
1 Kay, S.M. Modern Spectral Estimation. Engl ewood Cl i ffs, NJ: Prenti ce Hal l ,
1988.
2 Oppenhei m, A.V., and R.W. Schafer. Discrete-TimeSignal Processing.
Engl ewood Cl i ffs, NJ: Prenti ce Hal l , 1989.
3 Parks, T.W., and C.S. Burrus. Digital Filter Design. New York: John Wi l ey
& Sons, 1987.
4 Pratt,W.K. Digital I mageProcessing. New York: John Wi l ey & Sons, 1991.
5
I nteracti ve Tool s
SPTool: An InteractiveSignal ProcessingEnvironment . 5-2
UsingSPTool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3
UsingtheSignal Browser: InteractiveSignal Analysis . 5-43
UsingtheFilter Designer: InteractiveFilter Design . . . 5-59
UsingtheFilter Viewer: InteractiveFilter Analysis . . . 5-84
UsingtheSpectrumViewer: InteractivePSD Analysis . 5-97
Example: Generation of Bandlimited Noise . . . . . . . . . . 5-113
5 Interactive Tools
5-2
SPTool: An Interactive Signal Processing Environment
The Si gnal Processi ng Tool box i ncl udes an i nteracti ve graphi cal user i nterface
(GUI ), cal l ed SPTool , for performi ng di gi tal si gnal processi ng tasks. SPTool
provi des an easy-to-use i nterface to many of the most i mportant tool box
functi ons. Wi th i t, you can use the mouse and on-screen control s to i mport,
vi ew, measure, and pri nt di gi tal si gnal s; desi gn, vi ew, and i mpl ement di gi tal
fi l ters; and anal yze the frequency content of si gnal s.
Thi s chapter descri bes how to use the di fferent components of SPTool . Where
appropri ate, we poi nt you to other areas of the manual that descri be how to
perform si mi l ar tasks by cal l i ng functi ons from the command l i ne or from
M-fi l es.
The secti on Exampl e: Generati on of Bandl i mi ted Noi se at the end of thi s
chapter descri bes how to use thi s graphi cal envi ronment for a compl ete fi l ter
desi gn and anal ysi s task.
Overview
SPTool i s a graphi cal envi ronment for anal yzi ng and mani pul ati ng di gi tal
si gnal s, fi l ters, and spectra. I t i s the starti ng poi nt for usi ng the i nteracti ve
si gnal processi ng envi ronment. I n SPTool , you can i mport si gnal s, fi l ters, and
spectra ei ther from the workspace or as MAT-fi l es. Through SPTool , you access
four addi ti onal GUI tool s that provi de an i ntegrated envi ronment for si gnal
browsi ng, fi l ter desi gn, anal ysi s, and i mpl ementati on. The four components of
the i nteracti ve si gnal processi ng envi ronment i ncl ude:
The Signal Browser, whi ch provi des a graphi cal vi ew of the si gnal objects
currentl y sel ected i n SPTool and enabl es you to di spl ay, measure, anal yze,
and pri nt these si gnal s i nteracti vel y
The Filter Designer, whi ch enabl es you to create and edi t l owpass, hi ghpass,
bandpass, and bandstop FI R and I I R di gi tal fi l ters of vari ous l engths and
types usi ng the fi l ter desi gn functi ons of the Si gnal Processi ng Tool box
The Filter Viewer, whi ch enabl es you to vi ew vari ous characteri sti cs of a
fi l ter that youve i mported or desi gned, i ncl udi ng i ts magni tude and phase
responses, group del ay, zero-pol e pl ot, and i mpul se and step responses
The SpectrumViewer, whi ch enabl es you to create, vi ew, modi fy, and pri nt
spectra i nteracti vel y, and to perform graphi cal anal ysi s of frequency domai n
data usi ng a vari ety of common methods of spectral esti mati on
Using SPTool
5-3
Using SPTool
SPTool i s the data management tool for the i nteracti ve GUI envi ronment of the
Si gnal Processi ng Tool box. Usi ng SPTool you can:
Load a saved sessi on
I mport a si gnal , fi l ter, or spectrum
Dupl i cate or cl ear a si gnal , fi l ter, or spectrum
Change the name of a si gnal , fi l ter, or spectrum
Change the sampl i ng frequency of a si gnal or fi l ter
Acti vate the Si gnal Browser, Fi l ter Vi ewer, Fi l ter Desi gner, or Spectrum
Vi ewer
Save a sessi on
Use the Windowmenu to change to any open MATLAB fi gure wi ndow
Opening SPTool
Open SPTool from the MATLAB command wi ndow by typi ng
sptool
and pressi ng Enter.
Quick Start
Once SPTool i s open, you can i mport data from the workspace or a fi l e. You can
then vi ew i t i n the Si gnal Browser or generate i ts spectrum i n the Spectrum
Vi ewer.
To get started ri ght away, work through the fol l owi ng exampl e. Then conti nue
through thi s chapter to l earn the detai l s of usi ng SPTool and i ts component
tool s.
Or, you can ski p the exampl e, read through the rest of thi s secti on (from Basi c
SPTool Functi ons to Usi ng the Si gnal Browser: I nteracti ve Si gnal Anal ysi s),
and then work through the exampl e.
Example: Importing Signal Data from a MAT-File
Thi s exampl e uses the sampl e fi l e mtlb.mat, whi ch i s i n the
toolbox/signal/signal di rectory.
5 Interactive Tools
5-4
1 Sel ect Import from the Filemenu.
The Import to SPTool wi ndow i s di spl ayed.
2 Make sure that Signal i s di spl ayed i n the Import As pop-up menu.
3 Press the FromDisk radi o button.
You can ei ther enter a MAT-fi l e name or press Browseto open the fi l e di al og
box and sel ect a MAT-fi l e.
4 To get started, type the fi l e name mtlb and press Tab or Enter. Note that
SPTool adds the .mat extensi on automati cal l y.
The data fr om the fi l e you sel ected i s di spl ayed i n the FileContentsl i st. I n
thi s exampl e, mtlb i s the si gnal data and Fs i s the sampl i ng frequency.
Noti ce that sig1 i s di spl ayed i n the Namefi el d. Thi s i s the defaul t name of
the i mported si gnal .
5 Cl i ck on mtlb to sel ect i t, and then press the arrow at the l eft of the Data
fi el d. mtlb i s transferred to the Data fi el d.
6 Cl i ck on Fs to sel ect i t, and then press the arrow at the l eft of the Sampling
Frequency fi el d.
Fs i s transferred to the SamplingFrequency fi el d.
Using SPTool
5-5
7 Press OK.
The si gnal has been i mported i nto SPTool wi th the name sig1.
You can l ook at thi s si gnal i n the Si gnal Browser by pressi ng the Viewbutton
under Signals.
You can l ook at the frequency content of the si gnal i n the Spectrum Vi ewer by
pressi ng the Createbutton under Spectra and then pressi ng Apply i n the
Spectrum Vi ewer.
Basic SPTool Functions
When you fi r st open SPTool , i t contai ns a col l ecti on of defaul t si gnal s, fi l ter s,
and spectra. You can i mport addi ti onal si gnal s, fi l ters, and spectra i nto SPTool ,
and you can al so desi gn fi l ters usi ng the Fi l ter Desi gner and create spectra
usi ng the Spectrum Vi ewer. You can save and export data from SPTool and
customi ze many properti es of the SPTool envi ronment. The fol l owi ng fi gure
shows the SPTool wi ndow and i ts Fileand Help menus, whi ch are descri bed
bel ow.
5 Interactive Tools
5-6
File Menu
Open Session. Sel ect OpenSessionfrom the Filemenu to l oad a saved sessi on
fi l e. An SPTool sessi on i s saved i n a fi l e wi th an .spt extensi on.
Import. Sel ect Import from the Filemenu to i mport a si gnal , fi l ter, or
spectrum i nto SPTool from ei ther the wor kspace or fr om a fi l e. You can i mpor t
vari abl es from any MAT-fi l e i nto SPTool . See I mporti ng Si gnal s, Fi l ters, and
Spectra on page 5-7 and Exampl e: I mporti ng Si gnal Data from a MAT-Fi l e
on page 5-3 for more i nformati on.
Export. Sel ect Export from the Filemenu to export si gnal s, fi l ters, and
spectra to the MATLAB workspace as structure vari abl es. See Savi ng Si gnal
Data on page 5-57, Savi ng Fi l ter Data on page 5-79, and Savi ng Spectrum
Data on page 5-110 for compl ete i nformati on.
Save Session. Sel ect SaveSession and SaveSession As from the Filemenu
to save the current sessi on. SaveSession overwri tes the exi sti ng sessi on fi l e.
SaveSession As saves the current sessi on wi th a name you speci fy. An
SPTool sessi on i s saved i n a MAT-fi l e wi th an .spt extensi on.
Preferences. Sel ect Preferencesfrom the Filemenu to customi ze preferences
for the behavi or of al l the Si gnal Processi ng GUI tool s. See Customi zi ng
Preferences on page 5-20 for a compl ete di scussi on.
Close. Sel ect Closefrom the Filemenu to cl ose SPTool and al l other acti ve
Si gnal Processi ng GUI tool s. SPTool prompts you to save i f you have not
recentl y saved the current sessi on.
When you cl ose SPTool , al l si gnal and fi l ter customi zati on and rul er
i nformati on set i n any of the GUI tool s are l ost. Setti ngs you changed and saved
usi ng the Preferences di al og box i n SPTool are used the next ti me you open
SPTool .
Help Menu
Overview Sel ect Overview from the Filemenu to get general hel p on
SPTool and the Si gnal Processi ng Tool box GUI envi ronment. Thi s al so gi ves
you access to the MATLAB Hel p Desk.
Using SPTool
5-7
Context Sensitive Sel ect Context Sensitivefrom the Filemenu for hel p on a
speci fi c part of SPTool . When you cl i ck on Context Sensitive, the mouse
poi nter becomes an arrow wi th a questi on mark symbol . You can then cl i ck on
anythi ng i n SPTool , i ncl udi ng menu i tems, to fi nd out what i t i s and how to use
i t.
Importing Signals, Filters, and Spectra
You can i mport a si gnal , fi l ter, or spectrum i nto SPTool from ei ther the
workspace or from a fi l e.
Sel ect Import from the Filemenu to open the Import to SPTool wi ndow:
Loading Variables from the MATLAB Workspace
To i mport vari abl es from the MATLAB workspace, fi rst l i st the workspace
vari abl es i n the WorkspaceContents l i st. Then sel ect the vari abl es to be
i mported i nto SPTool :
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.
Display all MATLAB workspace variables in the
Workspace Contents list box by clicking here.
Workspace Contents
or File Contents list.
5 Interactive Tools
5-8
1 Cl i ck the FromWorkspaceradi o button.
The contents of the MATLAB workspace are di spl ayed i n the Workspace
Contents l i st.
2 You can now i mport one or more vari abl es from the WorkspaceContents
l i st i nto SPTool . See I mporti ng Workspace Contents and Fi l e Contents
bel ow.
Loading Variables from Disk
To i mport vari abl es from a MAT-fi l e on di sk, fi rst l i st the fi l es vari abl es i n the
FileContents l i st. Then sel ect the vari abl es to be i mported i nto SPTool :
1 Cl i ck the FromDisk radi o button.
2 Type the name of the fi l e you want to i mport i nto the MAT-fileNamefi el d
and press Tab or Enter.
or
Press Browse, and then fi nd and sel ect the fi l e you want to i mport usi ng the
Fi l e Search wi ndow. Press OK.
The data from the fi l e you sel ected i s di spl ayed i n the FileContents l i st.
3 You can now i mport one or more vari abl es from the FileContentsl i st i nto
SPTool (see bel ow).
Importing Workspace Contents and File Contents
Once youve l oaded the contents of the workspace or a fi l e i nto the Workspace
Contents or FileContents l i st, you can sel ect one or more vari abl es from the
l i st to i mport i nto SPTool . You can i mport a vari abl e as a si gnal , a fi l ter, or a
spectrum. You can al so i mport a vari abl e whose val ue represents a sampl i ng
frequency or other desi gn parameter.
Dependi ng on whether youre i mporti ng a si gnal , a fi l ter, or a spectrum, you
can customi ze di fferent parameters before you i mport the data i nto SPTool . I n
each case, however, the general procedure for speci fyi ng a vari abl e or a val ue
i s the same. I n the fol l owi ng exampl e, the sel ected vari abl e i s bei ng i mported
as a si gnal . See I mporti ng a Si gnal on page 5-10, I mporti ng a Fi l ter on page
Using SPTool
5-9
5-11, and I mporti ng a Spectrum on page 5-13 for detai l s on customi zi ng
vari abl es that are i mported i nto SPTool .
1 Cl i ck on a vari abl e name i n the WorkspaceContents l i st or the
FileContents l i st to sel ect i t.
I f the vari abl e i s not a saved data object from SPTool , sel ect the appropri ate
data type (Signal, Filter, or Spectrum) from the Import As pop-up menu
and type a name i nto the Namefi el d.
I f the vari abl e i s a saved data object from SPTool , i ts name i s di spl ayed i n
the Namefi el d, and i ts type (Signal, Filter, or Spectrum) i s automati cal l y
sel ected i n the Import As pop-up menu.
2 Press the arrow at the l eft of the Data fi el d. The sel ected vari abl e i s
transferred to the Data fi el d.
NOTE You can al so type a vari abl e name i nto the Data fi el d di rectl y.
3 To change the sampl i ng frequency of the vari abl e youre i mporti ng, you can
ei ther:
a Cl i ck on a vari abl e i n the WorkspaceContentsl i st or FileContentsl i st
whose val ue i s a sampl i ng frequency, and then press the arrow at the l eft
of the SamplingFrequency fi el d.
The sel ected vari abl e i s transferred to the SamplingFrequency fi el d.
or
b Type a val ue or vari abl e name i n the SamplingFrequency fi el d.
5 Interactive Tools
5-10
4 Press OK.
The si gnal i s i mported i nto SPTool wi th the speci fi ed name and sampl i ng
frequency.
5 To i mport another vari abl e, sel ect Import agai n, press the From
Workspaceor FromFileradi o button, and repeat steps 1 through 4 for each
vari abl e that you want to l oad i nto SPTool .
NOTE When youre i mporti ng from the workspace, you can speci fy ei ther a
vari abl e or a val ue for each data fi el d. When youre i mporti ng from a di sk, you
can onl y speci fy vari abl es.
Importing a Signal. When you i mport a si gnal , you speci fy:
A vari abl e name for the si gnal data (or the si gnal data val ues) i n the Data
fi el d
A vari abl e or a val ue for the si gnal s sampl i ng frequency i n the Sampling
Frequency fi el d
Using SPTool
5-11
Importing a Filter. When you i mport a fi l ter, fi rst sel ect the appropri ate fi l ter
form from the Formpop-up menu.
Each fi l ter form requi res di fferent vari abl es.
For Transfer Function, you speci fy the fi l ter by i ts transfer functi on
representati on:
- The Numerator fi el d speci fi es a vari abl e name or val ue for the numerator
coeffi ci ent vector b, whi ch contai ns m+1 coeffi ci ents i n descendi ng powers
of z.
- The Denominator fi el d speci fi es a vari abl e name or val ue for the
denomi nator coeffi ci ent vector a, whi ch contai ns n+1 coeffi ci ents i n
descendi ng powers of z.
For StateSpace, you speci fy the fi l ter by i ts state-space representati on:
The A-Matrix, B-Matrix, C-Matrix, and D-Matrix fi el ds speci fy a vari abl e
name or a val ue for each matri x i n thi s system.
For Zeros, Poles, Gain, you speci fy the fi l ter by i ts zer o-pol e-gai n
representati on:
H z ( )
B z ( )
A z ( )
-----------
b 1 ( ) b 2 ( )z
1
L b m 1 + ( )z
m
+ + +
a 1 ( ) a 2 ( )z
1
L a n 1 + ( )z
n
+ + +
------------------------------------------------------------------------------------ = =
x

Ax Bu + =
y Cx Du + =
5 Interactive Tools
5-12
- The Zeros fi el d speci fi es a vari abl e name or val ue for the zeros vector z,
whi ch contai ns the l ocati ons of mzeros.
- The Poles fi el d speci fi es a vari abl e name or val ue for the zeros vector p,
whi ch contai ns the l ocati ons of n pol es.
- The Gain fi el d speci fi es a vari abl e name or val ue for the gai n k.
For 2nd Order Sections you speci fy the fi l ter by i ts second-order secti on
representati on:
The SOSMatrixfi el d speci fi es a vari abl e name or a val ue for the L-by-6 SOS
matri x
whose rows contai n the numerator and denomi nator coeffi ci ents b
ik
and a
ik
of the second-order secti ons of H(z):
For every fi l ter, you speci fy:
A vari abl e name or a val ue for the fi l ters sampl i ng frequency i n the
SamplingFrequency fi el d
H z ( )
Z z ( )
P z ( )
---------- k
z z 1 ( ) ( ) z z 2 ( ) ( )Lz z m ( ) ( )
z p 1 ( ) ( ) z p 2 ( ) ( )Lz p n ( ) ( )
--------------------------------------------------------------------------------- = =
H z ( ) H
k
z ( )
k 1 =
L

b
0k
b
1k
z
1
b
2k
z
2
+ +
1 a
1k
z
1
a
2k
z
2
+ +
--------------------------------------------------------- -
k 1 =
L

= =
sos
b
01
b
11
b
21
1 a
11
a
21
b
02
b
12
b
22
1 a
12
a
22
M M M M M M
b
0L
b
1L
b
2L
1 a
1L
a
2L
=
Using SPTool
5-13
Importing a Spectrum. When you i mport a spectrum, you speci fy:
A vari abl e name or a val ue for the power spectral densi ty (PSD) vector i n the
PSD fi el d
A vari abl e name or a val ue for the frequency vector i n the Freq. Vector fi el d
The PSD val ues i n the PSD vector correspond to the frequenci es contai ned
i n the Freq. Vector vector; the two vectors must have the same l ength.
Working with Signals, Filters, and Spectra
When a si gnal , fi l ter , or spectr um i s i mpor ted i nto SPTool or cr eated i n SPTool ,
i t i s di spl ayed i n the appropri ate l i st box, as shown bel ow. Usi ng the Edit menu
functi ons and SPTool buttons, you can edi t vari ous properti es of the data i n
SPTool and i nvoke al l of SPTool s di gi tal si gnal pr ocessi ng functi ons.
5 Interactive Tools
5-14
Component Lists in SPTool
Each si gnal , fi l ter, and spectrum i n SPTool i s di spl ayed i n the appropri ate
Signals l i st, Filters l i st, or Spectra l i st.
Si gnal s are di spl ayed wi th the signal type[vector] or [array]:
- A vector signal ([vector]) has one col umn of data.
- An array signal ([array]) has more than one col umn of data.
Fi l ters are di spl ayed wi th the filter type[design] or [imported]:
- A designed filter ([design]) i s a fi l ter that was created usi ng the Fi l ter
Desi gner. Thi s type of fi l ter can al so be edi ted i n the Fi l ter Desi gner.
- An imported filter ([imported]) i s a fi l ter that was i mported from the
MATLAB workspace or a fi l e, or one that was edi ted i n the Pol e/Zero
Edi tor.
Spectrum View button Signal View button
Filter View button
Signals list
Filters list
Spectra list
Using SPTool
5-15
Spectra are di spl ayed wi th the spectrumtype[auto]:
An auto-spectrum([auto]) i s a spectrum whose source i s a si ngl e si gnal , as
opposed to the cross-spectrum of two channel s of data. spectrum[auto] i s the
onl y spectrum type i n SPTool .
Selecting Data Objects in SPTool
Each si gnal , fi l ter, and spectrum i n SPTool i s one data object. A data object i s
sel ected when i t i s hi ghl i ghted. When you fi rst i mport or create a data object,
i t i s sel ected.
The Signals l i st shows al l vector and array si gnal s i n the current SPTool
sessi on.
The Filters l i st shows al l desi gned and i mported fi l ters i n the current SPTool
sessi on.
The Spectra l i st shows al l spectra i n the current SPTool sessi on.
You can sel ect a si ngl e data object i n a l i st, a range of data objects i n a l i st, or
mul ti pl e separate data objects i n a l i st. You can al so have data objects
si mul taneousl y sel ected i n di fferent l i sts:
To sel ect a si ngl e unsel ected data object, cl i ck on i t. Al l other data objects i n
that l i st box become unsel ected.
To add or remove a range of data objects, Shift-cl i ck on the data objects at
the top and bottom of the secti on of the l i st that you want to add.
To add a si ngl e data object to a sel ecti on or remove a si ngl e data object from
a mul ti pl e sel ecti on, Ctrl-cl i ck on the object. You can al so use the ri ght
mouse button.
Editing Data Objects in SPTool
The Edit menu entri es are avai l abl e onl y when there i s at l east one sel ected
data object (si gnal , fi l ter, or spectrum) i n SPTool . Use the Edit menu to
dupl i cate and cl ear objects i n SPTool and to edi t object names and change
sampl i ng frequenci es.
A si gnal , fi l ter, or spectrum must be sel ected to be edi ted. When you cl i ck on an
Edit menu entry, al l selected data objects are di spl ayed i n a pop-up menu.
5 Interactive Tools
5-16
To edi t an SPTool object:
1 Sel ect a si gnal , fi l ter, or spectrum.
2 Sel ect the appropri ate Edit menu functi on.
The pop-up menu shows the names of al l sel ected data objects.
3 Drag to choose a speci fi c si gnal , fi l ter, or spectrum for edi ti ng.
Duplicate. Use Duplicatefrom the Edit menu to make a copy of the sel ected
si gnal , fi l ter, or spectrum i n SPTool .
Sel ect Duplicateand drag to choose the si gnal , fi l ter, or spectrum you want to
copy. When you sel ect a data object to dupl i cate i t, a new data object of the
same type i s automati cal l y created. The new data object i s named as a copy of
the sel ected data object. I t i s pl aced at the bottom of the l i st and i s sel ected. You
can change i ts name usi ng Name from the Edit menu.
Clear. Use Clear from the Edit menu to del ete the sel ected si gnal , fi l ter, or
spectrum from SPTool .
Sel ect Clear and drag to choose the si gnal , fi l ter, or spectrum you want to
remove. The data object i s del eted from the current SPTool sessi on.
Name. Use Name from the Edit menu to gi ve the sel ected si gnal , fi l ter, or
spectrum a new, uni que name.
1 Sel ect Name... and drag to choose the si gnal , fi l ter, or spectrum you want to
rename.
The NameChangedi al og box i s di spl ayed.
2 Type i n the new name and press OK.
Sampling Frequency. Use SamplingFrequencyfr om the Edit menu to suppl y
a sampl i ng frequency for a sel ected si gnal or fi l ter. The sampl i ng frequency
may be a number, such as 1, 0.001, or 1/5000, or a val i d MATLAB expressi on
i ncl udi ng workspace vari abl es, such as Fs, 1/Ts, or cos(0.1*pi).
Using SPTool
5-17
1 Sel ect SamplingFrequency... and drag to choose the si gnal or fi l ter you
want to change.
The SamplingFrequency... di al og box i s di spl ayed.
2 Type i n the val ue, vari abl e name, or expressi on and press OK.
Viewing a Signal
Use the Si gnal Viewbutton to make the Si gnal Browser acti ve and vi ew one or
more i mported si gnal s. The Si gnal Browser provi des tool s for graphi cal
anal ysi s of the sel ected si gnal (s).
Sel ect one or more si gnal s from the Signals l i st and press the Viewbutton i n
the si gnal panel . The Si gnal Browser di spl ays the sel ected si gnal (s). See Usi ng
the Si gnal Browser: I nteracti ve Si gnal Anal ysi s on page 5-43 for a ful l
descri pti on of Si gnal Browser functi ons and operati ons.
Viewing a Filter
Use the Viewbutton i n the Filterspanel to make the Fi l ter Vi ewer acti ve and
vi ew i mported fi l ters or fi l ters desi gned/edi ted i n the Fi l ter Desi gner. The
Fi l ter Vi ewer provi des tool s for anal yzi ng fi l ters; you can i nvesti gate the
magni tude response, phase, group del ay, zeros and pol es, and i mpul se and step
responses of the sel ected fi l ters.
Sel ect one or more fi l ters from the Filtersl i st and press the Viewbutton i n the
fi l ter panel . The Fi l ter Vi ewer di spl ays the sel ected fi l ters. See Usi ng the
Fi l ter Vi ewer: I nteracti ve Fi l ter Anal ysi s on page 5-84 for a ful l descri pti on of
Fi l ter Vi ewer functi ons and operati ons.
Designing a Filter
New Design. Use the Fi l ter NewDesign button to make the Fi l ter Desi gner
acti ve and desi gn a fi l ter. The Fi l ter Desi gner l ets you create FI R and I I R
di gi tal fi l ters of vari ous l engths and types usi ng the fi l ter desi gn functi ons i n
the Si gnal Processi ng Tool box.
Press the NewDesign button i n the Filter panel . The Fi l ter Desi gner di spl ays
a fi l ter created wi th the defaul t setti ngs and assi gns i t a defaul t name of filtn,
where n i s a uni que sequenti al i denti fyi ng di gi t. Once the defaul t fi l ter i s
created, you can use i t as i s or edi t i t wi th the Fi l ter Desi gner. You can rename
i t usi ng Name from the Edit menu.
5 Interactive Tools
5-18
Edit Design. Use the Filter panel s Edit Design button to make the Fi l ter
Desi gner acti ve and edi t a fi l ter. I mported fi l ters al ways open i n the Pol e/Zero
Edi tor.
Sel ect one or mor e fi l ter s from the Filters l i st and press the Edit Design
button i n the fi l ter panel . The Fi l ter Desi gner di spl ays the fi rst of the sel ected
fi l ter s. The other sel ected fi l ter s can be edi ted, one at a ti me, by sel ecti ng them
from the Filter pop-up menu. See Usi ng the Fi l ter Desi gner: I nteracti ve Fi l ter
Desi gn on page 5-59 for a ful l descri pti on of Fi l ter Desi gner functi ons and
operati ons.
Applying a Filter
Use the Apply Filter button to appl y a fi l ter to a sel ected si gnal . Thi s creates
a new si gnal :
1 Sel ect one si gnal from the Signalsl i st and one fi l ter from the Filtersl i st and
press the Apply Filter button i n the fi l ter panel .
The Apply Filter di al og box i s di spl ayed.
2 Sel ect the fi l teri ng al gori thm from the Algorithmpop-up menu, type the
name for the new si gnal i n the Output Signal fi el d, and press OK.
The avai l abl e fi l ter al gori thms are:
- Transposed di rect-form I I (uses the filter functi on)
- Zero-phase I I R (uses the filtfilt functi on)
- FFT-based FI R (uses the fftfilt functi on)
The sel ected fi l ter i s appl i ed to the sel ected i nput si gnal and the new output
si gnal i s l i sted i n the Signals l i st.
Drag to select the
algorithm you want
to use.
Type the new signal
name here.
Using SPTool
5-19
Creating a Spectrum
Use the Createbutton to acti vate the Spectrum Vi ewer and generate a defaul t
spectrum of a sel ected si gnal . Once youve generated a spectrum, you can vi ew
i t i n a vari ety of ways, measure i t, and modi fy i t i n the Spectrum Vi ewer.
1 Sel ect one si gnal from the Signals l i st and press the Createbutton i n the
Spectra panel .
The Spectrum Vi ewer i s acti vated and a spectrum object wi th defaul t
parameters i s created i n the Spectra panel . The PSD data i s not computed
or di spl ayed yet. The newl y cr eated spectrum object has a defaul t name of
specn, where n i s a uni que sequenti al i denti fyi ng di gi t. Once the spectrum
object i s created, you can use i t wi th the defaul t setti ngs, or conti nue to edi t
i t i n the Spectrum Vi ewer. You can rename i t usi ng Name from the Edit
menu.
2 Modi fy the spectrum parameters (e.g., Method and Nfft) as desi red.
3 Press Apply i n the Spectrum Vi ewer to compute the spectrum data. Thi s
button i s enabl ed when the spectrum has just been created or when you have
changed one or more parameters i n the Spectrum Vi ewer.
The updated spectrum i s di spl ayed i n the Spectrum Vi ewer. See Usi ng the
Spectrum Vi ewer: I nteracti ve PSD Anal ysi s on page 5-97 for a ful l
descri pti on of Spectrum Vi ewer parameters and di spl ays.
Viewing a Spectrum
Sel ect one or more spectra from the Spectral i st and press Viewi n the Spectra
panel . The Spectrum Vi ewer di spl ays the sel ected spectrum or spectra.
Updating a Spectrum
Use the Updatebutton to update the sel ected spectrum so that i t refl ects the
data i n the currentl y sel ected si gnal .
1 Sel ect one si gnal from the Signals l i st and one spectrum from the Spectra
l i st and press Updatei n the Spectra panel .
The spectral data from the current spectrum i s removed from the Spectrum
Vi ewer. The Spectrum Vi ewer i s acti vated. No spectrum i s di spl ayed yet.
5 Interactive Tools
5-20
2 Press Applyi n the Spectrum Vi ewer to compute the spectrum and compl ete
the update.
The spectr um i s regenerated wi th the same parameter s but usi ng the data
i n the currentl y sel ected si gnal . Thi s feature i s useful when you have al tered
a si gnal (by fi l teri ng i t, for exampl e), and want to update the exi sti ng
spectrum to refl ect the change.
Customizing Preferences
Use Preferences from the Filemenu to customi ze di spl ays and certai n
parameters for SPTool and i ts four component tool s. The new setti ngs are
saved on di sk and are used when you restart MATLAB.
I n the Preferences panel s, you can:
Sel ect col ors and markers for rul ers, and set the i ni ti al rul er styl e
Sel ect col or and l i ne styl e sequence for di spl ayed si gnal s
Confi gure axi s l abel s, and enabl e/di sabl e rul ers, panner, and mouse zoom i n
the Si gnal Browser
Confi gure axi s parameters, and enabl e/di sabl e rul ers and mouse zoom i n the
Spectrum Vi ewer
Confi gure fi l ter and axi s parameters and enabl e/di sabl e mouse zoom i n the
Fi l ter Vi ewer
Confi gure ti l i ng preferences i n the Fi l ter Vi ewer
Speci fy FFT l ength, and enabl e/di sabl e mouse zoom and gri d i n the Fi l ter
Desi gner
Enabl e/di sabl e use of a defaul t sessi on fi l e
Confi gure fi l ters for export to the Control System Tool box (for users of that
product)
Enabl e/di sabl e search for pl ug-i ns at start-up
When you fi rst sel ect Preferences, the Preferences di al og box di spl ays the
Rulers panel . You can change the setti ngs for rul ers, or choose on any of the
other setti ngs categori es to customi ze other setti ngs.
Cl i ck once on a setti ngs category to sel ect i t.
Using SPTool
5-21
The fol l owi ng secti ons descri be al l of the setti ngs you can modi fy. The
i l l ustrati ons show the defaul t setti ngs for each category. For addi ti onal
i nformati on on preference setti ngs, use the Help... button at the bottom of the
Preferences di al og box.
Ruler Settings
The Rulers preferences appl y to the rul ers i n the Si gnal Browser, Spectrum
Vi ewer, and Fi l ter Vi ewer. These preferences al so appl y to pri ntouts from the
Si gnal Browser and Spectrum Vi ewer.
Ruler Color. Speci fi es the col or of the rul ers. Col or i s speci fi ed as a stri ng
(e.g., 'r') or RGB tri pl e (e.g., [1 0 0]).
Ruler Marker. Speci fi es the marker used i n the track and sl ope rul ers.
Marker Size. Speci fi es the si ze of the rul er marker i n poi nts. Thi s can be any
posi ti ve val ue.
Initial Type. Speci fi es the type of rul er (hori zontal , verti cal , track, or sl ope) that
i s sel ected when you fi rst open the Si gnal Browser, Spectrum Vi ewer, or Fi l ter
Vi ewer.
5 Interactive Tools
5-22
Color Settings
The Colors preferences appl y to si gnal s di spl ayed i n the Si gnal Browser,
Spectrum Vi ewer, and Fi l ter Vi ewer. These preferences al so appl y to pri ntouts
from the Si gnal Browser and Spectrum Vi ewer.
Color Order. Speci fi es the col or order to cycl e through for data pl otted i n the
Si gnal Browser, Spectrum Vi ewer, and Fi l ter Vi ewer. The defaul t i s the axi s
col or order.
Type i n a new val ue or val ue stri ng to change the col or order. Col or i s speci fi ed
as a stri ng (e.g., 'r') or RGB tri pl e (e.g., [1 0 0]), an n-by-3 matri x of n col ors,
or an n-by-1 cel l array of such objects.
Line Style Order. Speci fi es the l i ne styl es to cycl e through for data pl otted i n the
Si gnal Browser, Spectrum Vi ewer, and Fi l ter Vi ewer. The defaul t i s the axi s
l i ne styl e order.
Type i n a new stri ng val ue (e.g., '--') or an array of stri ngs
(e.g., {'-','--',':'}) to change the l i ne styl e order.
Using SPTool
5-23
Signal Browser Settings
The Signal Browser preferences l et you set opti onal x-axi s and y-axi s l abel s,
enabl e and di sabl e the di spl ay of the rul ers and the panner, and toggl e zoom
persi stence.
Except for zoom persi stence, these preferences al so appl y to pri nti ng from the
Si gnal Browser. See Pri nti ng Si gnal Data on page 5-54 for detai l s on pri nti ng
from the Si gnal Browser.
X Label, Y Label. Type i n a stri ng for the x-axi s l abel and the y-axi s l abel i n the
Si gnal Browser. The defaul t i s Time for the x-axi s.
Rulers. Cl i ck i n the check box to di spl ay (checked) or hi de (unchecked) the rul er
buttons and the rul er panel i n the Si gnal Browser. See Rul er Control s on
page 5-33 for detai l s on usi ng the rul ers i n the Si gnal Browser.
Panner. Cl i ck i n the check box to di spl ay (checked) or hi de (unchecked) the
panner i n the Si gnal Browser. See Panner Di spl ay on page 5-52 for detai l s on
usi ng the panner i n the Si gnal Browser.
Stay in Zoom-mode After Zoom. Cl i ck i n the check box to enabl e (checked) or
di sabl e (unchecked) zoom persi stence i n the Si gnal Browser. See Zoom
Control s on page 5-31 for detai l s on zoom control s i n the Si gnal Browser.
5 Interactive Tools
5-24
Spectrum Viewer Settings
The SpectrumViewer pr efer ences l et you set axi s par ameter s, enabl e and
di sabl e the di spl ay of the rul ers, and toggl e zoom persi stence.
Except for zoom persi stence, these preferences al so appl y to pri nti ng from the
Spectrum Vi ewer. See Pri nti ng Spectrum Data on page 5-107 for detai l s on
pri nti ng from the Spectrum Vi ewer.
Magnitude Axis Scaling. Speci fi es the scal i ng uni ts for the magni tude (y) axi s i n
the Spectrum Vi ewer. Scal i ng uni ts can be decibels or linear.
Frequency Axis Scaling. Speci fi es the scal i ng uni ts for the frequency (x) axi s i n the
Spectrum Vi ewer. Scal i ng uni ts can be linear or log.
Frequency Axis Range. Speci fi es the numeri cal range for the frequency (x) axi s i n
the Spectrum Vi ewer. Scal i ng opti ons are [0,Fs/2], [0,Fs], or [-Fs/2,Fs/2].
Rulers. Cl i ck i n the check box to di spl ay (checked) or hi de (unchecked) the rul er
buttons and the rul er panel i n the Spectrum Vi ewer. See Rul er Control s on
page 5-33 for detai l s on usi ng the rul ers i n the Spectrum Vi ewer.
Stay in Zoom-mode After Zoom. Cl i ck i n the check box to enabl e (checked) or
di sabl e (unchecked) zoom persi stence i n the Spectrum Vi ewer. See Zoom
Control s on page 5-31 for detai l s on zoom control s i n the Spectrum Vi ewer.
Using SPTool
5-25
Filter Viewer Settings
The Filter Viewer preferences l et you set key fi l ter pl ot confi gurati on
parameters and toggl e zoom persi stence.
FFT Length. Speci fi es the number of poi nts at whi ch the frequency response i s
computed (for the magni tude, phase, and group del ay pl ots).
Time Response Length. Speci fi es the ti me response l ength (i n sampl es) for the
i mpul se and step response pl ots. An empty val ue, [ ], for an FI R fi l ter i ndi cates
that the compl ete response l ength wi l l be shown; an empty val ue for an I I R
fi l ter i ndi cates that the response l ength wi l l be automati cal l y determi ned usi ng
the impz functi on.
Magnitude Axis Scaling. Speci fi es the scal i ng uni ts for the magni tude (y) axi s i n
the Fi l ter Vi ewer. Scal i ng uni ts can be linear, log, or decibels.
Phase Units. Speci fi es the phase uni ts for the phase response pl ot. Phase uni ts
can be degrees or radians.
Frequency Axis Scaling. Speci fi es the scal i ng uni ts for the frequency (x)axi s i n the
Fi l ter Vi ewer. Scal i ng uni ts can be linear or log.
Frequency Axis Range. Speci fi es the numeri cal range for the frequency (x) axi s i n
the Fi l ter Vi ewer. Scal i ng opti ons are [0,Fs/2], [0,Fs], or [-Fs/2,Fs/2].
5 Interactive Tools
5-26
Rulers. Cl i ck i n the check box to di spl ay (checked) or hi de (unchecked) the rul er
buttons and the rul er panel i n the Fi l ter Vi ewer. See Rul er Control s on page
5-33 for detai l s on usi ng the rul ers i n the Fi l ter Vi ewer.
Stay in Zoom-mode After Zoom. Cl i ck i n the check box to enabl e (checked) or
di sabl e (unchecked)zoom persi stence i n the Fi l ter Vi ewer. See Zoom Control s
on page 5-31 for detai l s on zoom control s i n the Fi l ter Vi ewer.
Filter Viewer Tiling Settings
The Filter ViewerTilingpreferences l et you change the way the Fi l ter Vi ewer
di spl ays the anal ysi s pl ots.
Cl i ck the radi o button to sel ect how the pl ots are ti l ed i n the di spl ay area.
Opti ons are 2-by-3Grid, 3-by-2Grid, Vertical (6-by-1Grid), and
Horizontal (1-by-6Grid).
Thi s speci fi es how the pl ots are arranged when al l si x pl ot opti ons are turned
on. When fewer opti ons are turned on, the pl ots are di spl ayed as symmetri cal l y
as possi bl e.
Using SPTool
5-27
Filter Designer Settings
The Filter Designer preferences l et you set key fi l ter confi gur ati on and pl ot
parameters.
FFT Length. Speci fi es the number of poi nts used to cal cul ate a fi l ters frequency
response.
Display grid lines. Turns pl ot gri d l i nes on (checked) or off (unchecked).
Auto Design initial value. Speci fi es the defaul t setti ng for the AutoDesigncheck
box i n the Fi l ter Desi gner. When the Fi l ter Desi gner i s fi rst l aunched, the Auto
Design check box wi l l have the same setti ng (checked or unchecked) as the
Auto Design initial valuecheck box here.
Stay in Zoom-mode After Zoom. Turns persi stent zoomi ng on and off, as descri bed
i n Zoom Control s on page 5-31.
5 Interactive Tools
5-28
Default Session Setting
The Default Session preference l ets you speci fy whether or not to l oad a
defaul t sessi on fi l e when SPTool i s l aunched.
Default Session. Enabl es (checked) or di sabl es (unchecked) l oadi ng of a defaul t
sessi on fi l e, whi ch must have the name startup.spt, when starti ng SPTool .
An SPTool sessi on fi l e i s a MAT-fi l e (see UsingMATLAB) wi th a .spt
extensi on.
The Default Session preference onl y affects the sessi on contents when you
start SPTool . You can l oad a new sessi on fi l e after starti ng SPTool usi ng the
Open Session opti on i n the SPTool Filemenu. You can al so save a sessi on fi l e
at any ti me usi ng the SaveSessionopti on i n the Filemenu. I f you cl ose SPTool
wi thout havi ng recentl y saved a sessi on fi l e, you wi l l be prompted to do so. (See
Fi l e Menu on page 5-6.)
NOTE Changes that you make i n the SPTool preference panel s are saved i n
a separate MAT-fi l e, whi ch i s rel oaded the next ti me you open SPTool (see
Savi ng and Di scardi ng Changes to Preferences Setti ngs on page 5-30). The
Default Session preference does not affect these preference setti ngs.
Using SPTool
5-29
Exporting Components Setting
The ExportingComponents preference l ets you speci fy whether or not to
expor t fi l ter s cr eated i n SPTool as TF objects for the Control System Tool box.
Export Filters as TF objects. Enabl es (checked) or di sabl es (unchecked) exporti ng of
SPTool fi l ters as TF (transfer functi on) objects, for use i n the Control System
Tool box (see the Control SystemToolbox Users Guide).
NOTE Thi s preference category onl y appears i n the i n SPTool Preferences
di al og box i f you have i nstal l ed the Control System Tool box.
5 Interactive Tools
5-30
Plug-Ins Setting
The Plug-Inspreference l ets you search for pl ug-i ns when SPTool i s started up.
Search for Plug-Ins at start-up. Enabl es (checked) or di sabl es (unchecked)
searchi ng for i nstal l ed pl ug-i ns.
A plug-in i s an extensi on to SPTool . Pl ug-i ns i ncl ude customi zed add-on panel s
and new buttons i n the panel s i n SPTool , new spectral methods i n the
Spectrum Vi ewer, and new SPTool preferences. You can al so pl ug one or more
tool boxes i nto SPTool .
You need to use thi s setti ng onl y when you have i nstal l ed extensi ons or have
other tool boxes pl ugged i nto SPTool .
To use SPTool wi th extensi ons, check Search for Plug-ins at start-up, cl ose
SPTool , and restart i t.
Saving and Discarding Changes to Preferences Settings
The buttons at the bottom of the Preferences panel s l et you save or di scard
any changes you have made, or return to the defaul t setti ngs.
Factory Settings. Restores the preferences i n the current panel to thei r ori gi nal
setti ngs; that i s, the setti ngs at the ti me the Si gnal Processi ng Tool box was
fi rst i nstal l ed.
Using SPTool
5-31
Revert Panel. Cancel s changes i n the current panel onl y. Setti ngs i n the current
panel revert to the previ ous setti ngs.
Cancel. Cancel s changes i n al l preference categori es and cl oses the
Preferences di al og box. Setti ngs i n al l panel s revert to thei r previ ous state.
OK. Appl i es changes i n al l Preferences panel s and cl oses the Preferences
di al og box. Setti ngs i n al l panel s are saved i n a MAT-fi l e cal l ed sigprefs.mat.
I f sigprefs.mat does not exi st, ei ther on the current MATLAB path or i n the
current di rectory, you are prompted for a l ocati on to save the fi l e. The saved
setti ngs are used the next ti me you open SPTool .
Controls for Viewing and Measuring
The GUI tool s share common control s for vi ewi ng and measuri ng si gnal s.
These control s ar e descr i bed i n thi s secti on. Not al l tool s use al l of the vi ewi ng
and measuri ng control s; speci fi c detai l s about the tool s and procedures for
vi ewi ng and measuri ng are descri bed i n the secti on on each tool .
Zoom Controls
The GUI tool s share a common set of zoom control buttons. The Si gnal Browser
and Spectrum Vi ewer use the same set of common zoom control buttons, whi ch
affect both on-screen and pri nted i mages.
The Fi l ter Desi gner has one addi ti onal vi ewi ng button, the PassBandbutton.
The Fi l ter Vi ewer has a subset of the zoom control buttons.
Each button works the same way i n every GUI tool i n whi ch i t occurs.
I n ordi nary use, you press a button once to zoom i n or out of the si gnal di spl ay.
5 Interactive Tools
5-32
Zoom In-X, Zoom Out-X, Zoom In-Y, and Zoom Out-Y. Cl i ck once to perform one zoom
operati on (i n or out) on the x- or y-axi s. Each zoom operati on changes the axes
l i mi ts by a factor of two on the speci fi ed axi s, about the center of the di spl ayed
si gnal . You can press repeatedl y on one or more buttons to conti nue to change
the scal e i n one or both axes.
When you zoom i n the x-axi s (hori zontal scal i ng), the yl i mi ts (verti cal scal i ng)
of the mai n axes are not changed. Si mi l arl y, when you zoom i n the y-axi s, the
xl i mi ts of the mai n axes are not changed.
Full View. Cl i ck once to restore the di spl ayed si gnal to i ts ful l range i n both axes.
Mouse Zoom. Cl i ck once to acti vate zoom mode. The cursor changes to a
crosshai r. You can ei ther zoom i n wi thout speci fyi ng a zoom wi ndow, or you can
use a zoom rectangl e to sel ect a speci fi c zoom wi ndow. I n ei ther case, the x- and
y-axi s are automati cal l y adjusted to di spl ay the sel ected si gnal :
To zoom i n wi thout speci fyi ng a zoom wi ndow, cl i ck on the pl ot. The posi ti on
of the crosshai r i s the center of a zoom operati on that hal ves both the x- and
y-axi s l i mi ts.
To use a zoom rectangl e, cl i ck where you want the rectangl e to begi n, drag
the mouse di agonal l y to wher e you want i t to end, and rel ease the mouse
button.
To get out of mouse zoom mode wi thout zoomi ng i n or out, press the Mouse
Zoombutton agai n.
Zoom Persistence. Mouse zoomi ng can ei ther be one-timeor persistent:
One-ti me zoomi ng i s acti vated when you pr ess the MouseZoombutton. I t
automati cal l y turns i tsel f off after you cl i ck i n the di spl ay area and the zoom
operati on occurs. Thi s i s the defaul t for al l the tool s.
Persi stent zoomi ng i s al so acti vated by pressi ng the MouseZoombutton. I t
does not turn off after you cl i ck i n the di spl ay area and a zoom operati on
occurs; you can conti nue to cl i ck and zoom wi thout resetti ng the Mouse
Zoombutton.
You can change whether zoomi ng i s one-ti me or persi stent by sel ecti ng
Preferences from the Filemenu and toggl i ng Stay in Zoom-modeAfter
Zoomi n the Preferencespanel s for the Si gnal Browser, the Spectrum Vi ewer,
the Fi l ter Desi gner, and the Fi l ter Vi ewer.
Using SPTool
5-33
When Stay in Zoom-modeAfter Zoomi s sel ected, zoomi ng i s persi stent. To
turn off mouse zoomi ng when Stay in Zoom-modeAfter Zoomi s sel ected,
press the MouseZoombutton.
Passband Zoom (Filter Designer). Cl i ck once to zoom i n on the passband of the
response.
Both the x- and y-l i mi ts of the mai n axes are changed so that the passband fi l l s
the mai n axes.
Ther e i s no stopband zoom button. To zoom the stopband, use standar d Mouse
Zoom, centeri ng the crosshai r on the area of the stopband you want to vi ew. I f
you are i n passband zoom, fi rst press Full Viewto return to the standard vi ew.
Ruler Controls
The Si gnal Browser, Fi l ter Vi ewer, and Spectrum Vi ewer share a common set
of rul er control s. Use the rul ers to make measurements on the si gnal s or
spectra i n the mai n axes (di spl ay) area. The rul er control s gi ve you a vari ety of
ways to read and control the val ues of the rul ers i n the mai n axes. Wi th the
rul ers you can measure such i nformati on as the verti cal and hori zontal
di stance between features i n a si gnal or spectrum, the di mensi ons of peaks and
val l eys, and sl ope i nformati on.
I n the fol l owi ng di scussi on, the Si gnal Browser i s shown. The rul er control s
i ncl ude the Selection control s at the top ri ght of the wi ndow and the buttons
and edi t boxes i n the Rulers panel . The control s i n the Fi l ter Vi ewer and
Spectrum Vi ewer work the same way. The control s i n the Si gnal Browser and
the Spectrum Vi ewer al so affect i mages pri nted from these tool s.
I n the Fi l ter Vi ewer, the rul ers appear on onl y one subpl ot at a ti me. You can
choose whi ch subpl ot the rul ers appear on by sel ecti ng the subpl ot from the
pop-up menu at the top of the Rulerspanel , or by cl i cki ng on a l i ne i n the pl ot
that you want to measure. I f a subpl ot i s not currentl y vi si bl e when you sel ect
i ts name from the pop-up menu, the Fi l ter Vi ewer creates the subpl ot and
pl aces the rul ers i n i t.
5 Interactive Tools
5-34
Selecting a Line to Measure. When there i s onl y one si gnal di spl ayed, the di spl ayed
si gnal i s automati cal l y sel ected and i s measured when you use the rul ers.
When there i s more than one si gnal di spl ayed, onl y one si gnal (l i ne) may be
sel ected and measured at a ti me.
When a si gnal (l i ne) i s sel ected, you can use the rul er control s (Vertical,
Horizontal, Track, or Slope) and the Peaks and/or Valleys control s on the
sel ected l i ne. The l abel of the sel ected si gnal (l i ne) i s di spl ayed i n the Selection
pop-up menu.
There are two ways to sel ect a si gnal (l i ne):
Cl i ck on the Selection pop-up menu and drag to sel ect the l i ne to measure.
Al l si gnal s that are currentl y sel ected i n SPTool are l i sted. Vector si gnal s i n
the Si gnal Browser, spectra i n the Spectrum Vi ewer, and fi l ters i n the Fi l ter
Vi ewer are l i sted as si ngl e vari abl es; i n the Si gnal Browser, each col umn of
a two-di mensi onal si gnal matri x i s l i sted as a separate vari abl e.
Move the mouse poi nter over any poi nt i n the l i ne you want to sel ect and cl i ck
on i t.
Find ruler buttons
Ruler control buttons
Selection pop-up menu Selection display
Color button
Rulers panel
Display peaks and valleys
buttons
Save Rulers button
Edit boxes
Using SPTool
5-35
The l abel of the si gnal , i ncl udi ng the col umn number i f the l i ne i s one col umn
of a matri x, i s di spl ayed i n the Selection pop-up menu.
The l i ne sel ecti on di spl ay changes to the col or and patter n of the sel ected
si gnal , spectr um, or fi l ter .
Line Selection Pop-Up Menu. Use to sel ect a l i ne (vector si gnal , array col umn,
fi l ter, or spectrum) to measure.
Cl i ck the Selection pop-up menu and drag to sel ect the l i ne.
Line Selection Display. The l i ne col or and styl e of the sel ected si gnal ar e di spl ayed.
Color Button. Use to edi t the l i ne styl e or di spl ay col or of the sel ected l i ne.
Cl i ck on the Color button at the top ri ght of the wi ndow to di spl ay the
Edit Linepop-up menu, whi ch i s shown on the l eft. The l abel of the sel ected
l i ne i s di spl ayed i n the Label fi el d.
Cl i ck the LineStylepop-up menu and drag to sel ect a l i ne styl e, as shown
on the l eft.
Cl i ck a radi o button to sel ect a col or. I f you sel ect Other, you can type a col or
val ue i n the Enter colorspec box; the col or val ue can be a stri ng (e.g., 'r')
or an RGB tri pl e (e.g., [1 0 0]).
Cl i ck OK to appl y the l i ne styl e and col or you sel ected.
Find Ruler Buttons. Use the fi nd rul er buttons to bri ng one or both rul ers i nto the
vi ewi ng area of the mai n axes. When both rul ers are wi thi n the si gnal di spl ay
(mai n axes) area, the Find Ruler buttons, at the top r i ght of the mai n axes
area, are not di spl ayed.
I f the rul ers are not wi thi n the si gnal di spl ay area, both Find Ruler
buttons are di spl ayed, as shown on the ri ght.
I f one rul er i s wi thi n the si gnal di spl ay area, the button for the other
rul er i s di spl ayed, as shown on the ri ght.
Cl i ck a Find Ruler button to bri ng the speci fi ed rul er i nto the di spl ay area.
When a rul er i s vi si bl e, you can cl i ck on i t and drag i t to make a measurement
on the sel ected si gnal . See Maki ng Si gnal Measurements on page 5-37 for
detai l s on mani pul ati ng the rul ers and measuri ng the sel ected si gnal .
5 Interactive Tools
5-36
Ruler Control Buttons. Use the rul er control buttons to sel ect the type of
measurement you want to make: Vertical, Horizontal, Track, or Slope. The
defaul t setti ng i s Track.
Cl i ck a rul er control button to sel ect i t. The Rulers panel changes dependi ng
on whi ch rul er contr ol i s sel ected. See Maki ng Si gnal Measurements on page
5-37 for detai l s on the four ki nds of measurements you can make and the
parameters for each one.
Rulers Panel and Edit Boxes. The Rulers panel changes dependi ng on whi ch rul er
control i s sel ected: Vertical, Horizontal, Track, or Slope. I t shows the
parameters for the sel ected rul er control . Dependi ng on whi ch rul er control i s
sel ected, the fol l owi ng fi el ds are di spl ayed: x1, y1, x2, y2, dx, dy, m. The
pi cture on the l eft shows the Rulers panel when Slopei s sel ected.
When you press a rul er control button, rul ers are di spl ayed superi mposed on
the si gnal (s) i n the mai n axes di spl ay area. The rul ers are ei ther verti cal (for
Vertical, Track, and Slope) or hori zontal (for Horizontal). For Track and
Slope, rul er markers are al so di spl ayed. The rul ers and rul er markers are
associ ated wi th the currentl y sel ected si gnal . The fol l owi ng pi cture shows the
rul ers and rul er markers that are di spl ayed when Slopei s sel ected.
To posi ti on a rul er, you can cl i ck and drag on i t. When you drag a rul er, the
parameters i n the Rulers panel change to refl ect the measurements on the
sel ected si gnal .
You can al so posi ti on a rul er by speci fyi ng parameters i n the edi t boxes i n the
Rulerspanel . The parameters are ei ther the x1and x2val ues or the y1and y2
val ues, dependi ng on whi ch rul er control i s sel ected.
Using SPTool
5-37
Type the val ue or vari abl e for the rul er parameter i n the x1and x2boxes or the
y1and y2boxes. See Maki ng Si gnal Measurements on page 5-37 for detai l s
on mani pul ati ng the rul ers and the parameters you can measure wi th each
one.
Peaks and Valleys. Use these buttons to show or hi de the l ocal maxi ma and/or
l ocal mi ni ma of the currentl y sel ected si gnal , fi l ter response, or spectrum. Onl y
peaks or val l eys, or both peaks and val l eys may be di spl ayed.
Cl i ck Peaks to toggl e showi ng (down) or hi di ng (up) the maxi ma of the
si gnal .
Cl i ck Valleys to toggl e showi ng (down) or hi di ng (up) the mi ni ma of the
si gnal .
I n track and sl ope mode (see Maki ng Si gnal Measurements on page 5-37), the
rul ers are constrai ned to the peaks or val l eys. I n hori zontal and verti cal mode,
the peaks and val l eys are onl y vi sual and do not affect the behavi or of the
rul ers.
Save Rulers Button. Once youve set up and made a certai n set of
measurements, you may fi nd i t useful to save them for future reference. Use
the SaveRulersbutton to save a structure i n the MATLAB workspace wi th
the fi el ds x1, y1, x2, y2, dx, dy, m, peaks, and valleys. Undefi ned val ues are set
to NaN.
1 Cl i ck SaveRulersto save the current measurements as a vari abl e i n the
workspace.
The Save Rul ers di al og box i s di spl ayed.
2 Type a vari abl e name i n the edi t fi el d and press OK.
Making Signal Measurements
Use the rul ers to make measurements on a sel ected l i ne, whi ch i s a vector or a
col umn of a matri x i n the Si gnal Browser, a fi l ter response i n the Fi l ter Vi ewer,
or a spectrum i n the Spectrum Vi ewer. To make a measurement:
1 Sel ect a l i ne as descri bed i n Sel ecti ng a Li ne to Measure on page 5-34.
2 Appl y a rul er to the di spl ay as descri bed i n Rul er Control Buttons on page
5-36.
5 Interactive Tools
5-38
3 Posi ti on a rul er where you want i t i n the mai n axes area by cl i cki ng and
draggi ng i t:
a Move the mouse over the rul er (1 or 2) that you want to dr ag.
The hand cursor i s di spl ayed when youre over a rul er, wi th the rul er
number i nsi de i t:
b Cl i ck and drag the rul er to where you want i t on the si gnal .
Dependi ng on whi ch rul er control i s sel ected, you can drag the rul er to the
ri ght and l eft (Vertical, Track, and Slope) or up and down (Horizontal).
As you drag a rul er, the Rulers panel shows the current posi ti on of both
rul ers. Dependi ng on whi ch rul er control i s sel ected, the fol l owi ng fi el ds are
di spl ayed: x1, y1, x2, y2, dx, dy, m. These fi el ds wi l l al so be di spl ayed i n
pri ntouts from the Si gnal Browser, unl ess you suppress them. See Pri nti ng
Si gnal Data on page 5-54 and Pri nti ng Spectrum Data on page 5-107 for
detai l s on pri nti ng from these tool s.
You can al so posi ti on a rul er by typi ng i ts x1and x2or y1and y2val ues i n the
Rulers panel , as descri bed on page 5-36.
Ruler Controls: Vertical. There are two verti cal rul ers, cal l ed rul er 1 and rul er 2.
When verti cal rul ers are i n use, the measurements di spl ayed i n the Rulers
Using SPTool
5-39
panel are x1(the posi ti on of rul er 1 on the x-axi s), x2(the posi ti on of rul er 2 on
the x-axi s), and dx (the val ue of x2-x1).
Press Vertical to put the rul ers i n verti cal mode.
I n verti cal mode, you may change the x-val ues of the rul er s (that i s, thei r
hori zontal posi ti on). As the x1and x2val ues change, the val ue of dx changes
automati cal l y.
Change the x1and x2val ues i n one of two ways:
Drag the rul ers to the l eft and the ri ght wi th the mouse
Enter thei r val ues i n the x1and x2edi t boxes i n the Rulers panel
Ruler Controls: Horizontal. There are two hori zontal rul ers, cal l ed rul er 1 and
rul er 2. When hori zontal rul ers are i n use, the measurements di spl ayed i n the
5 Interactive Tools
5-40
Rulers panel are y1(the posi ti on of r ul er 1 on the y-axi s), y2(the posi ti on of
rul er 2 on the y-axi s), and dy (the val ue of y2-y1).
Press Horizontal to put the rul ers i n hori zontal mode.
I n hori zontal mode, you may change the y-val ues of the rul ers (that i s, thei r
verti cal posi ti on). As the y1and y2val ues change, the val ue of dy changes
automati cal l y.
Change the y1and y2val ues i n one of two ways:
Draggi ng the rul ers up and down wi th the mouse
Enteri ng thei r val ues i n the y1and y2edi t boxes i n the Rulers panel
Ruler Controls: Track. There are two verti cal rul ers, cal l ed rul er 1 and rul er 2,
wi th a marker on each that shows the y-val ues of the si gnal at the x-val ues of
the rul ers. When track rul ers are i n use, the measurements di spl ayed i n the
Rulers panel are x1(the posi ti on of r ul er 1 on the x-axi s), y1(the posi ti on of
Using SPTool
5-41
rul er 1 on the y-axi s), x2(the posi ti on of rul er 2 on the x-axi s), y2(the posi ti on
of rul er 2 on the y-axi s), dx (the val ue of x2-x1), and dy (the val ue of y2-y1).
Press Track to put the rul ers i n track mode.
You can change the track marker i n the Rulers panel from the Preferences
di al og box; see Rul er Setti ngs on page 5-21.
I n track mode, you may change the x-val ues of the rul ers (that i s, thei r
hori zontal posi ti on). As the x1and x2val ues change, the val ues of y1, y2, dx,
and dy change automati cal l y.
Change the x1and x2val ues i n one of two ways:
Draggi ng the rul ers to the l eft and the ri ght wi th the mouse
Enteri ng thei r val ues i n the x1and x2edi t boxes i n the Rulers panel
Ruler Controls: Slope. There are two verti cal rul ers, cal l ed rul er 1 and rul er 2,
wi th the sl ope l i ne passi ng through the y-axi s i ntersecti ons of the two verti cal
rul ers and the si gnal . The rul ers al so track the si gnal wi th markers on each
rul er that shows the y-val ues of the si gnal at the x-val ues of the rul ers. The l i ne
connecti ng (x1, y1) and (x2, y2) i s i ncl uded i n the mai n pl ot, so you can
approxi mate deri vati ves and sl opes of the si gnal .
5 Interactive Tools
5-42
When sl ope rul ers are i n use, the measurements di spl ayed i n the Rulerspanel
are x1(the posi ti on of rul er 1 on the x-axi s), y1(the posi ti on of rul er 1 on the
y-axi s), x2(the posi ti on of r ul er 2 on the x-axi s), y2(the posi ti on of rul er 2 on
the y-axi s), dx (the val ue of x2- x1), dy (the val ue of y2- y1), and m(equal to
dy/ dx, the sl ope of the l i ne between x1and x2).
Press Slopeto put the rul ers i n sl ope mode.
I n sl ope mode, you may change the x-val ues of the rul ers (that i s, thei r
hori zontal posi ti on). As the x1and x2val ues change, the val ues of dy and m
change automati cal l y.
Change the x1and x2val ues i n one of two ways:
Draggi ng the rul ers to the l eft and the ri ght wi th the mouse
Enteri ng thei r val ues i n the x1and x2edi t boxes i n the Rulers panel
Using the Signal Browser: Interactive Signal Analysis
5-43
Using the Signal Browser: Interactive Signal Analysis
The Si gnal Browser tool i s an i nteracti ve si gnal expl orati on envi ronment. I t
provi des a graphi cal vi ew of the si gnal object(s) currentl y sel ected i n the
Signals col umn of SPTool .
Usi ng the Si gnal Browser you can:
Vi ew and compare vector or array si gnal s
Zoom i n on a range of si gnal data to exami ne i t more cl osel y
Measure a vari ety of characteri sti cs of si gnal data
Pl ay si gnal data on audi o hardware
Pri nt si gnal data
Opening the Signal Browser
To open or acti vate the Si gnal Browser from SPTool :
1 Cl i ck on one or more si gnal s i n the Signals l i st of SPTool .
2 Press Viewi n the Signals panel of SPTool .
The Si gnal Browser i s acti vated and the sel ected si gnal (s) are l oaded i nto
the Si gnal Browser and di spl ayed.
5 Interactive Tools
5-44
Basic Signal Browser Functions
The Si gnal Browser has the fol l owi ng components:
A mai n axes (di spl ay) area for vi ewi ng si gnal s graphi cal l y
Di spl ay management control s: Array Signals and the compl ex si gnal
di spl ay pop-up menu
Zoom control s for getti ng a cl oser l ook at si gnal features
Rul ers and l i ne di spl ay control s for maki ng si gnal measurements and
compari sons
A panner for seei ng what part of the si gnal i s currentl y bei ng di spl ayed and
for qui ckl y movi ng the vi ew to other features of the si gnal
Menu opti ons for pri nti ng si gnal data
A menu opti on for pl ayi ng a sel ected si gnal through audi o equi pment
Viewing (zoom) controls Measuring (line and ruler) controls
Panner
Main axes
(display) area
Display management controls
Using the Signal Browser: Interactive Signal Analysis
5-45
Menus
File Menu. Use PageSetup... from the Filemenu to open the standard
MATLAB PageSetupdi al og box, i n whi ch you can set the ori entati on, si ze and
posi ti on, l i mi ts, and col or of your pri ntout.
See UsingMATLAB Graphics for more i nformati on about the PageSetup
di al og box.
Use Print Preview... from the Filemenu to open a MATLAB fi gure wi ndow
wi th a previ ew of the i nformati on from the Si gnal Browser wi ndow that wi l l
appear i n your pri ntout. See Si gnal Browser Setti ngs on page 5-23 and
Pri nti ng Si gnal Data on page 5-54 for detai l s about pri nti ng from the Si gnal
Browser.
Use Print... from the Filemenu to open the standard pri nt di al og box, from
whi ch you can pri nt your si gnal data.
Use Closefrom the Filemenu to cl ose the Si gnal Browser. Al l si gnal sel ecti on
and rul er i nformati on wi l l be l ost. (You may want to save rul er i nformati on to
the workspace usi ng the SaveRulers... button, as descri bed on page 5-37.)
Setti ngs you changed and saved usi ng the Preferences di al og box i n SPTool
are saved and used the next ti me you open a Si gnal Browser.
5 Interactive Tools
5-46
Options Menu. Use Play from the Options menu to pl ay the sel ected si gnal .
Play works onl y when you have sound capabi l i ti es on your computer. I f your
computer does not have sound capabi l i ti es, thi s menu choi ce does nothi ng.
The enti re sel ected si gnal i s pl ayed at ei ther Fs (the sampl i ng frequency of the
si gnal ) or at the defaul t pl atform sampl i ng frequency i f Fs i s l ess than 25 Hz.
The real part and the i magi nary part of a compl ex si gnal are pl ayed i n separate
channel s.
Window Menu. Use the Windowmenu to sel ect a currentl y open MATLAB
wi ndow.
Zoom Controls
The avai l abl e zoom control s i n the Si gnal Browser are MouseZoom, Full
View, ZoomIn-Y, ZoomOut-Y, ZoomIn-X, and ZoomOut-X. See Zoom
Control s on page 5-31 for detai l s on usi ng the zoom control s i n the Si gnal
Browser.
Zoom persi stence i s off by defaul t i n the Si gnal Browser; use the Si gnal
Browser setti ngs panel i n the Preferencesdi al og box i n SPTool to toggl e zoom
persi stence on and off. See Si gnal Browser Setti ngs on page 5-23.
Ruler and Line Display Controls
Usi ng the rul ers and l i ne di spl ay control s, you can measure a vari ety of
characteri sti cs of si gnal s i n the Si gnal Browser. See Rul er Control s on page
5-33 for detai l s on usi ng rul ers and modi fyi ng l i ne di spl ays i n the Si gnal
Browser.
The rul ers are di spl ayed by defaul t i n the Si gnal Browser; you can turn off the
rul er di spl ay i n the Signal Browser setti ngs panel i n the Preferences di al og
box. See Si gnal Browser Setti ngs on page 5-23.
Help Button
To use context-sensi ti ve hel p, press the Help button. The mouse poi nter
becomes an arrow wi th a questi on mark symbol . You can then cl i ck on anythi ng
i n the Si gnal Browser, i ncl udi ng menu i tems, to fi nd out what i t i s and how to
use i t.
Using the Signal Browser: Interactive Signal Analysis
5-47
Display Management Controls
Array Signals Button. Use thi s to enter a col umn i ndex vector for a sel ected
array si gnal . Al l array si gnal s start out wi th onl y the fi rst col umn di spl ayed.
The Array Signals button i s enabl ed when at l east one ar r ay si gnal i s
sel ected i n SPTool :
1 Press Array Signals
The Column Selection for Array Signals di al og box i s di spl ayed.
Al l array si gnal s that are sel ected i n SPTool are shown i n the l i st.
2 Sel ect a si gnal from the l i st.
3 Type a col umn i ndex vector for the sel ected si gnal .
Val i d i ndex vectors are of the form 1 or 1:3 or [1 3 5].
Complex Signal Display. Use to speci fy whether the Si gnal Browser pl ots the real
part, the i magi nary part, the magni tude, or the angl e of a compl ex si gnal .
Thi s menu i s enabl ed when at l east one of the si gnal vari abl es sel ected i n
SPTool i s compl ex. The Compl ex Di spl ay mode affects al l of the vari abl es i n the
current sel ecti on, even those that are stri ctl y real .
Cl i ck and drag to sel ect the pl otti ng mode.
Main Axes Display Area
The Signalsl i st i n SPTool shows al l si gnal s i n the current SPTool sessi on. One
or more si gnal s may be sel ected. The si gnal data of al l sel ected si gnal s are
di spl ayed graphi cal l y i n the mai n axes di spl ay area of the Si gnal Browser.
5 Interactive Tools
5-48
When there i s onl y one si gnal di spl ayed, i ts properti es are refl ected i n the
di spl ay management control s and i ts measurements are di spl ayed i n the rul er
di spl ay panel . When more than one si gnal i s di spl ayed, sel ect the l i ne you want
to focus on.
When a si gnal i s sel ected, you can use the rul er control s on the sel ected l i ne
(see Maki ng Si gnal Measurements on page 5-37), you can choose how to
di spl ay the si gnal (see Di spl ay Management Control s on page 5-47), and you
can pl ay the si gnal (see Opti ons Menu on page 5-46). The l abel of the sel ected
si gnal (l i ne) i s di spl ayed i n the Selection pop-up menu.
Use one of three ways to sel ect a si gnal (l i ne) i n the Si gnal Browser:
Cl i ck on the Selection pop-up menu and drag to sel ect the l i ne to measure.
Move the mouse poi nter over any poi nt i n the l i ne i n the mai n axes di spl ay
and cl i ck on i t.
Move the mouse poi nter over any poi nt i n the l i ne i n the panner and cl i ck on
i t.
See Sel ecti ng a Li ne to Measure on page 5-34 for detai l s.
Axes Labels. By defaul t, the x-axi s i n the Si gnal Browser i s l abel ed Time. You
can change the x-axi s l abel and add a y-axi s l abel usi ng the Signal Browser
setti ngs panel i n the Preferences di al og box i n SPTool . See Si gnal Browser
Setti ngs on page 5-23.
Click-and-Drag Panning. You can use the mouse to pan around the mai n axes
di spl ay; cl i ck on a l i ne i n the mai n axes, hol d down the mouse button, and drag
the mouse.
Cl i ck-and-drag panni ng i s not enabl ed i n mouse zoom mode.
Panner
The panner gi ves a panorami c vi ew of the si gnal (s) di spl ayed i n the mai n axes.
The panner al ways di spl ays the enti re si gnal sampl e. When you zoom i n on the
mai n axes, a patch i n the panner shows the secti on of the pl ot that i s currentl y
i n vi ew i n the mai n axes. Cl i ck-and-drag the patch i n the panner wi ndow to pan
dynami cal l y across the si gnal data i n the mai n axes.
You can al so sel ect a l i ne by cl i cki ng on i t i n the panner; the sel ected l i ne i s
hi ghl i ghted i n both the panner and i n the mai n axes di spl ay area.
Using the Signal Browser: Interactive Signal Analysis
5-49
See Panner Di spl ay on page 5-52 for more detai l s.
The panner i s di spl ayed by defaul t i n the Si gnal Browser; you can turn off the
panner i n the Si gnal Browser setti ngs panel i n the Preferences di al og box i n
SPTool . See Si gnal Br owser Setti ngs on page 5-23.
Making Signal Measurements
Use the rul ers to make a vari ety of measurements on the sel ected si gnal . See
Maki ng Si gnal Measurements on page 5-37 for detai l s.
Viewing and Exploring Signals
You can open or acti vate the Si gnal Browser i n SPTool by sel ecti ng one or more
si gnal s and pr essi ng Viewi n the Si gnal panel . The sel ected si gnal s are l oaded
i nto the Si gnal Browser. See Vi ewi ng a Si gnal on page 5-17 for detai l s.
Selecting and Displaying a Signal
When the Si gnal Browser i s acti vated, al l sel ected si gnal s are di spl ayed i n the
mai n axes di spl ay area and i n the panner. The data of the sel ected si gnal s are
pl otted agai nst an equal l y spaced ti me vector i n both the mai n axes di spl ay and
the panner.
5 Interactive Tools
5-50
When the vari abl e i s a vector, one si gnal i s di spl ayed, as i n the exampl e above.
I t i s automati cal l y sel ected and i ts name, si ze, type, and sampl i ng frequency
are di spl ayed above the mai n axes di spl ay; the name i s al so hi ghl i ghted i n the
Selection pop-up menu.
When more than one si gnal i s sel ected, each si gnal i s di spl ayed i n a di fferent
col or i n both the mai n axes di spl ay and the panner.
The names of al l si gnal s are di spl ayed above the mai n axes di spl ay. The fi rst
si gnal i n the l i st i s automati cal l y sel ected i n both the mai n axes di spl ay and
the panner, i ts name i s hi ghl i ghted i n the Selectionpop-up menu, and i ts col or
i s shown i n the Selection di spl ay.
Using the Signal Browser: Interactive Signal Analysis
5-51
When the si gnal i s an array, onl y the fi rst col umn i s i ni ti al l y di spl ayed i n both
the mai n axes and the panner.
To di spl ay a di fferent array col umn, or more than one col umn of the array,
press the Array Signalsbutton and speci fy the col umns to be di spl ayed (see
Array Si gnal s Button on page 5-47). Al l di spl ayed col umns of an array are
shown i n the same col or; the sel ected col umn i s emphasi zed wi th a heavi er l i ne
5 Interactive Tools
5-52
i n both the mai n axes and the panner, and i ts l abel i s di spl ayed i n the
Selection pop-up menu.
Panner Display
The panner di spl ays the enti re si gnal sampl e at al l ti mes.
Using the Signal Browser: Interactive Signal Analysis
5-53
When the si gnal i n the mai n axes i s zoomed, the part of the si gnal that i s shown
i n the mai n axes i s shown i n the panner wi th a wi ndow around i t.
Each ti me you zoom, the panner i s updated to frame the regi on of data
di spl ayed i n the mai n axes.
Cl i ck-and-drag on the panner wi ndow to move i t. As the wi ndow moves over the
si gnal i n the panner, the si gnal i n the mai n axes area i s panned.
Manipulating Displays
Changing Signal Displays. The si gnal s are di spl ayed i n the defaul t l i ne col ors and
defaul t l i ne styl es. You can change the defaul ts usi ng the Color Order and
LineStyleOrder fi el ds i n the Colors setti ngs panel (see Col or Setti ngs on
page 5-22).
Changing the Sample Interval. You can change the sampl e i nterval by sel ecti ng
SamplingFrequency from the Edit menu i n SPTool . See Edi ti ng Data
Objects i n SPTool on page 5-15.
Displaying Complex Signals. You can change how compl ex numbers are di spl ayed
by sel ecti ng Real, Imaginary, Magnitude, or Anglefrom the pop-up menu.
See Array Si gnal s Button on page 5-47.
Changing Signal Browser Displays. Usi ng the Signal Browser setti ngs panel i n the
Preferencesdi al og box i n SPTool , you can set opti onal x-axi s and y-axi s l abel s,
5 Interactive Tools
5-54
enabl e and di sabl e the di spl ay of the rul ers and the panner, and toggl e zoom
persi stence. See Si gnal Browser Setti ngs on page 5-23.
Working with Signals
Once a si gnal i s di spl ayed, you can browse i t i n a vari ety of ways:
You can zoom i n on a speci fi c area of the di spl ay (see Zoom Control s on page
5-31).
You can mark off a segment of the di spl ay wi th the rul ers (see Rul er
Control s on page 5-33) and save rul er setti ngs (see Save Rul ers Button
on page 5-37).
You can sel ect a segment of the di spl ay wi th the panner (see Panner
Di spl ay on page 5-52).
You can make certai n measurements on the di spl ayed si gnal s (see Maki ng
Si gnal Measurements on page 5-37).
When there i s more than one si gnal i n the di spl ay, you can sel ect whi ch one
you want to measure (see Sel ecti ng a Li ne to Measure on page 5-34).
You can use the other GUI tool s to mani pul ate si gnal s i n a vari ety of ways:
You can i nteracti vel y desi gn and anal yze fi l ters to be appl i ed to si gnal s (see
Usi ng the Fi l ter Desi gner: I nteracti ve Fi l ter Desi gn on page 5-59 and
Usi ng the Fi l ter Vi ewer: I nteracti ve Fi l ter Anal ysi s on page 5-84).
You can create a spectrum for a si gnal and i nteracti vel y anal yze i ts spectral
densi ty wi th a vari ety of esti mati on methods (see Usi ng the Spectrum
Vi ewer: I nteracti ve PSD Anal ysi s on page 5-97).
You access the Fi l ter Desi gner, Fi l ter Vi ewer, and Spectrum Vi ewer tool s from
SPTool . You can access SPTool from the Si gnal Browser i n one of two ways:
Cl i ck on an acti ve SPTool wi ndow
Acti vate SPTool usi ng the Windowmenu i n the Si gnal Browser
Printing Signal Data
You can pri nt al l of the si gnal data that you can di spl ay and mani pul ate i n the
Si gnal Browser. Your pri ntout wi l l contai n up to three components:
Using the Signal Browser: Interactive Signal Analysis
5-55
The pl ots of one or more si gnal s, as di spl ayed i n the mai n axes area
The panner di spl ay of the si gnal (s) di spl ayed i n the mai n axes area
The rul er measur ements of the sel ected si gnal
You can previ ew your pr i ntout by choosi ng Print Preview... from the File
menu i n the Si gnal Browser wi ndow. Thi s opens the Signal Browser Print
Previewwi ndow, shown bel ow wi th defaul t setti ngs for si gnal mtlb.
The Closebutton on the Signal Browser Print Previewwi ndow cl oses the
pri nt previ ew wi ndow and returns you to the Si gnal Browser.
The Print... button on the Signal Browser Print Previewwi ndow opens the
standard pri nt di al og box, from whi ch you can pri nt the contents of your pri nt
previ ew wi ndow.
I f you choose to pri nt from the pri nt di al og, both that di al og and the Signal
Browser Print Previewwi ndow wi l l cl ose, and the contents of the pri nt
previ ew wi l l pri nt.
I f you choose not to pri nt, the pri nt di al og and the Signal Browser Print
Previewwi ndow wi l l cl ose, and you wi l l return to the Si gnal Browser.
Any changes you make, before openi ng the pri nt previ ew wi ndow, that affect
the di spl ay of data i n the Si gnal Browser (see Vi ewi ng and Expl ori ng Si gnal s
5 Interactive Tools
5-56
on page 5-49) wi l l affect the di spl ay of data i n the Signal Browser Print
Previewwi ndow i n exactl y the same way. For exampl e, i n the pri nt previ ew
shown bel ow:
The pl ot of the mtlb data has been mouse zoomed (see Zoom Control s on
page 5-31).
The panner di spl ay refl ects the current zoom l evel by encl osi ng the zoomed
porti on of the whol e si gnal i n a wi ndow (see Panner Di spl ay on page 5-52).
The rul ers have been moved i nto the zoomed area and the rul er control s have
been changed from Track to Slope(see Rul er Control s on page 5-33).
The rul er measurements di spl ayed refl ect the changes to the rul ers i n the
di spl ay area (see Maki ng Si gnal Measurements on page 5-37).
Changes you make i n the Preferencesdi al og box i n SPTool , before openi ng the
pri nt previ ew wi ndow, wi l l al so affect the Signal Browser Print Preview
wi ndow i n the same way that they affect the Si gnal Browser i tsel f. For
exampl e, i n the pri nt previ ew shown bel ow, the panner di spl ay and the rul er
measurements have been suppressed, and the axi s l abel s have been changed,
Using the Signal Browser: Interactive Signal Analysis
5-57
by changes to the Si gnal Browser preferences (see Si gnal Browser Setti ngs
on page 5-23).
NOTE The HandleVisibility property of the Print Previewfi gure wi ndow
i s set to 'on'. Thi s al l ows you to modi fy the previ ew usi ng Handl e Graphi cs
commands from the MATLAB command l i ne or the Pl ot Edi tor tool s (see
UsingMATLAB Graphics for more i nformati on). Changes that you make i n
the previ ew wi ndow pri nt exactl y as they appear on the screen; however, they
are not saved when the Print Previewfi gure wi ndow i s cl osed.
Saving Signal Data
After creati ng a si gnal i n SPTool (by appl yi ng a fi l ter to an i mported si gnal , for
exampl e), you can export the si gnal i nformati on to the workspace or to di sk
usi ng Export... from the Filemenu i n SPTool . The si gnal i nformati on i s stored
i n a structure that you can access to retri eve the si gnal data and sampl e
frequency. The si gnal structure al so contai ns a number of fi el ds that are used
i nternal l y by SPTool .
To see the fi el ds of the si gnal structure, try exporti ng a si gnal to the workspace:
5 Interactive Tools
5-58
1 I mport a si gnal i nto SPTool i f there are none currentl y l oaded (see
I mporti ng Si gnal s, Fi l ters, and Spectra on page 5-7). Label the i mported
si gnal sig1.
2 Export the si gnal . Sel ect Export... from the Filemenu.
3 I n the Export di al og box, sel ect sig1 and press the Export to Workspace
button.
4 Type who at the MATLAB command l i ne to l ook at the vari abl es i n the
workspace. The vari abl e cal l ed sig1 i s the si gnal structure you exported
from SPTool .
5 Type sig1 at the command l i ne to l i st the fi el ds of the si gnal structure.
The data and Fs fi el ds of the si gnal structure contai n the i nformati on that
defi nes the si gnal . The other fi el ds are used i nternal l y by SPTool and are
subject to change i n future rel eases:
The data fi el d i s a vector or array contai ni ng the si gnal s data.
The Fs fi el d contai ns the sampl e frequency of the si gnal i n Hertz.
Using the Filter Designer: Interactive Filter Design
5-59
Using the Filter Designer: Interactive Filter Design
The Fi l ter Desi gner provi des an i nteracti ve graphi cal envi ronment for the
desi gn of di gi tal I I R and FI R fi l ters based on speci fi cati ons that you enter on a
magni tude or pol e-zero pl ot. Usi ng the Fi l ter Desi gner, you can desi gn I I R and
FI R fi l ters of vari ous l engths and types, wi th standard frequency band
confi gurati ons (hi ghpass, l owpass, bandpass, bandstop, and mul ti band).
Usi ng the Fi l ter Desi gner you can:
Desi gn I I R fi l ters wi th standard band confi gurati ons, usi ng the Butterworth,
Chebyshev type I , Chebyshev type I I , and el l i pti c desi gn opti ons
Desi gn FI R fi l ters wi th standard band confi gurati ons, usi ng the equi ri ppl e,
l east squares, and Kai ser wi ndow desi gn opti ons
Desi gn FI R and I I R fi l ters wi th arbi trary band confi gurati ons, usi ng the
Pol e/Zero Edi tor
Redesi gn a fi l ter by manual l y adjusti ng i ndi cators i n the magni tude pl ot, or
by graphi cal l y reposi ti oni ng the transfer functi ons pol es and zeros
Overl ay a spectrum on the fi l ters magni tude response pl ot
When you have desi gned a fi l ter to your speci fi cati ons, you can appl y the fi l ter
to a sel ected si gnal usi ng the Apply button i n SPTool (see Appl yi ng a Fi l ter
on page 5-18).
NOTE For i nformati on on usi ng fi l ter desi gn functi ons from the command
l i ne or from M-fi l es, see Chapter 2.
Opening the Filter Designer
You can open or acti vate the Fi l ter Desi gner from SPTool by pressi ng the New
Design or Edit Design buttons:
To create a fi l ter, press NewDesign i n SPTool . A defaul t fi l ter i s generated
and di spl ayed i n the Fi l ter Desi gner. You can vi ew the fi l ter i n a vari ety of
ways i n the Fi l ter Vi ewer and modi fy i t i n the Fi l ter Desi gner.
To edi t a fi l ter, sel ect i t i n SPTool and press Edit Design. You can modi fy the
fi l ter i n a vari ety of ways i n the Fi l ter Desi gner.
5 Interactive Tools
5-60
See Desi gni ng a Fi l ter on page 5-17 for compl ete detai l s.
Basic Filter Designer Functions
The Fi l ter Desi gner has the fol l owi ng components:
A pop-up menu for sel ecti ng di fferent fi l ter desi gn methods
A magni tude pl ot (di spl ay) area for graphi cal l y adjusti ng fi l ter responses
A pol e-zero pl ot (di spl ay) area for graphi cal l y adjusti ng fi l ter transfer
functi ons
A Specificationspanel for vi ewi ng and modi fyi ng the desi gn parameters or
pol e-zero l ocati ons of the current fi l ter
A Measurements panel for vi ewi ng the response characteri sti cs and
stabi l i ty of the current fi l ter
Speci fi cati on l i nes for graphi cal l y adjusti ng the magni tude response
parameters of a fi l ter
Measurement l i nes for measuri ng the magni tude response parameters of a
fi l ter
Zoom control s for getti ng a cl oser l ook at the magni tude response or pol e-zero
features
The fol l owi ng secti ons descri be the di fferent components of the Fi l ter
Desi gners i nterface and how you can use them together to create and edi t
fi l ters.
Menus
File Menu. Use Closefrom the Filemenu to cl ose the Fi l ter Desi gner. Setti ngs
you changed and saved usi ng the Preferences di al og box i n SPTool ar e saved
and used the next ti me you open the Fi l ter Desi gner.
Window Menu. Use the Windowmenu to sel ect a MATLAB fi gure wi ndow.
Filter Pop-Up Menu
The Filter pop-up menu di spl ays al l of the fi l ters currentl y sel ected i n SPTool .
Sel ect a fi l ter i n the menu to make i t the current fi l ter i n the Fi l ter Desi gner.
Using the Filter Designer: Interactive Filter Design
5-61
Zoom Controls
The avai l abl e zoom control s i n the Fi l ter Desi gner are ZoomIn-Y, Zoom
Out-Y, ZoomIn-X, ZoomOut-X, Pass Band, Full View, and MouseZoom.
See Zoom Control s on page 5-31 for detai l s on usi ng the zoom control s.
Zoom persi stence i s off by defaul t i n the Fi l ter Desi gner; use the Fi l ter
Desi gner setti ngs panel i n the Preferences di al og box to toggl e zoom
persi stence on and off. See Fi l ter Desi gner Setti ngs on page 5-27.
Help Button
To use context-sensi ti ve hel p, press the Help button. The mouse poi nter
becomes an arrow wi th a questi on mark symbol . You can then cl i ck on any
General controls
Viewing (zoom) controls
Specifications panel for
setting filter parameters
Magnitude response and pole-zero display area
Measurements
panel for
viewing filter
characteristics
Apply the specifications,
or revert to the previous
specifications
5 Interactive Tools
5-62
object i n the Fi l ter Desi gner, i ncl udi ng menu i tems, to fi nd out what i t i s and
how to use i t.
General Controls
Beneath the zoom control s are several general control s for fi l ter desi gn and
di spl ay. Some of these control s are avai l abl e onl y when an opti mal fi l ter desi gn
method (e.g., EquirippleFIR, Butterworth IIR) i s sel ected from the
Algorithmmenu, and are not avai l abl e when the Pole/ZeroEditor i s sel ected.
Algorithm. Use the Algorithmpop-up menu to sel ect a desi gn method for the
current fi l ter. The fi rst seven opti ons i n the Algorithmmenu the optimal
design methods al l desi gn fi l ters based on a hi gh-l evel speci fi cati on of fi l ter
magni tude response characteri sti cs (such as passband frequenci es or stopband
attenuati on). The fi l ter characteri sti cs are speci fi ed numeri cal l y i n the
Specifications panel or graphi cal l y on the magni tude response pl ot.
The ei ghth opti on, Pole/Zero Editor, i s not an opti mal desi gn method but
al l ows l ow-l evel speci fi cati on of the fi l ters transfer functi on vi a numeri cal or
graphi cal pol e-zero pl acement.
When you sel ect one of the opti mal desi gn methods from the menu, the
magni tude response pl ot, Specificationspanel , and Measurements panel al l
update to refl ect the desi gn parameters avai l abl e for that method. When you
sel ect Pole/ZeroEditor, the magni tude response pl ot i s repl aced by the z-pl ane
for pol e-zero pl acement.
Auto Design (optimal design methods only). When the Auto Design check box i s
checked, the fi l ters magni tude response i s redrawn whenever you change a
fi l ter speci fi cati on, ei ther by enteri ng a val ue i n the Specificationspanel or by
draggi ng a speci fi cati on l i ne on the pl ot. When the box i s not checked, the new
response i s computed and redrawn onl y when you press the Apply button or
rel ease the speci fi cati on l i ne. Auto Design i s i ni ti al l y off by defaul t; use the
Optimal design
methods
Transfer function
pole-zero placement
Using the Filter Designer: Interactive Filter Design
5-63
Filter Designer setti ngs panel i n the Preferences di al og box to change thi s
defaul t setti ng. See Fi l ter Desi gner Setti ngs on page 5-27.
Sampling Frequency. The SamplingFrequency fi el d al l ows you to speci fy the
fi l ters sampl i ng frequency i n Hertz. To change the sampl i ng frequency, type a
val ue i n the box and press Enter. Thi s i s the same as changi ng the sampl i ng
frequency by sel ecti ng SamplingFrequency...from the SPTool Edit menu (see
Edi ti ng Data Objects i n SPTool on page 5-15). The frequency axi s of the
magni tude response pl ot i s updated to refl ect the new sampl i ng frequency.
Changi ng the SamplingFrequency i n the Pol e/Zero Edi tor does not al ter the
pol e-zero pl ot, but does scal e the correspondi ng magni tude pl ot i n the Fi l ter
Vi ewer (i f the Vi ewer i s open).
Overlay Spectrum (design methods only). The Fi l ter Desi gner al l ows you to overl ay
a si gnal spectrum on the fi l ters magni tude response pl ot. Press the Overlay
Spectrum... button to di spl ay a l i st of the current spectra i n SPTool . Sel ect a
spectrum from the l i st and press OK to overl ay i t on the current magni tude
response pl ot. Note that the spectrum i s pl otted on the exi sti ng frequency axi s,
whi ch i s scal ed to the fi l ters sampl i ng frequency.
Filter Specifications PanelDesign Methods
When you desi gn a new fi l ter wi th the desi gn methods, the Fi l ter Desi gner
i ni ti al l y contai ns the speci fi cati ons and magni tude response pl ot for an order
22, l owpass, equi ri ppl e fi l ter.
Use the Typepop-up menu i n the Specifications panel to sel ect a band
confi gurati on. Use the edi t boxes bel ow i t i n the panel to change the band edge
frequenci es and the amount of ri ppl e i n the passband and attenuati on i n the
stopband. Check the MinimumOrder box to l et the Fi l ter Desi gner
automati cal l y determi ne the l owest fi l ter order that achi eves the current
speci fi cati ons.
The desi gn parameters avai l abl e i n the Specifications panel depend on the
fi l ter desi gn sel ected i n the Algorithmpop-up menu, the band confi gurati on
sel ected i n the Typepop-up menu, and the state of the MinimumOrder check
box.
Specifications Parameters Automatic Order Selection. When the MinimumOrder
box i s checked, al l of the fi l ter desi gns except Least Squares FIR di spl ay the
same set of parameters i n the Specifications panel . (The order for the Least
Squares FIR desi gn cannot be automati cal l y computed). For l owpass and
5 Interactive Tools
5-64
hi ghpass band confi gur ati ons, these parameter s i ncl ude the passband edge
frequency Fp, the stopband edge frequency Fs, the passband ri ppl e Rp, and the
stopband attenuati on Rs. For bandpass and bandstop confi gurati ons, the
parameters i ncl ude the l ower and upper passband edge frequenci es, Fp1 and
Fp2, the l ower and upper stopband edge frequenci es, Fs1 and Fs2, the
passband ri ppl e Rp, and the stopband attenuati on Rs. Frequency val ues are i n
Hertz, and ri ppl e and attenuati on val ues are i n dB.
Specifications ParametersManual Order Selection. When the MinimumOrder box
i s not checked, an Order parameter for setti ng the fi l ter order appears bel ow
i t, and each fi l ter desi gn di spl ays a uni que set of parameters i n the
Specifications panel . These are shown i n the tabl e bel ow, where Wp and Ws
are the wei ghts for the passband and stopband, Beta i s the Kai ser wi ndow
parameter, Fc i s the cutoff frequency, and F3db i s the -3 dB frequency.
Designing a New Filter With the Design Methods. I n general , fol l ow these steps to
desi gn a new fi l ter usi ng the Specifications panel parameters:
1 Cl i ck-and-drag to sel ect an appropri ate opti mal
fi l ter desi gn method from the Algorithmpop-up
menu.
2 Cl i ck-and-drag to sel ect the band confi gurati on
from the Typepop-up menu.
3 Type i n the Specifications panel s edi tabl e fi el ds
to change the val ues for band edge frequenci es, ri ppl e, attenuati on, and
other fi l ter characteri sti cs.
Lowpass Highpass Bandpass Bandstop
Equiripple FIR Fp, Fs, Wp, Ws Fp, Fs, Wp, Ws Fp1, Fp2, Fs1, Fs2, Wp, Ws Fp1, Fp2, Fs1, Fs2, Wp, Ws
Least Squares FIR Fp, Fs, Wp, Ws Fp, Fs, Wp, Ws Fp1, Fp2, Fs1, Fs2, Wp, Ws Fp1, Fp2, Fs1, Fs2, Wp, Ws
Kaiser Window FIR Fc, Beta Fc, Beta Fc1, Fc2, Beta Fc1, Fc2, Beta
Butterworth IIR F3db F3db F3db 1, F3db 2 F3db 1, F3db 2
Chebyshev Type I IIR Fp, Rp Fp, Rp Fp1, Fp2, Rp Fp1, Fp2, Rp
Chebyshev Type II IIR Fs, Rs Fs, Rs Fs1, Fs2, Rs Fs1, Fs2, Rs
Elliptic IIR Fp, Rp, Rs Fp, Rp, Rs Fp1, Fp2, Rp, Rs Fp1, Fp2, Rp, Rs
Using the Filter Designer: Interactive Filter Design
5-65
4 Press Enter after typi ng i n an edi tabl e text box to enter the val ue. I f Auto
Design i s not checked, press the Apply button bel ow the Specifications
panel to update the magni tude pl ot.
5 To speci fy a fi l ter order, press MinimizeOrder to desel ect the check box and
di sabl e automati c fi l ter order sel ecti on. Then type a val ue for the Order
parameter. I f Auto Design i s not checked, press Apply.
Edi t a new fi l ter or an exi sti ng fi l ter i n the same way. Note that when Auto
Design i s di sabl ed and you change a fi l ters parameter val ues, the magni tude
response pl ot changes from sol i d l i nes to dashed l i nes. Thi s i ndi cates that the
pl ot no l onger refl ects the current speci fi cati ons. When you press the Apply
button, the new response i s computed and the l i nes revert to the sol i d styl e.
When Auto Design i s enabl ed, the pl ot updates whenever you change a fi l ter
speci fi cati on.
Filter Measurements PanelDesign Methods
When you desi gn a fi l ter, the Measurementspanel (shown at l eft) di spl ays the
val ues of fi l ter par ameter s that donot appear i n the Specificationspanel . For
exampl e, when the Fi l ter Desi gner pr ovi des an Fs parameter i n the
Specifications panel , i t di spl ays the Actual Fs val ue i n the Measurements
panel . Si mi l arl y, when the MinimumOrder opti on i s sel ected i n the
Specificationspanel , the computed fi l ter order i s di spl ayed i n the Order fi el d
of the Measurements panel . The val ues i n the Measurements panel are
updated whenever the magni tude pl ot i s redrawn.
Measurement Parameters Automatic Order Selection. The parameter combi nati ons
that appear i n the Measurementspanel are shown i n the fol l owi ng two tabl es.
The fi rst tabl e l i sts the parameters that appear when MinimumOrder i s
checked (automati c order sel ecti on). The stopband edge frequency parameters
l i sted (Fs, Fs1, Fs2) are the actual edge frequenci es for the desi gn, rather than
the desired frequenci es entered i n the Specifications panel .
5 Interactive Tools
5-66
Measurement Parameters Manual Order Selection. The next tabl e shows the
parameter sets that appear i n the Measurements panel when Minimum
Order i s not sel ected. The measurements that can be i nteracti vel y changed by
draggi ng the red measurement l i nes on the response pl ot are shown shaded.
Filter Specifications PanelPole/Zero Editor
When you desi gn a new fi l ter usi ng the Pol e/Zero Edi tor, the Fi l ter Desi gner
i ni ti al l y di spl ays a pol e-zero pl ot for the defaul t order-22 fi l ter.
The general pol e-zero (factored) form of the transfer functi on of a di gi tal fi l ter
i s:
where z
1
, z
2
, ..., z
m
are the fi l ter zeros, p
1
, p
2
, ..., p
n
are the fi l ter pol es, and k i s
the overal l transfer functi on gai n. The number of zeros and pol es do not need
to be the same.
The control s i n the Specifications panel al l ow you to set the overal l gai n and
to numeri cal l y adjust the posi ti on of each pol e and zero usi ng pol ar or
rectangul ar coordi nates.
Lowpass Highpass Bandpass Bandstop
Equiripple FIR
Or der, Rp, Rs, Wp,
Ws
Or der, Rp, Rs, Wp,
Ws
Or der, Rp, Rs, Wp, Ws Or der, Rp, Rs, Wp, Ws
Least Squares FIR Or der cannot be automati cal l y computed.
Kaiser Window FIR
Or der, Fc, Beta,
Rp, Rs
Or der, Fc, Beta,
Rp, Rs
Or der, Fc1, Fc2, Beta, Rp,
Rs
Or der, Fc1, Fc2, Beta, Rp,
Rs
Butterworth IIR Or der, Rp, F3db Or der, Rp, F3db Or der, Rp, F3db 1, F3db 2 Or der, Rp, F3db 1, F3db 2
Chebyshev Type I IIR Or der, Fs Or der, Fs Or der, Fs1, Fs2 Or der, Fs1, Fs2
Chebyshev Type II IIR Or der, Fs Or der, Fs Or der, Fs1, Fs2 Or der, Fs1, Fs2
Elliptic IIR Or der, Fs Or der, Fs Or der, Fs1, Fs2 Or der, Fs1, Fs2
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, Rp, Rs Fp, Fs, Rp, Rs Fp1, Fp2, Fs1, Fs2, Rp, Rs Fp1, Fp2, Fs1, Fs2, Rp, Rs
Butterworth IIR Fp, Fs, Rp, Rs Fp, Fs, Rp, Rs Fp1, Fp2, Fs1, Fs2, Rp, Rs Fp1, Fp2, Fs1, Fs2, Rp, Rs
Chebyshev Type I IIR Fs, Rs Fs, Rs Fs1, Fs2, Rs Fs1, Fs2, Rs
Chebyshev Type II IIR Fp, Rp Fp, Rp Fp1, Fp2, Rp Fp1, Fp2, Rp
Elliptic IIR Fs Fs Fs1, Fs2 Fs1, Fs2
H z ( )
Z z ( )
P z ( )
---------- k
z z
1
( ) z z
2
( )Lz z
m
( )
z p
1
( ) z p
2
( )Lz p
n
( )
---------------------------------------------------------------- = =
Using the Filter Designer: Interactive Filter Design
5-67
The val ue you enter i n the Gainedi t box speci fi es the gai n, k. The Coordinates
pop-up menu l ets you posi ti on the pol es and zeros usi ng ei ther pol ar or
rectangul ar measurements. When Polar i s sel ected, you can speci fy the
coordi nates of the currentl y sel ected pol e or zero by enteri ng val ues i n the Mag
and Angleedi t boxes. The resul ti ng l ocati on of the sel ected pol e or zer o i s
where M i s the magni tude speci fi ed by Mag, and i s the angl e i n radi ans
speci fi ed by Angle.
When Rectangular i s sel ected, you can speci fy the coordi nates of the currentl y
sel ected pol e or zero by enteri ng val ues i n the Xand Y edi t boxes. The resul ti ng
l ocati on of the sel ected pol e or zero i s
The Conjugatepair checkbox control s whether the current sel ecti on i s a
compl ex conjugate pai r of pol es or zeros, or a l one pol e or zero. When a l one pol e
or zero i s sel ected on the pol e-zero pl ot, the Conjugatepair checkbox i s
i nacti ve. I f you now enabl e the Conjugatepair checkbox by cl i cki ng i t, a new
conjugate pol e or zero (as appropri ate) i s created to compl ete the pai r.
When a conjugate pai r of pol es or zeros i s sel ected on the pl ot (by cl i cki ng one
of the pai r ), the Conjugatepair checkbox i s acti ve. I f you now di sabl e the
Conjugatepair checkbox by cl i cki ng i t, the conjugate pai r i s broken i nto two
l one pol es or zeros at the same posi ti ons, and onl y one of these remai ns
sel ected.
When the Conjugatepair checkbox i s sel ected, the coordi nates you speci fy (i n
ei ther angul ar or rectangul ar form) control the l ocati on of the currentl y
sel ected compl ex conjugate pai r of pol es or zeros, wi th l ocati ons
or
Designing a New Filter with the Pole/Zero Editor. I n general , fol l ow these steps to
desi gn a new fi l ter usi ng the Specifications panel parameters:
z Me
j
=
z X j Y + =
z X j Y t =
z Me
j t
=
5 Interactive Tools
5-68
1 Cl i ck-and-drag to sel ect the Pole/Zero Editor
opti on from the Algorithmpop-up menu.
2 Enter the desi red fi l ter gai n i n the Gain edi t box.
3 Sel ect a pol e or zero (or conjugate pai r) by cl i cki ng
on one of the or symbol s on the pl ot.
4 Choose the coordi nates to work i n by speci fyi ng Polar or Rectangular from
the Coordinates pop-up menu.
5 Speci fy the new l ocati on(s) of the sel ected pol e, zero, or conjugate pai r by
typi ng val ues i nto the Magand Angle(for angul ar coordi nates) or X and Y
(for rectangul ar coordi nates) edi t boxes.
6 Use the Conjugatepair checkbox to create a conjugate pai r from a l one pol e
or zero or to break a conjugate pai r i nto two i ndi vi dual pol es or zeros.
Edi t a new fi l ter or an exi sti ng fi l ter i n the same way.
TIP Keep the Fi l ter Vi ewer open whi l e desi gni ng a fi l ter wi th the Pol e/Zer o
Edi tor. Any changes that you make to the fi l ter transfer functi on i n the
Pol e/Zero Edi tor ar e then si mul taneousl y refl ected i n the response pl ots of the
Fi l ter Vi ewer.
Filter Measurements PanelPole/Zero Editor
When you desi gn a fi l ter, the Measurements panel (shown at l eft) di spl ays
useful i nformati on about the fi l ter bei ng desi gned. The panel al ways shows the
number of zeros and pol es (the l arger of whi ch i s the order of the fi l ter), and
i ndi cates whether the fi l ter i s stabl e or unstabl e (pol es outsi de the uni t ci rcl e).
The panel al so shows the phase characteri sti cs of the fi l ter. Where mi s the
total number of zeros, the four possi bl e phase condi ti ons are:
MinimumPhase, whi ch i ndi cates that between 1 and m-1 zeros are on the
uni t ci rcl e, whi l e the rest of the zeros are i nsi de the uni t ci rcl e
Pole
Zero
i 1 m , , = z
i
1
Using the Filter Designer: Interactive Filter Design
5-69
StrictlyMinimumPhase, whi ch i ndi cates that al l of the zeros are i nsi de the
uni t ci rcl e
MaximumPhase, whi ch i ndi cates that between 1 and mzeros are on the
uni t ci rcl e, whi l e the rest of the zeros are outsi de the uni t ci rcl e
Strictly MaximumPhase, whi ch i ndi cates that al l of the zeros are outsi de
the uni t ci rcl e
When the Measurements panel does not i ndi cate any of the above condi ti ons,
zeros are both i nsi de and outsi de the uni t ci rcl e.
When a new pol e or zero i s bei ng pl aced on the pl ot (usi ng the Add Poles or
Add Zeros tool s, descri bed on page 5-72) the Measurements panel shows
addi ti onal posi ti oni ng i nfor mati on. After pressi ng ei ther the AddPolesor Add
Zerosbutton, and before cl i cki ng on the pl ot to pl ace the new pol e(s) or zero(s),
the Measurements panel di spl ays the preci se posi ti on of the poi nter over the
pl ot area.
Al l val ues i n the Measurements panel are updated conti nuousl y as a pol e or
zero i s reposi ti oned.
Magnitude Plot (Display) AreaDesign Methods
The response of the fi l ter sel ected i n the Filter pop-up menu i s di spl ayed
graphi cal l y i n the magni tude response pl ot area of the Fi l ter Desi gner, and i ts
characteri sti cs are shown i n the Specifications and Measurements panel s.
i 1 m , , = z
i
1 <
i 1 m , , = z
i
1
i 1 m , , = z
i
1 >
Add Poles Pointer
Add Zeros Pointer
5 Interactive Tools
5-70
You can zoom i n on the di spl ayed fi l ter i n the magni tude pl ot (see Zoom
Control s on page 5-31) and you can drag the speci fi cati on l i nes to redesi gn the
di spl ayed fi l ter vi sual l y (see the next secti on).
Specification Lines. You can redesi gn a fi l ter by mani pul ati ng the green
speci fi cati on l i nes i n the magni tude pl ot. Usi ng the speci fi cati on l i nes, you can
change the passband ri ppl e, stopband attenuati on, and edge frequenci es of a
fi l ter:
Set passband ri ppl e or stopband attenuati on by cl i cki ng on a green l i ne and
draggi ng i t up or down. The Rp and Rs val ues di spl ayed i n the
Specifications panel change as you drag. I f Auto Design i s checked, the
response pl ot al so updates as you drag the l i nes. I f AutoDesign i s di sabl ed,
the response pl ot updates when you rel ease the mouse.
NOTE Wi th I I R fi l ters you can onl y drag the l ower passband bar and the
stopband bar. The upper passband bar i s fi xed at 0.
Set edge frequenci es ei ther by cl i cki ng on the edge of a horizontal green l i ne
(the mouse poi nter changes to ) and draggi ng the edge to a new frequency,
or by cl i cki ng anywhere on a vertical green l i ne (i f the Fi l ter Desi gner
provi des one) and draggi ng i t hori zontal l y to a new frequency. The Fp and Fs
val ues di spl ayed i n the Specifications panel change as you drag. I f Auto
Design i s checked, the response pl ot al so updates as you drag the l i nes. I f
Auto Design i s di sabl ed, the response pl ot updates when you rel ease the
mouse.
See Redesi gni ng a Fi l ter Usi ng the Magni tude Pl ot on page 5-78 for detai l s.
Measurement Lines. A number of the fi l ter desi gns provi de rul ers on the response
pl ot that al l ow you to measure response magni tude l evel s. These measurement
l i nes, whi ch appear i n red on the pl ot, are avai l abl e for the Kai ser wi ndow,
Butterworth, Chebyshev type I , and Chebyshev type I I fi l ters when the
MinimumOrder check box i s not sel ected. As you drag a measurement l i ne,
the correspondi ng val ues i n the Measurements panel change to refl ect the
measurement l i nes current posi ti on.
Using the Filter Designer: Interactive Filter Design
5-71
Magnitude Plot (Display) AreaPole/Zero Editor
The pl ot area of the Pol e/Zero Edi tor di spl ays the fi l ter transfer functi ons pol e
and zeros on the compl ex z-pl ane. The uni t ci rcl e i s shown i n dashed l i nes,
al ong wi th the verti cal and hori zontal gri d l i nes, to provi de a vi sual reference
for pol e-zero pl acement.
You can zoom i n on the z-pl ane (see Zoom Control s on page 5-31) and you can
drag the pol e and zero symbol s to redesi gn the fi l ter transfer functi on vi sual l y
(see the next secti on).
Positioning Poles and Zeros. You can redesi gn the transfer functi on by si mpl y
cl i cki ng and draggi ng on one of the pol e or zero symbol s. Pol es or zeros appear
green (rather than the usual bl ue) when sel ected. I n a conjugate pai r of pol es
or zeros, both conjugates are sel ected when ei ther i s cl i cked; conjugate pai rs
move together when dragged, mai ntai ni ng equal di stance from the real axi s at
al l ti mes. To ungroup conjugates, sel ect the desi red pai r and uncheck
Conjugatepair i n the Specifications panel .
When two or more pol e symbol s (or two or more zero symbol s) are pl aced
di rectl y on top of each other, a number i s di spl ayed next to the symbol s (on the
l eft for pol es, and on the ri ght for zeros) i ndi cati ng the number of pol es or zeros
at that l ocati on (e.g., ). Thi s number makes i t easy to keep track of al l the
pol es and zeros i n the pl ot area, even when several are superi mposed on each
other and are not vi sual l y di fferenti abl e. Note, however, that thi s number does
not i ndi cate the multiplicity of the pol es or zeros to whi ch i t i s attached.
5 Interactive Tools
5-72
To hel p detect whether a set of pol es or zeros are trul y mul ti pl es, use the zoom
tool s to magni fy the regi on around the pol es or zeros i n questi on. Because
numeri cal l i mi tati ons usual l y prevent any set of pol es or zeros from shari ng
exactly the same val ue, at a hi gh enough zoom l evel even trul y mul ti pl e pol es
or zeros appear di sti nct from each other. A common way to assess whether a
parti cul ar group of pol es or zeros contai ns mul ti pl es i s by compari ng the
mutual proxi mi ty of the group members agai nst a sel ected threshol d val ue. As
an exampl e, the residuez functi on defi nes a pol e or zero as bei ng a mul ti pl e of
another pol e or zero i f the absol ute di stance separati ng them i s l ess than 0.1%
of the l arger pol e or zeros magni tude.
Tools. The Pol e/Zer o Edi tor pr ovi des sever al tool s to assi st wi th pol e-zer o
pl acement. The tool s are l ocated at the top l eft of the pol e-zero pl ot area.
At the bottom of the pl ot area, there are two addi ti onal buttons, SendToBack
and DeleteAll. Use SendToBack when you are unabl e to sel ect a pol e or zero
because another pol e or zero i s i n the way. Sel ect the i nterferi ng pol e or zero on
the pl ot, and press Send To Back to move that pol e or zero behi nd al l other
symbol s on the pl ot (i .e., l ast i n the stacki ng order). You can then sel ect the
desi red pol e or zero wi thout the i nterference of the other symbol .
Icon Name Description
Dr ag Pol es/Zer os Tool
Use thi s tool to sel ect and dr ag pol es and zeros on
the pl ot.
Add Pol es Tool
Use thi s tool to add pol es to the pl ot. Si mpl y cl i ck
on the pl ot wher e you want to pl ace the new pol e
(or conjugate pai r, when the Conjugatepair
checkbox i s sel ected).
Add Zeros Tool
Use thi s tool to add zeros to the pl ot. Si mpl y cl i ck
on the pl ot wher e you want to pl ace the new zero
(or conjugate pai r, when the Conjugatepair
checkbox i s sel ected).
Del ete Pol es/Zeros Tool
Use thi s tool to del ete pol es and zer os from the
pl ot. Si mpl y cl i ck on any pol e or zero to del ete i t.
When you cl i ck on a set of pol es or zer o occupyi ng
the same l ocati on, onl y the top-most pol e or zer o
i s removed. You can al so use the Delete or
Backspace key on the keyboard to del ete the
curr entl y sel ected pol e or zero.
Using the Filter Designer: Interactive Filter Design
5-73
The DeleteAll button del etes every pol e and zero i n the pl ot area.
NOTE The DeleteAll operati on cannot be undone. Once al l the pol es and
zeros are removed, they cannot be restored.
Designing Finite Impulse Response (FIR) Filters
The Fi l ter Desi gner provi des three opti ons for basi c FI R fi l ter desi gn. These
opti ons al l ow you to create FI R fi l ters wi th standard band confi gurati ons
(l owpass, hi ghpass, bandpass, or bandstop confi gurati ons onl y). The three
opti ons for FI R fi l ter desi gn i n the Algorithmpop-up menu are:
EquirippleFIR, whi ch accesses the tool box functi on remez to create an
equi ri ppl e FI R fi l ter.
Least Squares FIR, whi ch accesses the tool box functi on firls to create an
FI R fi l ter usi ng the l east square desi gn method.
Kaiser WindowFIR, whi ch accesses the fir1 functi on to create an FI R fi l ter
usi ng a Kai ser wi ndow.
Example: FIR Filter Design, Standard Band Configuration
I n the fol l owi ng exampl e, use the Kai ser wi ndow fi l ter desi gn opti on:
1 Sel ect Kaiser WindowFIR as the fi l ter desi gn from the Algorithmpop-up
menu.
2 Sel ect bandpass from the Typepop-up menu as the confi gurati on.
3 Set the fi l ters sampl i ng frequency to 2000 Hz by enteri ng thi s val ue i n the
SamplingFrequency text box.
4 Press Apply to redraw the response wi th these setti ngs.
NOTE You must press Apply before you change the fol l owi ng parameters.
5 Check the MinimumOrder check box to enabl e automati c order sel ecti on.
5 Interactive Tools
5-74
6 Set Fp1to 290 and Fp2to 525.
These fi el ds respecti vel y defi ne the l ower and upper passband edge
frequenci es i n Hertz.
7 Set Fs1to 200 and Fs2to 625.
These fi el ds respecti vel y defi ne the l ower and upper stopband edge
frequenci es i n Hertz.
8 Set Rp (passband ri ppl e) to 4 and Rs (stopband attenuati on) to 30.
Rp and Rs are speci fi ed i n dB.
9 Press the Apply button.
The Fi l ter Desi gner cal l s fir1 to create the fi l ter usi ng a Kai ser wi ndow. The
Fi l ter Desi gner updates the magni tude pl ot to show the new fi l ters magni tude
response.
Using the Filter Designer: Interactive Filter Design
5-75
Filter Design Options
When the MinimumOrder opti on i s di sabl ed, you can speci fy parameters that
defi ne characteri sti cs uni que to certai n fi l ter types:
For equi ri ppl e and l east squares fi l ters: the wei ghts for error mi ni mi zati on
For Kai ser wi ndow fi l ters: the cutoff frequency and parameter of the Kai ser
wi ndow
Order Selection for FIR Filter Design
As descri bed earl i er, the FI R fi l ter desi gn opti ons avai l abl e through the Fi l ter
Desi gner cal l the tool box functi ons remez, firls, and fir1. I n cal cul ati ng fi l ter
order, the Fi l ter Desi gner uses the same gui del i nes as the tool box functi ons:
The EquirippleFIR desi gn opti on cal l s the remezord order esti mati on
functi on to determi ne a fi l ter order that meets a set of speci fi cati ons. I n some
cases, remezord underesti mates the fi l ter order n. I f the fi l ter does not
appear to meet the gi ven speci fi cati ons usi ng MinimumOrder order
sel ecti on, desel ect MinimumOrder and manual l y speci fy a sl i ghtl y l arger
order (n+1 or n+2).
The Least Squares FIR desi gn opti on cal l s the tool box functi on firls.
Because the tool box does not provi de an order esti mati on functi on for use
wi th firls, you cannot use the MinimumOrder opti on wi th the Least
Squares FIR method.
The Kaiser WindowFIR desi gn opti on cal l s kaiserord, the order esti mati on
functi on, whi ch someti mes underesti mates the fi l ter order n. I f the fi l ter does
not appear to meet the gi ven speci fi cati ons usi ng MinimumOrder order
sel ecti on, desel ect MinimumOrder and manual l y speci fy a sl i ghtl y l arger
order (n+1 or n+2).
Al l of the FI R fi l ter desi gn opti ons i n the Fi l ter Desi gner requi re an even fi l ter
order for the hi ghpass and bandstop confi gurati ons. For more i nformati on on
order sel ecti on wi th the FI R fi l ter desi gn opti ons, see the reference descri pti ons
of remez, remezord, kaiserord, firls, and fir1 i n Chapter 6.
5 Interactive Tools
5-76
Designing Infinite Impulse Response (IIR) Filters
The Fi l ter Desi gner l ets you desi gn a number of cl assi cal I I R fi l ters, i ncl udi ng
Butterworth, Chebyshev type I , Chebyshev type I I , and el l i pti c fi l ters.
Example: Classical IIR Filter Design
I n the fol l owi ng exampl e, desi gn a si mpl e Chebyshev type I fi l ter:
1 Sel ect Chebyshev TypeI IIR as the fi l ter desi gn from the Algorithm
pop-up menu.
2 Sel ect highpass from the Typemenu as the confi gurati on.
3 Set the fi l ters sampl e frequency to 2000 Hz by enteri ng thi s val ue i n the
SamplingFrequency text box.
4 Press Apply to redraw the response wi th these setti ngs.
NOTE You must press Apply before you change the fol l owi ng parameters.
5 Check the MinimumOrder check box.
6 Set Fp (passband edge frequency) to 800 and Fs (stopband edge frequency)
to 700.
Fp and Fs are speci fi ed i n Hertz.
7 Set Rp (passband ri ppl e) to 2.5 and Rs (stopband attenuati on) to 35.
Rp and Rs are speci fi ed i n dB.
8 Press Apply to draw the magni tude response.
9 Desel ect MinimumOrder and speci fy a fi l ter order of 7. Press Apply to
redraw the magni tude response.
Using the Filter Designer: Interactive Filter Design
5-77
The Fi l ter Desi gner cal l s the appropri ate fi l ter desi gn functi on to create the
fi l ter.
To zoom i n on pl ot detai l s, use the zoom control buttons as descri bed i n Zoom
Control s on page 5-31.
Filter Design Options
When the MinimumOrder opti on i s di sabl ed, you can speci fy parameters that
defi ne characteri sti cs uni que to certai n fi l ter types:
For Butterworth fi l ters: the -3 dB frequenci es
For Chebyshev type I fi l ters: the passband edge frequenci es
For Chebyshev type I I fi l ters: the stopband edge frequenci es
For el l i pti c fi l ters: the passband edge frequenci es
I n the fol l owi ng exampl e, redesi gn the Chebyshev type I fi l ter from the
previ ous exampl e as a Butterworth fi l ter, usi ng a -3 dB frequency of 800 Hz:
5 Interactive Tools
5-78
1 Sel ect the Butterworth IIR fi l ter desi gn from the Algorithmmenu.
The magni tude r esponse pl ot changes to refl ect the new desi gn.
2 Type a val ue of 800 i n the F3db text fi el d.
3 Press Apply to update the response pl ot.
Order Selection for IIR Filter Design
The I I R fi l ter desi gn opti ons avai l abl e through the Fi l ter Desi gner cal l the
tool box fi l ter desi gn functi ons. I n cal cul ati ng the order for a gi ven fi l ter, the
Fi l ter Desi gner uses the correspondi ng order esti mati on functi on i f the
MinimumOrder check box i s sel ected.
For detai l s on order sel ecti on wi th the I I R fi l ter desi gn opti ons, see the
reference descri pti ons of buttord, cheb1ord, cheb2ord, and ellipord i n
Chapter 6.
Redesigning a Filter Using the Magnitude Plot
After desi gni ng a fi l ter i n the Fi l ter Desi gner, you can redesi gn i t by draggi ng
the speci fi cati on l i nes i n the magni tude pl ot. Use the speci fi cati on l i nes to
change passband ri ppl e, stopband attenuati on, and edge frequenci es (see
Speci fi cati on Li nes on page 5-70 for detai l s). I n the fol l owi ng exampl e, create
a Chebyshev fi l ter and modi fy i t by draggi ng the speci fi cati on l i nes:
1 Create a Chebyshev type I hi ghpass fi l ter wi th a sampl e frequency of
2000 Hz. Set the fol l owi ng parameters:
Fp = 800
Fs = 700
Rp = 2.5
Rs = 35
2 Check MinimumOrder so the Fi l ter Desi gner can cal cul ate the l owest fi l ter
order that produces the desi red characteri sti cs.
3 Press Apply to update the response pl ot.
4 Posi ti on the cursor over the gr een l i ne speci fyi ng the stopband.
The cursor changes to the up/down drag i ndi cator.
Using the Filter Designer: Interactive Filter Design
5-79
5 Drag the l i ne unti l the Rs (stopband attenuati on) fi el d reads 100.
Note that the Order val ue i n the Measurements panel changes because a
hi gher fi l ter order i s needed to meet the new speci fi cati ons.
Saving Filter Data
After desi gni ng a fi l ter i n the Fi l ter Desi gner, you can export the fi l ter
i nformati on to the workspace or to di sk usi ng Export... from the Filemenu i n
SPTool . The fi l ter i nformati on i s stored i n a structure that you can access to
retri eve the coeffi ci ents and desi gn parameters of the fi l ter you created. The
fi l ter structure al so contai ns a number of fi el ds that are used i nternal l y by
SPTool .
To see the fi el ds of the fi l ter structure, fi rst export a fi l ter to the workspace:
1 Create a new fi l ter by pressi ng NewDesign i n SPTool . The new fi l ter i s
cal l ed filt1.
2 Sel ect Export... from the Filemenu.
3 I n the Export fromSPTool di al og box, sel ect filt1 and press the Export
to Workspacebutton.
4 Type who at the MATLAB command l i ne to l ook at the vari abl es i n the
workspace. The vari abl e cal l ed filt1 i s the fi l ter structure you exported
from SPTool .
5 At the command l i ne type filt1 to l i st the fi el ds of the fi l ter structure.
The tf, Fs, and specs fi el ds of the fi l ter structure contai n the i nformati on that
descri bes the fi l ter. These fi el ds are di scussed bel ow. The other fi el ds i n the
structure are used i nternal l y by SPTool , and are subject to change i n future
rel eases.
tf. The tf fi el d i s a structure contai ni ng the transfer functi on representati on of
the fi l ter:
tf.num contai ns the numerator coeffi ci ents
tf.den contai ns the denomi nator coeffi ci ents
5 Interactive Tools
5-80
both i n descendi ng powers of z
where b i s a vector contai ni ng the coeffi ci ents fr om the tf.num fi el d, a i s a
vector contai ni ng the coeffi ci ents from the tf.den fi el d, mi s the numerator
order, and ni s the denomi nator or der . You can change the fi l ter r epresentati on
from the defaul t transfer functi on to another form by usi ng the tf2ss or tf2zp
functi ons.
Fs. The Fs fi el d contai ns the sampl i ng frequency of the fi l ter i n Hertz.
specs. The specs fi el d i s a structure contai ni ng i nformati on about the fi l ter
desi gn. The fi rst fi el d, specs.currentModule, contai ns a stri ng representi ng
the desi gn sel ected for the fi l ter i n the Fi l ter Desi gners Algorithmpop-up
menu. The possi bl e contents of the currentModule fi el d, and the correspondi ng
desi gns, ar e shown bel ow.
Fol l owi ng the specs.currentModule fi el d, there may be up to seven addi ti onal
fi el ds, wi th l abel s such as specs.fdremez, specs.fdfirls, etc. The desi gn
speci fi cati ons for the most recentl y exported fi l ter are contai ned i n the fi el d
currentModule Algorithm
fdbutter Butterworth I I R
fdcheby1 Chebyshev Type I I I R
fdcheby2 Chebyshev Type I I I I R
fdellip El l i pti c I I R
fdfirls Least Squares FI R
fdkaiser Kai ser Wi ndow FI R
fdremez Equi ri ppl e FI R
H z ( )
B z ( )
A z ( )
-----------
b 1 ( ) b 2 ( )z
1
L b nb 1 + ( )z
m
+ + +
a 1 ( ) a 2 ( )z
1
L a na 1 + ( )z
n
+ + +
-------------------------------------------------------------------------------------- = =
Using the Filter Designer: Interactive Filter Design
5-81
whose l abel matches the currentModule stri ng. For exampl e, i f the specs
structure i s
currentModule: 'fdkaiser'
fdremez: [1x1 struct]
fdfirls: [1x1 struct]
fdkaiser: [1x1 struct]
the fi l ter speci fi cati ons are contai ned i n the fdkaiser fi el d, whi ch i s i tsel f a
data structure.
The speci fi cati ons i ncl ude the parameter val ues from the Specificationspanel
of the Fi l ter Desi gner, such as band edges and fi l ter order. For exampl e, the
Kai ser wi ndow fi l ter above has the fol l owi ng speci fi cati ons stored i n
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]
Because certai n fi l ter parameters are uni que to a parti cul ar desi gn, thi s
structure has a di fferent set of fi el ds for each fi l ter desi gn. For exampl e, the
Beta fi el d above onl y appears i n the specs structure i f the desi gn i s a Kai ser
wi ndow FI R fi l ter.
The tabl e bel ow l i sts the possi bl e speci fi cati ons fi el ds that can appear i n the
export structure, and descri bes thei r contents.
Parameter Description
Beta Kai ser wi ndow parameter.
f Contai ns a vector of band-edge frequenci es, normal i zed
to 1 (i .e., 1 = Nyqui st).
5 Interactive Tools
5-82
Viewing Frequency Response Plots
I t i s often useful to vi ew a fi l ters frequency response, i mpul se response, and
step response duri ng the fi l ter desi gn process. You can use the Fi l ter Vi ewer to
vi ew frequency-domai n i nformati on about fi l ters i n the Fi l ter Desi gner:
Fpass Passband cutoff frequenci es. Scal ar for l owpass and
hi ghpass desi gns, two-el ement vector for bandpass and
bandstop desi gns.
Fstop Stopband cutoff frequenci es. Scal ar for l owpass and
hi ghpass desi gns, two-el ement vector for bandpass and
bandstop desi gns.
m The response magni tudes correspondi ng to the band-edge
frequenci es i n f.
order Fi l ter order.
Rp Passband ri ppl e (dB)
Rs Stopband attenuati on (dB)
setOrderFlag Contai ns 1 i f the fi l ter order was speci fi ed manual l y (i .e.,
the MinimumOrder box i n the Specificationspanel was
not checked). Contai ns 0 i f the fi l ter order was computed
automati cal l y.
type Contai ns 1 for l owpass, 2 for hi ghpass, 3 for bandpass, or
4 for bandstop.
w3db -3 dB frequency for Butterworth I I R desi gns.
wind Vector of Kai ser wi ndow coeffi ci ents.
Wn Cutoff frequency for the Kai ser wi ndow FI R fi l ter when
setOrderFlag = 1.
wt Vector of wei ghts, one wei ght per frequency band.
Parameter Description
Using the Filter Designer: Interactive Filter Design
5-83
1 Acti vate SPTool from the Windowmenu.
2 Make sure the fi l ters you want to anal yze are sel ected i n the Filters l i st.
3 Press Viewi n the Fi l ter panel .
The Fi l ter Vi ewer i s acti vated wi th the sel ected fi l ters di spl ayed.
4 To edi t one of the fi l ters youre vi ewi ng, you can reacti vate the Fi l ter
Desi gner from the Windowmenu i n the Fi l ter Vi ewer.
5 When you want to revi ew a fi l ters characteri sti cs after youve edi ted i t,
reacti vate the Fi l ter Vi ewer from the Windowmenu i n the Fi l ter Desi gner.
When the Fi l ter Vi ewer i s open at the same ti me that the Fi l ter Desi gner i s
open, they both di spl ay the same fi l ter . You can move back and for th between
the Fi l ter Desi gner and the Fi l ter Vi ewer unti l the fi l ter desi gn i s fi ni shed.
You can appl y the fi l ter to a si gnal by acti vati ng SPTool , sel ecti ng the fi l ter i n
the Filtersl i st, and the si gnal to appl y i t to from the Signalsl i st, and pressi ng
Apply. See Appl yi ng a Fi l ter on page 5-18 for detai l s.
See Usi ng the Fi l ter Vi ewer: I nteracti ve Fi l ter Anal ysi s on page 5-84 for more
i nformati on on the Fi l ter Vi ewer.
5 Interactive Tools
5-84
Using the Filter Viewer: Interactive Filter Analysis
An i mportant aspect of fi l ter desi gn i s fi l ter anal ysi s, whi ch encompasses both
frequency and ti me-domai n anal ysi s of a fi l ter. The Fi l ter Vi ewer i s a
GUI -based frequency anal ysi s tool that provi des an i nteracti ve envi ronment
for the graphi cal di spl ay of di gi tal fi l ter characteri sti cs.
The Fi l ter Vi ewer can di spl ay si x di fferent characteri sti cs subpl ots of a sel ected
fi l ter. Any combi nati on of the si x subpl ots may be di spl ayed.
Usi ng the Fi l ter Vi ewer you can:
Vi ew magni tude-response pl ots for one or more fi l ters
Vi ew phase-response pl ots for one or more fi l ters
Vi ew group-del ay pl ots for one or more fi l ters
Vi ew zero-pol e pl ots for one or more fi l ters
Vi ew i mpul se-response pl ots for one or more fi l ters
Vi ew step-response pl ots for one or more fi l ters
Zoom i n to expl ore fi l ter response detai l s
Modi fy sel ected pl ot parameters and di spl ay characteri sti cs
Measure a vari ety of characteri sti cs of the fi l ter response
For i nformati on on frequency anal ysi s usi ng tool box functi ons from the
command l i ne or from M-fi l es, see Frequency Response i n Chapter 1 of thi s
manual .
Opening the Filter Viewer
Open or acti vate the Fi l ter Vi ewer from SPTool :
1 Sel ect one or more fi l ters from the Filters l i st i n SPTool .
2 Press Viewi n the Filters panel i n SPTool .
The Fi l ter Vi ewer i s acti vated and the sel ected fi l ters are l oaded i nto the
Fi l ter Vi ewer and di spl ayed.
Basic Filter Viewer Functions
The Fi l ter Vi ewer has the fol l owi ng components:
Using the Filter Viewer: Interactive Filter Analysis
5-85
A Plots panel for sel ecti ng whi ch subpl ots di spl ay i n the mai n pl ots wi ndow
A Rulers panel and l i ne di spl ay control s for maki ng si gnal measurements
and compari sons
A Frequency Axis panel for speci fyi ng x-axi s scal i ng i n the mai n pl ots
wi ndow
A fi l ter i denti fi cati on panel that di spl ays i nformati on about the currentl y
sel ected fi l ter(s)
A mai n pl ots (di spl ay) area for vi ewi ng one or more frequency-domai n pl ots
for the sel ected fi l ter(s)
Zoom control s for getti ng a cl oser l ook at fi l ter response characteri sti cs
When you fi rst open or acti vate the Fi l ter Vi ewer, i t di spl ays the defaul t pl ot
confi gurati on for the sel ected fi l ter(s):
The fi l ters magni tude and phase pl ots are di spl ayed. The frequency axi s of the
pl ots i s set to linear, and the frequency axi s range i s set to [0,Fs/2].
Plots panel, including menus for
modifying plot characteristics
Frequency Axis panel
Filter ID panel
View (zoom) controls
Rulers panel, including controls for measuring filter responses
Line display controls
5 Interactive Tools
5-86
You can choose to di spl ay one or any combi nati on of the si x avai l abl e subpl ots
by usi ng the check boxes i n the Plots panel , and you can modi fy many of the
pl ot di spl ay characteri sti cs usi ng the pop-up menus i n the Plotspanel and the
Frequency Axis panel .
Menus
File Menu. Use Closefrom the Filemenu to cl ose the Fi l ter Vi ewer. Setti ngs you
changed and saved usi ng the Preferences di al og box i n SPTool are saved and
used the next ti me you open a Fi l ter Vi ewer.
Window Menu. Use the Windowmenu to sel ect a currentl y open MATLAB
fi gure wi ndow.
Filter Identification Panel
Thi s panel di spl ays the vari abl e names and the hi ghest sampl i ng frequency of
the currentl y sel ected fi l ters. To change names or sampl i ng frequenci es, use
Name or SamplingFrequency from the Edit menu i n SPTool .
Plots Panel
The check boxes i n thi s panel sel ect the subpl ots to di spl ay i n the mai n pl ots
area. Any combi nati on of subpl ots may be di spl ayed.
To di spl ay a subpl ot, check the box at the l eft of the pl ot descri pti on.
There are si x avai l abl e subpl ots:
Magnitude: di spl ays the magni tude of the frequency response of the
currentl y sel ected fi l ter(s).
Phase: di spl ays the phase of the frequency response.
Group Delay: di spl ays the negati ve of the deri vati ve of the phase response.
Zeros and Poles: di spl ays the pol es and zeros of the fi l ter transfer
functi on(s) and thei r proxi mi ty to the uni t ci rcl e.
ImpulseResponse: di spl ays the response of the currentl y sel ected fi l ter(s)
to a di screte-ti me uni t-hei ght i mpul se at t=0.
Step Response: di spl ays the response of the currentl y sel ected fi l ter(s) to a
di screte-ti me uni t-hei ght step functi on.
Using the Filter Viewer: Interactive Filter Analysis
5-87
You can customi ze the di spl ay characteri sti cs of the magni tude and phase
subpl ots usi ng the Magnitudeand Phasepop-up menus. The opti ons i ncl ude:
Magnitude: Scal i ng for the magni tude pl ot may be linear, log, or decibels.
Phase: Phase uni ts may be degrees or radians.
You can al so change the magni tude and phase di spl ay characteri sti cs for the
Fi l ter Vi ewer usi ng the Fi l ter setti ngs panel of the Preferences di al og box i n
SPTool .
Frequency Axis Settings
You can change frequency axi s scal i ng and range parameters for pl ots i n the
Fi l ter Vi ewer .
Cl i ck on the opti on i n the Frequency Axis panel you want to edi t and drag to
sel ect a val ue. The opti ons i ncl ude:
Scale: Scal i ng for the frequency axi s may be linear or log.
Range: The range for the frequency axi s may be [0,Fs/2], [0,Fs], or
[-Fs/2,Fs/2], where Fs represents the fi l ters sampl i ng frequency.
The frequency range cannot be negati ve i f Scalei s set to log.
You can al so change the frequency axi s di spl ay characteri sti cs for the Fi l ter
Vi ewer usi ng the Filter Viewer setti ngs panel of the Preferences di al og box
i n SPTool .
Zoom Controls
The avai l abl e zoom control s i n the Fi l ter Vi ewer are MouseZoomand Full
View. You can zoom i ndependentl y i n each di spl ayed subpl ot.
By defaul t, persi stent zoomi ng i s di sabl ed i n the Fi l ter Vi ewer. You can turn
persi stent zoomi ng on from the Filter Viewer setti ngs panel of the
Preferences di al og box i n SPTool .
See Zoom Control s on page 5-31 for detai l s on usi ng the zoom control s i n the
Fi l ter Vi ewer .
Help Button
To use context-sensi ti ve hel p, press the Help button. The mouse poi nter
becomes an arrow wi th a questi on mark symbol . You can then cl i ck on anythi ng
5 Interactive Tools
5-88
i n the Fi l ter Vi ewer, i ncl udi ng menu i tems, to fi nd out what i t i s and how to
use i t.
Main Plots Area
One or more of the si x fi l ter response subpl ots may be di spl ayed graphi cal l y i n
the mai n pl ots area of the Fi l ter Vi ewer. You can speci fy how the subpl ots are
arranged by sel ecti ng Filter Viewer Tilingfrom the Preferencesdi al og box i n
SPTool . The opti ons are 2-by-3Grid, 3-by-2Grid, Vertical (6-by-1Grid), and
Horizontal (1-by-6Grid).
The fol l owi ng fi gure shows the Fi l ter Vi ewer when four subpl ots are turned on
and the 2-by-3 gri d opti on i s sel ected.
You can exper i ment to fi nd the ti l i ng opti on that wor ks best for each speci fi c
combi nati on and number of subpl ots.
You can zoom i n on a subpl ot by pressi ng MouseZoomand then cl i cki ng on or
draggi ng over a sel ected area of the subpl ot. By defaul t, mouse zoomi ng i n the
Fi l ter Vi ewer i s not persi stent; after you cl i ck once, the zoom mode i s turned
off. You can make zoomi ng persi stent by checki ng Stay in Zoom-modeafter
Using the Filter Viewer: Interactive Filter Analysis
5-89
Zoomi n the SPTool Preferencesdi al og box. Thi s al l ows you to cl i ck repeatedl y
i n a subpl ot to conti nue to zoom i n on a parti cul ar feature of the di spl ay.
After you zoom i n on a subpl ot, you can cl i ck and drag to pan around the
subpl ot:
1 Press MouseZoomto turn on mouse zoom mode.
2 Cl i ck on a feature of a subpl ot to zoom i n on i t.
3 I f persi stent zoomi ng i s enabl ed, press MouseZoomagai n to turn off mouse
zoom mode.
4 Cl i ck agai n i n the same subpl ot, hol d down the mouse button unti l the hand
cursor i s di spl ayed, and drag the mouse to pan around the subpl ot.
Viewing Filter Plots
Thi s secti on has a bri ef descri pti on and pi cture of each of the si x fi l ter response
pl ots avai l abl e i n the Fi l ter Vi ewer. A sequence of connected exampl es shows
you how to di spl ay each pl ot on i ts own; you can al so di spl ay any combi nati on
of pl ots, as needed.
Each pl ot i n the exampl e sequence di spl ays the response of an order 22
equi ri ppl e l owpass fi l ter wi th a sampl i ng frequency of 1 Hz.
Regardl ess of how many or what combi nati on of pl ots i s di spl ayed, you can
zoom i n on and pan each subpl ot i ndependentl y.
Viewing Magnitude Response
A magni tude response pl ot i s general l y the si mpl est way to obtai n a hi gh-l evel
vi ew of a fi l ters shape and fi t to speci fi cati ons. I n the fol l owi ng exampl e, use
the Fi l ter Desi gner to create a standard defaul t fi l ter and then vi ew i ts
magni tude response pl ot i n the Fi l ter Vi ewer:
5 Interactive Tools
5-90
1 From SPTool , press Create.
The Fi l ter Desi gner i s acti vated and a standard defaul t fi l ter i s created and
di spl ayed.
Thi s i s an order 22 equi ri ppl e l owpass fi l ter wi th a sampl i ng frequency of
1 Hz.
2 Use the Windowmenu i n the Fi l ter Desi gner to acti vate SPTool .
3 Press Viewfrom the Filters panel i n SPTool to acti vate the Fi l ter Vi ewer.
The Fi l ter Vi ewer i s di spl ayed wi th a magni tude response pl ot and a phase
response pl ot.
Using the Filter Viewer: Interactive Filter Analysis
5-91
4 Cl i ck the check box next to the Phaseopti on to turn off the phase pl ot.
The magni tude pl ot for the defaul t fi l ter i s di spl ayed.
By defaul t, thi s pl ot uses the defaul t scal i ng (linear) for both axes and the
defaul t range for the frequency axi s.
You can change the fol l owi ng di spl ay characteri sti cs of the magni tude pl ot:
Use the Magnitudepop-up menu to choose between linear, log, or decibels
scal i ng of the y-axi s.
Use the Scalepop-up menu to choose between linear and logscal i ng of the
x-axi s.
Use the Rangepop-up menu to choose between the fol l owi ng ranges for the
x-axi s: [0,Fs/2], [0,Fs], or [-Fs/2,Fs/2], where Fs represents the fi l ters
sampl i ng frequency.
Viewing Phase Response
I n addi ti on to di spl ayi ng magni tude response, the Fi l ter Vi ewer can cal cul ate
and pl ot the fi l ters phase response. Phaseresponsei s the angul ar component
of a fi l ters frequency response. To di spl ay onl y a phase response pl ot for the
current fi l ter:
5 Interactive Tools
5-92
1 Cl i ck the check box next to the Magnitudeopti on to turn off the magni tude
pl ot.
2 Cl i ck the check box next to the Phaseopti on to turn on the phase pl ot and
update the di spl ay.
By defaul t, thi s pl ot uses the defaul t phase (degrees) and the defaul t scal i ng
and range for the frequency axi s.
You can change the fol l owi ng di spl ay characteri sti cs of the phase pl ot:
Use the Phasepop-up menu to choose between di spl ayi ng phase i n degrees
or radians.
Use the Scalepop-up menu to choose between linear and logscal i ng of the
x-axi s.
Use the Rangepop-up menu to choose between the fol l owi ng ranges for the
x-axi s: [0,Fs/2], [0,Fs], or [-Fs/2,Fs/2], where Fs represents the fi l ters
sampl i ng frequency.
Using the Filter Viewer: Interactive Filter Analysis
5-93
Viewing Group Delay
Group delay i s a measure of the average del ay of a fi l ter as a functi on of
frequency. To di spl ay onl y a group del ay pl ot for the currentl y sel ected fi l ter(s):
1 Cl i ck the check box next to the Phaseopti on to turn off the phase pl ot.
2 Cl i ck the check box next to the Group Delay opti on to turn on the group
del ay pl ot and update the di spl ay.
By defaul t, thi s pl ot uses the defaul t scal i ng and range for the frequency
axi s.
You can change the fol l owi ng di spl ay characteri sti cs of the group del ay pl ot:
Use the Scalepop-up menu to choose between linear and logscal i ng of the
x-axi s.
Use the Rangepop-up menu to choose between the fol l owi ng ranges for the
x-axi s: [0,Fs/2], [0,Fs], or [-Fs/2,Fs/2], where Fs represents the hi ghest
sampl i ng frequency of the currentl y sel ected fi l ters.
5 Interactive Tools
5-94
Viewing a Zero-Pole Plot
The zero-poleplot di spl ays the pol es and zeros of the transfer functi on and thei r
proxi mi ty to the uni t ci rcl e. An represents a pol e of the transfer functi on; a
represents a zero of the transfer functi on. To di spl ay onl y a zero-pol e pl ot for
the currentl y sel ected fi l ter(s):
1 Cl i ck the check box next to the Group Delay opti on to turn off the group
del ay pl ot.
2 Cl i ck the check box next to the Zeros and Poles opti on to turn on the
zero-pol e pl ot and update the di spl ay.
Viewing Impulse Response
The impulseresponseplot di spl ays the response of the current fi l ter(s) to a
di screte-ti me uni t-hei ght i mpul se at t=0.
To di spl ay onl y an i mpul se response pl ot for the currentl y sel ected fi l ter(s):
Using the Filter Viewer: Interactive Filter Analysis
5-95
1 Cl i ck the check box next to the Zeros and Poles opti on to turn off the
zero-pol e pl ot.
2 Cl i ck the check box next to the ImpulseResponseopti on to turn on the
i mpul se response pl ot and update the di spl ay.
You can change the fol l owi ng di spl ay characteri sti cs of the i mpul se response
pl ot:
Edi t the TimeResponseLengthfi el d i n the Filter Viewer Preferencespanel
to set the number of sampl es used to di spl ay the i mpul se response.
Viewing Step Response
The step responseplot di spl ays the response of the current fi l ter(s) to a
di screte-ti me uni t-hei ght step functi on. To di spl ay onl y a step response pl ot for
the currentl y sel ected fi l ter(s):
5 Interactive Tools
5-96
1 Cl i ck the check box next to the ImpulseResponseopti on to turn off the
i mpul se response pl ot.
2 Cl i ck the check box next to the Step Responseopti on to turn on the step
response pl ot and update the di spl ay.
You can change the fol l owi ng di spl ay characteri sti cs of the step response pl ot:
Edi t the TimeResponseLengthfi el d i n the Filter Viewer Preferencespanel
to set the number of sampl es used to di spl ay the step response.
Using the Spectrum Viewer: Interactive PSD Analysis
5-97
Using the Spectrum Viewer: Interactive PSD Analysis
The Spectrum Vi ewer provi des an i nteracti ve envi ronment for the esti mati on
of power spectral densi ty for one data channel . I t al l ows you to vi ew and modi fy
spectra cr eated i n SPTool .
Usi ng the Spectrum Vi ewer you can:
Vi ew and compare spectral densi ty pl ots
Use di fferent esti mati on methods, i ncl udi ng Burg, FFT, MTM, MUSI C,
Wel ch, and Yul e-Wal ker AR
Modi fy spectrum parameters such as FFT l ength, wi ndow type, and sampl e
frequency
Pri nt spectrum data
For i nformati on on spectral anal ysi s usi ng tool box functi ons from the command
l i ne or from M-fi l es, see Chapter 3 of thi s manual .
Opening the Spectrum Viewer
You can open or acti vate the Spectrum Vi ewer from SPTool by pressi ng one of
the fol l owi ng buttons: Create, View, and Update. See Creati ng a Spectrum
on page 5-19, Vi ewi ng a Spectrum on page 5-19, and Updati ng a Spectrum
on page 5-19 for compl ete detai l s.
Here i s a bri ef summary of each method of acti vati ng the Spectrum Vi ewer:
To cr eate a spectr um, sel ect a si gnal i n SPTool and press Create. Press
Apply i n the Spectrum Vi ewer.
A defaul t spectrum of the sel ected si gnal i s generated and di spl ayed. You can
vi ew i t i n a vari ety of ways, measure i t, and modi fy i t i n the Spectrum
Vi ewer.
To vi ew a spectrum, sel ect one or more spectra i n SPTool and press Viewi n
the Spectra panel .
To update a spectrum, sel ect exactl y one si gnal and one spectrum i n SPTool
and press Update. Press Apply i n the Spectrum Vi ewer.
The spectrum i s updated to refl ect the data i n the currentl y sel ected si gnal .
5 Interactive Tools
5-98
Basic Spectrum Viewer Functions
The Spectrum Vi ewer wi ndow has the fol l owi ng components:
A Parameterspanel for vi ewi ng and modi fyi ng the parameters or method of
the current spectrum
A si gnal i denti fi cati on panel that di spl ays i nformati on about the si gnal
l i nked to the current spectrum
A mai n axes (di spl ay) area for vi ewi ng spectra graphi cal l y
Zoom control s for getti ng a cl oser l ook at spectral features
Rul ers and l i ne-di spl ay control s for maki ng spectral measurements and
compari sons
Spectrum management control s: Inherit from..., Revert, and Apply
Menu opti ons for modi fyi ng pl ot di spl ay characteri sti cs
Menu opti ons for pri nti ng spectrum data
Main axes area
Signal ID
Ruler and line display controls
Zoom controls
Parameters panel
Using the Spectrum Viewer: Interactive PSD Analysis
5-99
Menus
File Menu. Use PageSetup... from the Filemenu to open the standard
MATLAB PageSetupdi al og box (see UsingMATLAB Graphics), i n whi ch you
can set the ori entati on, si ze and posi ti on, l i mi ts, and col or of your pri ntout.
Use Print Preview... from the Filemenu to open a MATLAB fi gure wi ndow
wi th a previ ew of the i nformati on from the Spectrum Vi ewer wi ndow that wi l l
appear i n your pri ntout. See Spectrum Vi ewer Setti ngs on page 5-24 and
Pri nti ng Spectrum Data on page 5-107 for detai l s of pri nti ng from the
Spectrum Vi ewer.
Use Print... from the Filemenu to open the standard operati ng system pri nt
di al og box, from whi ch you can pri nt your spectrum data.
Use Closefrom the Filemenu to cl ose the Spectrum Vi ewer. Al l spectrum
sel ecti on and rul er i nformati on wi l l be l ost. Setti ngs you changed and saved
usi ng the Preferencesdi al og box i n SPTool are saved and used the next ti me
you open the Spectrum Vi ewer.
Options Menu. Use these opti ons to change scal i ng and range parameters for
pl ots i n the Spectrum Vi ewer.
Cl i ck on the opti on you want to edi t and drag to sel ect a val ue.
5 Interactive Tools
5-100
The opti ons i ncl ude:
MagnitudeScale: Scal i ng for the magni tude pl ot may be dB or linear.
FrequencyRange: The range for the frequency axi s may be [0, Fs/2], [0, Fs],
or [-Fs/2, Fs/2], where Fs i s the sampl i ng frequency. I f mul ti pl e spectra are
di spl ayed, the val ue of Fs i s the maxi mum of al l the sampl i ng frequenci es.
Fs i s not defi ned for the case of a spectrum whose si gnal i s <None>, that i s, a
spectrum whose associ ated si gnal has been del eted from SPTool . I n thi s case,
a val ue twi ce the hi ghest frequency i n the spectrums frequency vector i s
chosen.
The frequency range cannot be negati ve i f Frequency Scalei s set to log.
Frequency Scale: Scal i ng for the frequency axi s may be linear or log.
Window Menu. Use the Windowmenu to sel ect a currentl y open MATLAB
fi gure wi ndow.
Signal ID Panel
Thi s panel di spl ays i nformati on about the si gnal l i nked to the currentl y
sel ected spectrum. The i nformati on i ncl udes the si gnal s name, si ze, data type
(real or complex), and sampl i ng frequency. To change any of these si gnal
properti es, use SPTool .
To associ ate a compl etel y new si gnal wi th a di spl ayed spectrum, sel ect the
si gnal i n SPTool and press Updatei n the Spectra panel .
Spectrum Management Buttons
Inherit from Choose a spectrum from thi s menu to l et the acti ve spectrum
i nheri t i ts parameters (not i ncl udi ng the associ ated si gnal ).
Press Inherit fromand drag to sel ect the spectrum from whi ch you want to
i nheri t parameters.
Revert. Restores the properti es of the current spectrum to what they were the
l ast ti me Apply was pressed.
Apply. Compute and di spl ay the acti ve spectrum usi ng the parameters set i n
the Parameters panel .
Using the Spectrum Viewer: Interactive PSD Analysis
5-101
Zoom Controls
The avai l abl e zoom control s i n the Spectrum Vi ewer are MouseZoom, Full
View, ZoomIn-Y, ZoomOut-Y, ZoomIn-X, and ZoomOut-X. See Zoom
Control s on page 5-31 for detai l s on usi ng the zoom control s i n the Spectrum
Vi ewer.
Ruler and Line Display Controls
Usi ng the rul ers and l i ne-di spl ay control s, you can measure a vari ety of
characteri sti cs of spectra i n the Spectrum Vi ewer. See Rul er Control s on page
5-33 for detai l s on usi ng rul ers and modi fyi ng l i ne di spl ays i n the Spectrum
Vi ewer.
Help Button
To use context-sensi ti ve hel p, press the Help button. The mouse poi nter
becomes an arrow wi th a questi on mark symbol . You can then cl i ck on anythi ng
i n the Spectrum Vi ewer, i ncl udi ng menu i tems, to fi nd out what i t i s and how
to use i t.
Main Axes Display Area
The Spectral i st i n SPTool shows al l spectra i n the current SPTool sessi on. One
or more spectra may be sel ected. The spectral data of al l sel ected spectra are
di spl ayed graphi cal l y i n the mai n axes di spl ay area of the Spectrum Vi ewer.
NOTE I f a spectrum i s not di spl ayed, or i f i t i s di spl ayed wi th the wrong
si gnal i nformati on, press Apply to recompute the spectral data.
When there i s onl y one spectrum di spl ayed, i ts properti es are di spl ayed i n the
Parameters panel and i ts measurements are di spl ayed i n the Rulers panel .
When more than one spectrum i s di spl ayed, sel ect the l i ne you want to focus on.
When a spectrum i s sel ected, you can use the rul er control s on the sel ected l i ne
(see Maki ng Si gnal Measurements on page 5-37) and you can modi fy i ts
parameters (see bel ow). The l abel of the sel ected spectrum (l i ne) i s di spl ayed i n
the Selection pop-up menu.
5 Interactive Tools
5-102
Sel ect a spectrum (l i ne) i n one of two ways:
Cl i ck on the Selection pop-up menu and drag to sel ect the l i ne to measure
Move the mouse poi nter over any poi nt i n the l i ne you want to sel ect and cl i ck
on i t
See Sel ecti ng a Li ne to Measure on page 5-34 for detai l s.
Click-and-Drag Panning. You can use the mouse to pan around the mai n axes
di spl ay:
Cl i ck on a l i ne i n the mai n axes, hol d down the mouse button, and drag the
mouse.
Cl i ck-and-drag panni ng i s not enabl ed i n mouse zoom mode.
Making Spectrum Measurements
Use the rul ers to make a vari ety of measurements on the sel ected spectrum.
See Maki ng Si gnal Measurements on page 5-37 for detai l s.
Viewing Spectral Density Plots
Spectral densi ty esti mati on i s a techni que that fi nds the approxi mate
frequency content of a si gnal . The Spectrum Vi ewer cal cul ates si ngl e-channel
power spectral densi ty (PSD). When you fi rst generate a spectrum, the
Spectrum Vi ewer shows a defaul t power spectral densi ty functi on of the i nput
data. By defaul t, the Spectrum Vi ewer uses the Wel ch method of PSD
esti mati on wi th a l ength-256 Hanni ng wi ndow and an FFT l ength of 1024.
You can change pl ot properti es and computati on parameters for a di spl ayed
spectrum, and you can set confi dence i nterval s.
Controlling and Manipulating Plots
Changing Plot Properties
You can control the axes uni ts and scal i ng properti es that affect the Spectrum
Vi ewers pl ots.
Using the Spectrum Viewer: Interactive PSD Analysis
5-103
Use the Options menu to sel ect:
Li near or deci bel scal i ng for the magni tude axi s
Li near or l ogari thmi c scal i ng for the frequency axi s
The frequency range to vi ew
See Opti ons Menu on page 5-99 for detai l s.
You can al so zoom i n on any of the Spectrum Vi ewers pl ots. See Zoom
Control s on page 5-31 for detai l s.
You can set other scal i ng properti es i n the Parameters panel , dependi ng on
the PSD method computati on parameters you choose.
Choosing Computation Parameters
The Spectrum Vi ewer l ets you control the PSD esti mati on parameters of the
sel ected spectrum. Di fferent parameters are avai l abl e, dependi ng on whi ch
method of PSD computati on you choose. Set these parameters from the
Parameters panel , as i l l ustrated i n the fol l owi ng steps:
1 Cl i ck on the Method pop-up menu and drag to sel ect one of the fol l owi ng
methods:
- Burg
- Covari ance
- FFT
- Modi fi ed Covari ance
- MTM
- MUSI C
- Wel ch
- Yul e AR
Appropri ate parameter sel ecti ons are di spl ayed for each method you choose.
5 Interactive Tools
5-104
2 Modi fy the appropri ate parameters.
- When a parameter i s i n a pop-up menu, cl i ck on the parameter l abel and
drag to sel ect a val ue from the menu.
- When a parameter i s i n an edi t box, type the val ue or vari abl e i nto the box.
You can al so modi fy the parameters by usi ng Inherit fromto copy the
parameters of another spectrum i n SPTool . See I nheri t from on page
5-100 for detai l s.
3 I f you change your mi nd, you can di scard changes you make by pressi ng
Revert.
4 To appl y the modi fi ed parameters, press Apply.
The new parameters are appl i ed to the sel ected spectrum; the Spectrum
Vi ewer recal cul ates the spectral densi ty functi on and di spl ays the modi fi ed
spectrum.
Computation Methods and Parameters
You can choose from seven PSD computati on methods. Each method has i ts
own set of parameters.
Thi s secti on shows the Parameters panel for each of the PSD computati on
methods. For detai l ed defi ni ti ons and val ues for each parameter, use
context-sensi ti ve hel p (see Hel p Button on page 5-101).
Burg. For the Burg method, you can speci fy the fol l owi ng
parameters:
Order
Nfft
Using the Spectrum Viewer: Interactive PSD Analysis
5-105
Covariance. For the Covari ance method, you can speci fy the
fol l owi ng parameters:
Order
Nfft
FFT. For the FFT method, you can speci fy the fol l owi ng
parameter:
Nfft
Mod. Covar. For the Modi fi ed Covari ance method, you can
speci fy the fol l owi ng parameters:
Order
Nfft
MTM. For the MTM method, you can speci fy the fol l owi ng
parameters:
NW
Nfft
5 Interactive Tools
5-106
Weights
Sel ect one of the fol l owi ng from the pop-up menu:
- adapt
- unity
- eigen
Conf. Int.
Check to compute a confi dence i nterval and type i n a val ue (see Setti ng
Confi dence I nterval s on page 5-107).
MUSIC. For the MUSI C method, you can speci fy the fol l owi ng
parameters:
Signal Dim.
Threshold
Nfft
Nwind
Window
Overlap
Corr. Matrix
Check i f sel ected si gnal i s a correl ati on matri x.
Eigenvector Weights
Check to sel ect ei genvector wei ghts.
Welch. For Wel chs method, you can speci fy the fol l owi ng
parameters:
NFFT
Nwind
Window
Overlap
Scaling
Sel ect one of the fol l owi ng from the pop-up menu:
- Unbiased
- Peaks
Using the Spectrum Viewer: Interactive PSD Analysis
5-107
Conf. Int.
Check to compute a confi dence i nterval and type i n a val ue (see Setti ng
Confi dence I nterval s on page 5-107).
Yule AR. For the Yul e AR method, you can speci fy the fol l owi ng
parameters:
Order
Nfft
Corr. Matrix
Check i f sel ected si gnal i s a correl ati on matri x.
Setting Confidence Intervals
By defaul t, the Spectrum Vi ewer does not compute confi dence i nterval s for
spectral densi ty. You can enabl e the computati on of confi dence i nterval s for the
Wel ch and MTM methods by fol l owi ng these steps:
1 Cl i ck the Conf. Int. check box so that i t i s sel ected.
2 Type a val ue for the confi dence l evel i n the Conf. Int. edi t box.
Thi s val ue must be a scal ar between 0 and 1.
3 Press Apply.
NOTE Confi dence i nterval s are rel i abl e onl y for nonoverl appi ng secti ons.
Printing Spectrum Data
You can pri nt al l of the spectrum data that you can di spl ay and mani pul ate i n
the Spectrum Vi ewer. Your pri ntout wi l l al ways contai n:
The pl ots of one or more spectra, as di spl ayed i n the mai n axes area
A l egend di spl ayed i n the mai n axes area to l abel each spectrum by name,
l i ne col or/styl e, method, and FFT l ength
The rul er measurements of the currentl y sel ected spectrum wi l l be di spl ayed
at the bottom of the fi gure, unl ess you suppress them wi th the Rulers check
5 Interactive Tools
5-108
box i n the SpectrumViewer preferences panel of the Preferences di al og box
i n SPTool (see Spectrum Vi ewer Setti ngs on page 5-24).
You can pr evi ew your pr i ntout by choosi ng Print Preview... from the File
menu i n the Spectrum Vi ewer wi ndow. Thi s opens the SpectrumViewer
Print Previewwi ndow, shown bel ow wi th defaul t setti ngs for the spectrum
mtlbse.
The Closebutton on the SpectrumViewer Print Previewwi ndow cl oses the
pri nt previ ew wi ndow and returns you to the Spectrum Vi ewer.
The Print... button on the SpectrumViewer Print Previewwi ndow opens the
standard pri nt di al og box, from whi ch you can pri nt the contents of your pri nt
previ ew wi ndow.
I f you choose to pri nt from the pri nt di al og, both that di al og and the Spectrum
Viewer Print Previewwi ndow wi l l cl ose, and the contents of the pri nt previ ew
wi l l pri nt.
I f you choose not to pri nt, the pri nt di al og and the SpectrumViewer Print
Previewwi ndow wi l l cl ose, and you wi l l return to the Spectrum Vi ewer.
Any changes you make, pri or to openi ng the pri nt previ ew wi ndow, that affect
the di spl ay of data i n the Spectrum Vi ewer (see Control l i ng and Mani pul ati ng
Pl ots on page 5-102) wi l l affect the di spl ay of data i n the SpectrumViewer
Using the Spectrum Viewer: Interactive PSD Analysis
5-109
Print Previewwi ndow i n exactl y the same way. For exampl e, i n the pri nt
previ ew shown bel ow:
Data from three di fferent sampl e spectra have been sel ected for di spl ay i n
the same mai n axes area (see Openi ng the Fi l ter Vi ewer on page 5-84).
Usi ng the tool s i n the Edit Linepop-up menu (see Rul er and Li ne Di spl ay
Control s on page 5-101), the spectrum l i nes have al l been changed to bl ack
and thei r l i ne styl es have been di fferenti ated, as i s refl ected i n the l egend.
The pl ots of al l three spectra have been zoomed to an i nterval between thei r
rul ers (see Zoom Control s on page 5-101). Note that the rul er
measurements di spl ayed are for the trainse spectrum, whi ch i s the
currentl y sel ected spectrum.
Changes you make i n the Preferencesdi al og box i n SPTool wi l l al so affect the
SpectrumViewer Print Previewwi ndow i n the same way that they affect the
Spectrum Vi ewer i tsel f. For exampl e, i n the pri nt previ ew shown bel ow, the
5 Interactive Tools
5-110
rul er measurements have been suppressed by changes i n the Spectrum Vi ewer
preferences (see Spectrum Vi ewer Setti ngs on page 5-24).
NOTE The HandleVisibility property of the Print Previewfi gure wi ndow i s
set to 'on'. Thi s al l ows you to modi fy the previ ew usi ng Handl e Graphi cs
commands from the MATLAB command l i ne or the Pl ot Edi tor tool s (see Using
MATLAB Graphics for more i nformati on). For exampl e, you can drag the
l egend to a di fferent posi ti on wi thi n the fi gure, as has been done i n the fi gure
shown above
Changes that you make i n the previ ew wi ndow pri nt exactl y as they appear on
the screen; however, they are not saved when the Print Previewfi gure
wi ndow i s cl osed.
Saving Spectrum Data
After creati ng a spectrum i n SPTool , you can export spectrum i nformati on to
the workspace or to di sk usi ng Export... from the Filemenu i n SPTool . The
spectrum i nformati on i s stored i n a structure that you can access to retri eve the
spectral power and frequency data. The spectrum structure al so contai ns a
number of fi el ds that are used i nternal l y by SPTool .
Using the Spectrum Viewer: Interactive PSD Analysis
5-111
To see the fi el ds of the spectrum structure, try exporti ng a spectrum to the
wor kspace:
1 Create a new spectrum i f none are currentl y l oaded. Label the spectrum
spect1.
2 I n SPTool , sel ect Export... from the Filemenu.
3 I n the Export di al og box, sel ect spect1 and press the Export toWorkspace
button.
4 Type who at the MATLAB command l i ne to l ook at the vari abl es i n the
workspace. The vari abl e cal l ed spect1 i s the spectrum structure you
exported from SPTool .
5 Type spect1 to l i st the fi el ds of the spectrum structure.
The fol l owi ng structure fi el ds descri be the spectrum.
Field Description
P The spectral power vector.
f The spectral frequency vector.
confid A structure contai ni ng the confi dence i nterval s data:
The confid.level fi el d contai ns the chosen
confi dence l evel .
The confid.Pc fi el d contai ns the spectral power
data for the confi dence i nterval s.
The confid.enable fi el d contai ns a 1 i f confi dence
l evel s are enabl ed for the spectrum.
signalLabel The name of the si gnal from whi ch the spectrum was
generated.
Fs The associ ated si gnal s sampl e r ate.
5 Interactive Tools
5-112
The other fi el ds are used i nternal l y by SPTool , and are subject to change i n
future rel eases.
Example: Generation of Bandlimited Noise
5-113
Example: Generation of Bandlimited Noise
Thi s secti on provi des a compl ete exampl e of usi ng the GUI -based i nteracti ve
tool s to desi gn and i mpl ement an FI R di gi tal fi l ter, appl y i t to a si gnal , and
di spl ay si gnal s and spectra. The steps i ncl ude:
I mporti ng and nami ng a si gnal usi ng SPTool
Desi gni ng a fi l ter usi ng the Fi l ter Desi gner
I n SPTool , appl yi ng the fi l ter to the si gnal to create another si gnal
Vi ewi ng the ti me domai n i nformati on of the ori gi nal and fi l tered si gnal s
usi ng the Si gnal Browser
Compari ng the spectra of both si gnal s usi ng the Spectrum Vi ewer
Create, Import, and Name a Signal
You can i mport an exi sti ng si gnal i nto SPTool , or you can create a new si gnal
and edi t and name i t i n SPTool . I n thi s step, youl l create a new si gnal at the
command l i ne and then i mport i t i nto SPTool .
1 At the command l i ne, create a random si gnal by typi ng:
x = randn(5000,1);
2 Acti vate SPTool by typi ng:
sptool
The SPTool wi ndow i s di spl ayed.
5 Interactive Tools
5-114
3 Sel ect Import... from the Filemenu:
The Import to SPTool wi ndow i s di spl ayed.
Noti ce that the vari abl e x i s di spl ayed i n the WorkspaceContents l i st. (I f
i t i s not, cl i ck the FromWorkspaceradi o button to di spl ay the contents of
the workspace.)
4 Name the si gnal and i mport i t i nto SPTool :
a Make sure that Signal i s sel ected i n the Import As pop-up menu.
b Cl i ck i n the Data fi el d and type x.
You can al so move the vari abl e x i nto the Data fi el d by cl i cki ng on x i n
the WorkspaceContentsl i st and then cl i cki ng on the arrow to the l eft of
the Data fi el d.
c Cl i ck i n the SamplingFrequency fi el d and type 5000.
d Name the si gnal by cl i cki ng i n the Namefi el d and typi ng noise.
e Press OK.
The SPTool wi ndow i s reacti vated, and the si gnal noise[vector] i s sel ected
i n the Signals l i st.
Example: Generation of Bandlimited Noise
5-115
Design a Filter
You can i mport an exi sti ng fi l ter i nto SPTool , or you can desi gn and edi t a new
fi l ter usi ng the Fi l ter Desi gner. I n thi s step, youl l create a defaul t fi l ter and
customi ze i t i n the Fi l ter Desi gner.
1 Press NewDesign i n SPTool to acti vate the Fi l ter Desi gner and generate a
defaul t fi l ter.
The Fi l ter Desi gner wi ndow i s di spl ayed wi th the defaul t fi l ter filt1.
2 Change the fi l ter sampl i ng frequency to 5000 by enteri ng thi s val ue i n the
SamplingFrequency text box i n the Fi l ter Desi gner.
3 Speci fy the fi l ter par ameter s shown at l eft:
a Make sure EquirippleFIR i s sel ected i n the Algorithmpop-up menu.
b Sel ect bandpass from the Typepop-up menu.
c Set the passband edge frequenci es by enteri ng 750 for Fp1and 1250 for
Fp2.
d Set the stopband edge frequenci es by enteri ng 500 for Fs1and 1500 for
Fs2.
e Type .01 i nto the Rp fi el d and 75 i nto the Rs fi el d.
Rp sets the maxi mum passband ri ppl e and Rs sets the stopband
attenuati on for the fi l ter.
f Press the Apply button to compute the new fi l ter.
5 Interactive Tools
5-116
When the new fi l ter i s computed, the magni tude response of the fi l ter i s
di spl ayed wi th a sol i d l i ne i n the mai n axes di spl ay area.
The resul ti ng fi l ter i s an order 78 bandpass equi ri ppl e fi l ter.
Apply the Filter to a Signal
I n thi s step, you appl y the fi l ter to the si gnal i n SPTool . The new, fi l tered si gnal
i s automati cal l y created i n SPTool .
Example: Generation of Bandlimited Noise
5-117
1 Acti vate SPTool from the Windowmenu i n the Fi l ter Desi gner.
2 Cl i ck to sel ect the si gnal noise[vector] from the Signals l i st and cl i ck to
sel ect the fi l ter (named filt1[design]) from the Filters l i st, as shown
bel ow.
3 Press Apply to appl y the fi l ter filt1 to the si gnal noise.
The Apply Filter di al og box i s di spl ayed.
4 Name the new si gnal by cl i cki ng i n the Output Signal fi el d and typi ng
blnoise.
5 Press OK.
The fi l ter i s appl i ed to the sel ected si gnal . The new, fi l tered si gnal
blnoise[vector] i s di spl ayed i n the Signals l i st.
View, Play, and Print the Signals
You can vi ew and pri nt the ti me domai n i nformati on of the si gnal s usi ng the
Si gnal Browser. You can al so pl ay the si gnal s, i f your computer has audi o
output capabi l i ti es. I n thi s step, youl l di spl ay both si gnal s i n the Si gnal
Browser, sel ect and pl ay each si gnal , and pri nt both si gnal s.
5 Interactive Tools
5-118
1 Shift-cl i ck on the noise and blnoise si gnal s i n the Signalsl i st of SPTool to
sel ect both si gnal s.
2 Press Viewi n the Signals panel .
The Si gnal Browser i s acti vated and both si gnal s are di spl ayed i n the mai n
axes di spl ay area. I ni ti al l y, the noise si gnal covers up the bandl i mi ted
blnoise si gnal , but you can see that both si gnal s are di spl ayed because the
names of both si gnal s are shown above the mai n axes di spl ay area.
3 Cl i ck-and-drag i n the Selection pop-up menu to sel ect the blnoise si gnal .
The mai n axes di spl ay area i s redi spl ayed. Now you can see the blnoise
si gnal superi mposed on top of the noise si gnal . The si gnal s are di spl ayed i n
di fferent col ors i n both the mai n axes di spl ay area and the panner. Noti ce
Example: Generation of Bandlimited Noise
5-119
that the col or of the l i ne i n the Selection di spl ay changes to correspond to
the col or of the si gnal that youve sel ected.
The si gnal thats di spl ayed i n the Selection pop-up menu and i n the
Selection di spl ay i s the acti ve si gnal . When you sel ect Play, or use the
rul ers, the acti ve si gnal i s the one that i s pl ayed or measured.
4 To hear the acti ve si gnal , sel ect Play from the Options menu.
5 To hear the other si gnal , sel ect i t as i n step 3 above (you can al so sel ect the
si gnal by cl i cki ng on i t i n the mai n axes di spl ay area). Sel ect Play from the
Options menu agai n.
6 Before pri nti ng the two si gnal s together, use the l i ne control s to maxi mi ze
the vi sual contrast between the si gnal s by setti ng the l i ne col or for noise to
5 Interactive Tools
5-120
gray and the l i ne col or for blnoise to whi te. (See Rul er Control s on page
5-33 for detai l s on usi ng these control s.)
Use the Si gnal Browser panel i n the Preferences di al og box i n SPTool to
suppress pri nti ng of both the panner and the rul er setti ngs. (See Si gnal
Br owser Setti ngs on page 5-23 for detai l s on these pr efer ences.)
To pr i nt both si gnal s, as seen i n the pi ctur e bel ow, sel ect Print... from the
Filemenu i n the Si gnal Browser.
Compare Spectra of Both Signals
You can get an i dea of the frequency content of the two si gnal s by di spl ayi ng
thei r power spectra usi ng the Spectrum Vi ewer, as descri bed bel ow.
1 Reacti vate SPTool by sel ecti ng i t from the Windowmenu of the Si gnal
Browser.
2 Cl i ck on the noise[vector] si gnal i n the Signals l i st of SPTool to sel ect i t.
Example: Generation of Bandlimited Noise
5-121
3 Press Createi n the Spectra panel .
The Spectrum Vi ewer i s acti vated, and a spectrum object (spect1)
correspondi ng to the noise si gnal i s created i n the Spectra l i st. The
spectrum i s not computed or di spl ayed yet.
4 Press Apply i n the Spectrum Vi ewer to compute and di spl ay spect1. The
spectrum of the noise si gnal i s di spl ayed i n the mai n axes di spl ay area.
Noti ce that the spectrums si gnal i denti fi cati on i nformati on i ncl udi ng i ts
name, i ts type, and i ts sampl i ng frequency i s di spl ayed above the
Parameters panel , and the spectrums name i s di spl ayed both above the
mai n axes di spl ay area and i n the Selection pop-up menu.
The spectrum esti mate i s wi thi n 2 or 3 dB of 0, so the noi se has a fai rl y fl at
spectrum.
5 Reacti vate SPTool by sel ecti ng i t from the Windowmenu i n the Spectrum
Vi ewer.
6 Cl i ck on the blnoise si gnal i n the Signals l i st of SPTool to sel ect i t.
5 Interactive Tools
5-122
7 Press Createi n the Spectra panel .
The Spectrum Vi ewer i s agai n acti vated, and a spectrum object (spect2)
correspondi ng to the blnoise si gnal i s created i n the Spectra l i st. The
spectrum i s not computed or di spl ayed yet.
8 Press Apply i n the Spectrum Vi ewer to di spl ay spect2.
The spectrum of the blnoise si gnal i s di spl ayed i n the mai n axes di spl ay
area.
The new spectrums si gnal i denti fi cati on i nformati on i ncl udi ng i ts name,
i ts type, and i ts sampl i ng frequency i s di spl ayed above the Parameters
panel , and the spectrums name i s di spl ayed both above the mai n axes
di spl ay area and i n the Selection pop-up menu.
Thi s spectrum i s fl at between 750 and 1250 Hz and has 75 dB l ess power i n
the stopband regi ons of filt1.
9 Reacti vate SPTool agai n, as i n step 5 above.
Example: Generation of Bandlimited Noise
5-123
10 Shift-cl i ck on spect1 and spect2 i n the Spectra l i st to sel ect them both.
11 Press Viewi n the Spectra panel to reacti vate the Spectrum Vi ewer and
di spl ay both spectra together.
12 To sel ect one of the spectra for measuri ng or edi ti ng, use the Selection
pop-up menu, or cl i ck on the spectrum i n the mai n axes di spl ay area.
The col or of the l i ne i n the Selection di spl ay changes to correspond to the
col or of the spectrum that youve sel ected.
The spectrum thats di spl ayed i n the Selection pop-up menu and i n the
Selectiondi spl ay i s the acti ve spectrum. When you use the rul ers or change
parameters, the acti ve spectrum i s the one that i s measured or modi fi ed.
13 Before pri nti ng the two spectra together, use the sel ecti on and rul er control s
to di fferenti ate the two pl ots by l i ne styl e, rather than by col or. Drag the
rul ers to demark the stopband edge frequenci es and change the rul ers from
5 Interactive Tools
5-124
Track to Vertical. (See Rul er Control s on page 5-33 for detai l s on usi ng
these control s.)
Sel ect Print Preview... from the Filemenu i n the Spectrum Vi ewer. From
the SpectrumViewer Print Previewwi ndow, drag the l egend out of the
axes di spl ay area so that i t doesnt obscure part of the pl ot.
To pri nt both si gnal s, as seen i n the pi cture bel ow, sel ect the Print... button
on the SpectrumViewer Print Previewwi ndow.
6
Reference
6 Reference
6-2
Thi s chapter contai ns detai l ed descri pti ons of al l Si gnal Processi ng Tool box
functi ons. I t begi ns wi th a l i st of functi ons grouped by subject area and
conti nues wi th the reference entri es i n al phabeti cal order. For more
i nformati on, see the onl i ne MATLAB Function Reference.
Waveform Generation and Plotting
chirp Swept-frequency cosi ne generator.
diric Di ri chl et or peri odi c si nc functi on.
gauspuls Gaussi an-modul ated si nusoi dal pul se generator.
pulstran Pul se trai n generator.
rectpuls Sampl ed aperi odi c rectangl e generator.
sawtooth Sawtooth or tri angl e wave generator.
sinc Si nc functi on.
square Square wave generator.
strips Stri p pl ot.
tripuls Sampl ed aperi odi c tri angl e generator.
Filter Analysis and Implementation
abs Absol ute val ue (magni tude).
angle Phase angl e.
conv Convol uti on and pol ynomi al mul ti pl i cati on.
conv2 Two-di mensi onal convol uti on.
fftfilt FFT-based FI R fi l teri ng usi ng the overl ap-add method.
filter Fi l ter data wi th a recursi ve (I I R) or nonrecursi ve (FI R)
fi l ter.
6-3
filter2 Two-di mensi onal di gi tal fi l teri ng.
filtfilt Zero-phase di gi tal fi l teri ng.
filtic Fi nd i ni ti al condi ti ons for a transposed di rect form I I fi l ter
i mpl ementati on.
freqs Frequency response of anal og fi l ters.
freqspace Frequency spaci ng for frequency response.
freqz Frequency response of di gi tal fi l ters.
grpdelay Average fi l ter del ay (group del ay).
impz I mpul se response of di gi tal fi l ters.
latcfilt Latti ce and l atti ce-l adder fi l ter i mpl ementati on.
sgolayfilt Savi tzky-Gol ay fi l teri ng.
sosfilt Second-order (bi quadrati c) I I R fi l teri ng.
unwrap Unwrap phase angl es.
zplane Zero-pol e pl ot.
Linear System Transformations
ac2poly Conversi on of autocorrel ati on sequence to predi cti on
pol ynomi al .
ac2rc Conversi on of autocorrel ati on sequence to refl ecti on
coeffi ci ents.
convmtx Convol uti on matri x.
latc2tf Latti ce fi l ter to transfer functi on conversi on.
Filter Analysis and Implementation
6 Reference
6-4
poly2ac Conversi on of predi cti on pol ynomi al to autocorrel ati on
sequence.
poly2rc Conversi on of predi cti on pol ynomi al to refl ecti on
coeffi ci ents.
rc2ac Conversi on of refl ecti on coeffi ci ents to autocorrel ati on
sequence.
rc2poly Conversi on of refl ecti on coeffi ci ents to predi cti on
pol ynomi al .
residuez z-transform parti al -fracti on expansi on.
sos2ss
Conversi on of second-order secti ons to state-space.
sos2tf Conversi on of second-order secti ons to transfer functi on.
sos2zp Conversi on of second-order secti ons to zero-pol e-gai n.
ss2sos Conversi on of state-space to second-order secti ons.
ss2tf Conversi on of state-space to transfer functi on.
ss2zp Conversi on of state-space to zero-pol e-gai n.
tf2latc Conversi on of transfer functi on to l atti ce fi l ter.
tf2sos Conversi on of transfer functi on to second-order secti ons.
tf2ss Conversi on of transfer functi on to state-space.
tf2zp Conversi on of transfer functi on to zero-pol e-gai n.
zp2sos Conversi on of zero-pol e-gai n to second-order secti ons.
zp2ss Conversi on of zero-pol e-gai n to state-space.
zp2tf Conversi on of zero-pol e-gai n to transfer functi on.
Linear System Transformations
6-5
IIR Filter DesignClassical and Direct
besself Bessel anal og fi l ter desi gn.
butter Butterworth anal og and di gi tal fi l ter desi gn.
cheby1 Chebyshev type I fi l ter desi gn (passband ri ppl e).
cheby2 Chebyshev type I I fi l ter desi gn (stopband ri ppl e).
ellip El l i pti c (Cauer) fi l ter desi gn.
maxflat General i zed di gi tal Butterworth fi l ter desi gn.
yulewalk Recursi ve di gi tal fi l ter desi gn.
IIR Filter Order Selection
buttord Butterworth fi l ter order sel ecti on.
cheb1ord Chebyshev type I fi l ter order sel ecti on.
cheb2ord Chebyshev type I I fi l ter order sel ecti on.
ellipord El l i pti c fi l ter order sel ecti on.
FIR Filter Design
cremez Compl ex and nonl i near-phase equi ri ppl e FI R fi l ter desi gn.
fir1 Wi ndow-based fi ni te i mpul se response fi l ter desi gn
standard response.
fir2 Wi ndow-based fi ni te i mpul se response fi l ter desi gn
arbi trary response.
fircls Constrai ned l east square FI R fi l ter desi gn for mul ti band
fi l ters.
6 Reference
6-6
fircls1 Constrai ned l east square fi l ter desi gn for l owpass and
hi ghpass l i near phase FI R fi l ters.
firls Least square l i near-phase FI R fi l ter desi gn.
firrcos Rai sed cosi ne FI R fi l ter desi gn.
intfilt I nter pol ati on FI R fi l ter desi gn.
kaiserord Esti mate parameters for an FI R fi l ter desi gn wi th Kai ser
wi ndow.
remez Parks-McCl el l an opti mal FI R fi l ter desi gn.
remezord Parks-McCl el l an opti mal FI R fi l ter order esti mati on.
sgolay Savi tzky-Gol ay fi l ter desi gn.
Transforms
czt Chi rp z-transform.
dct Di screte cosi ne transform (DCT).
dftmtx Di screte Fouri er transform matri x.
fft One-di mensi onal fast Fouri er transform.
fft2 Two-di mensi onal fast Fouri er transform.
fftshift Rearrange the outputs of the FFT functi ons.
hilbert Hi l bert transform.
idct I nverse di screte cosi ne transform.
ifft One-di mensi onal i nverse fast Fouri er transform.
ifft2 Two-di mensi onal i nverse fast Fouri er transform.
FIR Filter Design
6-7
Statistical Signal Processing
cohere Esti mate magni tude squared coherence functi on between
two si gnal s.
corrcoef Correl ati on coeffi ci ent matri x.
cov Covari ance matri x.
csd Esti mate the cross spectral densi ty (CSD) of two si gnal s.
pburg Power spectrum esti mate usi ng the Burg method.
pcov Power spectrum esti mate usi ng the covari ance method.
pmcov Power spectrum esti mate usi ng the modi fi ed covari ance
method.
pmtm Power spectrum esti mate usi ng the mul ti taper method
(MTM).
pmusic Power spectrum esti mate usi ng MUSI C ei genvector
method.
pwelch Esti mate the power spectral densi ty (PSD) of a si gnal usi ng
Wel chs method.
pyulear Power spectrum esti mate usi ng Yul e-Wal ker AR method.
tfe Transfer functi on esti mate from i nput and output.
xcorr Cross-correl ati on functi on esti mate.
xcorr2 Two-di mensi onal cross-correl ati on.
xcov Cross-covari ance functi on esti mate (equal to
mean-removed cross-correl ati on).
6 Reference
6-8
Windows
bartlett Bartl ett wi ndow.
blackman Bl ackman wi ndow.
boxcar Rectangul ar wi ndow.
chebwin Chebyshev wi ndow.
hamming Hammi ng wi ndow.
hanning Hanni ng wi ndow.
kaiser Kai ser wi ndow.
triang Tri angul ar wi ndow.
Parametric Modeling
arburg Compute an esti mate of AR model parameters usi ng the
Burg method.
arcov Compute an esti mate of AR model parameters usi ng the
covari ance method.
armcov Compute an esti mate of AR model parameters usi ng the
modi fi ed covari ance method.
aryule Compute an esti mate of AR model parameters usi ng the
Yul e-Wal ker method.
invfreqs Conti nuous-ti me (anal og) fi l ter i denti fi cati on from
frequency data.
invfreqz Di screte-ti me fi l ter i denti fi cati on from frequency data.
levinson Levi nson-Durbi n recursi on.
lpc Li near predi cti on coeffi ci ents.
prony Pronys method for ti me domai n I I R fi l ter desi gn.
6-9
rlevinson Reverse Levi nson-Durbi n recursi on.
stmcb Li near model usi ng Stei gl i tz-McBri de i terati on.
Specialized Operations
buffer Buffer a si gnal vector i nto a matri x of data frames.
cceps Compl ex cepstral anal ysi s.
cplxpair Group compl ex numbers i nto compl ex conjugate pai rs.
decimate Decrease the sampl i ng rate for a sequence (deci mati on).
deconv Deconvol uti on and pol ynomi al di vi si on.
demod Demodul ati on for communi cati ons si mul ati on.
dpss Di screte prol ate spheroi dal sequences (Sl epi an sequences).
dpssclear Remove di screte prol ate spheroi dal sequences from
database.
dpssdir Di screte prol ate spheroi dal sequences database di rectory.
dpssload Load di screte prol ate spheroi dal sequences from database.
dpsssave Save di screte prol ate spheroi dal sequences i n database.
icceps I nverse compl ex cepstrum.
interp I ncrease sampl i ng rate by an i nteger factor (i nterpol ati on).
medfilt1 One-di mensi onal medi an fi l teri ng.
modulate Modul ati on for communi cati ons si mul ati on.
polystab Stabi l i ze pol ynomi al .
rceps Real cepstrum and mi ni mum phase reconstructi on.
Parametric Modeling
6 Reference
6-10
resample Change sampl i ng rate by any rati onal factor.
specgram Ti me-dependent frequency anal ysi s (spectrogram).
upfirdn Upsampl e, appl y an FI R fi l ter, and downsampl e.
vco Vol tage control l ed osci l l ator.
Analog Prototype Design
besselap Bessel anal og l owpass fi l ter prototype.
buttap Butterworth anal og l owpass fi l ter prototype.
cheb1ap Chebyshev type I anal og l owpass fi l ter prototype.
cheb2ap Chebyshev type I I anal og l owpass fi l ter prototype.
ellipap El l i pti c anal og l owpass fi l ter prototype.
Frequency Translation
lp2bp Lowpass to bandpass anal og fi l ter transformati on.
lp2bs Lowpass to bandstop anal og fi l ter transformati on.
lp2hp Lowpass to hi ghpass anal og fi l ter transformati on.
lp2lp Lowpass to l owpass anal og fi l ter transformati on.
Specialized Operations
6-11
Filter Discretization
bilinear Bi l i near transformati on method of anal og-to-di gi tal fi l ter
conversi on.
impinvar I mpul se i nvari ance method of anal og-to-di gi tal fi l ter
conversi on.
Interactive Tools
sptool I nteracti ve di gi tal si gnal processi ng tool (SPTool ).
abs
6-12
6abs
Purpose Absol ute val ue (magni tude).
Syntax y = abs(x)
Description y = abs(x) returns the absol ute val ue of the el ements of x. I f x i s compl ex, abs
returns the compl ex modul us (magni tude):
abs(x) = sqrt(real(x).^2 + imag(x).^2)
I f x i s a MATLAB stri ng, abs returns the numeri c val ues of the ASCI I
characters i n the stri ng. The di spl ay format of the stri ng changes; the i nternal
representati on does not.
The abs functi on i s part of the standard MATLAB l anguage.
Example Cal cul ate the magni tude of the FFT of a sequence:
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
Pl ot the magni tude:
f = (0:length(y)1)'/length(y)*100; % frequency vector
plot(f,m)
See Also
angle Phase angl e.
ac2poly
6-13
6ac2pol y
Purpose Conversi on of autocorrel ati on sequence to predi cti on pol ynomi al .
Syntax a = ac2poly(r)
[a,efinal] = ac2poly(r)
Description a = ac2poly(r) fi nds the predi cti on pol ynomi al , a, correspondi ng to the
autocorrel ati on sequence r. a i s the same l ength as r, and a(1) = 1.
[a,efinal] = ac2poly(r) returns the fi nal predi cti on error, efinal.
Example Consi der the autocorrel ati on sequence
r = [5.0000 1.5450 3.9547 3.9331 1.4681 4.7500];
The equi val ent predi cti on pol ynomi al i s
a = ac2poly(r)
a =
1.0000 0.6147 0.9898 0.0004 0.0034 0.0077
See Also
References [1] Kay, S.M. Modern Spectral Estimation. Engl ewood Cl i ffs, NJ:
Prenti ce-Hal l , 1988.
ac2rc Conversi on of autocorrel ati on sequence to refl ecti on
coeffi ci ents.
poly2ac Conversi on of pr edi cti on pol ynomi al to
autocorrel ati on sequence.
rc2poly Conversi on of pr edi cti on pol ynomi al to r efl ecti on
coeffi ci ents.
ac2rc
6-14
6ac2rc
Purpose Conversi on of autocorrel ati on sequence to refl ecti on coeffi ci ents.
Syntax [k,r0] = ac2rc(r)
Description [k,r0] = ac2rc(r) fi nds the refl ecti on coeffi ci ents, k, correspondi ng to the
autocorrel ati on sequence r. r0 contai ns the zero-l ag autocorrel ati on.
See Also
References [1] Kay, S.M. Modern Spectral Estimation. Engl ewood Cl i ffs, NJ:
Prenti ce-Hal l , 1988.
ac2poly Conversi on of autocorrel ati on sequence to predi cti on
pol ynomi al .
poly2rc Conversi on of predi cti on pol ynomi al to refl ecti on
coeffi ci ents.
rc2ac Conversi on of refl ecti on coeffi ci ents to
autocorrel ati on sequence.
angle
6-15
6angl e
Purpose Phase angl e.
Syntax p = angle(h)
Description p = angle(h) returns the phase angl es, i n radi ans, of the el ements of compl ex
vector or array h. The phase angl es l i e between - and .
For compl ex sequence h =x+iy=me
i p
, the magni tude and phase are gi ven by
m = abs(h)
p = angle(h)
To convert to the ori gi nal h from i ts magni tude and phase:
i = sqrt(1)
h = m.*exp(i*p)
The angle functi on i s part of the standard MATLAB l anguage.
Example Cal cul ate the phase of the FFT of a sequence:
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
Pl ot the phase:
f = (0:length(y)1)'/length(y)*100; % frequency vector
plot(f,p)
Algorithm angle can be expressed as:
angle(x) = imag(log(x)) = atan2(imag(x),real(x))
See Also
abs Absol ute val ue (magni tude).
arburg
6-16
6ar bur g
Purpose Compute an esti mate of AR model parameters usi ng the Burg method.
Syntax a = arburg(x,p)
[a,e] = arburg(x,p)
[a,e,k] = arburg(x,p)
Description a = arburg(x,p) uses the Burg method to fi t a p-th order autoregressi ve (AR)
model to the i nput si gnal , x, by mi ni mi zi ng (l east squares) the forward and
backward predi cti on errors whi l e constrai ni ng the AR parameters to sati sfy
the Levi nson-Durbi n recursi on. x i s assumed to be the output of an AR system
dri ven by whi te noi se. Vector a contai ns the normal i zed esti mate of the AR
system par ameter s, A(z), i n descendi ng powers of z.
Si nce the method characteri zes the i nput data usi ng an al l -pol e model , the
correct choi ce of the model order p i s i mportant.
[a,e] = arburg(x,p) returns the vari ance esti mate, e, of the whi te noi se
i nput to the AR model .
[a,e,k] = arburg(x,p) returns a vector, k, of refl ecti on coeffi ci ents.
See Also
H z ( )
e
A z ( )
------------
e
1 a
2
z
1
a
p 1 + ( )
z
p
+ + +
---------------------------------------------------------------------- = =
arcov Compute an esti mate of AR model parameters usi ng
the covari ance method.
armcov Compute an esti mate of AR model parameters usi ng
the modi fi ed covari ance method.
aryule Compute an esti mate of AR model parameters usi ng
the Yul e-Wal ker method.
lpc Li near predi cti on coeffi ci ents.
pburg Power spectrum esti mate usi ng the Burg method.
prony Pronys method for ti me domai n I I R fi l ter desi gn.
arcov
6-17
6ar cov
Purpose Compute an esti mate of AR model parameters usi ng the covari ance method.
Syntax a = arcov(x,p)
[a,e] = arcov(x,p)
Description a = arcov(x,p) uses the covari ance method to fi t a p-th order autoregressi ve
(AR) model to the i nput si gnal , x, whi ch i s assumed to be the output of an AR
system dri ven by whi te noi se. Thi s method mi ni mi zes the forward predi cti on
error i n the l east-squares sense. Vector a contai ns the normal i zed esti mate of
the AR system par ameter s, A(z), i n descendi ng powers of z.
Because the method characteri zes the i nput data usi ng an al l -pol e model , the
correct choi ce of the model order p i s i mportant.
[a,e] = arcov(x,p) returns the vari ance esti mate, e, of the whi te noi se i nput
to the AR model .
See Also
H z ( )
e
A z ( )
------------
e
1 a
2
z
1
a
p 1 + ( )
z
p
+ + +
---------------------------------------------------------------------- = =
arburg Compute an esti mate of AR model parameters usi ng
the Burg method.
armcov Compute an esti mate of AR model parameters usi ng
the modi fi ed covari ance method.
aryule Compute an esti mate of AR model parameters usi ng
the Yul e-Wal ker method.
lpc Li near pr edi cti on coeffi ci ents.
pcov Power spectrum esti mate usi ng the covari ance
method.
prony Pronys method for ti me domai n I I R fi l ter desi gn.
armcov
6-18
6ar mcov
Purpose Compute an esti mate of AR model parameters usi ng the modi fi ed covari ance
method.
Syntax a = armcov(x,p)
[a,e] = armcov(x,p)
Description a = armcov(x,p) uses the modi fi ed covari ance method to fi t a p-th order
autoregressi ve (AR) model to the i nput si gnal , x, whi ch i s assumed to be the
output of an AR system dri ven by whi te noi se. Thi s method mi ni mi zes the
forward and backward predi cti on errors i n the l east-squares sense. Vector a
contai ns the normal i zed esti mate of the AR system parameters, A(z), i n
descendi ng powers of z.
Because the method characteri zes the i nput data usi ng an al l -pol e model , the
correct choi ce of the model order p i s i mportant.
[a,e] = armcov(x,p) returns the vari ance esti mate, e, of the whi te noi se
i nput to the AR model .
See Also
H z ( )
e
A z ( )
------------
e
1 a
2
z
1
a
p 1 + ( )
z
p
+ + +
---------------------------------------------------------------------- = =
arburg Compute an esti mate of AR model parameters usi ng
the Burg method.
arcov Compute an esti mate of AR model parameters usi ng
the covari ance method.
aryule Compute an esti mate of AR model parameters usi ng
the Yul e-Wal ker method.
lpc Li near predi cti on coeffi ci ents.
pmcov Power spectrum esti mate usi ng the modi fi ed
covari ance method.
prony Pronys method for ti me domai n I I R fi l ter desi gn.
aryule
6-19
6ar yul e
Purpose Compute an esti mate of AR model parameters usi ng the Yul e-Wal ker method.
Syntax a = aryule(x,p)
[a,e] = aryule(x,p)
[a,e,k] = aryule(x,p)
Description a = aryule(x,p) uses the Yul e-Wal ker method, al so cal l ed the
autocorrel ati on method, to fi t a p-th order autoregressi ve (AR) model to the
wi ndowed i nput si gnal , x, by mi ni mi zi ng the forward predi cti on error i n the
l east-squares sense. Thi s formul ati on l eads to the Yul e-Wal ker equati ons,
whi ch are sol ved by the Levi nson-Durbi n recursi on. x i s assumed to be the
output of an AR system dri ven by whi te noi se. Vector a contai ns the normal i zed
esti mate of the AR system par ameter s, A(z), i n descendi ng powers of z.
Because the method characteri zes the i nput data usi ng an al l -pol e model , the
correct choi ce of the model order p i s i mportant.
[a,e] = aryule(x,p) returns the vari ance esti mate, e, of the whi te noi se
i nput to the AR model .
[a,e,k] = aryule(x,p) returns a vector, k, of refl ecti on coeffi ci ents.
See Also
H z ( )
e
A z ( )
------------
e
1 a
2
z
1
a
p 1 + ( )
z
p
+ + +
---------------------------------------------------------------------- = =
arburg Compute an esti mate of AR model parameters usi ng
the Burg method.
arcov Compute an esti mate of AR model parameters usi ng
the covari ance method.
armcov Compute an esti mate of AR model parameters usi ng
the modi fi ed covari ance method.
lpc Li near pr edi cti on coeffi ci ents.
prony Pronys method for ti me domai n I I R fi l ter desi gn.
pyulear Power spectrum esti mate usi ng Yul e-Wal ker AR
method.
bartlett
6-20
6bar tl ett
Purpose Bartl ett wi ndow.
Syntax w = bartlett(n)
Description w = bartlett(n) returns an n-poi nt Bartl ett wi ndow i n the col umn vector w.
The coeffi ci ents of a Bartl ett wi ndow are:
For n odd
For n even
The Bartl ett wi ndow i s very si mi l ar to a tri angul ar wi ndow as returned by the
triang functi on. The Bartl ett wi ndow al ways ends wi th zeros at sampl es 1 and
n, however, whi l e the tri angul ar wi ndow i s nonzero at those poi nts. For n odd,
the center n2 poi nts of bartle9tt(n) are equi val ent to triang(n2).
See Also
References [1] Oppenhei m, A.V., and R.W. Schafer. Discrete-TimeSignal Processing.
Engl ewood Cl i ffs, NJ: Prenti ce-Hal l , 1989.
w k [ ]
2 k 1 ( )
n 1
--------------------- 1 k
n 1 +
2
------------- ,
2
2 k 1 ( )
n 1
---------------------
n 1 +
2
------------- k n ,

'

=
w k [ ]
2 k 1 ( )
n 1
--------------------- 1 k
n
2
--- ,
2 n k ( )
n 1
---------------------
n
2
--- 1 + k n ,

'

=
blackman Bl ackman wi ndow.
boxcar Rectangul ar wi ndow.
chebwin Chebyshev wi ndow.
hamming Hammi ng wi ndow.
hanning Hanni ng wi ndow.
kaiser Kai ser wi ndow.
triang Tri angul ar wi ndow.
besselap
6-21
6bessel ap
Purpose Bessel anal og l owpass fi l ter prototype.
Syntax [z,p,k] = besselap(n)
Description [z,p,k] = besselap(n) returns the zeros, pol es, and gai n of an order n Bessel
anal og l owpass fi l ter prototype. I t returns the pol es i n the l ength n col umn
vector p and the gai n i n scal ar k. z i s an empty matri x, because there are no
zeros. n must be l ess than or equal to 25. The transfer functi on i s
besselap normal i zes the pol es and gai n so that at l ow frequency and hi gh
frequency the Bessel prototype i s asymptoti cal l y equi val ent to the Butterworth
prototype of the same order [1]. The magni tude of the fi l ter i s l ess than
sqrt(1/2) at the uni ty cutoff frequency
c
= 1.
Anal og Bessel fi l ters are characteri zed by a group del ay that i s maxi mal l y fl at
at zero frequency and al most constant throughout the passband. The group
del ay at zero frequency i s
Algorithm besselap fi nds the fi l ter roots from a l ook-up tabl e constructed usi ng the
Symbol i c Math Tool box.
See Also
Al so see the Symbolic Math Toolbox Users Guide.
References [1] Rabi ner, L.R., and B. Gol d. Theory and Application of Digital Signal
Processing. Engl ewood Cl i ffs, NJ: Prenti ce-Hal l , 1975. Pgs. 228-230.
H s ( )
k
s p 1 ( ) ( ) s p 2 ( ) ( )Ls p n ( ) ( )
----------------------------------------------------------------------------- =
2n ( )!
2
n
n!
--------------
,
_
1 n
besself Bessel anal og fi l ter desi gn.
buttap Butterworth anal og l owpass fi l ter prototype.
cheb1ap Chebyshev type I anal og l owpass fi l ter prototype.
cheb2ap Chebyshev type I I anal og l owpass fi l ter prototype.
ellipap El l i pti c anal og l owpass fi l ter prototype.
besself
6-22
6bessel f
Purpose Bessel anal og fi l ter desi gn.
Syntax [b,a] = besself(n,Wn)
[b,a] = besself(n,Wn,'ftype')
[z,p,k] = besself(...)
[A,B,C,D] = besself(...)
Description besself desi gns l owpass, bandpass, hi ghpass, and bandstop anal og Bessel
fi l ters. Anal og Bessel fi l ters are characteri zed by al most constant group del ay
across the enti re passband, thus preservi ng the wave shape of fi l tered si gnal s
i n the passband. Di gi tal Bessel fi l ters do not retai n thi s qual i ty, and besself
ther efor e does not support the desi gn of di gi tal Bessel fi l ter s.
[b,a] = besself(n,Wn) desi gns an order n l owpass anal og fi l ter wi th cutoff
frequency Wn. I t returns the fi l ter coeffi ci ents i n the l ength n+1 row vectors b
and a, wi th coeffi ci ents i n descendi ng powers of s:
Cutoff frequencyi s the frequency at whi ch the magni tude response of the fi l ter
begi ns to decrease si gni fi cantl y. For besself, the cutoff frequency Wn must be
greater than 0. The magni tude response of a Bessel fi l ter desi gned by besself
i s al ways l ess than sqrt(1/2) at the cutoff frequency, and i t decreases as the
order n i ncreases.
I f Wn i s a two-el ement vector, Wn = [w1 w2] wi th w1 < w2, besself(n,Wn)
returns an order 2*n bandpass anal og fi l ter wi th passband w1 < < w2.
[b,a] = besself(n,Wn,'ftype') desi gns a hi ghpass or bandstop fi l ter, where
ftype i s
high for a hi ghpass anal og fi l ter wi th cutoff frequency Wn
stop for an order 2*n bandstop anal og fi l ter i f Wn i s a two-el ement vector,
Wn = [w1 w2]
The stopband i s w1 < < w2.
Wi th di fferent numbers of output arguments, besself di rectl y obtai ns other
real i zati ons of the anal og fi l ter. To obtai n zero-pol e-gai n form, use three output
arguments:
H s ( )
B s ( )
A s ( )
---------- -
b 1 ( )s
n
b 2 ( )s
n 1
L b n 1 + ( ) + + +
s
n
a 2 ( )s
n 1
L a n 1 + ( ) + + +
---------------------------------------------------------------------------------- = =
besself
6-23
[z,p,k] = besself(n,Wn) or
[z,p,k] = besself(n,Wn,'ftype')
besself returns the zeros and pol es i n l ength n or 2*n col umn vectors z and p
and the gai n i n the scal ar k.
To obtai n state-space form, use four output arguments:
[A,B,C,D] = besself(n,Wn) or
[A,B,C,D] = besself(n,Wn,'ftype') where A, B, C, and D are
and u i s the i nput, x i s the state vector, and y i s the output.
Example Desi gn a fi fth-order anal og l owpass Bessel fi l ter that suppresses frequenci es
greater than 10,000 rad/sec and pl ot the frequency response of the fi l ter usi ng
freqs:
[b,a] = besself(5,10000);
freqs(b,a) % plot frequency response
x

Ax Bu + =
y Cx Du + =
10
2
10
3
10
4
10
5
-200
0
200
Frequency (radians)
P
h
a
s
e

(
d
e
g
r
e
e
s
)
10
2
10
3
10
4
10
5
10
-5
10
0
Frequency (radians)
M
a
g
n
i
t
u
d
e
Frequency Response
besself
6-24
Limitations Lowpass Bessel fi l ters have a monotoni cal l y decreasi ng magni tude response,
as do l owpass Butterworth fi l ters. Compared to the Butterworth, Chebyshev,
and el l i pti c fi l ters, the Bessel fi l ter has the sl owest rol l off and requi res the
hi ghest order to meet an attenuati on speci fi cati on.
For hi gh order fi l ters, the state-space form i s the most numeri cal l y accurate,
fol l owed by the zero-pol e-gai n form. The transfer functi on coeffi ci ent form i s
the l east accurate; numeri cal probl ems can ari se for fi l ter orders as l ow as 15.
Algorithm besself performs a four-step al gori thm:
1 I t fi nds l owpass anal og prototype pol es, zeros, and gai n usi ng the besselap
functi on.
2 I t converts the pol es, zeros, and gai n i nto state-space form.
3 I t transforms the l owpass fi l ter i nto a bandpass, hi ghpass, or bandstop fi l ter
wi th desi red cutoff frequenci es, usi ng a state-space transformati on.
4 I t converts the state-space fi l ter back to transfer functi on or zero-pol e-gai n
form, as requi red.
See Also
besselap Bessel anal og l owpass fi l ter prototype.
butter Butterworth anal og and di gi tal fi l ter desi gn.
cheby1 Chebyshev type I fi l ter desi gn (passband ri ppl e).
cheby2 Chebyshev type I I fi l ter desi gn (stopband ri ppl e).
ellip El l i pti c (Cauer) fi l ter desi gn.
bilinear
6-25
6bi l i near
Purpose Bi l i near transformati on method of anal og-to-di gi tal fi l ter conversi on.
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 The bilinear transformation i s a mathemati cal mappi ng of vari abl es. I n di gi tal
fi l teri ng, i t i s a standard method of mappi ng the s or anal og pl ane i nto the z or
di gi tal pl ane. I t transforms anal og fi l ters, desi gned usi ng cl assi cal fi l ter desi gn
techni ques, i nto thei r di screte equi val ents.
The bi l i near transformati on maps the s-pl ane i nto the z-pl ane by
Thi s transformati on maps the j axi s (from = - to +) repeatedl y around
the uni t ci rcl e (exp(j), from = to ) by
bilinear can accept an opti onal parameter Fp that speci fi es prewarpi ng. Fp, i n
Hertz, i ndi cates a match frequency, that i s, a frequency for whi ch the
frequency responses before and after mappi ng match exactl y. I n prewarped
mode, the bi l i near transformati on maps the s-pl ane i nto the z-pl ane wi th
H z ( ) H s ( )
s 2f
s
z 1
z 1 +
------------ =
=
2tan
1

2f
s
------- -
,
_
=
H z ( ) H s ( )
s
2f
p

f
p
f
s
----
,
_
tan
------------------------
z 1 ( )
z 1 + ( )
----------------- =
=
bilinear
6-26
Wi th the prewarpi ng opti on, bilinear maps the j axi s (from = - to +)
repeatedl y around the uni t ci rcl e (exp(j), from = to ) by
I n prewarped mode, bilinear matches the frequency 2f
p
(i n radi ans per
second) i n the s-pl ane to the normal i zed frequency 2f
p
/f
s
(i n radi ans per
second) i n the z-pl ane.
The bilinear functi on works wi th three di fferent l i near system
representati ons: zero-pol e-gai n, transfer functi on, and state-space form.
Zero-Pole-Gain
[zd,pd,kd] = bilinear(z,p,k,Fs) and
[zd,pd,kd] = bilinear(z,p,k,Fs,Fp) convert the s-domai n transfer
functi on speci fi ed by z, p, and k to a di screte equi val ent. I nputs z and p are
col umn vectors contai ni ng the zeros and pol es, and k i s a scal ar gai n. Fs i s the
sampl i ng frequency i n Hertz. bilinear returns the di screte equi val ent i n
col umn vectors zd and pd and scal ar kd. Fp i s the opti onal match frequency, i n
Hertz, for prewarpi ng.
Transfer Function
[numd,dend] = bilinear(num,den,Fs) and
[numd,dend] = bilinear(num,den,Fs,Fp) convert an s-domai n transfer
functi on gi ven by num and den to a di screte equi val ent. Row vectors num and den
speci fy the coeffi ci ents of the numerator and denomi nator, respecti vel y, i n
descendi ng powers of s
2tan
1

f
p
f
s
----
,
_
tan
2f
p
-----------------------------
,



_
=
num s ( )
den s ( )
--------------------
num1 ( )s
nn
L numnn ( )s num nn 1 + ( ) + + +
den 1 ( )s
nd
L den nd ( )s den nd 1 + ( ) + + +
------------------------------------------------------------------------------------------------------------------- =
bilinear
6-27
Fs i s the sampl i ng frequency i n Hertz. bilinear returns the di screte
equi val ent i n row vectors numd and dend i n descendi ng powers of z (ascendi ng
powers of z
-1
). Fp i s the opti onal match frequency, i n Hertz, for prewarpi ng.
State-Space
[Ad,Bd,Cd,Dd] = bilinear(A,B,C,D,Fs) and
[Ad,Bd,Cd,Dd] = bilinear(A,B,C,D,Fs,Fp) convert the conti nuous-ti me
state-space system i n matr i ces A, B, C, D,
to the di screte-ti me system
Fs i s the sampl i ng frequency i n Hertz. bilinear returns the di screte
equi val ent i n matri ces Ad, Bd, Cd, Dd. Fp i s the opti onal match frequency, i n
Hertz, for prewarpi ng.
Algorithm bilinear uses one of two al gori thms, dependi ng on the format of the i nput
l i near system you suppl y. One al gori thm works on the zero-pol e-gai n format
and the other on the state-space format. For transfer functi on representati ons,
bilinear converts to state-space form, performs the transformati on, and
converts the resul ti ng state-space system back to transfer functi on form.
Zero-Pole-Gain Algorithm
For a system i n zer o-pol e-gai n for m, bilinear performs four steps:
1 I f Fp i s pr esent, k = 2*pi*Fp/tan(pi*Fp/Fs); otherwi se k = 2*Fs.
2 I t stri ps any zeros at pl us or mi nus i nfi ni ty usi ng
z = z(find(finite(z)));
x

Ax Bu + =
y Cx Du + =
x n 1 + [ ] A
d
x n [ ] B
d
u n [ ] + =
y n [ ] C
d
x n [ ] D
d
u n [ ] + =
bilinear
6-28
3 I t transforms the zeros, pol es, and gai n usi ng
pd = (1+p/k)./(1p/k);
zd = (1+z/k)./(1z/k);
kd = real(k*prod(fsz)./prod(fsp));
4 I t adds extra zeros at -1 so the resul ti ng system has equi val ent numerator
and denomi nator order.
State-Space Algorithm
For a system i n state-space form, bilinear performs two steps:
1 I f Fp i s present, k = 2*pi*Fp/tan(pi*Fp/Fs); el se k = 2*Fs.
2 I t computes Ad, Bd, Cd, and Dd i n terms of A, B, C, and D usi ng
bilinear i mpl ements these rel ati ons usi ng conventi onal MATLAB
statements. The scal ar r i s arbi trary; bilinear uses sqrt(2/k) to ensure good
quanti zati on noi se properti es i n the resul ti ng system.
Diagnostics bilinear requi res that the numerator order be no greater than the
denomi nator order. I f thi s i s not the case, bilinear di spl ays:
Numerator cannot be higher order than denominator.
For bilinear to di sti ngui sh between the zero-pol e-gai n and tr ansfer functi on
l i near system formats, the fi rst two i nput parameters must be vectors wi th the
same ori entati on i n these cases. I f thi s i s not the case, bilinear di spl ays:
First two arguments must have the same orientation.
A
d
I
1
k
---
,
_
A +
,
_
I
1
k
---
,
_
A
,
_
1
=
B
d
2k
r
------ - I
1
k
---
,
_
A
,
_
1
B =
C
d
rC I
1
k
---
,
_
A
,
_
1
=
D
d
1
k
---
,
_
C I
1
k
---
,
_
A
,
_
1
B D + =
bilinear
6-29
See Also
References [1] Parks, T.W., and C.S. Burrus. Digital Filter Design. New York: John Wi l ey
& Sons, 1987. Pgs. 209-213.
[2] Oppenhei m, A.V., and R.W. Schafer. Discrete-TimeSignal Processing.
Engl ewood Cl i ffs, NJ: Prenti ce-Hal l , 1989. Pgs. 415-430.
impinvar I mpul se i nvari ance method of anal og-to-di gi tal fi l ter
conversi on.
lp2bp Lowpass to bandpass anal og fi l ter transformati on.
lp2bs Lowpass to bandstop anal og fi l ter transformati on.
lp2hp Lowpass to hi ghpass anal og fi l ter transformati on.
lp2lp Lowpass to l owpass anal og fi l ter transformati on.
blackman
6-30
6bl ackman
Purpose Bl ackman wi ndow.
Syntax w = blackman(n)
w = blackman(n,sflag)
Description w = blackman(n) returns the n-poi nt symmetri cal l y sampl ed Bl ackman
wi ndow i n the col umn vector w. n shoul d be a nonnegati ve i nteger. The
equati on for a Bl ackman wi ndow i s
Bl ackman wi ndows have sl i ghtl y wi der central l obes and l ess si deband l eakage
than equi val ent l ength Hammi ng and Hanni ng wi ndows.
w = blackman(n,sflag) returns an n-poi nt Bl ackman wi ndow usi ng the
wi ndow sampl i ng speci fi ed by sflag, whi ch can be ei ther 'periodic' or
'symmetric' (the defaul t). When 'periodic' i s speci fi ed, blackman computes
a l ength n+1 wi ndow and returns the fi rst n poi nts.
Algorithm w = (0.42 0.5*cos(2*pi*(0:N1)/(N1)) + ...
0.08*cos(4*pi*(0:N1)/(N1)))';
Diagnostics An error message i s di spl ayed when i ncorrect arguments are used:
Order cannot be less than zero.
Sampling must be either 'symmetric' or 'periodic'.
A warni ng message i s di spl ayed for noni nteger n:
Warning: Rounding order to nearest integer.
w k [ ] 0.42 0.5 2
k 1
n 1
------------ -
,
_
cos 0.08 4
k 1
n 1
-------------
,
_
cos + k 1 = n , , , =
blackman
6-31
See Also
References [1] Oppenhei m, A.V., and R.W. Schafer. Discrete-TimeSignal Processing.
Engl ewood Cl i ffs, NJ: Prenti ce-Hal l , 1989.
bartlett Bartl ett wi ndow.
boxcar Rectangul ar wi ndow.
chebwin Chebyshev wi ndow.
hamming Hammi ng wi ndow.
hanning Hanni ng wi ndow.
kaiser Kai ser wi ndow.
triang Tri angul ar wi ndow.
boxcar
6-32
6boxcar
Purpose Rectangul ar wi ndow.
Syntax w = boxcar(n)
Description w = boxcar(n) returns a rectangul ar wi ndow of l ength n i n the col umn vector
w. Thi s functi on i s provi ded for compl eteness; a rectangul ar wi ndow i s
equi val ent to no wi ndow at al l .
Algorithm w = ones(n,1);
See Also
References [1] Oppenhei m, A.V., and R.W. Schafer. Discrete-TimeSignal Processing.
Engl ewood Cl i ffs, NJ: Prenti ce-Hal l , 1989.
bartlett Bartl ett wi ndow.
blackman Bl ackman wi ndow.
chebwin Chebyshev wi ndow.
hamming Hammi ng wi ndow.
hanning Hanni ng wi ndow.
kaiser Kai ser wi ndow.
triang Tri angul ar wi ndow.
buffer
6-33
6buffer
Purpose Buffer a si gnal vector i nto a matri x of data frames.
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) parti ti ons a l ength-L si gnal vector x i nto nonoverl appi ng
data segments (frames) of l ength n. Each data frame occupi es one col umn of
matri x output y, whi ch has n rows and ceil(L/n) col umns. I f L i s not evenl y
di vi si bl e by n, the l ast col umn i s zero-padded to l ength n.
y = buffer(x,n,p) overl aps or underl aps successi ve frames i n the output
matri x by p sampl es:
For 0<p<n (overl ap), buffer repeats the fi nal p sampl es of each frame at the
begi nni ng of the fol l owi ng frame. For exampl e, i f x=1:30 and n=7, an overl ap
of p=3 l ooks l i ke thi s:
The fi rst frame starts wi th p zeros (the defaul t i ni ti al condi ti on), and the
number of col umns i n y i s ceil(L/(np)).
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
buffer
6-34
For p<0 (underl ap), buffer ski ps p sampl es between consecuti ve frames. For
exampl e, i f x=1:30 and n=7, a buffer wi th underl ap of p=3 l ooks l i ke thi s:
The number of col umns i n y i s ceil(L/(np)).
y = buffer(x,n,p,opt) speci fi es a vector of sampl es to precede x(1) i n an
overl appi ng buffer, or the number of i ni ti al sampl es to ski p i n an underl appi ng
buffer:
For 0<p<n (overl ap), opt speci fi es a l ength-p vector to i nsert before x(1) i n
the buffer. Thi s vector can be consi dered an initial condition, whi ch i s needed
when the current bufferi ng operati on i s one i n a sequence of consecuti ve
bufferi ng operati ons. To mai ntai n the desi red frame overl ap from one buffer
to the next, opt shoul d contai n the fi nal p sampl es of the previ ous buffer i n
the sequence. See Conti nuous Bufferi ng bel ow.
By defaul t, opt i s zeros(p,1) for an overl appi ng buffer. Set opt to
'nodelay' to ski p the i ni ti al condi ti on and begi n fi l l i ng the buffer
i mmedi atel y wi th x(1). I n thi s case, L must be length(p) or l onger. For
exampl e, i f x=1:30 and n=7, a buffer wi th overl ap of p=3 l ooks l i ke thi s:
For p<0 (underl ap), opt i s an i nteger val ue i n the range [0,p] speci fyi ng the
number of i ni ti al i nput sampl es, x(1:opt), to ski p before addi ng sampl es to
y =
1 11 21
2 12 22
3 13 23
4 14 24
5 15 25
6 16 26
7 17 27
8 18 28
9 19 29
10 20 30
skipped
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
buffer
6-35
the buffer. The fi rst val ue i n the buffer i s therefore x(opt+1). By defaul t, opt
i s zero for an underl appi ng buffer.
Thi s opti on i s especi al l y useful when the current bufferi ng operati on i s one
i n a sequence of consecuti ve bufferi ng operati ons. To mai ntai n the desi red
frame underl ap from one buffer to the next, opt shoul d equal the di fference
between the total number of poi nts to ski p between frames (p) and the
number of poi nts that were availableto be ski pped i n the previ ous i nput to
buffer. I f the previ ous i nput had fewer than p poi nts that coul d be ski pped
after fi l l i ng the fi nal frame of that buffer, the remai ni ng opt poi nts need to
be removed from the fi rst frame of the current buffer. See Conti nuous
Bufferi ng bel ow for an exampl e of how thi s works i n practi ce.
[y,z] = buffer(...) parti ti ons the l ength-L si gnal vector x i nto frames of
l ength n, and outputs onl y the full frames i n y. I f y i s an overl appi ng buffer, i t
has n rows and m col umns, where
m = floor(L/(np)) % when length(opt) = p
or
m = floor((Ln)/(np))+1 % when opt = 'nodelay'
I f y i s an underl appi ng buffer, i t has n rows and m col umns, where
m = floor((Lopt)/(np)) + (rem((Lopt),(np)) >= n)
I f the number of sampl es i n the i nput vector (after the appropri ate overl appi ng
or underl appi ng operati ons) exceeds the number of pl aces avai l abl e i n the
n-by-m buffer, the remai ni ng sampl es i n x are output i n vector z, whi ch for an
overl appi ng buffer has l ength
length(z) = L m*(np) % when length(opt) = p
or
length(z) = L ((m1)*(np)+n) % when opt = 'nodelay'
and for an underl appi ng buffer has l ength
length(z) = (Lopt) m*(np)
buffer
6-36
Output z shares the same ori entati on (row or col umn) as x. I f there are no
remai ni ng sampl es i n the i nput after the buffer wi th the speci fi ed overl ap or
underl ap i s fi l l ed, z i s an empty vector.
[y,z,opt] = buffer(...) returns the l ast p sampl es of a overl appi ng buffer
i n output opt. I n an underl appi ng buffer, opt i s the di fference between the total
number of poi nts to ski p between frames (p)and the number of poi nts i n x that
were availableto be ski pped after fi l l i ng the l ast frame:
For 0<p<n (overl ap), opt (as an output) contai ns the fi nal p sampl es i n the
l ast frame of the buffer. Thi s vector can be used as the initial condition for a
subsequent bufferi ng operati on i n a sequence of consecuti ve bufferi ng
operati ons. Thi s al l ows the desi red frame overl ap to be mai ntai ned from one
buffer to the next. See Conti nuous Bufferi ng bel ow.
For p<0 (underl ap), opt (as an output) i s the di ffer ence between the total
number of poi nts to ski p between frames (p) and the number of poi nts i n x
that were availableto be ski pped after fi l l i ng the l ast frame.
opt = m*(np) + opt L % for z = empty vector
where opt on the ri ght-hand si de i s the i nput argument to buffer, and opt
on the l eft-hand si de i s the output argument. Here m i s the number of
col umns i n the buffer, whi ch i s
m = floor((Lopt)/(np)) + (rem((Lopt),(np)) >= n)
Note that for an underl appi ng buffer output opt i s al ways zero when output
z contai ns data.
The opt output for an underl appi ng buffer i s especi al l y useful when the
current bufferi ng operati on i s one i n a sequence of consecuti ve bufferi ng
operati ons. The opt output from each bufferi ng operati on speci fi es the
number of sampl es that need to be ski pped at the start of the next bufferi ng
operati on to mai ntai n the desi red frame underl ap from one buffer to the
next. I f fewer than p poi nts were avai l abl e to be ski pped after fi l l i ng the fi nal
frame of the current buffer, the remai ni ng opt poi nts need to be removed
from the fi rst frame of the next buffer.
I n a sequence of bufferi ng operati ons, the opt output from each operati on
shoul d be used as the opt i nput to the subsequent bufferi ng operati on. Thi s
ensures that the desi red frame overl ap or underl ap i s mai ntai ned from buffer
buffer
6-37
to buffer, as wel l as from frame to frame wi thi n the same buffer. See
Conti nuous Bufferi ng bel ow for an exampl e of how thi s works i n practi ce.
Continuous Buffering
I n a conti nuous bufferi ng operati on, the vector i nput to the buffer functi on
represents one frame i n a sequence of frames that make up a di screte si gnal .
These si gnal frames can ori gi nate i n a frame-based data acqui si ti on process, or
wi thi n a frame-based al gori thm l i ke the FFT.
As an exampl e, you mi ght acqui re data from an A/D card i n frames of 64
sampl es. I n the si mpl est case, you coul d rebuffer the data i nto frames of 16
sampl es; buffer wi th n=16 creates a buffer of four frames from each
64-el ement i nput frame. The resul t i s that the si gnal of frame si ze 64 has been
converted to a si gnal of frame si ze 16; no sampl es were added or removed.
I n the general case where the ori gi nal si gnal frame si ze, L, i s not equal l y
di vi si bl e by the new frame si ze, n, the overfl ow from the l ast frame needs to be
captured and recycl ed i nto the fol l owi ng buffer. You can do thi s by i terati vel y
cal l i ng buffer on i nput x wi th the two-output-argument syntax:
[y,z] = buffer([z;x],n) % for column vector x
[y,z] = buffer([z,x],n) % for row vector x
Thi s si mpl y captures any buffer overfl ow i n z, and prepends the data to the
subsequent i nput i n the next cal l to buffer. Agai n, the i nput si gnal , x, of frame
si ze L, has been converted to a si gnal of frame si ze n wi thout any i nserti on or
del eti on of sampl es.
Note that conti nuous bufferi ng cannot be done wi th the si ngl e-output syntax
y = buffer(...), because the l ast frame of y i n thi s case i s zero padded, whi ch
adds new sampl es to the si gnal .
Conti nuous bufferi ng i n the presence of overl ap and underl ap i s handl ed wi th
the opt parameter, whi ch i s used as both an i nput and output to buffer. The
fol l owi ng two exampl es demonstrate how the opt parameter shoul d be used.
Examples Example 1: Continuous Overlapping Buffers
Fi rst create a buffer contai ni ng 100 frames, each wi th 11 sampl es.
data = buffer(1:1100,11); % 11 samples per frame
buffer
6-38
I magi ne that the frames (col umns) i n the matri x cal l ed data are the sequenti al
outputs of a data acqui si ti on board sampl i ng a physi cal si gnal : data(:,1) i s
the fi rst D/A output, contai ni ng the fi rst 11 si gnal sampl es; data(:,2) i s the
second output, contai ni ng the next 11 si gnal sampl es, and so on.
You want to rebuffer thi s si gnal from the acqui red frame si ze of 11 to a frame
si ze of 4 wi th an overl ap of 1. To do thi s, you wi l l repeatedl y cal l buffer to
operate on each successi ve i nput frame, usi ng the opt parameter to mai ntai n
consi stency i n the overl ap from one buffer to the next.
Set the buffer parameters.
n = 4; % new frame size
p = 1; % overlap
opt = 5; % value of y(1)
z = []; % initialize the carry-over vector
Now repeatedl y cal l buffer, each ti me passi ng i n a new si gnal frame from
data. Note that overfl ow sampl es (returned i n z) are carri ed over and
prepended to the i nput i n the subsequent cal l to 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
buffer
6-39
Heres what happens duri ng the fi rst four i terati ons.
Note that the si ze of the output matri x, y, can vary by a si ngl e col umn from one
i terati on to the next. Thi s i s typi cal for bufferi ng operati ons wi th overl ap or
underl ap.
Example 2: Continuous Underlapping Buffers
Agai n create a buffer contai ni ng 100 frames, each wi th 11 sampl es.
data = buffer(1:1100,11); % 11 samples per frame
Agai n, i magi ne that data(:,1) i s the fi rst D/A output, contai ni ng the fi rst 11
si gnal sampl es; data(:,2) i s the second output, contai ni ng the next 11 si gnal
sampl es, and so on.
You want to rebuffer thi s si gnal from the acqui red frame si ze of 11 to a frame
si ze of 4 wi th an underl ap of 2. To do thi s, you wi l l repeatedl y cal l buffer to
operate on each successi ve i nput frame, usi ng the opt parameter to mai ntai n
consi stency i n the underl ap from one buffer to the next.
[1:11] i=1
5 3 6
1 4 7
2 5 8
3 6 9
Iteration Input frame [z;x]' opt (input) opt (output) Output buffer (y) Overflow (z)
[10 11] 5 9
i=2 [10 11 12:22] 9 21
9 12 15 18
10 13 16 19
11 14 17 20
12 15 18 21
[22]
i=3 [22 23:33] 21 33
21 24 27 30
22 25 28 31
23 26 29 32
24 27 30 33
[]
33 36 39
34 37 40
35 38 41
36 39 42
[43 44] 42 [34:44]
i=4
33
buffer
6-40
Set the buffer parameters:
n = 4; % new frame size
p = 2; % underlap
opt = 1; % skip the first input element, x(1)
z = []; % initialize the carry-over vector
Now repeatedl y cal l buffer, each ti me passi ng i n a new si gnal frame from
data. Note that overfl ow sampl es (returned i n z) are carri ed over and
prepended to the i nput i n the subsequent cal l to 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
buffer
6-41
Heres what happens duri ng the fi rst three i terati ons.
Diagnostics Error messages are di spl ayed when pn or length(opt)length(p) i n an
overl appi ng buffer case:
Frame overlap P must be less than the buffer size N.
Initial conditions must be specified as a length-P vector.
See Also
[1:11] i=1
2 8
3 9
4 10
5 11
Iteration Input frame [z;x]' opt (input) opt (output) Output buffer (y) Overflow (z)
[] 1 2
i=2 [12:22] 2 0
14
15
16
17
[20 21 22]
i=3 [20 21 22 23:33] 0 0
20 26
21 27
22 28
23 29
[32 33]
6
7
1
18
19
12
13

24 30
25 31
skip
skip
skip
skip
skip
skip
reshape Reshape array.
buttap
6-42
6buttap
Purpose Butterworth anal og l owpass fi l ter prototype.
Syntax [z,p,k] = buttap(n)
Description [z,p,k] = buttap(n) returns the zeros, pol es, and gai n of an order n
Butterworth anal og l owpass fi l ter prototype. I t returns the pol es i n the l ength
n col umn vector p and the gai n i n scal ar k. z i s an empty matri x, because there
are no zeros. The transfer functi on i s
Butterworth fi l ters are characteri zed by a magni tude response that i s
maxi mal l y fl at i n the passband and monotoni c overal l . I n the l owpass case, the
fi rst 2n1 deri vati ves of the squared magni tude response are zero at =0. The
squared magni tude response functi on i s
correspondi ng to a transfer functi on wi th pol es equal l y spaced around a ci rcl e
i n the l eft hal f pl ane. The magni tude response at the cutoff frequency
0
i s
al ways 1/sqrt(2), regardl ess of the fi l ter order. buttap sets
0
to 1 for a
normal i zed resul t.
Algorithm z = [];
p = exp(sqrt(1)*(pi*(1:2:2*n1)/(2*n)+pi/2)).';
k = real(prod(p));
See Also
References [1] Parks, T.W., and C.S. Burrus. Digital Filter Design. New York: John Wi l ey
& Sons, 1987. Chapter 7.
H s ( )
z s ( )
p s ( )
----------
k
s p 1 ( ) ( ) s p 2 ( ) ( )Ls p n ( ) ( )
----------------------------------------------------------------------------- = =
H ( )
2
1
1
0
( )
2n
+
----------------------------------- - =
besselap Bessel anal og l owpass fi l ter prototype.
butter Butterworth anal og and di gi tal fi l ter desi gn.
cheb1ap Chebyshev type I anal og l owpass fi l ter prototype.
cheb2ap Chebyshev type I I anal og l owpass fi l ter prototype.
ellipap El l i pti c anal og l owpass fi l ter prototype.
butter
6-43
6butter
Purpose Butterworth anal og and di gi tal fi l ter desi gn.
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 desi gns l owpass, bandpass, hi ghpass, and bandstop di gi tal and anal og
Butterworth fi l ters. Butterworth fi l ters are characteri zed by a magni tude
response that i s maxi mal l y fl at i n the passband and monotoni c overal l .
Butterworth fi l ters sacri fi ce rol l off steepness for monotoni ci ty i n the pass- and
stopbands. Unl ess the smoothness of the Butter worth fi l ter i s needed, an
el l i pti c or Chebyshev fi l ter can general l y provi de steeper rol l off characteri sti cs
wi th a l ower fi l ter order.
Digital Domain
[b,a] = butter(n,Wn) desi gns an order n l owpass di gi tal Butterworth fi l ter
wi th cutoff frequency Wn. I t returns the fi l ter coeffi ci ents i n l ength n + 1 row
vectors b and a, wi th coeffi ci ents i n descendi ng powers of z:
Cutoff frequency i s that frequency where the magni tude response of the fi l ter
i s sqrt(1/2). For butter, the cutoff frequency Wn must be a number between 0
and 1, where 1 corresponds to hal f the sampl i ng frequency (the Nyqui st
frequency).
I f Wn i s a two-el ement vector, Wn = [w1 w2], butter returns an order 2*n di gi tal
bandpass fi l ter wi th passband w1 < < w2.
[b,a] = butter(n,Wn,'ftype') desi gns a hi ghpass or bandstop fi l ter, where
ftype i s
H z ( )
B z ( )
A z ( )
-----------
b 1 ( ) b 2 ( )z
1
L b n 1 + ( )z
n
+ + +
1 a 2 ( )z
1
L a n 1 + ( )z
n
+ + +
--------------------------------------------------------------------------------- = =

butter
6-44
high for a hi ghpass di gi tal fi l ter wi th cutoff frequency Wn
stop for an order 2*n bandstop di gi tal fi l ter i f Wn i s a two-el ement vector,
Wn = [w1 w2]
The stopband i s w1 < < w2.
Wi th di fferent numbers of output arguments, butter di rectl y obtai ns other
real i zati ons of the fi l ter. To obtai n zero-pol e-gai n form, use three output
arguments:
[z,p,k] = butter(n,Wn) or
[z,p,k] = butter(n,Wn,'ftype')
butter returns the zeros and pol es i n l ength n col umn vectors z and p, and the
gai n i n the scal ar k.
To obtai n state-space form, use four output arguments:
[A,B,C,D] = butter(n,Wn) or
[A,B,C,D] = butter(n,Wn,'ftype') where A, B, C, and D are
and u i s the i nput, x i s the state vector, and y i s the output.
Analog Domain
[b,a] = butter(n,Wn,'s') desi gns an order n l owpass anal og Butterworth
fi l ter wi th cutoff frequency Wn. I t returns the fi l ter coeffi ci ents i n the l ength
n + 1 row vectors b and a, i n descendi ng powers of s:
butters cutoff frequency Wn must be greater than 0.
I f Wn i s a two-el ement vector wi th w1 < w2, butter(n,Wn,'s') returns an order
2*n bandpass anal og fi l ter wi th passband w1 < < w2.
x n 1 + [ ] Ax n [ ] Bu n [ ] + =
y n [ ] Cx n [ ] Du n [ ] + =
H s ( )
B s ( )
A s ( )
---------- -
b 1 ( )s
n
b 2 ( )s
n 1
L b n 1 + ( ) + + +
s
n
a 2 ( )s
n 1
L a n 1 + ( ) + + +
---------------------------------------------------------------------------------- = =
butter
6-45
[b,a] = butter(n,Wn,'ftype','s') desi gns a hi ghpass or bandstop fi l ter,
where ftype i s
high for a hi ghpass anal og fi l ter wi th cutoff frequency Wn
stop for an order 2*n bandstop anal og fi l ter i f Wn i s a two-el ement vector,
Wn = [w1 w2]
The stopband i s w1 < < w2.
Wi th di fferent numbers of output arguments, butter di rectl y obtai ns other
real i zati ons of the anal og fi l ter. To obtai n zero-pol e-gai n form, use three output
arguments:
[z,p,k] = butter(n,Wn,'s') or
[z,p,k] = butter(n,Wn,'ftype','s') returns the zeros and pol es i n l ength
n or 2*n col umn vectors z and p and the gai n i n the scal ar k.
To obtai n state-space form, use four output arguments:
[A,B,C,D] = butter(n,Wn,'s') or
[A,B,C,D] = butter(n,Wn,'ftype','s') where A, B, C, and D are
and u i s the i nput, x i s the state vector, and y i s the output.
Examples For data sampl ed at 1000 Hz, desi gn a 9th-order hi ghpass Butterworth fi l ter
wi th cutoff frequency of 300 Hz:
[b,a] = butter(9,300/500,'high');
x

Ax Bu + =
y Cx Du + =
butter
6-46
The fi l ters frequency response i s
freqz(b,a,128,1000)
Desi gn a 10th-order bandpass Butterworth fi l ter wi th a passband from 100 to
200 Hz and pl ot i ts i mpul se response, or unit sampleresponse:
n = 5; Wn = [100 200]/500;
[b,a] = butter(n,Wn);
[y,t] = impz(b,a,101);
stem(t,y)
0 100 200 300 400 500
800
600
400
200
0
200
Frequency (Hz)
P
h
a
s
e

(
d
e
g
r
e
e
s
)
0 100 200 300 400 500
400
300
200
100
0
100
Frequency (Hz)
M
a
g
n
i
t
u
d
e

(
d
B
)
0 10 20 30 40 50 60 70 80 90 100
-0.25
-0.2
-0.15
-0.1
-0.05
0
0.05
0.1
0.15
0.2
butter
6-47
Limitations For hi gh order fi l ters, the state-space form i s the most numeri cal l y accurate,
fol l owed by the zero-pol e-gai n form. The transfer functi on coeffi ci ent form i s
the l east accurate; numeri cal probl ems can ari se for fi l ter orders as l ow as 15.
Algorithm butter uses a fi ve-step al gori thm:
1 I t fi nds the l owpass anal og prototype pol es, zeros, and gai n usi ng the buttap
functi on.
2 I t converts the pol es, zeros, and gai n i nto state-space form.
3 I t transfor ms the l owpass fi l ter i nto a bandpass, hi ghpass, or bandstop fi l ter
wi th desi red cutoff frequenci es, usi ng a state-space transformati on.
4 For di gi tal fi l ter desi gn, butter uses bilinear to convert the anal og fi l ter
i nto a di gi tal fi l ter through a bi l i near transformati on wi th frequency
prewarpi ng. Careful frequency adjustment guarantees that the anal og
fi l ters and the di gi tal fi l ters wi l l have the same frequency response
magni tude at Wn or w1 and w2.
5 I t converts the state-space fi l ter back to transfer functi on or zero-pol e-gai n
form, as requi red.
See Also
besself Bessel anal og fi l ter desi gn.
buttap Butterworth anal og l owpass fi l ter prototype.
buttord Butterworth fi l ter order sel ecti on.
cheby1 Chebyshev type I fi l ter desi gn (passband ri ppl e).
cheby2 Chebyshev type I I fi l ter desi gn (stopband ri ppl e).
ellip El l i pti c (Cauer) fi l ter desi gn.
maxflat General i zed di gi tal Butterworth fi l ter desi gn.
buttord
6-48
6buttor d
Purpose Butterworth fi l ter order sel ecti on.
Syntax [n,Wn] = buttord(Wp,Ws,Rp,Rs)
[n,Wn] = buttord(Wp,Ws,Rp,Rs,'s')
Description buttord sel ects the mi ni mum order di gi tal or anal og Butterworth fi l ter
requi red to meet a set of fi l ter desi gn speci fi cati ons:
Digital Domain
[n,Wn] = buttord(Wp,Ws,Rp,Rs) returns the order n of the l owest order
di gi tal Butterworth fi l ter that l oses no more than Rp dB i n the passband and
has at l east Rs dB of attenuati on i n the stopband. The passband runs from 0 to
Wp and the stopband runs from Ws to 1, the Nyqui st frequency. buttord al so
returns Wn, the Butterworth cutoff frequency that al l ows butter to achi eve the
gi ven speci fi cati ons (the -3 dB frequency).
Use buttord for hi ghpass, bandpass, and bandstop fi l ters. For hi ghpass fi l ters,
Wp i s greater than Ws. For bandpass and bandstop fi l ters, Wp and Ws are
two-el ement vectors that speci fy the corner frequenci es at both edges of the
fi l ter, l ower frequency edge fi rst. For the band fi l ters, buttord returns Wn as a
two-el ement row vector for i nput to butter.
I f fi l ter speci fi cati ons cal l for a bandpass or bandstop fi l ter wi th unequal ri ppl e
i n each of the passbands or stopbands, desi gn the fi l ter as separate l owpass and
hi ghpass secti ons and cascade the two fi l ters together.
Wp Passband corner frequency. Wp, the cutoff frequency, has a val ue
between 0 and 1, where 1 corresponds to hal f the sampl i ng
frequency (the Nyqui st frequency).
Ws Stopband corner frequency. Ws i s i n the same uni ts as Wp; i t has
a val ue between 0 and 1, where 1 corresponds to hal f the
sampl i ng frequency (the Nyqui st frequency).
Rp Passband ri ppl e, i n deci bel s. Thi s val ue i s the maxi mum
permi ssi bl e passband l oss i n deci bel s. The passband i s 0 < w < Wp.
Rs Stopband attenuati on, i n deci bel s. Thi s val ue i s the number of
deci bel s the stopband i s down from the passband. The stopband
i s Ws < w < 1.
buttord
6-49
Analog Domain
[n,Wn] = buttord(Wp,Ws,Rp,Rs,'s') fi nds the mi ni mum order n and cutoff
frequenci es Wn for an anal og fi l ter. I n thi s case the frequenci es i n Wp and Ws are
i n radi ans per second and may be greater than 1.
Use buttord for hi ghpass, bandpass, and bandstop fi l ters, as descri bed under
Di gi tal Domai n.
Examples For data sampl ed at 1000 Hz, desi gn a l owpass fi l ter wi th l ess than 3 dB of
attenuati on from 0 to 100 Hz, and attenuati on at l east 15 dB from 150 Hz to
the Nyqui st frequency. Pl ot the fi l ters frequency response:
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')
0 50 100 150 200 250 300 350 400 450 500
-400
-300
-200
-100
0
Frequency (Hertz)
P
h
a
s
e

(
d
e
g
r
e
e
s
)
0 50 100 150 200 250 300 350 400 450 500
-300
-200
-100
0
100
Frequency (Hertz)
M
a
g
n
i
t
u
d
e

R
e
s
p
o
n
s
e

(
d
B
)
n = 4 Butterworth Lowpass Filter
buttord
6-50
Next desi gn a bandpass fi l ter wi th passband of 100 Hz to 200 Hz, l ess than
3 dB of attenuati on at the passband corners, and attenuati on down 30 dB by
50 Hz out on both si des of the passband:
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)
Algorithm buttords order predi cti on formul a i s descri bed i n [1]. I t operates i n the anal og
domai n for both anal og and di gi tal cases. For the di gi tal case, i t converts the
frequency parameters to the s-domai n before esti mati ng the order and natural
frequency, then converts back to the z-domai n.
buttord i ni ti al l y devel ops a l owpass fi l ter prototype by transformi ng the
passband frequenci es of the desi red fi l ter to 1 rad/sec (for l ow- and hi ghpass
fi l ters) and to -1 and 1 rad/sec (for bandpass and bandstop fi l ters). I t then
computes the mi ni mum order requi red for a l owpass fi l ter to meet the stopband
speci fi cati on.
0 50 100 150 200 250 300 350 400 450 500
-300
-200
-100
0
100
Frequency (Hertz)
M
a
g
n
i
t
u
d
e

R
e
s
p
o
n
s
e

(
d
B
)
0 50 100 150 200 250 300 350 400 450 500
-1000
-500
0
500
Frequency (Hertz)
P
h
a
s
e

(
d
e
g
r
e
e
s
)
buttord
6-51
See Also
References [1] Rabi ner, L.R., and B. Gol d. Theory and Application of Digital Signal
Processing. Engl ewood Cl i ffs, NJ: Prenti ce-Hal l , 1975. Pg. 227.
butter Butterworth anal og and di gi tal fi l ter desi gn.
cheb1ord Chebyshev type I fi l ter order sel ecti on.
cheb2ord Chebyshev type I I fi l ter order sel ecti on.
ellipord El l i pti c fi l ter order sel ecti on.
kaiserord Esti mate parameters for an FI R fi l ter desi gn wi th
Kai ser wi ndow.
cceps
6-52
6cceps
Purpose Compl ex cepstral anal ysi s.
Syntax xhat = cceps(x)
[xhat,nd] = cceps(x)
[xhat,nd,xhat1] = cceps(x)
[...] = cceps(x,n)
Description Cepstral anal ysi s i s a nonl i near si gnal processi ng techni que that i s appl i ed
most commonl y i n speech processi ng and homomorphi c fi l teri ng [1].
xhat = cceps(x) returns the compl ex cepstrum of the (assumed real )
sequence x. The i nput i s al tered, by the appl i cati on of a l i near phase term, to
have no phase di sconti nui ty at t radi ans. That i s, i t i s ci rcul arl y shi fted (after
zero paddi ng) by some sampl es, i f necessary, to have zero phase at radi ans.
[xhat,nd] = cceps(x) returns the number of sampl es nd of (ci rcul ar) del ay
added to x pri or to fi ndi ng the compl ex cepstrum.
[xhat,nd,xhat1] = cceps(x) returns a second compl ex cepstrum, computed
usi ng an al ternate rooti ng al gori thm, i n xhat1. The al ternate method
([1] p.795)i s useful for short sequences that can be rooted and do not have zeros
on the uni t ci rcl e. For these si gnal s, xhat1 can provi de a veri fi cati on of xhat.
[...] = cceps(x,n) zero pads x to l ength n and returns the l ength n compl ex
cepstrum of x.
Algorithm cceps, i n i ts basi c form, i s an M-fi l e i mpl ementati on of al gori thm 7.1 i n [2]. A
l engthy Fortran program reduces to three l i nes of MATLAB code:
h = fft(x);
logh = log(abs(h)) + sqrt(1)*rcunwrap(angle(h));
y = real(ifft(logh));
rcunwrap i s a speci al versi on of unwrap that subtracts a strai ght l i ne from the
phase.
cceps
6-53
See Also
References [1] Oppenhei m, A.V., and R.W. Schafer. Discrete-TimeSignal Processing.
Engl ewood Cl i ffs, NJ: Prenti ce-Hal l , 1989.
[2] I EEE. Programsfor Digital Signal Processing. I EEE Press. New York: John
Wi l ey & Sons, 1979.
icceps I nverse compl ex cepstrum.
hilbert Hi l bert transform.
rceps Real cepstrum and mi ni mum phase reconstructi on.
unwrap Unwrap phase angl es.
cheb1ap
6-54
6cheb1ap
Purpose Chebyshev type I anal og l owpass fi l ter prototype.
Syntax [z,p,k] = cheb1ap(n,Rp)
Description [z,p,k] = cheb1ap(n,Rp) returns the zeros, pol es, and gai n of an order n
Chebyshev type I anal og l owpass fi l ter prototype wi th Rp dB of ri ppl e i n the
passband. I t returns the pol es i n the l ength n col umn vector p and the gai n i n
scal ar k. z i s an empty matri x, because there are no zeros. The transfer functi on
i s
Chebyshev type I fi l ters are equi ri ppl e i n the passband and monotoni c i n the
stopband. The pol es are evenl y spaced about an el l i pse i n the l eft hal f pl ane.
The Chebyshev type I cutoff frequency i s set to 1.0 for a normal i zed resul t.
Thi s i s the frequency at whi ch the passband ends and the fi l ter has magni tude
response of 10
-Rp/20
.
See Also
References [1] Parks, T.W., and C.S. Burrus. Digital Filter Design. New York: John Wi l ey
& Sons, 1987. Chapter 7.
H s ( )
z s ( )
p s ( )
----------
k
s p 1 ( ) ( ) s p 2 ( ) ( )Ls p n ( ) ( )
----------------------------------------------------------------------------- = =

0
besselap Bessel anal og l owpass fi l ter prototype.
buttap Butterworth anal og and di gi tal fi l ter desi gn.
cheb2ap Chebyshev type I anal og l owpass fi l ter prototype.
cheby1 Chebyshev type I fi l ter desi gn (passband ri ppl e).
ellipap El l i pti c anal og l owpass fi l ter prototype.
cheb1ord
6-55
6cheb1or d
Purpose Chebyshev type I fi l ter or der sel ecti on.
Syntax [n,Wn] = cheb1ord(Wp,Ws,Rp,Rs)
[n,Wn] = cheb1ord(Wp,Ws,Rp,Rs,'s')
Description cheb1ord sel ects the mi ni mum order di gi tal or anal og Chebyshev type I fi l ter
requi red to meet a set of fi l ter desi gn speci fi cati ons:
Digital Domain
[n,Wn] = cheb1ord(Wp,Ws,Rp,Rs) returns the order n of the l owest or der
Chebyshev fi l ter that l oses no more than Rp dB i n the passband and has at
l east Rs dB of attenuati on i n the stopband. The passband runs from 0 to Wp and
the stopband runs from Ws to 1, the Nyqui st frequency. cheb1ord al so returns
Wn, the Chebyshev type I cutoff frequency that al l ows cheby1 to achi eve the
gi ven speci fi cati ons.
Use cheb1ord for l owpass, hi ghpass, bandpass, and bandstop fi l ters. For
hi ghpass fi l ters, Wp > Ws. For bandpass and bandstop fi l ters, Wp and Ws are
two-el ement vectors that speci fy the corner frequenci es at both edges of the
fi l ter, l ower frequency edge fi rst. For the band fi l ters, cheb1ord returns Wn as
a two-el ement row vector for i nput to cheby1.
I f fi l ter speci fi cati ons cal l for a bandpass or bandstop fi l ter wi th unequal ri ppl e
i n each of the passbands or stopbands, desi gn the fi l ter as separate l owpass and
hi ghpass secti ons and cascade the two fi l ters together.
Wp Passband corner frequency. Wp, the cutoff frequency, has a val ue
between 0 and 1, where 1 corresponds to hal f the sampl i ng
frequency (the Nyqui st frequency).
Ws Stopband corner frequency. Ws i s i n the same uni ts as Wp; i t has
a val ue between 0 and 1, where 1 corresponds to hal f the
sampl i ng frequency (the Nyqui st frequency).
Rp Passband ri ppl e, i n deci bel s. Thi s val ue i s the maxi mum
permi ssi bl e passband l oss i n deci bel s. The passband i s 0 < w < Wp.
Rs Stopband attenuati on, i n deci bel s. Thi s val ue i s the number of
deci bel s the stopband i s down from the passband. The stopband
i s Ws < w < 1.
cheb1ord
6-56
Analog Domain
[n,Wn] = cheb1ord(Wp,Ws,Rp,Rs,'s') fi nds the mi ni mum order n and cutoff
frequenci es Wn for an anal og fi l ter. I n thi s case the frequenci es i n Wp and Ws are
i n radi ans per second and may be greater than 1.
Use cheb1ord for l owpass, hi ghpass, bandpass, and bandstop fi l ters, as
descri bed under Di gi tal Domai n.
Examples For data sampl ed at 1000 Hz, desi gn a l owpass fi l ter wi th l ess than 3 dB of
attenuati on from 0 to 100 Hz and attenuati on at l east 15 dB from 150 Hz to the
Nyqui st frequency:
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')
0 50 100 150 200 250 300 350 400 450 500
-300
-200
-100
0
Frequency (Hertz)
P
h
a
s
e

(
d
e
g
r
e
e
s
)
0 50 100 150 200 250 300 350 400 450 500
-200
-150
-100
-50
0
50
Frequency (Hertz)
M
a
g
n
i
t
u
d
e

R
e
s
p
o
n
s
e

(
d
B
)
n = 3 Chebyshev Type I Lowpass Filter
cheb1ord
6-57
Next desi gn a bandpass fi l ter wi th a passband of 100 Hz to 200 Hz, l ess than
3 dB of attenuati on throughout the passband, and 30 dB stopbands 50 Hz out
on both si des of the passband:
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')
Algorithm cheb1ord uses the Chebyshev l owpass fi l ter order predi cti on formul a descri bed
i n [1]. The functi on performs i ts cal cul ati ons i n the anal og domai n for both
anal og and di gi tal cases. For the di gi tal case, i t converts the frequency
parameters to the s-domai n before the order and natural frequency esti mati on
process, then converts them back to the z-domai n.
0 50 100 150 200 250 300 350 400 450 500
-800
-600
-400
-200
0
Frequency (Hertz)
P
h
a
s
e

(
d
e
g
r
e
e
s
)
0 50 100 150 200 250 300 350 400 450 500
-300
-200
-100
0
Frequency (Hertz)
M
a
g
n
i
t
u
d
e

R
e
s
p
o
n
s
e

(
d
B
)
n = 4 Chebyshev Type I Bandpass Filter
cheb1ord
6-58
cheb1ord i ni ti al l y devel ops a l owpass fi l ter prototype by transformi ng the
passband frequenci es of the desi red fi l ter to 1 rad/sec (for l ow- or hi ghpass
fi l ters) or to -1 and 1 rad/sec (for bandpass or bandstop fi l ters). I t then
computes the mi ni mum order requi red for a l owpass fi l ter to meet the stopband
speci fi cati on.
See Also
References [1] Rabi ner, L.R., and B. Gol d. Theory and Application of Digital Signal
Processing. Engl ewood Cl i ffs, NJ: Prenti ce-Hal l , 1975. Pg. 241.
buttord Butterworth fi l ter order sel ecti on.
cheby1 Chebyshev type I fi l ter desi gn (passband ri ppl e).
cheb2ord Chebyshev type I I fi l ter or der sel ecti on.
ellipord El l i pti c fi l ter order sel ecti on.
kaiserord Esti mate parameters for an FI R fi l ter desi gn wi th
Kai ser wi ndow.
cheb2ap
6-59
6cheb2ap
Purpose Chebyshev type I I anal og l owpass fi l ter prototype.
Syntax [z,p,k] = cheb2ap(n,Rs)
Description [z,p,k] = cheb2ap(n,Rs) fi nds the zeros, pol es, and gai n of an order n
Chebyshev type I I anal og l owpass fi l ter prototype wi th stopband ri ppl e Rs dB
down from the passband peak val ue. cheb2ap returns the zeros and pol es i n
l ength n col umn vectors z and p and the gai n i n scal ar k. I f n i s odd, z i s l ength
n1. The transfer functi on i s
Chebyshev type I I fi l ters are monotoni c i n the passband and equi ri ppl e i n the
stopband. The pol e l ocati ons are the i nverse of the pol e l ocati ons of cheb1ap,
whose pol es are evenl y spaced about an el l i pse i n the l eft hal f pl ane. The
Chebyshev type I I cutoff frequency
0
i s set to 1 for a normal i zed resul t. Thi s
i s the frequency at whi ch the stopband begi ns and the fi l ter has magni tude
response of 10
-Rs/20
.
Algorithm Chebyshev type I I fi l ters are someti mes cal l ed inverseChebyshev fi l ters
because of thei r rel ati onshi p to Chebyshev type I fi l ters. The cheb2ap functi on
i s a modi fi cati on of the Chebyshev type I prototype al gori thm:
1 cheb2ap repl aces the frequency vari abl e wi th 1/, turni ng the l owpass
fi l ter i nto a hi ghpass fi l ter whi l e preservi ng the performance at = 1.
2 cheb2ap subtracts the fi l ter transfer functi on from uni ty.
See Also
References [1] Parks, T.W., and C.S. Burrus. Digital Filter Design. New York: John Wi l ey
& Sons, 1987. Chapter 7.
H s ( )
z s ( )
p s ( )
---------- k
s z 1 ( ) ( ) s z 2 ( ) ( )Ls z n ( ) ( )
s p 1 ( ) ( ) s p 2 ( ) ( )Ls p n ( ) ( )
----------------------------------------------------------------------------- = =
besselap Bessel anal og l owpass fi l ter prototype.
buttap Butterworth anal og l owpass fi l ter prototype.
cheb1ap Chebyshev type I anal og l owpass fi l ter prototype.
cheby2 Chebyshev type I I fi l ter desi gn (stopband ri ppl e).
ellipap El l i pti c anal og l owpass fi l ter prototype.
cheb2ord
6-60
6cheb2or d
Purpose Chebyshev type I I fi l ter order sel ecti on.
Syntax [n,Wn] = cheb2ord(Wp,Ws,Rp,Rs)
[n,Wn] = cheb2ord(Wp,Ws,Rp,Rs,'s')
Description cheb2ord sel ects the mi ni mum order di gi tal or anal og Chebyshev type I I fi l ter
requi red to meet a set of fi l ter desi gn speci fi cati ons:
Digital Domain
[n,Wn] = cheb2ord(Wp,Ws,Rp,Rs) returns the order n of the l owest order
Chebyshev fi l ter that l oses no more than Rp dB i n the passband and has at
l east Rs dB of attenuati on i n the stopband. The passband runs from 0 to Wp and
the stopband runs from Ws to 1, the Nyqui st frequency. cheb2ord al so returns
Wn, the Chebyshev type I I cutoff frequency that al l ows cheby2 to achi eve the
gi ven speci fi cati ons.
Use cheb2ord for l owpass, hi ghpass, bandpass, and bandstop fi l ters. For
hi ghpass fi l ters, Wp i s greater than Ws. For bandpass and bandstop fi l ters, Wp
and Ws are two-el ement vectors that speci fy the corner frequenci es at both
edges of the fi l ter, l ower frequency edge fi rst. For the band fi l ters, cheb2ord
returns Wn as a two-el ement row vector for i nput to cheby2.
I f fi l ter speci fi cati ons cal l for a bandpass or bandstop fi l ter wi th unequal ri ppl e
i n each of the passbands or stopbands, desi gn the fi l ter as separate l owpass and
hi ghpass secti ons and cascade the two fi l ters together.
Wp Passband corner frequency. Wp, the cutoff frequency, has a val ue
between 0 and 1, where 1 corresponds to hal f the sampl i ng
frequency (the Nyqui st frequency).
Ws Stopband corner frequency. Ws i s i n the same uni ts as Wp; i t has
a val ue between 0 and 1, where 1 corresponds to hal f the
sampl i ng frequency (the Nyqui st frequency).
Rp Passband ri ppl e, i n deci bel s. Thi s val ue i s the maxi mum
permi ssi bl e passband l oss i n deci bel s. The passband i s 0 < w < Wp.
Rs Stopband attenuati on, i n deci bel s. Thi s val ue i s the number of
deci bel s the stopband i s down from the passband. The stopband
i s Ws < w < 1.
cheb2ord
6-61
Analog Domain
[n,Wn] = cheb2ord(Wp,Ws,Rp,Rs,'s') fi nds the mi ni mum order n and cutoff
frequenci es Wn for an anal og fi l ter. I n thi s case the frequenci es i n Wp and Ws are
i n radi ans per second and may be greater than 1.
Use cheb2ord for l owpass, hi ghpass, bandpass, and bandstop fi l ters, as
descri bed under Di gi tal Domai n.
Examples For data sampl ed at 1000 Hz, desi gn a l owpass fi l ter wi th l ess than 3 dB of
attenuati on from 0 to 100 Hz, and attenuati on at l east 15 dB from 150 Hz to
the Nyqui st frequency:
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')
0 50 100 150 200 250 300 350 400 450 500
-200
-150
-100
-50
0
Frequency (Hertz)
P
h
a
s
e

(
d
e
g
r
e
e
s
)
0 50 100 150 200 250 300 350 400 450 500
-80
-60
-40
-20
0
20
Frequency (Hertz)
M
a
g
n
i
t
u
d
e

R
e
s
p
o
n
s
e

(
d
B
)
n = 3 Chebyshev Type II Lowpass Filter
cheb2ord
6-62
Next desi gn a bandpass fi l ter wi th a passband of 100 Hz to 200 Hz, l ess than
3 dB of attenuati on throughout the passband, and 30 dB stopbands 50 Hz out
on both si des of the passband:
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')
Algorithm cheb2ord uses the Chebyshev l owpass fi l ter order predi cti on formul a descri bed
i n [1]. The functi on performs i ts cal cul ati ons i n the anal og domai n for both
anal og and di gi tal cases. For the di gi tal case, i t converts the frequency
parameters to the s-domai n before the order and natural frequency esti mati on
process, then converts them back to the z-domai n.
0 50 100 150 200 250 300 350 400 450 500
-400
-200
0
200
400
Frequency (Hertz)
P
h
a
s
e

(
d
e
g
r
e
e
s
)
0 50 100 150 200 250 300 350 400 450 500
-80
-60
-40
-20
0
Frequency (Hertz)
M
a
g
n
i
t
u
d
e

R
e
s
p
o
n
s
e

(
d
B
)
n = 4 Chebyshev Type II Bandpass Filter
cheb2ord
6-63
cheb2ord i ni ti al l y devel ops a l owpass fi l ter prototype by transformi ng the
stopband frequenci es of the desi red fi l ter to 1 rad/sec (for l ow- and hi ghpass
fi l ters) and to -1 and 1 rad/sec (for bandpass and bandstop fi l ters). I t then
computes the mi ni mum order requi r ed for a l owpass fi l ter to meet the
passband speci fi cati on.
See Also
References [1] Rabi ner, L.R., and B. Gol d. Theory and Application of Digital Signal
Processing. Engl ewood Cl i ffs, NJ: Prenti ce-Hal l , 1975. Pg. 241.
buttord Butterworth fi l ter order sel ecti on.
cheb1ord Chebyshev type I fi l ter order sel ecti on.
cheby2 Chebyshev type I I fi l ter desi gn (stopband ri ppl e).
ellipord El l i pti c fi l ter order sel ecti on.
kaiserord Esti mate parameters for an FI R fi l ter desi gn wi th
Kai ser wi ndow.
chebwin
6-64
6chebwi n
Purpose Chebyshev wi ndow.
Syntax w = chebwin(n,r)
Description w = chebwin(n,r) returns the col umn vector w, contai ni ng the l ength n
Chebyshev wi ndow whose Fouri er transform magni tude si del obe ri ppl e i s r dB
bel ow the mai nl obe magni tude.
See Also
References [1] I EEE. Programsfor Digital Signal Processing. I EEE Press. New York: John
Wi l ey & Sons, 1979. Program 5.2.
bartlett Bartl ett wi ndow.
blackman Bl ackman wi ndow.
boxcar Rectangul ar wi ndow.
hamming Hammi ng wi ndow.
hanning Hanni ng wi ndow.
kaiser Kai ser wi ndow.
triang Tri angul ar wi ndow.
cheby1
6-65
6cheby1
Purpose Chebyshev type I fi l ter desi gn (passband ri ppl e).
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 desi gns l owpass, bandpass, hi ghpass, and bandstop di gi tal and anal og
Chebyshev type I fi l ters. Chebyshev type I fi l ters are equi ri ppl e i n the
passband and monotoni c i n the stopband. Type I fi l ters rol l off faster than type
I I fi l ters, but at the expense of greater devi ati on from uni ty i n the passband.
Digital Domain
[b,a] = cheby1(n,Rp,Wn) desi gns an order n l owpass di gi tal Chebyshev fi l ter
wi th cutoff frequency Wn and Rp dB of ri ppl e i n the passband. I t returns the
fi l ter coeffi ci ents i n the l ength n+1 row vectors b and a, wi th coeffi ci ents i n
descendi ng powers of z:
Cutoff frequencyi s the frequency at whi ch the magni tude response of the fi l ter
i s equal to Rp dB. For cheby1, the cutoff frequency Wn i s a number between 0
and 1, where 1 corresponds to hal f the sampl i ng frequency (the Nyqui st
frequency). Smal l er val ues of passband ri ppl e Rp l ead to wi der transi ti on
wi dths (shal l ower rol l off characteri sti cs).
I f Wn i s a two-el ement vector, Wn = [w1 w2], cheby1 returns an order 2*n
bandpass fi l ter wi th passband w1 < < w2.
[b,a] = cheby1(n,Rp,Wn,'ftype') desi gns a hi ghpass or bandstop fi l ter,
where ftype i s
H z ( )
B z ( )
A z ( )
-----------
b 1 ( ) b 2 ( )z
1
L b n 1 + ( )z
n
+ + +
1 a 2 ( )z
1
L a n 1 + ( )z
n
+ + +
--------------------------------------------------------------------------------- = =

cheby1
6-66
high for a hi ghpass di gi tal fi l ter wi th cutoff frequency Wn
stop for an order 2*n bandstop di gi tal fi l ter i f Wn i s a two-el ement vector,
Wn = [w1 w2]
The stopband i s w1 < < w2.
Wi th di fferent numbers of output arguments, cheby1 di rectl y obtai ns other
real i zati ons of the fi l ter. To obtai n zero-pol e-gai n form, use three output
arguments:
[z,p,k] = cheby1(n,Rp,Wn) or
[z,p,k] = cheby1(n,Rp,Wn,'ftype') returns the zeros and pol es i n l ength n
col umn vectors z and p and the gai n i n the scal ar k.
To obtai n state-space form, use four output arguments:
[A,B,C,D] = cheby1(n,Rp,Wn) or
[A,B,C,D] = cheby1(n,Rp,Wn,'ftype') where A, B, C, and D are
and u i s the i nput, x i s the state vector, and y i s the output.
Analog Domain
[b,a] = cheby1(n,Rp,Wn,'s') desi gns an order n l owpass anal og Chebyshev
type I fi l ter wi th cutoff frequency Wn. I t returns the fi l ter coeffi ci ents i n l ength
n + 1 row vectors b and a, i n descendi ng powers of s:
Cutoff frequencyi s the frequency at whi ch the magni tude response of the fi l ter
i s Rp dB. For cheby1, the cutoff frequency Wn must be greater than 0.
I f Wn i s a two-el ement vector, Wn = [w1 w2], wi th w1 < w2, then
cheby1(n,Rp,Wn,'s') returns an order 2*n bandpass anal og fi l ter wi th
passband w1 < < w2.
x n 1 + [ ] Ax n [ ] Bu n [ ] + =
y n [ ] Cx n [ ] Du n [ ] + =
H s ( )
B s ( )
A s ( )
---------- -
b 1 ( )s
n
b 2 ( )s
n 1
L b n 1 + ( ) + + +
s
n
a 2 ( )s
n 1
L a n 1 + ( ) + + +
---------------------------------------------------------------------------------- = =
cheby1
6-67
[b,a] = cheby1(n,Rp,Wn,'ftype','s') desi gns a hi ghpass or bandstop
fi l ter, where ftype i s
high for a hi ghpass anal og fi l ter wi th cutoff frequency Wn
stop for an order 2*n bandstop anal og fi l ter i f Wn i s a two-el ement vector,
Wn = [w1 w2]
The stopband i s w1 < < w2.
You can suppl y di fferent numbers of output arguments for cheby1 to di rectl y
obtai n other real i zati ons of the anal og fi l ter. To obtai n zero-pol e-gai n form, use
three output arguments:
[z,p,k] = cheby1(n,Rp,Wn,'s') or
[z,p,k] = cheby1(n,Rp,Wn,'ftype','s') returns the zeros and pol es i n
l ength n or 2*n col umn vectors z and p and the gai n i n the scal ar k.
To obtai n state-space form, use four output arguments:
[A,B,C,D] = cheby1(n,Rp,Wn,'s') or
[A,B,C,D] = cheby1(n,Rp,Wn,'ftype','s') where A, B, C, and D are defi ned
as
and u i s the i nput, x i s the state vector, and y i s the output.
Examples For data sampl ed at 1000 Hz, desi gn a 9th-order l owpass Chebyshev type I
fi l ter wi th 0.5 dB of ri ppl e i n the passband and a cutoff frequency of 300 Hz:
[b,a] = cheby1(9,0.5,300/500);
x

Ax Bu + =
y Cx Du + =
cheby1
6-68
The fr equency r esponse of the fi l ter i s
freqz(b,a,512,1000)
Desi gn a 10th-order bandpass Chebyshev type I fi l ter wi th a passband from
100 to 200 Hz and pl ot i ts i mpul se response:
n = 10; Rp = 0.5;
Wn = [100 200]/500;
[b,a] = cheby1(n,Rp,Wn);
[y,t] = impz(b,a,101); stem(t,y)
0 50 100 150 200 250 300 350 400 450 500
-1000
-800
-600
-400
-200
0
Frequency (Hertz)
P
h
a
s
e

(
d
e
g
r
e
e
s
)
0 50 100 150 200 250 300 350 400 450 500
-300
-200
-100
0
100
Frequency (Hertz)
M
a
g
n
i
t
u
d
e

R
e
s
p
o
n
s
e

(
d
B
)
n = 9 Chebyshev Type I Lowpass Filter
0 10 20 30 40 50 60 70 80 90 100
-0.2
-0.15
-0.1
-0.05
0
0.05
0.1
0.15
Impulse Response of n = 10 Chebyshev Type I Filter
cheby1
6-69
Limitations For hi gh order fi l ters, the state-space form i s the most numeri cal l y accurate,
fol l owed by the zero-pol e-gai n form. The transfer functi on form i s the l east
accurate; numeri cal probl ems can ari se for fi l ter orders as l ow as 15.
Algorithm cheby1 uses a fi ve-step al gori thm:
1 I t fi nds the l owpass anal og prototype pol es, zeros, and gai n usi ng the
cheb1ap functi on.
2 I t converts the pol es, zeros, and gai n i nto state-space form.
3 I t transfor ms the l owpass fi l ter i nto a bandpass, hi ghpass, or bandstop fi l ter
wi th desi red cutoff frequenci es, usi ng a state-space transformati on.
4 For di gi tal fi l ter desi gn, cheby1 uses bilinear to convert the anal og fi l ter
i nto a di gi tal fi l ter through a bi l i near transformati on wi th frequency
prewarpi ng. Careful frequency adjustment guarantees that the anal og
fi l ters and the di gi tal fi l ters wi l l have the same frequency response
magni tude at Wn or w1 and w2.
5 I t converts the state-space fi l ter back to transfer functi on or zero-pol e-gai n
form, as requi red.
See Also
besself Bessel anal og fi l ter desi gn.
butter Butterworth anal og and di gi tal fi l ter desi gn.
cheb1ap Chebyshev type I anal og l owpass fi l ter prototype.
cheb1ord Chebyshev type I fi l ter order sel ecti on.
cheby2 Chebyshev type I I fi l ter desi gn (stopband ri ppl e).
ellip El l i pti c (Cauer) fi l ter desi gn.
cheby2
6-70
6cheby2
Purpose Chebyshev type I I fi l ter desi gn (stopband ri ppl e).
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 desi gns l owpass, hi ghpass, bandpass, and bandstop di gi tal and anal og
Chebyshev type I I fi l ters. Chebyshev type I I fi l ters are monotoni c i n the
passband and equi ri ppl e i n the stopband. Type I I fi l ters do not rol l off as fast
as type I fi l ters, but are free of passband ri ppl e.
Digital Domain
[b,a] = cheby2(n,Rs,Wn) desi gns an order n l owpass di gi tal Chebyshev type
I I fi l ter wi th cutoff frequency Wn and stopband ri ppl e Rs dB down from the peak
passband val ue. I t returns the fi l ter coeffi ci ents i n the l ength n + 1 row vectors
b and a, wi th coeffi ci ents i n descendi ng powers of z:
Cutoff frequencyi s the begi nni ng of the stopband, where the magni tude
response of the fi l ter i s equal to Rs dB. For cheby2, the cutoff frequency Wn i s
a number between 0 and 1, where 1 corresponds to hal f the sampl i ng frequency
(the Nyqui st frequency). Larger val ues of stopband attenuati on Rs l ead to
wi der transi ti on wi dths (shal l ower rol l off characteri sti cs).
I f Wn i s a two-el ement vector, Wn = [w1 w2], cheby2 returns an order 2*n
bandpass fi l ter wi th passband w1 < < w2.
[b,a] = cheby2(n,Rs,Wn,'ftype') desi gns a hi ghpass or bandstop fi l ter,
where ftype i s
H z ( )
B z ( )
A z ( )
-----------
b 1 ( ) b 2 ( )z
1
L b n 1 + ( )z
n
+ + +
1 a 2 ( )z
1
L a n 1 + ( )z
n
+ + +
--------------------------------------------------------------------------------- = =
cheby2
6-71
high for a hi ghpass di gi tal fi l ter wi th cutoff frequency Wn
stop for an order 2*n bandstop di gi tal fi l ter i f Wn i s a two-el ement vector,
Wn = [w1 w2].
The stopband i s w1 < < w2.
Wi th di fferent numbers of output arguments, cheby2 di rectl y obtai ns other
real i zati ons of the fi l ter. To obtai n zero-pol e-gai n form, use three output
arguments:
[z,p,k] = cheby2(n,Rs,Wn) or
[z,p,k] = cheby2(n,Rs,Wn,'ftype') returns the zeros and pol es i n l ength n
col umn vectors z and p and the gai n i n the scal ar k.
To obtai n state-space form, use four output arguments:
[A,B,C,D] = cheby2(n,Rs,Wn) or
[A,B,C,D] = cheby2(n,Rs,Wn,'ftype') where A, B, C, and D are
and u i s the i nput, x i s the state vector, and y i s the output.
Analog Domain
[b,a] = cheby2(n,Rs,Wn,'s') desi gns an order n l owpass anal og Chebyshev
type I I fi l ter wi th cutoff frequency Wn. I t returns the fi l ter coeffi ci ents i n the
l ength n + 1 row vectors b and a, wi th coeffi ci ents i n descendi ng powers of s:
Cutoff frequencyi s the frequency at whi ch the magni tude response of the fi l ter
i s equal to Rs dB. For cheby2, the cutoff frequency Wn must be greater than 0.
I f Wn i s a two-el ement vector, Wn = [w1 w2], wi th w1 < w2, then
cheby2(n,Rs,Wn,'s') returns an order 2*n bandpass anal og fi l ter wi th
passband w1 < < w2.
x n 1 + [ ] Ax n [ ] Bu n [ ] + =
y n [ ] Cx n [ ] Du n [ ] + =
H s ( )
B s ( )
A s ( )
---------- -
b 1 ( )s
n
b 2 ( )s
n 1
L b n 1 + ( ) + + +
s
n
a 2 ( )s
n 1
L a n 1 + ( ) + + +
---------------------------------------------------------------------------------- = =
cheby2
6-72
[b,a] = cheby2(n,Rs,Wn,'ftype','s') desi gns a hi ghpass or bandstop
fi l ter, where ftype i s
high for a hi ghpass anal og fi l ter wi th cutoff frequency Wn
stop for an order 2*n bandstop anal og fi l ter i f Wn i s a two-el ement vector,
Wn = [w1 w2]
The stopband i s w1 < < w2.
Wi th di fferent numbers of output arguments, cheby2 di rectl y obtai ns other
real i zati ons of the anal og fi l ter. To obtai n zero-pol e-gai n form, use three output
arguments:
[z,p,k] = cheby2(n,Rs,Wn,'s') or
[z,p,k] = cheby2(n,Rs,Wn,'ftype','s') returns the zeros and pol es i n
l ength n or 2*n col umn vectors z and p and the gai n i n the scal ar k.
To obtai n state-space form, use four output arguments:
[A,B,C,D] = cheby2(n,Rs,Wn,'s') or
[A,B,C,D] = cheby2(n,Rs,Wn,'ftype','s') where A, B, C, and D are
and u i s the i nput, x i s the state vector, and y i s the output.
Examples For data sampl ed at 1000 Hz, desi gn a ni nth-order l owpass Chebyshev type I I
fi l ter wi th stopband attenuati on 20 dB down from the passband and a cutoff
frequency of 300 Hz:
[b,a] = cheby2(9,20,300/500);
x

Ax Bu + =
y Cx Du + =
cheby2
6-73
The frequency response of the fi l ter i s
freqz(b,a,512,1000)
Desi gn a fi fth-or der bandpass Chebyshev type I I fi l ter wi th passband fr om 100
to 200 Hz and pl ot the i mpul se response of the fi l ter:
n = 5; r = 20;
Wn = [100 200]/500;
[b,a] = cheby2(n,r,Wn);
[y,t] = impz(b,a,101); stem(t,y)
0 50 100 150 200 250 300 350 400 450 500
-400
-300
-200
-100
0
100
Frequency (Hertz)
P
h
a
s
e

(
d
e
g
r
e
e
s
)
0 50 100 150 200 250 300 350 400 450 500
-80
-60
-40
-20
0
20
Frequency (Hertz)
M
a
g
n
i
t
u
d
e

R
e
s
p
o
n
s
e

(
d
B
)
n = 9 Chebyshev Type II Filter
0 10 20 30 40 50 60 70 80 90 100
-0.2
-0.15
-0.1
-0.05
0
0.05
0.1
0.15
0.2
Impulse Response of n = 5 Chebyshev Type II Filter
cheby2
6-74
Limitations For hi gh order fi l ters, the state-space form i s the most numeri cal l y accurate,
fol l owed by the zero-pol e-gai n form. The transfer functi on coeffi ci ent form i s
the l east accurate; numeri cal probl ems can ari se for fi l ter orders as l ow as 15.
Algorithm cheby2 uses a fi ve-step al gori thm:
1 I t fi nds the l owpass anal og prototype pol es, zeros, and gai n usi ng the
cheb2ap functi on.
2 I t converts pol es, zeros, and gai n i nto state-space form.
3 I t transforms the l owpass fi l ter i nto a bandpass, hi ghpass, or bandstop fi l ter
wi th desi red cutoff frequenci es, usi ng a state-space transformati on.
4 For di gi tal fi l ter desi gn, cheby2 uses bilinear to convert the anal og fi l ter
i nto a di gi tal fi l ter through a bi l i near transformati on wi th frequency
prewarpi ng. Careful frequency adjustment guarantees that the anal og
fi l ters and the di gi tal fi l ters wi l l have the same frequency response
magni tude at Wn or w1 and w2.
5 I t converts the state-space fi l ter back to transfer functi on or zero-pol e-gai n
form, as requi red.
See Also
besself Bessel anal og fi l ter desi gn.
butter Butterworth anal og and di gi tal fi l ter desi gn.
cheb2ap Chebyshev type I I anal og l owpass fi l ter prototype.
cheb2ord Chebyshev type I I fi l ter or der sel ecti on.
cheby1 Chebyshev type I fi l ter desi gn (passband ri ppl e).
ellip El l i pti c (Cauer) fi l ter desi gn.
chirp
6-75
6chi r p
Purpose Swept-frequency cosi ne generator.
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) generates sampl es of a l i near swept-frequency cosi ne
si gnal at the ti me i nstances defi ned i n array t, where f0 i s the i nstantaneous
frequency at ti me 0, and f1 i s the i nstantaneous frequency at ti me t1. f0 and
f1 are both i n Hertz. I f unspeci fi ed, f0 i s 0, t1 i s 1, and f1 i s 100.
y = chirp(t,f0,t1,f1,'method') speci fi es al ternati ve sweep method
opti ons, where method can be
linear, whi ch speci fi es an i nstantaneous frequency sweep f
i
(t) gi ven by
where
ensures that the desi red frequency breakpoi nt f
1
at ti me t
1
i s mai ntai ned.
quadratic, whi ch speci fi es an i nstantaneous frequency sweep f
i
(t) gi ven by
where
logarithmic speci fi es an i nstantaneous frequency sweep f
i
(t) gi ven by
where
For a l og-sweep, f1 must be greater than f0.
f
i
t ( ) f
0
t + =
f
1
f
0
( ) t
1
=
f
i
t ( ) f
0
t
2
+ =
f
1
f
0
( ) t
1
=
f
i
t ( ) f
0
10
t
+ =
l og
10
f
1
f
0
( ) [ ] t
1
=
chirp
6-76
y = chirp(t,f0,t1,f1,'method',phi) al l ows an i ni ti al phase phi to be
speci fi ed i n degrees. I f unspeci fi ed, phi i s 0. Defaul t val ues are substi tuted for
empty or omi tted trai l i ng i nput arguments.
Examples Compute the spectrogram of a chi rp wi th l i near i nstantaneous frequency
devi ati on:
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
Time
F
r
e
q
u
e
n
c
y
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6
0
50
100
150
200
250
300
350
400
450
500
chirp
6-77
Compute the spectrogram of a chi rp wi th quadrati c i nstantaneous frequency
devi ati on:
t = 2:0.001:2; % t2 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
Time
F
r
e
q
u
e
n
c
y
0 0.5 1 1.5 2 2.5 3 3.5
0
50
100
150
200
250
300
350
400
450
500
chirp
6-78
See Also
cos Cosi ne of vector/matri x el ements (see the onl i ne
MATLAB Function Reference).
diric Di ri chl et or peri odi c si nc functi on.
gauspuls Gaussi an-modul ated si nusoi dal pul se generator.
pulstran Pul se trai n generator.
rectpuls Sampl ed aperi odi c rectangl e generator.
sawtooth Sawtooth or tr i angl e wave gener ator.
sin Si ne of vector/matri x el ements (see the onl i ne
MATLAB Function Reference).
sinc Si nc functi on.
square Square wave generator.
tripuls Sampl ed aperi odi c tri angl e generator.
cohere
6-79
6coher e
Purpose Esti mate magni tude squared coherence functi on between two si gnal s.
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) fi nds the magni tude squared coherence between l ength n
si gnal vector s x and y. The coherence i s a functi on of the power spectra of x and
y and the cross spectrum of x and y:
x and y must be the same l ength. Cxy = cohere(x,y) uses the fol l owi ng defaul t
val ues:
nfft = min(256,length(x))
Fs = 2
window = hanning(nfft)
noverlap = 0
nfft speci fi es the FFT l ength that cohere uses. Thi s val ue determi nes the
frequenci es at whi ch the coherence i s esti mated. Fs i s a scal ar that speci fi es the
sampl i ng frequency. window speci fi es a wi ndowi ng functi on and the number of
sampl es cohere uses i n i ts secti oni ng of the x and y vectors. noverlap i s the
number of sampl es by whi ch the secti ons overl ap. Any arguments that you omi t
from the end of the parameter l i st use the defaul t val ues shown above.
I f x i s real , cohere esti mates the coherence functi on at posi ti ve frequenci es
onl y; i n thi s case, the output Cxy i s a col umn vector of l ength nfft/2 + 1 for
nfft even and (nfft + 1)/2 for n odd. I f x or y i s compl ex, cohere esti mates
the coherence functi on at both posi ti ve and negati ve frequenci es, and Cxy has
l ength nfft.
C
xy
f ( )
P
xy
f ( )
2
P
xx
f ( )P
yy
f ( )
------------------------------- =
cohere
6-80
Cxy = cohere(x,y,nfft) uses the FFT l ength nfft i n esti mati ng the power
spectr um for x. Speci fy nfft as a power of 2 for fastest executi on.
[Cxy,f] = cohere(x,y,nfft,Fs) returns a vector f of frequenci es at whi ch
the functi on eval uates the coherence. Fs i s the sampl i ng frequency. f i s the
same si ze as Cxy, so plot(f,Cxy) pl ots the coherence functi on versus properl y
scal ed frequency. Fs has no effect on the output Cxy; i t i s a frequency scal i ng
mul ti pl i er.
Cxy = cohere(x,y,nfft,Fs,window) speci fi es a wi ndowi ng functi on and the
number of sampl es per secti on of the vectors x and y. I f you suppl y a scal ar for
window, cohere uses a Hanni ng wi ndow of that l ength. The l ength of the
wi ndow must be l ess than or equal to nfft; cohere zero pads the secti ons i f the
wi ndow l ength exceeds nfft.
Cxy = cohere(x,y,nfft,Fs,window,noverlap) overl aps the secti ons of x by
noverlap sampl es.
You can use the empty matri x [] to speci fy the defaul t val ue for any i nput
argument except x or y. For exampl e,
Cxy = cohere(x,y,[],[],kaiser(128,5));
uses 256 as the val ue for nfft and 2 as the val ue for Fs.
Cxy = cohere(x,y,...,'dflag') speci fi es a detrend opti on, where dflag i s
linear, to remove the best strai ght-l i ne fi t from the prewi ndowed secti ons of
x and y
mean, to remove the mean from the prewi ndowed secti ons of x and y
none, for no detrendi ng (defaul t)
The dflag parameter must appear l ast i n the l i st of i nput arguments. cohere
recogni zes a dflag stri ng no matter how many i ntermedi ate arguments are
omi tted.
cohere wi th no output arguments pl ots the coherence esti mate versus
frequency i n the current fi gure wi ndow.
cohere
6-81
Example Compute and pl ot the coherence esti mate between two col ored noi se sequences
x and 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)
Diagnostics An appropri ate di agnosti c message i s di spl ayed when i ncorrect arguments are
used:
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 esti mates the magni tude squared coherence functi on [1] usi ng Wel chs
method of power spectrum esti mati on (see references [2] and [3]), as fol l ows:
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
Frequency
C
o
h
e
r
e
n
c
e

F
u
n
c
t
i
o
n

E
s
t
i
m
a
t
e
Coherence Function Estimate
cohere
6-82
1 I t di vi des the si gnal s x and y i nto overl appi ng secti ons, detrends each
secti on, and mul ti pl i es each secti on by window.
2 I t cal cul ates the l ength nfft fast Fouri er transform of each secti on.
3 I t averages the squares of the spectra of the x secti ons to form Pxx, averages
the squares of the spectra of the y secti ons to form Pyy, and averages the
products of the spectra of the x and y secti ons to form Pxy. I t cal cul ates Cxy
by
Cxy = abs(Pxy).^2/(Pxx.*Pyy)
See Also
References [1] Kay, S.M. Modern Spectral Estimation. Engl ewood Cl i ffs, NJ:
Prenti ce-Hal l , 1988. Pg. 454.
[2] Rabi ner, L.R., and B. Gol d. Theory and Application of Digital Signal
Processing. Engl ewood Cl i ffs, NJ: Prenti ce-Hal l , 1975.
[3] Wel ch, P.D. The Use of Fast Fouri er Transform for the Esti mati on of Power
Spectra: A Method Based on Ti me Averagi ng Over Short, Modi fi ed
Peri odograms. I EEE Trans. AudioElectroacoust. Vol . AU-15 (June 1967).
Pgs. 70-73.
csd Esti mate the cross spectral densi ty (CSD) of two
si gnal s.
pwelch Esti mate the power spectral densi ty (PSD) of a si gnal
usi ng Wel chs method.
tfe Transfer functi on esti mate from i nput and output.
conv
6-83
6conv
Purpose Convol uti on and pol ynomi al mul ti pl i cati on.
Syntax c = conv(a,b)
Description conv(a,b) convol ves vectors a and b. The convol uti on sum i s
where N i s the maxi mum sequence l ength. The seri es i s i ndexed from n+1 and
k + 1 i nstead of the usual n and k because MATLAB vectors run from 1 to n
i nstead of from 0 to n-1.
The conv functi on i s part of the standard MATLAB l anguage.
Example The convol uti on of a = [1 2 3] and b = [4 5 6] i s
c = conv(a,b)
c =
4 13 28 27 18
Algorithm The conv functi on i s an M-fi l e that uses the filter pri mi ti ve. conv computes
the convol uti on operati on as FI R fi l teri ng wi th an appropri ate number of zeros
appended to the i nput.
See Also
c n 1 + ( ) a k 1 + ( )b n k ( )
k 0 =
N 1

=
conv2 Two-di mensi onal convol uti on.
convmtx Convol uti on matri x.
convn N-di mensi onal convol uti on (see the onl i ne MATLAB
Function Reference).
deconv Deconvol uti on and pol ynomi al di vi si on.
filter Fi l ter data wi th a recursi ve (I I R) or nonrecursi ve
(FI R) fi l ter.
residuez z-transform parti al fracti on expansi on.
xcorr Cross-correl ati on functi on esti mate.
conv2
6-84
6conv2
Purpose Two-di mensi onal convol uti on.
Syntax C = conv2(A,B)
C = conv2(A,B,'shape')
Description C = conv2(A,B) computes the two-di mensi onal convol uti on of matri ces A and
B. I f one of these matri ces descri bes a two-di mensi onal FI R fi l ter, the other
matri x i s fi l tered i n two di mensi ons.
Each di mensi on of the output matri x C i s equal i n si ze to the sum of the
correspondi ng di mensi ons of the i nput matri ces mi nus 1. For
[ma,na] = size(A) and [mb,nb] = size(B), then
size(C) = [ma+mb1,na+nb1]
C = conv2(A,B,'shape') returns a subsecti on of the two-di mensi onal
convol uti on wi th si ze speci fi ed by shape, where:
full returns the ful l two-di mensi onal convol uti on (defaul t)
same returns the central part of the convol uti on that i s the same si ze as A
valid returns onl y those parts of the convol uti on that are computed wi thout
the zero-padded edges. Usi ng thi s opti on, size(C) = [mamb+1,nanb+1]
when size(A) > size(B)
conv2 executes most qui ckl y when size(A) > size(B).
The conv2 functi on i s part of the standard MATLAB l anguage.
Examples I n i mage processi ng, the Sobel edge-fi ndi ng operati on i s a two-di mensi onal
convol uti on of an i nput array wi th the speci al matri x
s = [1 2 1; 0 0 0; 1 2 1];
Gi ven any i mage, the fol l owi ng l i ne extracts the hori zontal edges:
h = conv2(I,s);
The l i nes bel ow extract fi rst the verti cal edges, then both hori zontal and
verti cal edges combi ned:
v = conv2(I,s');
v2 = (sqrt(h.^2 + v.^2))
conv2
6-85
See Also
conv Convol uti on and pol ynomi al mul ti pl i cati on.
convn N-di mensi onal convol uti on (see the onl i ne MATLAB
Function Reference).
deconv Deconvol uti on and pol ynomi al di vi si on.
filter2 Two-di mensi onal di gi tal fi l teri ng.
xcorr Cross-correl ati on functi on esti mate.
xcorr2 Two-di mensi onal cross-correl ati on.
convmtx
6-86
6convmtx
Purpose Convol uti on matri x.
Syntax A = convmtx(c,n)
A = convmtx(r,n)
Description A convolution matrix i s a matri x, formed from a vector, whose i nner product
wi th another vector i s the convol uti on of the two vectors.
A = convmtx(c,n) where c i s a l ength m col umn vector returns a matri x A of
si ze (m + n1)-by-n. The product of A and another col umn vector x of l ength n
i s the convol uti on of c wi th x.
A = convmtx(r,n) where r i s a l ength m row vector returns a matri x A of si ze
n-by-(m + n1). The product of A and another row vector x of l ength n i s the
convol uti on of r wi th x.
Example Generate a si mpl e convol uti on matri x:
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
Note that convmtx handl es edge condi ti ons by zero paddi ng.
I n practi ce, i t i s more effi ci ent to compute convol uti on usi ng
y = conv(c,x)
than by usi ng a convol uti on matri x:
n = length(x);
y = convmtx(c,n)*x
Algorithm convmtx uses the functi on toeplitz to generate the convol uti on matri x.
convmtx
6-87
See Also
conv Convol uti on and pol ynomi al mul ti pl i cati on.
convn N-di mensi onal convol uti on (see the onl i ne MATLAB
Function Reference).
conv2 Two-di mensi onal convol uti on.
dftmtx Di screte Fouri er transform matri x.
corrcoef
6-88
6cor r coef
Purpose Correl ati on coeffi ci ent matri x.
Syntax C = corrcoef(X)
C = corrcoef(X,Y)
Description corrcoef returns a matri x of correl ati on coeffi ci ents cal cul ated from an i nput
matri x whose rows are observati ons and whose col umns are vari abl es. I f
C = cov(X), then corrcoef(X) i s the matr i x whose el ement (i, j) i s
C = corrcoef(X) i s the zer oth l ag of the covari ance functi on, that i s, the
zeroth l ag of xcov(x,'coeff') packed i nto a square array.
C = corrcoef(X,Y) i s the same as corrcoef([X Y]), that i s, i t concatenates X
and Y i n the row di recti on before i ts computati on.
corrcoef removes the mean from each col umn before cal cul ati ng the resul ts.
See the xcorr functi on for cross-correl ati on opti ons.
The corrcoef functi on i s part of the standard MATLAB l anguage.
See Also
corrcoef i j , ( )
C i j , ( )
C i i , ( )C j j , ( )
---------------------------------- - =
cov Covari ance matri x.
mean Average val ue (see the onl i ne MATLAB Function
Reference).
median Medi an val ue (see the onl i ne MATLAB Function
Reference).
std Standard devi ati on (see the onl i ne MATLAB
Function Reference).
xcorr Cross-correl ati on functi on esti mate.
xcov Cross-covari ance functi on esti mate (equal to
mean-removed cross-correl ati on).
cov
6-89
6cov
Purpose Covari ance matri x.
Syntax c = cov(x)
c = cov(x,y)
Description cov computes the covari ance matri x. I f x i s a vector, c i s a scal ar contai ni ng the
vari ance. For an array where each row i s an observati on and each col umn a
vari abl e, cov(X) i s the covari ance matri x. diag(cov(X)) i s a vector of
vari ances for each col umn, and sqrt(diag(cov(X))) i s a vector of standard
devi ati ons.
cov(x) i s the zeroth l ag of the covari ance functi on, that i s, the zeroth l ag of
xcov(x)/(n1) packed i nto a square array.
cov(x,y) where x and y are col umn vectors of equal l ength i s equi val ent to
cov([x y])), that i s, i t concatenates x and y i n the row di r ecti on befor e i ts
computati on.
cov removes the mean from each col umn before cal cul ati ng the resul ts.
The cov functi on i s part of the standard MATLAB l anguage.
Algorithm [n,p] = size(x);
x = xones(n,1)*(sum(x)/n);
y = x'*x/(n1);
See Also
corrcoef Correl ati on coeffi ci ent matri x.
mean Average val ue (see the onl i ne MATLAB Function
Reference).
median Medi an val ue (see the onl i ne MATLAB Function
Reference).
std Standard devi ati on (see the onl i ne MATLAB
Function Reference).
xcorr Cross-correl ati on functi on esti mate.
xcov Cross-covari ance functi on esti mate (equal to
mean-removed cross-correl ati on).
cplxpair
6-90
6cpl xpai r
Purpose Group compl ex numbers i nto compl ex conjugate pai rs.
Syntax y = cplxpair(x)
y = cplxpair(x,tol)
Description y = cplxpair(x) returns x wi th compl ex conjugate pai rs grouped together.
cplxpair orders the conjugate pai rs by i ncreasi ng real part. Wi thi n a pai r, the
el ement wi th negati ve i magi nary part comes fi rst. The functi on returns al l
purel y real val ues fol l owi ng al l the compl ex pai rs.
y = cplxpair(x,tol) i ncl udes a tol erance, tol, for determi ni ng whi ch
numbers are real and whi ch are pai red compl ex conjugates. By defaul t,
cplxpair uses a tol erance of 100*eps rel ati ve to abs(x(i)). cplxpair forces
the compl ex conjugate pai rs to be exact compl ex conjugates.
The cplxpair functi on i s part of the standard MATLAB l anguage.
Example Order fi ve pol es evenl y spaced around the uni t ci rcl e i nto compl ex pai rs:
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 I f there i s an odd number of compl ex numbers, or i f the compl ex numbers
cannot be grouped i nto compl ex conjugate pai rs wi thi n the tol erance, cplxpair
generates the error message:
Complex numbers can't be paired.
cremez
6-91
6cr emez
Purpose Compl ex and nonl i near-phase equi ri ppl e FI R fi l ter desi gn.
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 al l ows arbi trary frequency-domai n constrai nts to be speci fi ed for the
desi gn of a possi bl y compl ex FI R fi l ter. The Chebyshev (or mi ni max)fi l ter error
i s opti mi zed, produci ng equi ri ppl e FI R fi l ter desi gns.
b = cremez(n,f,'fresp') returns a l ength n+1 FI R fi l ter wi th the best
approxi mati on to the desi red frequency response as returned by functi on
fresp. f i s a vector of frequency band edge pai rs, speci fi ed i n the range
-1 and 1, where 1 corresponds to hal f the sampl i ng frequency (the Nyqui st
frequency). The frequenci es must be i n i ncreasi ng order, and f must have even
l ength. The frequency bands span f(k) to f(k+1) for k odd; the i nterval s
f(k+1) to f(k+2) for k odd are transi ti on bands or dont care regi ons duri ng
opti mi zati on.
b = cremez(n,f,'fresp',w) uses the real , non-negati ve wei ghts i n vector w to
wei ght the fi t i n each frequency band. The l ength of w i s hal f the l ength of f, so
there i s exactl y one wei ght per band.
b = cremez(n,f,{'fresp',p1,p2,...},...) suppl i es opti onal parameters
p1, p2, ..., to the frequency response functi on fresp. Predefi ned 'fresp'
frequency response functi ons are i ncl uded for a number of common fi l ter
desi gns, as descri bed bel ow. For al l of the predefi ned frequency response
functi ons, the symmetry opti on 'sym' defaul ts to 'even' i f no negati ve
frequenci es are contai ned i n f and d = 0; otherwi se 'sym' defaul ts to 'none'.
(See the 'sym' opti on bel ow for detai l s.) For al l of the predefi ned frequency
response functi ons, d speci fi es a group-del ay offset such that the fi l ter response
cremez
6-92
has a group del ay of n/2+d i n uni ts of the sampl e i nterval . Negati ve val ues
create l ess del ay; posi ti ve val ues create more del ay. By defaul t, d = 0.
lowpass, highpass, bandpass, bandstop
These functi ons share a common syntax, exempl i fi ed here by 'lowpass':
b = cremez(n,f,'lowpass',...) and
b = cremez(n,f,{'lowpass',d},...) desi gn a l i near-phase (n/2+d del ay)
fi l ter.
multiband desi gns a l i near-phase frequency response fi l ter wi th arbi trary
band ampl i tudes.
b = cremez(n,f,{'multiband',a},...) and
b = cremez(n,f,{'multiband',a,d},...) speci fy vector a contai ni ng the
desi red ampl i tudes at the band edges i n f. The desi red ampl i tude at
frequenci es between pai rs of poi nts f(k) and f(k+1) for k odd i s the l i ne
segment connecti ng the poi nts (f(k),a(k)) and (f(k+1),a(k+1)).
differentiator desi gns a l i near-phase di fferenti ator. For these desi gns,
zero-frequency must be i n a transi ti on band, and band wei ghti ng i s set to be
i nversel y proporti onal to frequency.
b = cremez(n,f,{'differentiator',Fs},...) and
b = cremez(n,f,{'differentiator',Fs,d},...) speci fy the sampl e rate Fs
used to determi ne the sl ope of the di fferenti ator response. I f omi tted, Fs
defaul ts to 1.
hilbfilt desi gns a l i near-phase Hi l bert transform fi l ter response. For
Hi l bert desi gns, zero-frequency must be i n a transi ti on band.
b = cremez(n,f,'hilbfilt',...) and
b = cremez(N,F,{'hilbfilt',d},...) desi gn a l i near-phase (n/2+d del ay)
Hi l bert transform fi l ter.
b = cremez(n,f,a,w) i s a synonym for
b = cremez(n,f,{'multiband',a},w).
b = cremez(...,'sym') i mposes a symmetry constrai nt on the i mpul se
response of the desi gn, where 'sym' may be one of the fol l owi ng:
cremez
6-93
'none' i ndi cates no symmetry constrai nt
Thi s i s the defaul t i f any negati ve band edge frequenci es are passed, or i f
'fresp' does not suppl y a defaul t.
'even' i ndi cates a real and even i mpul se response
Thi s i s the defaul t for hi ghpass, l owpass, bandpass, bandstop, and
mul ti band desi gns.
'odd' i ndi cates a real and odd i mpul se response
Thi s i s the defaul t for Hi l bert and di fferenti ator desi gns.
'real' i ndi cates conjugate symmetry for the frequency response
I f any 'sym' opti on other than 'none' i s speci fi ed, the band edges shoul d onl y
be speci fi ed over posi ti ve frequenci es; the negati ve frequency regi on i s fi l l ed i n
from symmetry. I f a 'sym' opti on i s not speci fi ed, the 'fresp' functi on i s
queri ed for a defaul t setti ng.
b = cremez(...,'skip_stage2') di sabl es the second-stage opti mi zati on
al gori thm, whi ch executes onl y when cremez determi nes that an opti mal
sol uti on has not been reached by the standard Remez error-exchange.
Di sabl i ng thi s al gori thm may i ncrease the speed of computati on, but may i ncur
a reducti on i n accuracy. By defaul t, the second-stage opti mi zati on i s enabl ed.
b = cremez(...,'debug') enabl es the di spl ay of i ntermedi ate resul ts duri ng
the fi l ter desi gn, where 'debug' may be one of 'trace', 'plots', 'both', or
'off'. By defaul t, i t i s set to 'off'.
b = cremez(...,{lgrid}) uses the i nteger lgrid to control the densi ty of the
frequency gri d, whi ch has roughl y 2^nextpow2(lgrid*n) frequency poi nts.
The defaul t val ue for lgrid i s 25. Note that the {lgrid} argument must be a
1-by-1 cel l array.
Any combi nati on of the 'sym', 'skip_stage2', 'debug', and {lgrid} opti ons
may be speci fi ed.
[b,delta] = cremez(...) returns the maxi mum ri ppl e hei ght delta.
cremez
6-94
[b,delta,opt] = cremez(...) returns a structure opt of opti onal resul ts
computed by cremez and contai ns the fol l owi ng fi el ds:
Examples Example 1
Desi gn a 31-tap, l i near-phase, l owpass fi l ter:
b = cremez(30,[1 0.5 0.4 0.7 0.8 1],'lowpass');
freqz(b,1,512,'whole');
opt.fgrid Frequency gri d vector used for the fi l ter desi gn opti mi zati on
opt.des Desi red frequency response for each poi nt i n opt.fgrid
opt.wt Wei ghti ng for each poi nt i n opt.fgrid
opt.H Actual frequency response for each poi nt i n opt.fgrid
opt.error Error at each poi nt i n opt.fgrid
opt.iextr Vector of i ndi ces i nto opt.fgrid for extremal frequenci es
opt.fextr Vector of extremal frequenci es
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
4000
3000
2000
1000
0
Normalized Angular Frequency ( rads/sample)
P
h
a
s
e

(
d
e
g
r
e
e
s
)
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
100
50
0
50
Normalized Angular Frequency ( rads/sample)
M
a
g
n
i
t
u
d
e

(
d
B
)
cremez
6-95
Example 2
Desi gn a nonl i near-phase al l pass FI R fi l ter.
Fi rst sel ect (or create) the functi on fresp that returns the desi red frequency
response. For thi s exampl e, fresp i s the allpass.m functi on i n the
signal/signal/private di rectory whi ch returns the frequency response of a
nonl i near-phase al l pass fi l ter. Copy allpass.m to another l ocati on on the
MATLAB path befor e tryi ng the exampl e.
Before usi ng cremez wi th allpass.m to generate the fi l ter coeffi ci ents, cal l
allpass al one to create the desired response.
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
Vector d now contai ns the compl ex frequency response that we desi re for the
FI R fi l ter computed by cremez.
Now compute the FI R fi l ter that best approxi mates thi s response:
b = cremez(n,f,'allpass',w,'real' ); % Approximation
freqz(b,1,256,'whole');
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
3000
2000
1000
0
Normalized Angular Frequency ( rads/sample)
P
h
a
s
e

(
d
e
g
r
e
e
s
)
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
0.2
0.1
0
0.1
0.2
Normalized Angular Frequency ( rads/sample)
M
a
g
n
i
t
u
d
e

(
d
B
)
cremez
6-96
The freqz pl ot shows the frequency response of the fi l ter computed by cremez
to approxi mate the desi red response. Check the accuracy of the approxi mati on
by overl ayi ng the desired frequency response on the pl ot.
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')
Remarks User-defi nabl e functi ons may be used, i nstead of the predefi ned frequency
response functi ons for 'fresp'. The functi on i s cal l ed from wi thi n cremez usi ng
the fol l owi ng syntax:
[dh,dw] = fresp(n,f,gf,w,p1,p2,...) where
n i s the fi l ter order.
f i s the vector of frequency band edges that appear monotoni cal l y between
-1 and 1, where 1 i s the Nyqui st frequency.
gf i s a vector of gri d poi nts that have been l i nearl y i nterpol ated over each
speci fi ed frequency band by cremez. gf determi nes the frequency gri d at
whi ch the response functi on must be eval uated. Thi s i s the same data
returned by cremez i n the fgrid fi el d of the opt structure.
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
3000
2000
1000
0
Normalized Angular Frequency ( rads/sample)
P
h
a
s
e

(
d
e
g
r
e
e
s
)
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
0.2
0.1
0
0.1
0.2
Normalized Angular Frequency ( rads/sample)
M
a
g
n
i
t
u
d
e

(
d
B
)
Approximation
Desired
cremez
6-97
w i s a vector of real , posi ti ve wei ghts, one per band, used duri ng opti mi zati on.
w i s opti onal i n the cal l to cremez; i f not speci fi ed, i t i s set to uni ty wei ghti ng
before bei ng passed to 'fresp'.
dh and dw are the desi red compl ex frequency response and band wei ght
vectors, respecti vel y, eval uated at each frequency i n gri d gf.
p1, p2, ..., are opti onal parameters that may be passed to 'fresp'.
Addi ti onal l y, a prel i mi nary cal l i s made to 'fresp' to determi ne the defaul t
symmetry property 'sym'. Thi s cal l i s made usi ng the syntax:
sym = fresp('defaults',{n,f,[],w,p1,p2,...})
The arguments may be used i n determi ni ng an appropri ate symmetry defaul t
as necessary. The functi on private/lowpass.m may be useful as a templ ate for
generati ng new frequency response functi ons.
Algorithm An extended versi on of the Remez exchange method i s i mpl emented for the
compl ex case. Thi s exchange method obtai ns the opti mal fi l ter when the
equi ri ppl e nature of the fi l ter i s restri cted to have n+2 extremal s. When i t does
not converge, the al gori thm swi tches to an ascent-descent al gori thm that takes
over to fi ni sh the convergence to the opti mal sol uti on. See the references for
further detai l s.
cremez
6-98
Diagnostics The fol l owi ng di agnosti c messages ari se from i ncorrect usage 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.
cremez
6-99
See Also
References [1] Karam, L.J., and J.H. McCl el l an. Compl ex Chebyshev Approxi mati on for
FI R Fi l ter Desi gn. I EEE Trans. on Circuits and Systems I I . March 1995.
Pgs. 207-216.
[2] Karam, L.J. Design of ComplexDigital FI R Filters in theChebyshev Sense.
Ph.D. Thesi s, Georgi a I nsti tute of Technol ogy, March 1995.
[3] Demjanjov, V.F., and V.N. Mal ozemov. I ntroductiontoMinimax. New York:
John Wi l ey & Sons, 1974.
fir1 Wi ndow-based fi ni te i mpul se response fi l ter desi gn
standard response.
fir2 Wi ndow-based fi ni te i mpul se response fi l ter desi gn
arbi trary response.
firls Least square l i near-phase FI R fi l ter desi gn.
remez Parks-McCl el l an opti mal FI R fi l ter desi gn.
private/bandpass Bandpass fi l ter desi gn functi on.
private/bandstop Bandstop fi l ter desi gn functi on.
private/different
iator
Di fferenti ator fi l ter desi gn functi on.
private/highpass Hi ghpass fi l ter desi gn functi on.
private/hilbfilt Hi l bert fi l ter desi gn functi on.
private/lowpass Lowpass fi l ter desi gn functi on.
private/multiband Mul ti band fi l ter desi gn functi on.
csd
6-100
6csd
Purpose Esti mate the cross spectral densi ty (CSD) of two si gnal s.
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) esti mates the cross spectral densi ty of the l ength n sequences
x and y usi ng the Wel ch method of spectral esti mati on. Pxy = csd(x,y) uses
the fol l owi ng defaul t val ues:
nfft = min(256,length(x))
Fs = 2
window = hanning(nfft)
noverlap = 0
nfft speci fi es the FFT l ength that csd uses. Thi s val ue determi nes the
frequenci es at whi ch the cross spectrum i s esti mated. Fs i s a scal ar that
speci fi es the sampl i ng frequency. window speci fi es a wi ndowi ng functi on and
the number of sampl es csd uses i n i ts secti oni ng of the x and y vectors.
noverlap i s the number of sampl es by whi ch the secti ons overl ap. Any
arguments omi tted from the end of the parameter l i st use the defaul t val ues
shown above.
I f x and y are real , csd esti mates the cross spectral densi ty at posi ti ve
frequenci es onl y; i n thi s case, the output Pxy i s a col umn vector of l ength
nfft/2 + 1 for nfft even and (nfft + 1)/2 for nfft odd. I f x or y i s compl ex,
csd esti mates the cross spectral densi ty at both posi ti ve and negati ve
frequenci es and Pxy has l ength nfft.
Pxy = csd(x,y,nfft) uses the FFT l ength nfft i n esti mati ng the cross
spectral densi ty of x and y. Speci fy nfft as a power of 2 for fastest executi on.
[Pxy,f] = csd(x,y,nfft,Fs) returns a vector f of frequenci es at whi ch the
functi on eval uates the CSD. f i s the same si ze as Pxy, so plot(f,Pxy) pl ots the
csd
6-101
spectrum versus properl y scal ed frequency. Fs has no effect on the output Pxy;
i t i s a frequency scal i ng mul ti pl i er.
Pxy = csd(x,y,nfft,Fs,window) speci fi es a wi ndowi ng functi on and the
number of sampl es per secti on of the x vector. I f you suppl y a scal ar for window,
csd uses a Hanni ng wi ndow of that l ength. The l ength of the wi ndow must be
l ess than or equal to nfft; csd zero pads the secti ons i f the l ength of the wi ndow
i s l ess than nfft. csd returns an error i f the l ength of the wi ndow i s greater
than nfft.
Pxy = csd(x,y,nfft,Fs,window,noverlap) overl aps the secti ons of x and y
by noverlap sampl es.
You can use the empty matri x [] to speci fy the defaul t val ue for any i nput
argument except x or y. For exampl e,
csd(x,y,[],10000)
i s equi val ent to
csd(x)
but wi th a sampl i ng frequency of 10,000 Hz i nstead of the defaul t of 2 Hz.
Pxy = csd(x,y,...,'dflag') speci fi es a detrend opti on, where dflag i s:
linear, to remove the best str ai ght-l i ne fi t fr om the pr ewi ndowed secti ons of
x and y
mean, to remove the mean from the prewi ndowed secti ons of x and y
none, for no detrendi ng (defaul t)
The dflag parameter must appear l ast i n the l i st of i nput arguments. csd
recogni zes a dflag stri ng no matter how many i ntermedi ate arguments are
omi tted.
[Pxy,Pxyc,f] = csd(x,y,nfft,Fs,window,noverlap,p) where p i s a posi ti ve
scal ar between 0 and 1 returns a vector Pxyc that contai ns an esti mate of the
p*100 percent confi dence i nterval for Pxy. Pxyc i s a two-col umn matri x the
same l ength as Pxy. The i nterval [Pxyc(:,1), Pxyc(:,2)] covers the true
CSD wi th probabi l i ty p. plot(f,[Pxy Pxyc]) pl ots the cross spectrum i nsi de
the p*100 percent confi dence i nterval . I f unspeci fi ed, p defaul ts to 0.95.
csd
6-102
csd(x,y,...) pl ots the CSD versus frequency i n the current fi gure wi ndow. I f
the p parameter i s speci fi ed, the pl ot i ncl udes the confi dence i nterval .
Example Generate two col ored noi se si gnal s and pl ot thei r CSD wi th a confi dence
i nterval of 95%. Speci fy a l ength 1024 FFT, a 500 poi nt tri angul ar wi ndow wi th
no overl ap, and a sampl i ng frequency of 10 Hz:
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,[])
Algorithm csd i mpl ements the Wel ch method of spectral densi ty esti mati on (see
references [1] and [2]):
1 I t appl i es the wi ndow speci fi ed by the window vector to each successi ve
detrended secti on.
2 I t transforms each secti on wi th an nfft-poi nt FFT.
3 I t forms the peri odogram of each secti on by scal i ng the product of the
transform of the y secti on and the conjugate of the transformed x secti on.
0 1000 2000 3000 4000 5000
-70
-60
-50
-40
-30
-20
-10
0
10
20
Frequency
C
r
o
s
s

S
p
e
c
t
r
u
m

M
a
g
n
i
t
u
d
e

(
d
B
)
csd
6-103
4 I t averages the peri odograms of the successi ve overl appi ng secti ons to form
Pxy, the cross spectral densi ty of x and y.
The number of secti ons that csd aver ages i s k, where k i s
fix((length(x)noverlap)/(length(window)noverlap))
Diagnostics An appropri ate di agnosti c message i s di spl ayed when i ncorrect arguments to
csd are used:
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
References [1] Rabi ner, L.R., and B. Gol d. Theory and Application of Digital Signal
Processing. Engl ewood Cl i ffs, NJ: Prenti ce-Hal l , 1975. Pgs. 414-419.
[2] Wel ch, P.D. The Use of Fast Fouri er Transform for the Esti mati on of Power
Spectra: A Method Based on Ti me Averagi ng Over Short, Modi fi ed
Peri odograms. I EEE Trans. AudioElectroacoust. Vol . AU-15 (June 1967).
Pgs. 70-73.
cohere Esti mate magni tude squared coherence functi on
between two si gnal s.
pburg Power spectrum esti mate usi ng the Burg method.
pmtm Power spectrum esti mate usi ng the mul ti taper
method (MTM).
pmusic Power spectrum esti mate usi ng MUSI C ei genvector
method.
pwelch Esti mate the power spectral densi ty (PSD) of a si gnal
usi ng Wel chs method.
pyulear Power spectrum esti mate usi ng Yul e-Wal ker AR
method.
tfe Transfer functi on esti mate from i nput and output.
csd
6-104
[3] Oppenhei m, A.V., and R.W. Schafer. Discrete-TimeSignal Processing.
Engl ewood Cl i ffs, NJ: Prenti ce-Hal l , 1989. Pg. 737.
czt
6-105
6czt
Purpose Chi rp z-transform.
Syntax y = czt(x,m,w,a)
y = czt(x)
Description y = czt(x,m,w,a) returns the chi rp z-transform of si gnal x. The chi rp
z-transform i s the z-transform of x al ong a spi ral contour defi ned by w and a. m
i s a scal ar that speci fi es the l ength of the transform, w i s the rati o between
poi nts al ong the z-pl ane spi ral contour of i nterest, and scal ar a i s the compl ex
starti ng poi nt on that contour. The contour, a spi ral or chi rp i n the z-pl ane, i s
gi ven by
z = a*(w.^(0:m1))
y = czt(x) uses the fol l owi ng defaul t val ues:
m = length(x)
w = exp(j*2*pi/m)
a = 1
Wi th these defaul ts, czt returns the z-transform of x at m equal l y spaced poi nts
around the uni t ci rcl e. Thi s i s equi val ent to the di screte Fouri er transform of
x, or fft(x). The empty matri x [] speci fi es the defaul t val ue for a parameter.
I f x i s a matri x, czt(x,m,w,a) transforms the col umns of x.
Examples Create a random vector x of l ength 1013 and compute i ts DFT usi ng czt. Thi s
i s faster than the fft functi on on the same sequence.
x = randn(1013,1);
y = czt(x);
Use czt to zoom i n on a narrow-band secti on (100 to 150 Hz) of a fi l ters
frequency response. Fi rst desi gn the fi l ter:
h = fir1(30,125/500,boxcar(31)); % filter
czt
6-106
Establ i sh frequency and CZT parameters:
Fs = 1000; f1 = 100; f2 = 150; % in Hertz
m = 1024;
w = exp(j*2*pi*(f2f1)/(m*Fs));
a = exp(j*2*pi*f1/Fs);
Compute both the DFT and CZT of the fi l ter:
y = fft(h,1000);
z = czt(h,m,w,a);
Create frequency vectors and compare the resul ts:
fy = (0:length(y)1)'*1000/length(y);
fz = ((0:length(z)1)'*(f2f1)/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')
Algorithm czt uses the next power-of-2 l ength FFT to per form a fast convol uti on when
computi ng the z-transform on a speci fi ed chi rp contour [1]. czt can be
si gni fi cantl y faster than fft for l arge, pri me-l ength sequences.
Diagnostics I f m, w, or a i s not a scal ar, czt gi ves the fol l owi ng error message:
Inputs M, W, and A must be scalars.
100 200 300 400 500
0
0.2
0.4
0.6
0.8
1
FFT
100 110 120 130 140
0
0.2
0.4
0.6
0.8
1
CZT
czt
6-107
See Also
References [1] Rabi ner, L.R., and B. Gol d. Theory and Application of Digital Signal
Processing. Engl ewood Cl i ffs, NJ: Prenti ce-Hal l , 1975. Pgs. 393-399.
fft One-di mensi onal fast Fouri er transform.
freqz Frequency response of di gi tal fi l ters.
dct
6-108
6dct
Purpose Di screte cosi ne transform (DCT).
Syntax y = dct(x)
y = dct(x,n)
Description y = dct(x) returns the uni tary di screte cosi ne transform of x
where
N i s the l ength of x, and x and y are the same si ze. I f x i s a matri x, dct
transforms i ts col umns. The seri es i s i ndexed from n = 1 and k = 1 i nstead of
the usual n = 0 and k = 0 because MATLAB vectors run from 1 to N i nstead of
from 0 to N- 1.
y = dct(x,n) pads or truncates x to l ength n before transformi ng.
The DCT i s cl osel y rel ated to the di screte Fouri er transform. You can often
reconstruct a sequence very accuratel y from onl y a few DCT coeffi ci ents, a
useful property for appl i cati ons requi ri ng data reducti on.
y k ( ) w k ( ) x n ( )
2n 1 ( ) k 1 ( )
2N
------------------------------------------ - cos
n 1 =
N

k 1 N , , = , =
w k ( )
1
N
--------- k 1 = ,
2
N
---- 2 k N ,

'

=
dct
6-109
Example Fi nd how many DCT coeffi ci ents represent 99% of the energy i n a sequence:
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,100i)])/norm(X)<.99)
i = i + 1;
end
i =
3
See Also
References [1] Jai n, A.K. Fundamentalsof Digital I mageProcessing. Engl ewood Cl i ffs, NJ:
Prenti ce-Hal l , 1989.
[2] Pennebaker, W.B., and J.L. Mi tchel l . J PEG Still I mageData Compression
Standard. New York, NY: Van Nostrand Rei nhol d, 1993. Chapter 4.
fft One-di mensi onal fast Fouri er transform.
idct I nverse di screte cosi ne transform.
dct2 Two-di mensi onal DCT(see I mageProcessingToolbox
Users Guide).
idct2 Two-di mensi onal i nverse DCT (see I mageProcessing
Toolbox Users Guide).
decimate
6-110
6deci mate
Purpose Decrease the sampl i ng rate for a sequence (deci mati on).
Syntax y = decimate(x,r)
y = decimate(x,r,n)
y = decimate(x,r,'fir')
y = decimate(x,r,n,'fir')
Description Deci mati on reduces the ori gi nal sampl i ng rate for a sequence to a l ower rate.
I t i s the opposi te of i nterpol ati on. The deci mati on process fi l ters the i nput data
wi th a l owpass fi l ter and then resampl es the resul ti ng smoothed si gnal at a
l ower rate.
y = decimate(x,r) reduces the sampl e rate of x by a factor r. The deci mated
vector y i s r ti mes shorter i n l ength than the i nput vector x. By defaul t,
decimate empl oys an ei ghth-order l owpass Chebyshev type I fi l ter. I t fi l ters
the i nput sequence i n both the forward and reverse di recti ons to remove al l
phase di storti on, effecti vel y doubl i ng the fi l ter order.
y = decimate(x,r,n) uses an order n Chebyshev fi l ter. Orders above 13 are
not recommended because of numeri cal i nstabi l i ty. MATLAB di spl ays a
warni ng i n thi s case.
y = decimate(x,r,'fir') uses a 30-poi nt FI R fi l ter, i nstead of the Chebyshev
I I R fi l ter. Here decimate fi l ters the i nput sequence i n onl y one di recti on. Thi s
techni que conserves memory and i s useful for worki ng wi th l ong sequences.
y = decimate(x,r,n,'fir') uses a l ength n FI R fi l ter.
Example Deci mate a si gnal by a factor of four:
t = 0:.00025:1; % time vector
x = sin(2*pi*30*t) + sin(2*pi*60*t);
y = decimate(x,4);
decimate
6-111
Vi ew the ori gi nal and deci mated si gnal s:
stem(x(1:120)), axis([0 120 2 2]) % original signal
title('Original Signal')
figure
stem(y(1:30)) % decimated signal
title('Decimated Signal')
Algorithm decimate uses deci mati on al gori thms 8.2 and 8.3 from [1]:
1 I t desi gns a l owpass fi l ter. By defaul t, decimate uses a Chebyshev type I
fi l ter wi th normal i zed cutoff frequency 0.8/r and 0.05 dB of passband ri ppl e.
For the fir opti on, decimate desi gns a l owpass FI R fi l ter wi th cutoff
frequency 1/r usi ng fir1.
2 For the FI R fi l ter, decimate appl i es the fi l ter to the i nput vector i n one
di recti on. I n the I I R case, decimate appl i es the fi l ter i n forward and reverse
di recti ons wi th filtfilt.
3 decimate resampl es the fi l tered data by sel ecti ng every r-th poi nt.
Diagnostics I f r i s not an i nteger, decimate gi ves the fol l owi ng error message:
Resampling rate R must be an integer.
I f n speci fi es an I I R fi l ter wi th order greater than 13, decimate gi ves the
fol l owi ng warni ng:
Warning: IIR filters above order 13 may be unreliable.
0 50 100
-2
-1
0
1
2
Original Signal
0 10 20 30
-2
-1
0
1
2
Decimated Signal
decimate
6-112
See Also
References [1] I EEE. Programsfor Digital Signal Processing. I EEE Press. New York: John
Wi l ey & Sons, 1979. Chapter 8.
interp I ncrease sampl i ng rate by an i nteger factor (i nterpol ati on).
resample Change sampl i ng rate by any rati onal factor.
spline Cubi c spl i ne i nterpol ati on (see the onl i ne MATLAB
Function Reference).
upfirdn Upsampl e, appl y an FI R fi l ter, and downsampl e.
deconv
6-113
6deconv
Purpose Deconvol uti on and pol ynomi al di vi si on.
Syntax [q,r] = deconv(b,a)
Description [q,r] = deconv(b,a) deconvol ves vector a out of vector b, usi ng l ong di vi si on.
The resul t (quoti ent) i s returned i n vector q and the remai nder i n vector r such
that b = conv(q,a) + r.
I f a and b are vectors of pol ynomi al coeffi ci ents, convol vi ng them i s equi val ent
to pol ynomi al mul ti pl i cati on, and deconvol uti on i s equi val ent to pol ynomi al
di vi si on. The resul t of di vi di ng b by a i s quoti ent q and remai nder r.
The deconv functi on i s part of the standard MATLAB l anguage.
Example The convol uti on of a = [1 2 3] and b = [4 5 6] i s
c = conv(a,b)
c =
4 13 28 27 18
Use deconv to di vi de b back out:
[q,r] = deconv(c,a)
q =
4 5 6
r =
0 0 0 0 0
Algorithm Thi s functi on cal l s filter to compute the deconvol uti on as the i mpul se
response of an I I R fi l ter.
See Also
conv Convol uti on and pol ynomi al mul ti pl i cati on.
filter Fi l ter data wi th a recursi ve (I I R) or nonrecursi ve
(FI R) fi l ter.
residuez z-transform parti al fracti on expansi on.
demod
6-114
6demod
Purpose Demodul ati on for communi cati ons si mul ati on.
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 performs demodul ati on, that i s, i t obtai ns the ori gi nal si gnal from a
modul ated versi on of the si gnal . demod undoes the operati on performed by
modulate.
x = demod(y,Fc,Fs,'method') and
x = demod(y,Fc,Fs,'method',opt) demodul ate the real carri er si gnal y wi th
a carri er frequency Fc and sampl i ng frequency Fs, usi ng one of the opti ons
l i sted bel ow for method. (Note that some methods accept an opti on, opt.)
amdsbsc
or
am
Amplitudedemodulation, doublesideband, suppressed
carrier. Mul ti pl i es y by a si nusoi d of frequency Fc and appl i es a
fi fth-order Butterworth l owpass fi l ter usi ng filtfilt:
x = y.*cos(2*pi*Fc*t);
[b,a] = butter(5,Fc*2/Fs);
x = filtfilt(b,a,x);
amdsbtc Amplitudedemodulation, doublesideband, transmitted
carrier. Mul ti pl i es y by a si nusoi d of frequency Fc, and appl i es a
fi fth-order Butterworth l owpass fi l ter usi ng filtfilt:
x = y.*cos(2*pi*Fc*t);
[b,a] = butter(5,Fc*2/Fs);
x = filtfilt(b,a,x);
I f you speci fy opt, demod subtracts scal ar opt from x. The defaul t
val ue for opt i s 0.
amssb Amplitudedemodulation, singlesideband. Mul ti pl i es y by a
si nusoi d of frequency Fc and appl i es a fi fth-order Butterworth
l owpass fi l ter usi ng filtfilt:
x = y.*cos(2*pi*Fc*t);
[b,a] = butter(5,Fc*2/Fs);
x = filtfilt(b,a,x);
demod
6-115
The defaul t method i s 'am'. Except for the 'ptm' and 'pwm' cases, x i s the
same si ze as y.
I f y i s a matri x, demod demodul ates i ts col umns.
x = demod(y,Fc,Fs,'pwm','centered') fi nds the pul se wi dths assumi ng
they are centered at the begi nni ng of each peri od. x i s l ength
length(y)*Fc/Fs.
fm Frequency demodulation. Demodul ates the FM waveform by
modul ati ng the Hi l bert transform of y by a compl ex exponenti al
of frequency Fc Hz and obtai ns the i nstantaneous frequency of
the resul t.
pm Phasedemodulation. Demodul ates the PM waveform by
modul ati ng the Hi l bert transform of y by a compl ex exponenti al
of frequency Fc Hz and obtai ns the i nstantaneous phase of the
resul t.
ptm Pulse-timedemodulation. Fi nds the pul se ti mes of a pul se-ti me
modul ated si gnal y. For correct demodul ati on, the pul ses cannot
overl ap. x i s l ength length(t)*Fc/Fs.
pwm Pulse-width demodulation. Fi nds the pul se wi dths of a
pul se-wi dth modul ated si gnal y. demod returns i n x a vector whose
el ements speci fy the wi dth of each pul se i n fracti ons of a peri od.
The pul ses i n y shoul d start at the begi nni ng of each carri er
peri od, that i s, they shoul d be l eft justi fi ed.
qam Quadratureamplitudedemodulation.
[x1,x2] = demod(y,Fc,Fs,'qam') mul ti pl i es y by a cosi ne and a
si ne of frequency Fc and appl i es a fi fth-order Butterworth
l owpass fi l ter usi ng 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);
demod
6-116
See Also
modulate Modul ati on for communi cati ons si mul ati on.
vco Vol tage control l ed osci l l ator.
dftmtx
6-117
6dftmtx
Purpose Di screte Fouri er transform matri x.
Syntax A = dftmtx(n)
Description A discreteFourier transformmatrixi s a compl ex matri x of val ues around the
uni t ci rcl e, whose matri x product wi th a vector computes the di screte Fouri er
transform of the vector.
A = dftmtx(n) returns the n-by-n compl ex matri x A that, when mul ti pl i ed i nto
a l ength n col umn vector x:
y = A*x
computes the di screte Fouri er transform of x.
The i nverse di screte Fouri er transform matri x i s
Ai = conj(dftmtx(n))/n
Example I n practi ce, the di screte Fouri er transform i s computed more effi ci entl y and
uses l ess memory wi th an FFT al gori thm
x = 1:256;
y1 = fft(x);
than by usi ng the Fouri er transform matri x:
n = length(x);
y2 = x*dftmtx(n);
norm(y1y2)
ans =
1.8297e-009
Algorithm dftmtx uses an outer product to generate the transform matri x.
See Also
convmtx Convol uti on matri x.
fft One-di mensi onal fast Fouri er transform.
diric
6-118
6di r i c
Purpose Di ri chl et or peri odi c si nc functi on.
Syntax y = diric(x,n)
Description y = diric(x,n) returns a vector or array y the same si ze as x. The el ements
of y are the Di ri chl et functi on of the el ements of x. n must be a posi ti ve i nteger.
The Di ri chl et functi on, or peri odi c si nc functi on, i s
for any nonzero i nteger n. Thi s functi on has peri od 2 for n odd and peri od 4
for n even. I ts peak val ue i s 1, and i ts mi ni mum val ue i s -1 for n even. The
magni tude of thi s functi on i s (1/n) ti mes the magni tude of the di screte-ti me
Fouri er transform of the n-poi nt rectangul ar wi ndow.
Diagnostics I f n i s not a posi ti ve i nteger, diric gi ves the fol l owi ng error message:
Requires n to be a positive integer.
See Also
di ri c x n , ( )
1
x
2
------- n 1 ( )
x 0 2 t 4 t , , , =
nx 2 ( ) si n
n x 2 ( ) si n
----------------------------
el se

'

=
cos Cosi ne of vector/matri x el ements (see the onl i ne
MATLAB Function Reference).
gauspuls Gaussi an-modul ated si nusoi dal pul se generator.
pulstran Pul se trai n generator.
rectpuls Sampl ed aperi odi c rectangl e generator.
sawtooth Sawtooth or tr i angl e wave gener ator.
sin Si ne of vector/matri x el ements (see the onl i ne
MATLAB Function Reference).
sinc Si nc or si n(t)/t functi on.
square Square wave generator.
tripuls Sampl ed aperi odi c tri angl e generator.
dpss
6-119
6dpss
Purpose Di screte prol ate spheroi dal sequences (Sl epi an sequences).
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) generates the fi rst 2*nw discreteprolatespheroidal
sequences (DPSS) of l ength n i n the col umns of e, and thei r correspondi ng
concentrati ons i n vector v. They are al so generated i n the DPSS MAT-fi l e
database dpss.mat. nw must be l ess than n/2.
[e,v] = dpss(n,nw,k) returns the k most band-l i mi ted sequences of the 2*nw
di screte prol ate spheroi dal sequences cal cul ated. k must be between 0 and
2*nw.
[e,v] = dpss(n,nw,[k1 k2]) returns the k1-th through the k2-th sequences
from the 2*nw di screte prol ate spheroi dal sequences cal cul ated, where
1 k1 k2 (2*nw).
For al l of the above forms,
The Sl epi an sequences are cal cul ated di rectl y.
The sequences are generated i n the frequency band || (2W), where
W = nw/n i s the hal f-bandwi dth and i s i n radi ans.
e(:,1) i s the l ength n si gnal most concentrated i n the frequency band
|| (2W) radi ans, e(:,2) i s the si gnal orthogonal to e(:,1) that i s most
concentrated i n thi s band, e(:,3) i s the si gnal orthogonal to both e(:,1)
and e(:,2) that i s most concentrated i n thi s band, etc.
For mul ti taper spectral anal ysi s, typi cal choi ces for nw are 2, 5/2, 3, 7/2, or 4.
[e,v] = dpss(n,nw,'spline') uses spl i ne i nterpol ati on to compute e and v
from the sequences i n dpss.mat wi th l ength cl osest to n.
dpss
6-120
[e,v] = dpss(n,nw,'spline',Ni) i nterpol ates from exi sti ng l ength Ni
sequences.
[e,v] = dpss(n,nw,'linear') and
[e,v] = dpss(n,nw,'linear',Ni) use l i near i nterpol ati on, whi ch i s much
faster but l ess accurate than spl i ne i nterpol ati on. 'linear' requi res Ni > n.
[e,v] = dpss(...,'trace') and
[e,v] = dpss(...,'int','trace') use a trai l i ng 'trace' argument to fi nd
out whi ch method DPSS uses, where 'int' i s ei ther 'spline' or 'linear'.
See Also
References [1] Perci val , D.B., and A.T. Wal den. Spectral Analysis for Physical
Applications: Multitaper andConventional UnivariateTechniques. Cambri dge:
Cambri dge Uni versi ty Press, 1993.
dpssclear Remove di screte prol ate spheroi dal sequences from
database.
dpssdir Di scr ete prol ate spher oi dal sequences database
di rectory.
dpssload Load di screte prol ate spheroi dal sequences from
database.
dpsssave Save di screte prol ate spheroi dal sequences i n
database.
pmtm Power spectrum esti mate usi ng the mul ti taper
method (MTM).
dpssclear
6-121
6dpsscl ear
Purpose Remove di screte prol ate spheroi dal sequences from database.
Syntax dpssclear(n,nw)
Description dpssclear(n,nw) removes sequences wi th l ength n and ti me-bandwi dth
product nw from the DPSS MAT-fi l e database dpss.mat.
See Also
dpss Di screte prol ate spheroi dal sequences (Sl epi an
sequences).
dpssdir Di screte prol ate spheroi dal sequences database
di rectory.
dpssload Load di screte prol ate spheroi dal sequences from
database.
dpsssave Save di screte prol ate spheroi dal sequences i n
database.
dpssdir
6-122
6dpssdi r
Purpose Di screte prol ate spheroi dal sequences database di rectory.
Syntax dpssdir
dpssdir(n)
dpssdir(nw,'nw')
dpssdir(n,nw)
index = dpssdir
Description dpssdir manages the database di rectory that contai ns the generated DPSS
sampl es i n the DPSS MAT-fi l e database dpss.mat.
dpssdir l i sts the di rectory of saved sequences i n dpss.mat.
dpssdir(n) l i sts the sequences saved wi th l ength n.
dpssdir(nw,'nw') l i sts the sequences saved wi th ti me-bandwi dth product nw.
dpssdir(n,nw) l i sts the sequences saved wi th l ength n and ti me-bandwi dth
product nw.
index = dpssdir i s a structure array descri bi ng the DPSS database. Pass n
and nw opti ons as for the no output case to get a fi l tered index.
See Also
dpss Di screte prol ate spheroi dal sequences (Sl epi an
sequences).
dpssclear Remove di screte prol ate spheroi dal sequences from
database.
dpssload Load di screte prol ate spheroi dal sequences from
database.
dpsssave Save di screte prol ate spheroi dal sequences i n
database.
dpssload
6-123
6dpssl oad
Purpose Load di screte prol ate spheroi dal sequences from database.
Syntax [e,v] = dpssload(n,nw)
Description [e,v] = dpssload(n,nw) l oads al l sequences wi th l ength n and
ti me-bandwi dth product nw i n the col umns of e and thei r correspondi ng
concentrati ons i n vector v from the DPSS MAT-fi l e database dpss.mat.
See Also
dpss Di screte prol ate spheroi dal sequences (Sl epi an
sequences).
dpssclear Remove di screte prol ate spheroi dal sequences from
database.
dpssdir Di screte prol ate spheroi dal sequences database
di rectory.
dpsssave Save di screte prol ate spheroi dal sequences i n
database.
dpsssave
6-124
6dpsssave
Purpose Save di screte prol ate spheroi dal sequences i n database.
Syntax dpsssave(nw,e,v)
status = dpsssave(nw,e,v)
Description dpsssave(nw,e,v) saves the sequences i n the col umns of e and thei r
correspondi ng concentrati ons i n vector v i n the DPSS MAT-fi l e database
dpss.mat.
I t i s not necessary to speci fy sequence l ength, because the l ength of the
sequence i s determi ned by the number of rows of e.
nw i s the time-bandwidth product that was speci fi ed when the sequence was
created usi ng dpss.
status = dpsssave(nw,e,v) returns 0 i f the save was successful and 1 i f there
was an error.
See Also
dpss Di screte prol ate spheroi dal sequences (Sl epi an
sequences).
dpssclear Remove di screte prol ate spheroi dal sequences from
database.
dpssdir Di scr ete prol ate spher oi dal sequences database
di rectory.
dpssload Load di screte prol ate spheroi dal sequences from
database.
ellip
6-125
6el l i p
Purpose El l i pti c (Cauer) fi l ter desi gn.
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 desi gns l owpass, bandpass, hi ghpass, and bandstop di gi tal and anal og
el l i pti c fi l ters. El l i pti c fi l ters offer steeper rol l off characteri sti cs than
Butterworth or Chebyshev fi l ters, but are equi ri ppl e i n both the pass- and
stopbands. I n general , el l i pti c fi l ters meet gi ven performance speci fi cati ons
wi th the l owest or der of any fi l ter type.
Digital Domain
[b,a] = ellip(n,Rp,Rs,Wn) desi gns an order n l owpass di gi tal el l i pti c fi l ter
wi th cutoff frequency Wn, Rp dB of ri ppl e i n the passband, and a stopband Rs dB
down from the peak val ue i n the passband. I t returns the fi l ter coeffi ci ents i n the
l ength n + 1 row vectors b and a, wi th coeffi ci ents i n descendi ng powers of z:
The cutoff frequency i s the edge of the passband, at whi ch the magni tude
response of the fi l ter i s Rp dB. For ellip, the cutoff frequency Wn i s a number
between 0 and 1, where 1 corresponds to hal f the sampl e frequency (Nyqui st
frequency). Smal l er val ues of passband ri ppl e Rp and l arger val ues of stopband
attenuati on Rs both l ead to wi der transi ti on wi dths (shal l ower rol l off
characteri sti cs).
I f Wn i s a two-el ement vector, Wn = [w1 w2], ellip returns an order 2*n
bandpass fi l ter wi th passband w1 < < w2.
[b,a] = ellip(n,Rp,Rs,Wn,'ftype') desi gns a hi ghpass or bandstop fi l ter,
where ftype i s:
H z ( )
B z ( )
A z ( )
-----------
b 1 ( ) b 2 ( )z
1
L b n 1 + ( )z
n
+ + +
1 a 2 ( )z
1
L a n 1 + ( )z
n
+ + +
--------------------------------------------------------------------------------- = =

ellip
6-126
high for a hi ghpass di gi tal fi l ter wi th cutoff frequency Wn
stop for an order 2*n bandstop di gi tal fi l ter i f Wn i s a two-el ement vector,
Wn = [w1 w2]
The stopband i s w1 < < w2.
Wi th di fferent numbers of output arguments, ellip di rectl y obtai ns other
real i zati ons of the fi l ter. To obtai n zero-pol e-gai n form, use three output
arguments:
[z,p,k] = ellip(n,Rp,Rs,Wn) or
[z,p,k] = ellip(n,Rp,Rs,Wn,'ftype') returns the zeros and pol es i n l ength
n col umn vectors z and p and the gai n i n the scal ar k.
To obtai n state-space form, use four output arguments:
[A,B,C,D] = ellip(n,Rp,Rs,Wn) or
[A,B,C,D] = ellip(n,Rp,Rs,Wn,'ftype') where A, B, C, and D are
and u i s the i nput, x i s the state vector, and y i s the output.
Analog Domain
[b,a] = ellip(n,Rp,Rs,Wn,'s') desi gns an order n l owpass anal og el l i pti c
fi l ter wi th cutoff frequency Wn and returns the fi l ter coeffi ci ents i n the l ength
n + 1 row vectors b and a, i n descendi ng powers of s:
The cutoff frequency i s the edge of the passband, at whi ch the magni tude
response of the fi l ter i s Rp dB. For ellip, the cutoff frequency Wn must be
greater than 0.
I f Wn i s a two-el ement vector wi th w1 < w2, then ellip(n,Rp,Rs,Wn,'s')
returns an order 2*n bandpass anal og fi l ter wi th passband w1 < < w2.
x n 1 + [ ] Ax n [ ] Bu n [ ] + =
y n [ ] Cx n [ ] Du n [ ] + =
H s ( )
B s ( )
A s ( )
---------- -
b 1 ( )s
n
b 2 ( )s
n 1
L b n 1 + ( ) + + +
s
n
a 2 ( )s
n 1
L a n 1 + ( ) + + +
---------------------------------------------------------------------------------- = =
ellip
6-127
[b,a] = ellip(n,Rp,Rs,Wn,'ftype','s') desi gns a hi ghpass or bandstop
fi l ter, where ftype i s:
high for a hi ghpass anal og fi l ter wi th cutoff frequency Wn
stop for an order 2*n bandstop anal og fi l ter. Wn i s a two-el ement vector,
[w1 w2], speci fyi ng the stopband w1 < < w2.
Wi th di fferent numbers of output arguments, ellip di rectl y obtai ns other
real i zati ons of the anal og fi l ter. To obtai n zero-pol e-gai n form, use three output
arguments:
[z,p,k] = ellip(n,Rp,Rs,Wn,'s') or
[z,p,k] = ellip(n,Rp,Rs,Wn,'ftype','s') returns the zeros and pol es i n
l ength n or 2*n col umn vectors z and p and the gai n i n the scal ar k.
To obtai n state-space form, use four output arguments:
[A,B,C,D] = ellip(n,Rp,Rs,Wn,'s') or
[A,B,C,D] = ellip(n,Rp,Rs,Wn,'ftype','s') where A, B, C, and D are
and u i s the i nput, x i s the state vector, and y i s the output.
Examples For data sampl ed at 1000 Hz, desi gn a si xth-order l owpass el l i pti c fi l ter wi th a
cutoff frequency of 300 Hz, 3 dB of ri ppl e i n the passband, and 50 dB of
attenuati on i n the stopband:
[b,a] = ellip(6,3,50,300/500);
x

Ax Bu + =
y Cx Du + =
ellip
6-128
The fi l ters frequency response i s
freqz(b,a,512,1000)
title('n=6 Lowpass Elliptic Filter')
0 50 100 150 200 250 300 350 400 450 500
-600
-400
-200
0
200
Frequency (Hertz)
P
h
a
s
e

(
d
e
g
r
e
e
s
)
0 50 100 150 200 250 300 350 400 450 500
-100
-80
-60
-40
-20
0
Frequency (Hertz)
M
a
g
n
i
t
u
d
e

R
e
s
p
o
n
s
e

(
d
B
)
n = 6 Lowpass Elliptic Filter
ellip
6-129
Desi gn a 20th-order bandpass el l i pti c fi l ter wi th a passband from 100 to 200 Hz
and pl ot i ts i mpul se response:
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')
Limitations For hi gh order fi l ters, the state-space form i s the most numeri cal l y accurate,
fol l owed by the zero-pol e-gai n form. The transfer functi on form i s the l east
accurate; numeri cal probl ems can ari se for fi l ter orders as l ow as 15.
Algorithm The desi gn of el l i pti c fi l ters i s the most di ffi cul t and computati onal l y i ntensi ve
of the Butterworth, Chebyshev type I and I I , and el l i pti c desi gns. ellip uses a
fi ve-step al gori thm:
1 I t fi nds the l owpass anal og prototype pol es, zeros, and gai n usi ng the
ellipap functi on.
2 I t converts the pol es, zeros, and gai n i nto state-space form.
3 I t transforms the l owpass fi l ter to a bandpass, hi ghpass, or bandstop fi l ter
wi th the desi red cutoff frequenci es usi ng a state-space transformati on.
0 10 20 30 40 50 60 70 80 90 100
-0.2
-0.15
-0.1
-0.05
0
0.05
0.1
0.15
0.2
Impulse Response of n = 10 Elliptic Filter
ellip
6-130
4 For di gi tal fi l ter desi gn, ellip uses bilinear to convert the anal og fi l ter
i nto a di gi tal fi l ter through a bi l i near transformati on wi th frequency
prewarpi ng. Careful frequency adjustment guarantees that the anal og
fi l ters and the di gi tal fi l ters wi l l have the same frequency response
magni tude at Wn or w1 and w2.
5 I t converts the state-space fi l ter back to transfer functi on or zero-pol e-gai n
form, as requi red.
See Also
besself Bessel anal og fi l ter desi gn.
butter Butterworth anal og and di gi tal fi l ter desi gn.
cheby1 Chebyshev type I fi l ter desi gn (passband ri ppl e).
cheby2 Chebyshev type I I fi l ter desi gn (stopband ri ppl e).
ellipap El l i pti c anal og l owpass fi l ter prototype.
ellipord El l i pti c fi l ter order sel ecti on.
ellipap
6-131
6el l i pap
Purpose El l i pti c anal og l owpass fi l ter prototype.
Syntax [z,p,k] = ellipap(n,Rp,Rs)
Description [z,p,k] = ellipap(n,Rp,Rs) returns the zeros, pol es, and gai n of an order n
el l i pti c anal og l owpass fi l ter prototype, wi th Rp dB of ri ppl e i n the passband,
and a stopband Rs dB down from the peak val ue i n the passband. The zeros and
pol es are returned i n l ength n col umn vectors z and p and the gai n i n scal ar k.
I f n i s odd, z i s l ength n 1. The transfer functi on i s
El l i pti c fi l ters are equi ri ppl e i n both the passband and stopband. They offer
steeper rol l off characteri sti cs than Butterworth and Chebyshev fi l ters, but
they are equi ri ppl e i n both the passband and the stopband. Of the four cl assi cal
fi l ter types, el l i pti c fi l ters usual l y meet a gi ven set of fi l ter performance
speci fi cati ons wi th the l owest fi l ter order.
ellip sets the cutoff frequency of the el l i pti c fi l ter to 1 for a normal i zed
resul t. The cutoff frequency i s the frequency at whi ch the passband ends and
the fi l ter has a magni tude response of 10
-Rp/20
.
Algorithm ellipap uses the al gori thm outl i ned i n [1]. I t empl oys the M-fi l e ellipk to
cal cul ate the compl ete el l i pti c i ntegral of the fi rst ki nd and the M-fi l e ellipj
to cal cul ate Jacobi el l i pti c functi ons.
See Also
References [1] Parks, T.W., and C.S. Burrus. Digital Filter Design. New York: John Wi l ey
& Sons, 1987. Chapter 7.
H s ( )
z s ( )
p s ( )
---------- k
s z 1 ( ) ( ) s z 2 ( ) ( )Ls z n ( ) ( )
s p 1 ( ) ( ) s p 2 ( ) ( )Ls p n ( ) ( )
----------------------------------------------------------------------------- = =

0
besselap Bessel anal og l owpass fi l ter prototype.
buttap Butterworth anal og l owpass fi l ter prototype.
cheb1ap Chebyshev type I anal og l owpass fi l ter prototype.
cheb2ap Chebyshev type I I anal og l owpass fi l ter prototype.
ellip El l i pti c (Cauer) fi l ter desi gn.
ellipord
6-132
6el l i pord
Purpose El l i pti c fi l ter order sel ecti on.
Syntax [n,Wn] = ellipord(Wp,Ws,Rp,Rs)
[n,Wn] = ellipord(Wp,Ws,Rp,Rs,'s')
Description ellipord sel ects the mi ni mum order di gi tal or anal og el l i pti c fi l ter requi red to
meet a set of l owpass fi l ter desi gn speci fi cati ons:
Digital Domain
[n,Wn] = ellipord(Wp,Ws,Rp,Rs) returns the order n of the l owest order
el l i pti c fi l ter that l oses no more than Rp dB i n the passband and has at l east
Rs dB of attenuati on i n the stopband. The passband runs from 0 to Wp and the
stopband extends from Ws to 1, the Nyqui st frequency. ellipord al so returns
Wn, the cutoff frequency that al l ows ellip to achi eve the gi ven speci fi cati ons.
Use ellipord for l owpass, hi ghpass, bandpass, and bandstop fi l ters. For
hi ghpass fi l ters, Wp i s greater than Ws. For bandpass and bandstop fi l ters, Wp
and Ws are two-el ement vectors that speci fy the corner frequenci es at both
edges of the fi l ter, l ower frequency edge fi rst. For the band fi l ters, ellipord
returns Wn as a two-el ement row vector for i nput to ellip.
I f fi l ter speci fi cati ons cal l for a bandpass or bandstop fi l ter wi th unequal ri ppl e
i n each of the passbands or stopbands, desi gn the fi l ter as separate l owpass and
hi ghpass secti ons and cascade the two fi l ters together.
Wp Passband corner frequency. Wp, the cutoff frequency, has a val ue
between 0 and 1, where 1 corresponds to hal f the sampl i ng
frequency (the Nyqui st frequency).
Ws Stopband corner frequency. Ws i s i n the same uni ts as Wp; i t has a
val ue between 0 and 1, where 1 corresponds to hal f the sampl i ng
frequency (the Nyqui st frequency).
Rp Passband ri ppl e, i n deci bel s. Thi s val ue i s the maxi mum
permi ssi bl e passband l oss i n deci bel s. The passband i s 0 < w < Wp.
Rs Stopband attenuati on, i n deci bel s. Thi s val ue i s the number of
deci bel s the stopband i s down from the passband. The stopband
i s Ws < w < 1.
ellipord
6-133
Analog Domain
[n,Wn] = ellipord(Wp,Ws,Rp,Rs,'s') fi nds the mi ni mum order n and cutoff
frequenci es Wn for an anal og fi l ter. I n thi s case the frequenci es i n Wp and Ws are
i n radi ans per second and may be greater than 1.
Use ellipord for l owpass, hi ghpass, bandpass, and bandstop fi l ters as
descri bed under Di gi tal Domai n.
ellipord
6-134
Examples For 1000 Hz data, desi gn a l owpass fi l ter wi th l ess than 3 dB of attenuati on
from 0 to 100 Hz and at l east 15 dB of attenuati on from 150 Hz to the Nyqui st
frequency:
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')
0 50 100 150 200 250 300 350 400 450 500
-200
-150
-100
-50
0
50
Frequency (Hertz)
P
h
a
s
e

(
d
e
g
r
e
e
s
)
0 50 100 150 200 250 300 350 400 450 500
-80
-60
-40
-20
0
Frequency (Hertz)
M
a
g
n
i
t
u
d
e

R
e
s
p
o
n
s
e

(
d
B
)
n = 2 Elliptic Lowpass Filter
ellipord
6-135
Now desi gn a bandpass fi l ter wi th a passband from 90 Hz to 200 Hz, l ess than
3 dB of ri ppl e throughout the passband, and 30 dB stopbands 50 Hz out on both
si des of the passband:
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')
Algorithm ellipord uses the el l i pti c l owpass fi l ter order predi cti on formul a descri bed i n
[1]. The functi on performs i ts cal cul ati ons i n the anal og domai n for both the
anal og and di gi tal cases. For the di gi tal case, i t converts the frequency
0 50 100 150 200 250 300 350 400 450 500
-400
-200
0
200
400
Frequency (Hertz)
P
h
a
s
e

(
d
e
g
r
e
e
s
)
0 50 100 150 200 250 300 350 400 450 500
-300
-200
-100
0
Frequency (Hertz)
M
a
g
n
i
t
u
d
e

R
e
s
p
o
n
s
e

(
d
B
)
n = 3 Elliptic Bandpass Filter
ellipord
6-136
parameters to the s-domai n before the order and natural frequency esti mati on
process, then converts them back to the z-domai n.
ellipord i ni ti al l y devel ops a l owpass fi l ter prototype by transformi ng the
passband frequenci es of the desi red fi l ter to 1 rad/sec (for l ow- and hi ghpass
fi l ters) and to -1 and 1 rad/sec (for bandpass and bandstop fi l ters). I t then
computes the mi ni mum order requi red for a l owpass fi l ter to meet the stopband
speci fi cati on.
See Also
References [1] Rabi ner, L.R., and B. Gol d. Theory and Application of Digital Signal
Processing. Engl ewood Cl i ffs, NJ: Prenti ce-Hal l , 1975. Pg. 241.
buttord Butterworth fi l ter order sel ecti on.
cheb1ord Chebyshev type I fi l ter order sel ecti on.
cheb2ord Chebyshev type I I fi l ter or der sel ecti on.
ellip El l i pti c (Cauer) fi l ter desi gn.
fft
6-137
6fft
Purpose One-di mensi onal fast Fouri er transform.
Syntax y = fft(x)
y = fft(x,n)
Description fft computes the di screte Fouri er transform of a vector or matri x. Thi s
functi on i mpl ements the transform gi ven by
where W
N
= e
-j(2/N)
and N = length(x). Note that the seri es i s i ndexed as
n + 1 and k + 1 i nstead of the usual n and k because MATLAB vectors run from
1 to N i nstead of from 0 to N-1.
y = fft(x) i s the di screte Fouri er transform of vector x, computed wi th a fast
Fouri er transform (FFT)al gori thm. I f x i s a matri x, y i s the FFTof each col umn
of the matr i x. The fft functi on empl oys a radi x-2 fast Fouri er transform
al gori thm i f the l ength of the sequence i s a power of two, and a sl ower
al gori thm i f i t i s not; see the Al gori thm secti on for detai l s.
y = fft(x,n) i s the n-poi nt FFT. I f the l ength of x i s l ess than n, fft pads x
wi th trai l i ng zeros to l ength n. I f the l ength of x i s greater than n, fft truncates
the sequence x. I f x i s an array, fft adjusts the l ength of the col umns i n the
same manner.
The fft functi on i s part of the standard MATLAB l anguage.
Example A common use of the Fouri er transform i s to fi nd the frequency components of
a ti me-domai n si gnal buri ed i n noi se. Consi der data sampl ed at 1000 Hz. Form
X k 1 + ( ) x n 1 + ( )W
n
kn
n 0 =
N 1

=
fft
6-138
a si gnal consi sti ng of 50 Hz and 120 Hz si nusoi ds and corrupt the si gnal wi th
zero-mean random noi se:
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))
I t i s di ffi cul t to i denti fy the frequency components by studyi ng the ori gi nal
si gnal . Convert to the frequency domai n by taki ng the di screte Fouri er
transform of the noi sy si gnal y usi ng a 512-poi nt fast Fouri er transform (FFT):
Y = fft(y,512);
The power spectral densi ty, a measurement of the energy at vari ous
frequenci es, i s
Pyy = Y.*conj(Y) / 512;
0 5 10 15 20 25 30 35 40 45 50
-6
-5
-4
-3
-2
-1
0
1
2
3
4
fft
6-139
Graph the fi rst 256 poi nts (the other 256 poi nts are symmetri c) on a
meani ngful frequency axi s:
f = 1000*(0:255)/512;
plot(f,Pyy(1:256))
See the pwelch functi on for detai l s on cal cul ati ng spectral densi ty.
Someti mes i t i s useful to normal i ze the output of fft so that a uni t si nusoi d i n
the ti me domai n corresponds to uni t ampl i tude i n the frequency domai n. To
produce a normal i zed di screte-ti me Fouri er transform i n thi s manner, use
Pn = abs(fft(x))*2/length(x)
Algorithm fft i s a bui l t-i n MATLAB functi on. When the sequence l ength i s a power of
two, fft uses a hi gh-speed radi x-2 fast Fouri er transform al gori thm. The
radi x-2 FFTrouti ne i s opti mi zed to perform a real FFTi f the i nput sequence i s
purel y real ; otherwi se i t computes the compl ex FFT. Thi s causes a real
power-of-two FFT to be about 40% faster than a compl ex FFT of the same
l ength.
When the sequence l ength i s not an exact power of two, a separate al gori thm
fi nds the pri me factors of the sequence l ength and computes the mi xed-radi x
di screte Fouri er transforms of the shorter sequences.
0 100 200 300 400 500
0
10
20
30
40
50
60
70
fft
6-140
The executi on ti me for fft depends on the sequence l ength. I f the l ength of a
sequence has many pri me factors, the functi on computes the FFT qui ckl y; i f
the l ength has few pri me factors, executi on i s sl ower. For sequences whose
l engths are pri me numbers, fft uses the raw (and sl ow) DFT al gori thm. For
thi s reason i t i s usual l y better to use power-of-two FFTs, i f thi s i s supported by
your appl i cati on. For exampl e, on one machi ne a 4096-poi nt real FFTtakes 2.1
seconds and a compl ex FFTof the same l ength takes 3.7 seconds. The FFTs of
nei ghbori ng sequences of l ength 4095 and 4097, however, take 7 seconds and
58 seconds, respecti vel y.
Suppose a sequence xof N poi nts i s obtai ned at a sampl e frequency of . Then,
for up to the Nyqui st frequency, or poi nt n =N/ 2 +1, the rel ati onshi p between
the actual frequency and the i ndex k i nto x (out of N possi bl e i ndi ces) i s
See Also
f
s
f k 1 ( ) f
s
N =
dct Di screte cosi ne transform (DCT).
dftmtx Di screte Fouri er transform matri x.
fft2 Two-di mensi onal fast Fouri er transform.
fftshift Rearrange the outputs of fft and fft2.
filter Fi l ter data wi th a recursi ve (I I R) or nonrecursi ve
(FI R) fi l ter.
freqz Frequency response of di gi tal fi l ters.
ifft One-di mensi onal i nverse fast Fouri er transform.
pwelch Esti mate the power spectral densi ty (PSD) of a si gnal
usi ng Wel chs method.
fft2
6-141
6fft2
Purpose Two-di mensi onal fast Fouri er transform.
Syntax Y = fft2(X)
Y = fft2(X,m,n)
Description Y = fft2(X) performs a two-di mensi onal FFT, produci ng a resul t Y the same
si ze as X. I f X i s a vector, Y has the same ori entati on as X.
Y = fft2(X,m,n) truncates or zero pads X, i f necessary, to create an m-by-n
array before performi ng the FFT. The resul t Y i s al so m-by-n.
The fft2 functi on i s part of the standard MATLAB l anguage.
Algorithm fft2(x) i s si mpl y
fft(fft(x).').'
Thi s computes the one-di mensi onal fft of each col umn of x, then of each row
of the resul t. The ti me requi red to compute fft2(x) depends on the number of
pri me factors i n [m,n] = size(x). fft2 i s fastest when m and n are powers of 2.
See Also
fft One-di mensi onal fast Fouri er transform.
fftshift Rearrange the outputs of fft and fft2.
ifft One-di mensi onal i nverse fast Fouri er transform.
ifft2 Two-di mensi onal i nverse fast Fouri er transform.
fftfilt
6-142
6fftfi l t
Purpose FFT-based FI R fi l teri ng usi ng the overl ap-add method.
Syntax y = fftfilt(b,x)
y = fftfilt(b,x,n)
Description fftfilt fi l ters data usi ng the effi ci ent FFT-based method of overlap-add, a
frequency domai n fi l teri ng techni que that works onl y for FI R fi l ters.
y = fftfilt(b,x) fi l ters the data i n vector x wi th the fi l ter descri bed by
coeffi ci ent vector b. I t returns the data vector y. The operati on performed by
fftfilt i s descri bed i n the timedomain by the di fference equati on
An equi val ent representati on i s the z-transform or frequencydomaindescri pti on
By defaul t, fftfilt chooses an FFT l ength and data bl ock l ength that
guarantee effi ci ent executi on ti me.
y = fftfilt(b,x,n) uses an FFTl ength of nfft = 2^nextpow2(n) and a data
bl ock l ength of nfft length(b) + 1.
fftfilt works for both real and compl ex i nputs.
Example Show that the resul ts from fftfilt and filter are i denti cal :
b = [1 2 3 4];
x = [1 zeros(1,99)]';
norm(fftfilt(b,x) filter(b,1,x))
ans =
9.5914e15
Algorithm fftfilt uses fft to i mpl ement the overlap-add method [1], a techni que that
combi nes successi ve frequency domai n fi l tered bl ocks of an i nput sequence.
fftfilt breaks an i nput sequence x i nto l ength L data bl ocks:
y n ( ) b 1 ( )x n ( ) b 2 ( )x n 1 ( ) L b nb 1 + ( )x n nb ( ) + + + =
Y z ( ) b 1 ( ) b 2 ( )z
1
L b nb 1 + ( )z
nb
+ + + ( )X z ( ) =
x
L 2L 3L ceil(nx/L)*L
. . .
fftfilt
6-143
and convol ves each bl ock wi th the fi l ter b by
y = ifft(fft(x(i:i+L1),nfft).*fft(b,nfft));
where nfft i s the FFT l ength. fftfilt overl aps successi ve output secti ons by
nb1 poi nts, where nb i s the l ength of the fi l ter, and sums them:
fftfilt chooses the key parameters L and nfft i n di fferent ways, dependi ng
on whether you suppl y an FFT l ength n and on the l engths of the fi l ter and
si gnal . I f you do not speci fy a val ue for n (whi ch determi nes FFT l ength),
fftfilt chooses these key parameters automati cal l y:
I f length(x) > length(b), fftfilt chooses val ues that mi ni mi ze the
number of bl ocks ti mes the number of fl ops per FFT.
I f length(b) >= length(x), fftfilt uses a si ngl e FFT of l ength
2^nextpow2(length(b) + length(x) 1)
Thi s essenti al l y computes
y = ifft(fft(B,nfft).*fft(X,nfft))
I f you suppl y a val ue for n, fftfilt chooses an FFT l ength, nfft, of
2^nextpow2(n)and a data bl ock l ength of nfft length(b) + 1. I f n i s l ess
than length(b), fftfilt sets n to length(b).
See Also
References [1] Oppenhei m, A.V., and R.W. Schafer. Discrete-TimeSignal Processing.
Engl ewood Cl i ffs, NJ: Prenti ce Hal l , 1989.
nb1
L
nb1 2L
nb1 3L
. . .
conv Convol uti on and pol ynomi al mul ti pl i cati on.
filter Fi l ter data wi th a recursi ve (I I R) or nonrecursi ve
(FI R) fi l ter.
filtfilt Zero-phase di gi tal fi l teri ng.
fftshift
6-144
6fftshi ft
Purpose Rearrange the outputs of the FFT functi ons.
Syntax y = fftshift(x)
Description y = fftshift(x) rearranges the outputs of fft and fft2 by movi ng the zero
frequency component to the center of the spectrum, whi ch i s someti mes a more
conveni ent form.
For vectors, fftshift(x) returns a vector wi th the l eft and ri ght hal ves
swapped.
For arrays, fftshift(x) swaps quadrants one and three wi th quadrants two
and four.
The fftshift functi on i s part of the standard MATLAB l anguage.
Example For any array X,
Y = fft2(x)
has Y(1,1) = sum(sum(X)); the DC component of the si gnal i s i n the upper-l eft
corner of the two-di mensi onal FFT. For
Z = fftshift(Y)
the DC component i s near the center of the matri x.
See Also
fft One-di mensi onal fast Fouri er transform.
fft2 Two-di mensi onal fast Fouri er transform.
filter
6-145
6fi l ter
Purpose Fi l ter data wi th a recursi ve (I I R) or nonrecursi ve (FI R) fi l ter.
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 fi l ters real or compl ex data usi ng a di gi tal fi l ter. The fi l ter real i zati on
i s the transposed direct formI I structure [1], whi ch can handl e both FI R and
I I R fi l ters.
I f a(1) 1, filter normal i zes the fi l ter coeffi ci ents by a(1). I f a(1) =0, the i nput
i s i n error.
y = filter(b,a,x) fi l ters the data i n vector x wi th the fi l ter descri bed by
coeffi ci ent vectors a and b to create the fi l tered data vector y. When x i s a
matri x, fi l ter operates on the col umns of x. When x i s an N-di mensi onal array,
fi l ter operates on the fi rst non-si ngl eton di mensi on.
[y,zf] = filter(b,a,x) returns the fi nal val ues of the states i n the vector
zf.
[...] = filter(b,a,x,zi) speci fi es i ni ti al state condi ti ons i n the vector zi.
The si ze of the i ni ti al /fi nal condi ti on vector i s max(length(b),length(a))1.
zi or zf can al so be an array of such vectors, one for each col umn of x i f x i s a
matri x. I f x i s a mul ti di mensi onal array, filter works across the fi rst
nonsi ngl eton di mensi on of x by defaul t.
[...] = filter(b,a,x,zi,dim) works across the di mensi on dim of x. Set zi
to empty to get the defaul t i ni ti al condi ti ons.
The filter functi on i s part of the standard MATLAB l anguage.
filter
6-146
Example Fi nd and graph the 100-poi nt uni t i mpul se response of a di gi tal fi l ter:
x = [1 zeros(1,100)];
[b,a] = butter(12,400/1000);
y = filter(b,a,x);
stem(y)
Algorithm filter i s i mpl emented as a transposed di rect form I I structure
where n-1 i s the fi l ter order.
0 20 40 60 80 100 120
-0.2
-0.1
0
0.1
0.2
0.3
0.4
z
-1
z
-1
x(m)
y(m)
b( 3) b( 2) b(1)
a( 3) a( 2)
z
1
(m) z
2
(m)
z
-1
b(n)
a(n)
z
n-1
(m)
...
...
...
filter
6-147
The oper ati on of filter at sampl e mi s gi ven by the ti me domai n di fference
equati ons for yand the states z
i
:
You can use filtic to generate the state vector z
i
(0) from past i nputs and
outputs.
The i nput-output descri pti on of thi s fi l teri ng operati on i n the z-transform
domai n i s a rati onal transfer functi on:
Diagnostics I f a(1) = 0, filter gi ves the fol l owi ng error message:
First denominator coefficient must be nonzero.
I f the l ength of the i ni ti al condi ti on vector i s not the greater of na and nb,
filter gi ves the fol l owi ng error message:
Initial condition vector has incorrect dimensions.
See Also
References [1] Oppenhei m, A.V., and R.W. Schafer. Discrete-TimeSignal Processing.
Engl ewood Cl i ffs, NJ: Prenti ce Hal l , 1989. Pgs. 311-312.
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 =
z
n 2
m ( ) b n 1 ( )x m ( ) z
n 1
m 1 ( ) a n 1 ( )y m ( ) + =
z
n 1
m ( ) b n ( )x m ( ) a n ( )y m ( ) =
Y z ( )
b 1 ( ) b 2 ( )z
1
L b nb 1 + ( )z
nb
+ + +
a 1 ( ) a 2 ( )z
1
L a na 1 + ( )z
na
+ + +
---------------------------------------------------------------------------------------- -X z ( ) =
fftfilt FFT-based FI R fi l teri ng usi ng the overl ap-add
method.
filter2 Two-di mensi onal di gi tal fi l teri ng.
filtfilt Zero-phase di gi tal fi l teri ng.
filtic Make i ni ti al condi ti ons for filter functi on.
filter2
6-148
6fi l ter 2
Purpose Two-di mensi onal di gi tal fi l teri ng.
Syntax Y = filter2(B,X)
Y = filter2(B,X,'shape')
Description Y = filter2(B,X) fi l ters the two-di mensi onal data i n X wi th the
two-di mensi onal FI R fi l ter i n the matri x B. The resul t, Y, i s computed usi ng
two-di mensi onal convol uti on and i s the same si ze as X.
Y = filter2(B,X,'shape') returns Y computed wi th si ze speci fi ed by shape:
same returns the central part of the convol uti on that i s the same si ze as X
(defaul t).
full returns the ful l two-di mensi onal convol uti on, size(Y) > size(X).
valid returns onl y those parts of the convol uti on that are computed wi thout
the zero-padded edges, size(Y) < size(X).
The filter2 functi on i s part of the standard MATLAB l anguage.
Algorithm The filter2 functi on uses conv2 to compute the ful l two-di mensi onal
convol uti on of the FI R fi l ter wi th the i nput matri x. By defaul t, filter2
extracts and returns the central part of the convol uti on that i s the same si ze as
the i nput matri x. Use the shape parameter to speci fy an al ternate part of the
convol uti on for return.
See Also
conv2 Two-di mensi onal convol uti on.
filter Fi l ter data wi th a recursi ve (I I R) or nonrecursi ve
(FI R) fi l ter.
filtfilt
6-149
6fi l tfi l t
Purpose Zero-phase di gi tal fi l teri ng.
Syntax y = filtfilt(b,a,x)
Description y = filtfilt(b,a,x) performs zero-phase di gi tal fi l teri ng by processi ng the
i nput data i n both the forward and reverse di recti ons (see probl em 5.39 i n [1]).
After fi l teri ng i n the forward di recti on, i t reverses the fi l tered sequence and
runs i t back through the fi l ter. The resul ti ng sequence has preci sel y zero-phase
di storti on and doubl e the fi l ter order. filtfilt mi ni mi zes start-up and endi ng
transi ents by matchi ng i ni ti al condi ti ons, and works for both real and compl ex
i nputs.
Note that filtfilt shoul d not be used wi th di fferenti ator and Hi l bert FI R
fi l ters, si nce the operati on of these fi l ters depends heavi l y on thei r phase
response.
Algorithm filtfilt i s an M-fi l e that uses the filter functi on. I n addi ti on to the
forward-reverse fi l teri ng, i t attempts to mi ni mi ze startup transi ents by
adjusti ng i ni ti al condi ti ons to match the DC component of the si gnal and by
prependi ng several fi l ter l engths of a fl i pped, refl ected copy of the i nput si gnal .
See Also
References [1] Oppenhei m, A.V., and R.W. Schafer. Discrete-TimeSignal Processing.
Engl ewood Cl i ffs, NJ: Prenti ce Hal l , 1989. Pgs. 311-312.
fftfilt FFT-based FI R fi l teri ng usi ng the overl ap-add
method.
filter Fi l ter data wi th a recursi ve (I I R) or nonrecursi ve
(FI R) fi l ter.
filter2 Two-di mensi onal di gi tal fi l teri ng.
filtic
6-150
6fi l ti c
Purpose Fi nd i ni ti al condi ti ons for a transposed di rect form I I fi l ter i mpl ementati on.
Syntax z = filtic(b,a,y,x)
z = filtic(b,a,y)
Description z = filtic(b,a,y,x) fi nds the i ni ti al condi ti ons z for the del ays i n the
transposeddirect formI I fi l ter i mpl ementati on gi ven past outputs y and i nputs
x. The vectors b and a represent the numerator and denomi nator coeffi ci ents,
respecti vel y, of the fi l ters transfer functi on.
The vectors x and y contai n the most recent i nput or output fi rst, and ol dest
i nput or output l ast:
where nb i s length(b)1 (the numerator order) and na i s length(a)1 (the
denomi nator order). I f length(x) i s l ess than nb, filtic pads i t wi th zeros to
l ength nb; i f length(y) i s l ess than na, filtic pads i t wi th zeros to l ength na.
El ements of x beyond x(nb1) and el ements of y beyond y(na1) are
unnecessary so filtic i gnores them.
Output z i s a col umn vector of l ength equal to the l arger of nb and na.
z descri bes the state of the del ays gi ven past i nputs x and past outputs y.
z = filtic(b,a,y) assumes that the i nput x i s 0 i n the past.
The transposed di rect form I I structure i s
where n-1 i s the fi l ter order.
filtic works for both real and compl ex i nputs.
x x 1 ( ) x 2 ( ) x 3 ( ) x nb ( ) , , , , , { } =
y y 1 ( ) y 2 ( ) y 3 ( ) y n a ( ) , , , , , { } =
z
-1
z
-1
x(m)
y(m)
b( 3) b( 2) b(1)
a( 3) a( 2)
z
1
(m) z
2
(m)
z
-1
b(n)
a(n)
z
n-1
(m)
...
...
...
filtic
6-151
Algorithm filtic performs a reverse di fference equati on to obtai n the del ay states z.
Diagnostics I f any of the i nput arguments y, x, b, or a i s not a vector (that i s, i f any
argument i s a scal ar or array), filtic gi ves the fol l owi ng er r or message:
Requires vector inputs.
See Also
References [1] Oppenhei m, A.V., and R.W. Schafer. Discrete-TimeSignal Processing.
Engl ewood Cl i ffs, NJ: Prenti ce Hal l , 1989. Pgs. 296, 301-302.
filter Fi l ter data wi th a recursi ve (I I R) or nonrecursi ve
(FI R) fi l ter.
filtfilt Zero-phase di gi tal fi l teri ng.
fir1
6-152
6fi r 1
Purpose Wi ndow-based fi ni te i mpul se response fi l ter desi gn standard response.
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 i mpl ements the cl assi cal method of wi ndowed l i near -phase FI R di gi tal
fi l ter desi gn [1]. I t desi gns fi l ters i n standard l owpass, bandpass, hi ghpass, and
bandpass confi gurati ons. (For wi ndowed fi l ters wi th arbi trary frequency
response, use fir2.)
b = fir1(n,Wn) returns row vector b contai ni ng the n+1 coeffi ci ents of an
order n l owpass FI R fi l ter. Thi s i s a Hammi ng-wi ndowed, l i near-phase fi l ter
wi th cutoff frequency Wn. The output fi l ter coeffi ci ents, b, are ordered i n
descendi ng powers of z:
Wn, the cutoff frequency, i s a number between 0 and 1, where 1 corresponds to
hal f the sampl i ng frequency (the Nyqui st frequency).
I f Wn i s a two-el ement vector, Wn = [w1 w2], fir1 returns a bandpass fi l ter wi th
passband w1 < < w2.
I f Wn i s a mul ti -el ement vector, Wn = [w1 w2 w3 w4 w5 ... wn], fir1 returns
an order n mul ti band fi l ter wi th bands 0 < < w1, w1 < < w2, ..., wn < < 1.
By defaul t, the fi l ter i s scal ed so that the center of the fi rst passband has
magni tude exactl y 1 after wi ndowi ng.
b = fir1(n,Wn,'ftype') speci fi es a fi l ter type, where ftype i s
high for a hi ghpass fi l ter wi th cutoff frequency Wn
stop for a bandstop fi l ter, i f Wn = [w1 w2]
The stopband i s w1 < < w2.
'DC-1' to make the fi rst band of a mul ti band fi l ter a passband
'DC-0' to make the fi rst band of a mul ti band fi l ter a stopband
B z ( ) b 1 ( ) b 2 ( )z
1
L b n 1 + ( )z
n
+ + + =
fir1
6-153
fir1 al ways uses an even fi l ter order for the hi ghpass and bandstop
confi gurati ons. Thi s i s because for odd orders, the frequency response at the
Nyqui st frequency i s 0, whi ch i s i nappropri ate for hi ghpass and bandstop
fi l ters. I f you speci fy an odd-val ued n, fir1 i ncrements i t by 1.
b = fir1(n,Wn,window) uses the wi ndow speci fi ed i n col umn vector window
for the desi gn. The vector window must be n+1 el ements l ong. I f no wi ndow i s
speci fi ed, fir1 empl oys a Hammi ng wi ndow.
b = fir1(n,Wn,'ftype',window) accepts both ftype and window parameters.
b = fir1(...,'noscale') turns off the defaul t scal i ng.
The group del ay of the FI R fi l ter desi gned by fir1 i s n/2.
Algorithm fir1 uses the wi ndow method of FI R fi l ter desi gn [1]. I f w(n) denotes a wi ndow,
where 1 n N, and the i mpul se response of the i deal fi l ter i s h(n), where
h(n) i s the i nverse Fouri er transform of the i deal frequency response, then the
wi ndowed di gi tal fi l ter coeffi ci ents are gi ven by
b n ( ) w n ( )h n ( ) 1 n N , =
fir1
6-154
Examples Example 1
Desi gn a 48th-order FI R bandpass fi l ter wi th passband 0.35 w 0.65:
b = fir1(48,[0.35 0.65]);
freqz(b,1,512)
Example 2
The chirp.mat fi l e contai ns a si gnal , y, that has most of i ts power above Fs/4,
or hal f the Nyqui st frequency. Desi gn a 34th-order FI R hi ghpass fi l ter to
attenuate the components of the si gnal bel ow Fs/4. Use a cutoff frequency of
0.48 and a Chebyshev wi ndow wi th 30 dB of ri ppl e:
load chirp % loads y and Fs
b = fir1(34,0.48,'high',chebwin(35,30));
yfilt = filter(b,1,y);
0 0.2 0.4 0.6 0.8 1
2500
2000
1500
1000
500
0
Normalized Angular Frequency ( rads/sample)
P
h
a
s
e

(
d
e
g
r
e
e
s
)
0 0.2 0.4 0.6 0.8 1
100
50
0
50
Normalized Angular Frequency ( rads/sample)
M
a
g
n
i
t
u
d
e

(
d
B
)
fir1
6-155
Check the spectra of the ori gi nal and fi l tered si gnal s.
[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')
Pl ay the two si gnal s usi ng sound.
sound(y,Fs);
sound(yfilt,Fs);
Diagnostics I f n i s odd and you speci fy a bandstop or hi ghpass fi l ter, fir1 gi ves the
fol l owi ng warni ng message:
For highpass and bandstop filters, N must be even.
Order is being increased by 1.
0 500 1000 1500 2000 2500 3000 3500 4000 4500
140
130
120
110
100
90
80
70
60
50
40
M
a
g
n
i
t
u
d
e

(
d
B
)
Frequency (Hz)
Chirp
Filtered Chirp
fir1
6-156
See Also
References [1] I EEE. Programsfor Digital Signal Processing. I EEE Press. New York: John
Wi l ey & Sons, 1979. Al gori thm 5.2.
filter Fi l ter data wi th a recursi ve (I I R) or nonrecursi ve
(FI R) fi l ter.
fir2 Wi ndow-based fi ni te i mpul se response fi l ter
desi gnarbi trary response.
fircls Constrai ned l east square FI R fi l ter desi gn for
mul ti band fi l ters.
fircls1 Constrai ned l east square fi l ter desi gn for l owpass
and hi ghpass l i near phase FI R fi l ters.
firls Least square l i near-phase FI R fi l ter desi gn.
freqz Frequency response of di gi tal fi l ters.
kaiserord Esti mate parameters for fir1 wi th Kai ser wi ndow.
remez Parks-McCl el l an opti mal FI R fi l ter desi gn.
fir2
6-157
6fi r 2
Purpose Wi ndow-based fi ni te i mpul se response fi l ter desi gn arbi trary response.
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 desi gns wi ndowed di gi tal FI R fi l ters wi th arbi trari l y shaped frequency
response. (For standard l owpass, bandpass, hi ghpass, and bandstop
confi gurati ons, use fir1.)
b = fir2(n,f,m) returns row vector b contai ni ng the n+1 coeffi ci ents of an
order n FI R fi l ter. The frequency-magni tude characteri sti cs of thi s fi l ter match
those gi ven by vectors f and m:
f i s a vector of frequency poi nts i n the range from 0 to 1, where 1 corresponds
to hal f the sampl i ng frequency (the Nyqui st frequency). The fi rst poi nt of f
must be 0 and the l ast poi nt 1. The frequency poi nts must be i n i ncreasi ng
order.
m i s a vector contai ni ng the desi red magni tude response at the poi nts
speci fi ed i n f.
f and m must be the same l ength.
Dupl i cate frequency poi nts are al l owed, correspondi ng to steps i n the
frequency response.
Use plot(f,m) to vi ew the fi l ter shape.
The output fi l ter coeffi ci ents, b, are ordered i n descendi ng powers of z:
b = fir2(n,f,m,window) uses the wi ndow speci fi ed i n col umn vector window
for the fi l ter desi gn. The vector window must be n+1 el ements l ong. I f no wi ndow
i s speci fi ed, fir2 empl oys a Hammi ng wi ndow.
b z ( ) b 1 ( ) b 2 ( )z
1
L b n 1 + ( )z
n
+ + + =
fir2
6-158
b = fir2(n,f,m,npt) and
b = fir2(n,f,m,npt, window) speci fy the number of poi nts npt for the gri d
onto whi ch fir2 i nterpol ates the frequency response, wi th or wi thout a window
speci fi cati on.
b = fir2(n,f,m,npt,lap) and
b = fir2(n,f,m,npt,lap,window) speci fy the si ze of the regi on, lap, that
fir2 i nserts around dupl i cate frequency poi nts, wi th or wi thout a window
speci fi cati on.
See the Al gori thm secti on for more on npt and lap.
Algorithm The desi red frequency response i s i nterpol ated onto a dense, evenl y spaced gri d
of l ength npt. npt i s 512 by defaul t. I f two successi ve val ues of f are the same,
a regi on of lap poi nts i s set up around thi s frequency to provi de a smooth but
steep transi ti on i n the requested frequency response. By defaul t, lap i s 25. The
fi l ter coeffi ci ents are obtai ned by appl yi ng an i nverse fast Fouri er transform to
the gri d and mul ti pl yi ng by a wi ndow; by defaul t, thi s i s a Hammi ng wi ndow.
fir2
6-159
Example Desi gn a 30th-order l owpass fi l ter and overpl ot the desi red frequency response
wi th the actual frequency response:
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))
See Also
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
0
0.2
0.4
0.6
0.8
1
1.2
butter Butterworth anal og and di gi tal fi l ter desi gn.
cheby1 Chebyshev type I fi l ter desi gn (passband ri ppl e).
cheby2 Chebyshev type I I fi l ter desi gn (stopband ri ppl e).
ellip El l i pti c (Cauer) fi l ter desi gn.
fir1 Wi ndow-based fi ni te i mpul se response fi l ter desi gn
standard response.
maxflat General i zed di gi tal Butterworth fi l ter desi gn.
remez Parks-McCl el l an opti mal FI R fi l ter desi gn.
yulewalk Recursi ve di gi tal fi l ter desi gn.
fircls
6-160
6fi r cl s
Purpose Constrai ned l east square FI R fi l ter desi gn for mul ti band fi l ters.
Syntax b = fircls(n,f,amp,up,lo)
fircls(n,f,amp,up,lo,'design_flag')
Description b = fircls(n,f,amp,up,lo) generates a l ength n+1 l i near phase FI R fi l ter b.
The frequency-magni tude characteri sti cs of thi s fi l ter match those gi ven by
vectors f and amp:
f i s a vector of transi ti on frequenci es i n the range from 0 to 1, where 1
corresponds to hal f the sampl i ng frequency (the Nyqui st frequency). The fi rst
poi nt of f must be 0 and the l ast poi nt 1. The frequency poi nts must be i n
i ncreasi ng order.
amp i s a vector descri bi ng the pi ecewi se constant desi red ampl i tude of the
frequency response. The l ength of amp i s equal to the number of bands i n the
response and shoul d be equal to length(f)1.
up and lo are vectors wi th the same l ength as amp. They defi ne the upper and
l ower bounds for the frequency response i n each band.
fircls(n,f,amp,up,lo,'design_flag') enabl es you to moni tor the fi l ter
desi gn, where design_flag can be:
trace, for a textual di spl ay of the desi gn er r or at each i ter ati on step.
plots, for a col l ecti on of pl ots showi ng the fi l ters ful l -band magni tude
response and a zoomed vi ew of the magni tude response i n each sub-band. Al l
pl ots are updated at each i terati on step.
both, for both the textual di spl ay and pl ots.
fircls
6-161
Example Desi gn an order 50 bandpass fi l ter:
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
NOTE Normal l y, the l ower val ue i n the stopband wi l l be speci fi ed as
negati ve. By setti ng lo equal to 0 i n the stopbands, a nonnegati ve frequency
response ampl i tude can be obtai ned. Such fi l ters can be spectral l y factored to
obtai n mi ni mum phase fi l ters.
Algorithm The al gori thm i s a mul ti pl e exchange al gori thm that uses Lagrange
mul ti pl i ers and Kuhn-Tucker condi ti ons on each i terati on.
0 0.2 0.4 0.6 0.8 1 1.2 1.4
-2
0
2
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4
-0.02
0
0.02
B
a
n
d

#
1
0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8
0.98
1
1.02
B
a
n
d

#
2
0.8 0.85 0.9 0.95 1
-0.01
0
0.01
B
a
n
d

#
3
Frequency
fircls
6-162
See Also
References [1] Sel esni ck, I .W., M. Lang, and C.S. Burrus. Constrai ned Least Square
Desi gn of FI R Fi l ters wi thout Speci fi ed Transi ti on Bands. Proceedings of the
I EEE I nt. Conf. Acoust., Speech, Signal Processing. Vol . 2 (May 1995).
Pgs. 1260-1263.
[2] Sel esni ck, I .W., M. Lang, and C.S. Burrus. Constrai ned Least Square
Desi gn of FI R Fi l ters wi thout Speci fi ed Transi ti on Bands. I EEE Transactions
on Signal Processing, Vol . 44, No. 8 (August 1996).
fircls1 Constrai ned l east square fi l ter desi gn for l owpass
and hi ghpass l i near phase FI R fi l ters.
firls Least square l i near-phase FI R fi l ter desi gn.
remez Parks-McCl el l an opti mal FI R fi l ter desi gn.
fircls1
6-163
6fi r cl s1
Purpose Constrai ned l east square fi l ter desi gn for l owpass and hi ghpass l i near phase
FI R fi l ters.
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) generates a l owpass FI R fi l ter b. n+1 i s the fi l ter
l ength, wo i s the normal i zed cutoff frequency i n the range between 0 and 1
(where 1 corresponds to hal f the sampl i ng frequency, that i s, the Nyqui st
frequency), dp i s the maxi mum passband devi ati on from 1 (passband ri ppl e),
and ds i s the maxi mum stopband devi ati on from 0 (stopband ri ppl e).
b = fircls1(n,wo,dp,ds,'high') generates a hi ghpass FI R fi l ter b.
b = fircls1(n,wo,dp,ds,wt) and
b = fircls1(n,wo,dp,ds,wt,'high') speci fy a frequency wt above whi ch (for
wt>wo) or bel ow whi ch (for wt<wo) the fi l ter i s guaranteed to meet the gi ven
band cri teri on. Thi s wi l l hel p you desi gn a fi l ter that meets a passband or
stopband edge requi rement. There are four cases:
Lowpass:
- 0<wt<wo<1: the ampl i tude of the fi l ter i s wi thi n dp of 1 over the frequency
range 0 < < wt.
- 0<wo<wt<1: the ampl i tude of the fi l ter i s wi thi n ds of 0 over the frequency
range wt < < 1.
Hi ghpass:
- 0<wt<wo<1: the ampl i tude of the fi l ter i s wi thi n ds of 0 over the frequency
range 0 < < wt.
- 0<wo<wt<1: the ampl i tude of the fi l ter i s wi thi n dp of 1 over the frequency
range wt < < 1.

fircls1
6-164
b = fircls1(n,wo,dp,ds,wp,ws,k) generates a l owpass FI R fi l ter b wi th a
wei ghted functi on. n+1 i s the fi l ter l ength, wo i s the normal i zed cutoff frequency,
dp i s the maxi mum passband devi ati on from 1 (passband ri ppl e), and ds i s the
maxi mum stopband devi ati on from 0 (stopband ri ppl e). wp i s the passband edge
of the L2 wei ght functi on and ws i s the stopband edge of the L2 wei ght functi on,
where wp < wo < ws. k i s the rati o (passband L2 error)/(stopband L2 error):
b = fircls1(n,wo,dp,ds,wp,ws,k,'high') generates a hi ghpass FI R fi l ter b
wi th a wei ghted functi on, where ws < wo < wp.
b = fircls1(n,wo,dp,ds,,'design_flag') enabl es you to moni tor the fi l ter
desi gn, where design_flag can be
trace, for a textual di spl ay of the desi gn tabl e used i n the desi gn
plots, for pl ots of the fi l ters magni tude, group del ay, and zeros and pol es
both, for both the textual di spl ay and pl ots
NOTE I n the desi gn of very narrow band fi l ters wi th smal l dp and ds, there
may not exi st a fi l ter of the gi ven l ength that meets the speci fi cati ons.
A ( ) D ( )
2
d
0
w
p

A ( ) D ( )
2
d
w
s

------------------------------------------------------ k =
fircls1
6-165
Example Desi gn an order 55 l owpass fi l ter wi th a cutoff frequency at 0.3:
n = 55; wo = 0.3;
dp = 0.02; ds = 0.008;
b = fircls1(n,wo,dp,ds,'plots'); % plot magnitude response
Algorithm The al gori thm i s a mul ti pl e exchange al gori thm that uses Lagrange
mul ti pl i ers and Kuhn-Tucker condi ti ons on each i terati on.
See Also
References [1] Sel esni ck, I .W., M. Lang, and C.S. Burrus. Constrai ned Least Square
Desi gn of FI R Fi l ters wi thout Speci fi ed Transi ti on Bands. Proceedings of the
I EEE I nt. Conf. Acoust., Speech, Signal Processing. Vol . 2 (May 1995).
Pgs. 1260-1263.
[2] Sel esni ck, I .W., M. Lang, and C.S. Burrus. Constrai ned Least Square
Desi gn of FI R Fi l ters wi thout Speci fi ed Transi ti on Bands. I EEE Transactions
on Signal Processing, Vol . 44, No. 8 (August 1996).
0 0.2 0.4 0.6 0.8 1
0
0.5
1
0 0.05 0.1 0.15 0.2 0.25
-0.04
-0.02
0
0.02
0.04
0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-0.01
0
0.01
fircls Constrai ned l east square FI R fi l ter desi gn for
mul ti band fi l ters.
firls Least square l i near-phase FI R fi l ter desi gn.
remez Parks-McCl el l an opti mal FI R fi l ter desi gn.
firls
6-166
6fi r l s
Purpose Least square l i near-phase FI R fi l ter desi gn.
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 desi gns a l i near-phase FI R fi l ter that mi ni mi zes the wei ghted,
i ntegrated squared error between an i deal pi ecewi se l i near functi on and the
magni tude response of the fi l ter over a set of desi red frequency bands.
b = firls(n,f,a) returns row vector b contai ni ng the n+1 coeffi ci ents of the
order n FI R fi l ter whose frequency-ampl i tude characteri sti cs approxi matel y
match those gi ven by vectors f and a. The output fi l ter coeffi ci ents, or taps,
i n b obey the symmetry rel ati on
These are type I (n odd) and type I I (n even) l i near-phase fi l ters. Vectors f and
a speci fy the frequency-ampl i tude characteri sti cs of the fi l ter:
f i s a vector of pai rs of frequency poi nts, speci fi ed i n the range between 0 and
1, where 1 corresponds to hal f the sampl i ng frequency (the Nyqui st
frequency). The frequenci es must be i n i ncreasi ng order. Dupl i cate frequency
poi nts are al l owed and, i n fact, can be used to desi gn a fi l ter exactl y the same
as those returned by the fir1 and fir2 functi ons wi th a rectangul ar or
boxcar wi ndow.
a i s a vector contai ni ng the desi red ampl i tude at the poi nts speci fi ed i n f.
The desi red ampl i tude functi on at frequenci es between pai rs of poi nts (f(k),
f(k+1)) for k odd i s the l i ne segment connecti ng the poi nts (f(k), a(k)) and
(f(k+1), a(k+1)).
The desi red ampl i tude functi on at frequenci es between pai rs of poi nts (f(k),
f(k+1)) for k even i s unspeci fi ed. These are transi ti on or dont care regi ons.
f and a are the same l ength. Thi s l ength must be an even number.
b k ( ) b n 2 k + ( ) k 1 = n 1 + , , , =
firls
6-167
The rel ati onshi p between the f and a vectors i n defi ni ng a desi red ampl i tude
response i s
b = firls(n,f,a,w) uses the wei ghts i n vector w to wei ght the fi t i n each
frequency band. The l ength of w i s hal f the l ength of f and a, so there i s exactl y
one wei ght per band.
b = firls(n,f,a,'ftype') and
b = firls(n,f,a,w,'ftype') speci fy a fi l ter type, where ftype i s
hilbert for l i near-phase fi l ters wi th odd symmetry (type I I I and type I V)
The output coeffi ci ents i n b obey the rel ati on b(k) = -b(n + 2 - k),
k = 1, ..., n + 1. Thi s cl ass of fi l ters i ncl udes the Hi l bert transformer, whi ch
has a desi red ampl i tude of 1 across the enti re band.
differentiator for type I I I and type I V fi l ters, usi ng a speci al wei ghti ng
techni que
For nonzero ampl i tude bands, the i ntegrated squared error has a wei ght of
(1/f)
2
so that the error at l ow frequenci es i s much smal l er than at hi gh
frequenci es. For FI R di fferenti ators, whi ch have an ampl i tude characteri sti c
proporti onal to frequency, the fi l ters mi ni mi ze the rel ati ve i ntegrated
squared error (the i ntegral of the square of the rati o of the error to the
desi red ampl i tude).
1.0
0.0
Desired amplitude
response (a)
Normalized
frequency (f)
0.5
"Don't care"/transition regions
f = [0 .3 .4 .6 .7 .9]
a = [0 1 0 0 .5 .5]
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.0 0.8 0.9 1.0 (Nyquist)
firls
6-168
Examples Desi gn an order 255 l owpass fi l ter wi th transi ti on band:
b = firls(255,[0 0.25 0.3 1],[1 1 0 0]);
Desi gn a 31 coeffi ci ent di fferenti ator:
b = firls(30,[0 0.9],[0 0.9],'differentiator');
Desi gn a 24th-order anti -symmetri c fi l ter wi th pi ecewi se l i near passbands and
pl ot the desi red and actual frequency response:
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
Algorithm Reference [1] descri bes the theoreti cal approach that firls takes. The functi on
sol ves a system of l i near equati ons i nvol vi ng an i nner product matri x of si ze
roughl y n/2 usi ng MATLABs \ operator .
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
firls
6-169
Thi s functi on desi gns type I , I I , I I I , and I V l i near-phase fi l ters. Type I and I I
are the defaul ts for n even and odd respecti vel y, whi l e the 'hilbert' and
'differentiator' fl ags produce type I I I (n even) and I V (n odd) fi l ters. The
vari ous fi l ter types have di fferent symmetri es and constrai nts on thei r
frequency responses (see [2] for detai l s).
Diagnostics An appropri ate di agnosti c message i s di spl ayed when i ncorrect arguments are
used:
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 more seri ous warni ng message i s
Warning: Matrix is close to singular or badly scaled.
Thi s tends to happen when the fi l ter l ength ti mes the transi ti on wi dth grows
l arge. I n thi s case, the fi l ter coeffi ci ents b mi ght not represent the desi red fi l ter.
You can check the fi l ter by l ooki ng at i ts frequency response.
Linear
Phase
Filter Type
Filter
Order n Symmetry of Coefficients
Response H(f),
f = 0
Response H(f),
f = 1 (Nyquist)
Type I Even even: No restri cti on No restri cti on
Type I I Odd No restri cti on H(1) = 0
Type I I I Even odd: H(0) = 0 H(1) = 0
Type I V Odd H(0) = 0 No restri cti on
b k ( ) b n 2 k + ( ) k 1 = n 1 + , , , =
b k ( ) b n 2 k + ( ) k 1 = n 1 + , , , =
firls
6-170
See Also
References [1] Parks, T.W., and C.S. Burrus. Digital Filter Design. New York: John Wi l ey
& Sons, 1987. Pgs. 54-83.
[2] Oppenhei m, A.V., and R.W. Schafer. Discrete-TimeSignal Processing.
Engl ewood Cl i ffs, NJ: Prenti ce Hal l , 1989. Pgs. 256-266.
fir1 Wi ndow-based fi ni te i mpul se response fi l ter desi gn
standar d r esponse.
fir2 Wi ndow-based fi ni te i mpul se response fi l ter desi gn
arbi trary response.
firrcos Rai sed cosi ne FI R fi l ter desi gn.
remez Parks-McCl el l an opti mal FI R fi l ter desi gn.
firrcos
6-171
6fi r r cos
Purpose Rai sed cosi ne FI R fi l ter desi gn.
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) returns an order n l owpass l i near-phase FI R fi l ter wi th
a rai sed cosi ne transi ti on band. The fi l ter has cutoff frequency F0, transi ti on
bandwi dth df, and sampl i ng frequency Fs, al l i n Hertz. df must be smal l
enough so that F0 t df/2 i s between 0 and Fs/2. The coeffi ci ents i n b are
normal i zed so that the nomi nal passband gai n i s al ways equal to one.
firrcos(n,F0,df) uses a defaul t sampl i ng frequency of Fs = 2.
b = firrcos(n,F0,r,Fs,'rolloff') i nterprets the thi rd argument, r, as the
rol l off factor i nstead of the transi ti on bandwi dth, df. r must be i n the range
[0,1].
b = firrcos(...,'type') desi gns ei ther a normal rai sed cosi ne fi l ter or a
square root rai sed cosi ne fi l ter dependi ng on the type speci fi cati on, whi ch can
be
normal, for a regul ar rai sed cosi ne fi l ter. Thi s i s the defaul t, and i s al so i n
effect when the 'type' argument i s l eft empty, [].
sqrt, for a square root rai sed cosi ne fi l ter.
b = firrcos(...,'type',delay) speci fi es an i nteger del ay i n the range
[0,n+1]. The defaul t i s n/2 for even n and (n+1)/2 for odd n.
b = firrcos(...,'type',delay,window) appl i es a l ength n+1 wi ndow to the
desi gned fi l ter to reduce the ri ppl e i n the frequency response. window must be
a n+1 l ong col umn vector. I f no wi ndow i s speci fi ed, a boxcar (rectangul ar)
wi ndow i s used. Care must be exerci sed when usi ng a wi ndow wi th a del ay
other than the defaul t.
[b,a] = firrcos(...) al ways returns a = 1.
firrcos
6-172
Example Desi gn an order 20 rai sed cosi ne FI R fi l ter wi th cutoff frequency 0.25 of the
Nyqui st frequency and a transi ti on bandwi dth of 0.25:
h = firrcos(20,0.25,0.25);
freqz(h,1,'Fs',2,'phase','no')
See Also
0 0.2 0.4 0.6 0.8 1
120
100
80
60
40
20
0
20
Frequency (Hz)
M
a
g
n
i
t
u
d
e

(
d
B
)
fir1 Wi ndow-based fi ni te i mpul se response fi l ter desi gn
standar d r esponse.
fir2 Wi ndow-based fi ni te i mpul se response fi l ter desi gn
arbi trary response.
firls Least square l i near-phase FI R fi l ter desi gn.
remez Parks-McCl el l an opti mal FI R fi l ter desi gn.
freqs
6-173
6freqs
Purpose Frequency response of anal og fi l ters.
Syntax h = freqs(b,a,w)
[h,w] = freqs(b,a)
[h,w] = freqs(b,a,n)
freqs(b,a)
Description freqs returns the compl ex frequency response H(jw) (Lapl ace transform) of an
anal og fi l ter:
gi ven the numerator and denomi nator coeffi ci ents i n vectors b and a.
h = freqs(b,a,w) returns the compl ex frequency response of the anal og fi l ter
speci fi ed by coeffi ci ent vectors b and a. freqs eval uates the frequency response
al ong the i magi nary axi s i n the compl ex pl ane at the frequenci es speci fi ed i n
real vector w.
[h,w] = freqs(b,a) automati cal l y pi cks a set of 200 frequency poi nts w on
whi ch to compute the frequency response h.
[h,w] = freqs(b,a,n) pi cks n frequenci es on whi ch to compute the frequency
response h.
freqs wi th no output arguments pl ots the magni tude and phase response
versus frequency i n the current fi gure wi ndow.
freqs works onl y for real i nput systems and posi ti ve frequenci es.
H s ( )
B s ( )
A s ( )
---------- -
b 1 ( )s
nb
b 2 ( )s
nb 1
L b nb 1 + ( ) + + +
a 1 ( )s
na
a 2 ( )s
na 1
L a na 1 + ( ) + + +
---------------------------------------------------------------------------------------------- = =
freqs
6-174
Example Fi nd and graph the frequency response of the transfer functi on gi ven by
a = [1 0.4 1];
b = [0.2 0.3 1];
w = logspace(1,1);
freqs(b,a,w)
You can al so create the pl ot wi th
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 convert to Hertz, degrees, and deci bel s, use
f = w/(2*pi);
mag = 20*log10(mag);
phase = phase*180/pi;
H s ( )
0.2s
2
0.3s 1 + +
s
2
0.4s 1 + +
----------------------------------------- =
10
-1
10
0
10
1
10
-1
10
0
10
1
Frequency
M
a
g
n
i
t
u
d
e
10
-1
10
0
10
1
-150
-100
-50
0
Frequency
P
h
a
s
e

(
d
e
g
r
e
e
s
)
freqs
6-175
Algorithm freqs eval uates the pol ynomi al s at each frequency poi nt, then di vi des the
numerator response by the denomi nator response:
s = i*w;
h = polyval(b,s)./polyval(a,s);
See Also
abs Absol ute val ue (magni tude).
angle Phase angl e.
freqz Frequency response of di gi tal fi l ters.
invfreqs Conti nuous-ti me (anal og) fi l ter i denti fi cati on from
frequency data.
logspace Generate l ogari thmi cal l y spaced vectors (see the
onl i ne MATLAB Function Reference).
polyval Pol ynomi al eval uati on (see the onl i ne MATLAB
Function Reference).
freqspace
6-176
6fr eqspace
Purpose Frequency spaci ng for frequency response.
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 returns the i mpl i ed frequency range for equal l y spaced frequency
responses. Thi s i s useful when creati ng frequency vectors for use wi th freqz.
f = freqspace(n) returns the frequency vector f assumi ng n evenl y spaced
poi nts around the uni t ci rcl e. For n even or odd, f i s (0:2/n:1). For n even,
freqspace returns (n + 2)/2 poi nts. For N odd, i t returns (n + 1)/2 poi nts.
f = freqspace(n,'whole') returns n evenl y spaced poi nts around the whol e
uni t ci rcl e. I n thi s case, f i s 0:2/n:2*(n1)/n.
[f1,f2] = freqspace(n) returns the two-di mensi onal frequency vectors f1
and f2 for an n-by-n matri x. For n odd, both f1 and f2 are [1 + 1/n:2/n:1
1/n]. For n even, both f1 and f2 are [1:2/n:12/n].
[f1,f2] = freqspace([m n]) returns the two-di mensi onal frequency vectors
f1 and f2 for an m-by-n matri x.
[x1,y1] = freqspace(n,'meshgrid') and
[x1,y1] = freqspace([m n],'meshgrid') are equi val ent to
[f1,f2] = freqspace(...);
[x1,y1] = meshgrid(f1,f2);
See the onl i ne MATLAB Function Referencefor detai l s on the meshgrid
functi on.
See Also
freqz Frequency response of di gi tal fi l ters.
invfreqz Di screte-ti me fi l ter i denti fi cati on from frequency
data.
freqz
6-177
6freqz
Purpose Frequency response of di gi tal fi l ters.
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 returns the compl ex frequency response H(e
j
) of a di gi tal fi l ter, gi ven
the (real or compl ex) numerator and denomi nator coeffi ci ents i n vectors b
and a.
[h,w] = freqz(b,a,n) returns the n-poi nt compl ex frequency response of the
di gi tal fi l ter
eval uated at z=e
j
gi ven the coeffi ci ent vectors b and a. freqz returns both h,
the compl ex frequency response, and w, a vector contai ni ng the n frequency
poi nts i n uni ts of rads/sampl e. freqz eval uates the frequency response at n
poi nts equal l y spaced around the upper hal f of the uni t ci rcl e, so w contai ns n
poi nts between 0 and .
I t i s best, al though not necessary, to choose a val ue for n that i s an exact power
of two, because thi s al l ows fast computati on usi ng an FFTal gori thm. I f you do
not speci fy a val ue for n, i t defaul ts to 512.
[h,f] = freqz(b,a,n,Fs) speci fi es a posi ti ve sampl i ng frequency Fs, i n
Hertz. The defaul t for Fs i s 1. I t returns a vector f contai ni ng the actual
frequency poi nts between 0 and Fs/2 (the Nyqui st frequency) at whi ch i t
cal cul ated the frequency response. f i s of l ength n.
[h,w] = freqz(b,a,n,'whole') uses n poi nts around the whol e uni t ci rcl e, so
w has range [0,2).
[h,f] = freqz(b,a,n,'whole',Fs) uses n poi nts around the whol e uni t
ci rcl e, so f has range [0,Fs).
H z ( )
B z ( )
A z ( )
-----------
b 1 ( ) b 2 ( )z
1
L b nb 1 + ( )z
nb
+ + +
a 1 ( ) a 2 ( )z
1
L a na 1 + ( )z
na
+ + +
----------------------------------------------------------------------------------------- = =
freqz
6-178
h = freqz(b,a,w) returns the frequency response at the frequenci es i n vector
w (speci fi ed i n rads/sampl e).
h = freqz(b,a,f,Fs) returns the frequency response at the frequenci es i n
vector f (speci fi ed i n Hz).
freqz(...) wi th no output arguments pl ots the magni tude and phase
response versus frequency i n the current fi gure wi ndow.
Examples Pl ot the magni tude and phase response of an FI R fi l ter.
b = fir1(80,0.5,kaiser(81,8));
freqz(b,1);
Algorithm freqz uses an FFT al gori thm when argument n i s present. I t computes the
frequency response as the rati o of the transformed numerator and denomi nator
coeffi ci ents, padded wi th zeros to the desi red l ength:
h = fft(b,n)./fft(a,n)
I f n i s not a power of two, the FFT al gori thm i s not as effi ci ent and may cause
l ong computati on ti mes.
When a frequency vector w or f i s present, or i f n i s l ess than
max(length(b),length(a)), freqz eval uates the pol ynomi al s at each
frequency poi nt usi ng Horners method of pol ynomi al eval uati on and then
di vi des the numerator response by the denomi nator response.
0 0.2 0.4 0.6 0.8 1
5000
4000
3000
2000
1000
0
Normalized Angular Frequency ( rads/sample)
P
h
a
s
e

(
d
e
g
r
e
e
s
)
0 0.2 0.4 0.6 0.8 1
150
100
50
0
50
Normalized Angular Frequency ( rads/sample)
M
a
g
n
i
t
u
d
e

(
d
B
)
freqz
6-179
See Also
abs Absol ute val ue (magni tude).
angle Phase angl e.
fft One-di mensi onal fast Fouri er transform.
filter Fi l ter data wi th a recursi ve (I I R) or nonrecursi ve
(FI R) fi l ter.
freqs Frequency response of anal og fi l ters.
impz I mpul se response of di gi tal fi l ters.
invfreqz Di screte-ti me fi l ter i denti fi cati on from frequency
data.
logspace Generate l ogari thmi cal l y spaced vectors (see the
onl i ne MATLAB Function Reference).
gauspuls
6-180
6gauspul s
Purpose Gaussi an-modul ated si nusoi dal pul se generator.
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 generates Gaussi an-modul ated si nusoi dal pul ses.
yi = gauspuls(t,fc,bw) returns a uni ty-ampl i tude Gaussi an RF pul se at the
ti mes i ndi cated i n array t, wi th a center frequency fc i n Hertz and a fracti onal
bandwi dth bw, whi ch must be greater than 0. The defaul t val ue for fc i s
1000 Hz and for bw i s 0.5.
yi = gauspuls(t,fc,bw,bwr) returns a uni ty-ampl i tude Gaussi an RF pul se
wi th a fracti onal bandwi dth of bw as measured at a l evel of bwr dB wi th respect
to the normal i zed si gnal peak. The fracti onal bandwi dth reference l evel bwr
must be l ess than 0, because i t i ndi cates a reference l evel l ess than the peak
(uni ty) envel ope ampl i tude. The defaul t val ue for bwr i s -6 dB.
[yi,yq] = gauspuls() returns both the i n-phase and quadrature pul ses.
[yi,yq,ye] = gauspuls() returns the RF si gnal envel ope.
tc = gauspuls('cutoff',fc,bw,bwr,tpe) returns the cutoff ti me tc (greater
than or equal to 0) at whi ch the trai l i ng pul se envel ope fal l s bel ow tpe dB wi th
respect to the peak envel ope ampl i tude. The trai l i ng pul se envel ope l evel tpe
must be l ess than 0, because i t i ndi cates a reference l evel l ess than the peak
(uni ty) envel ope ampl i tude. The defaul t val ue for tpe i s -60 dB.
Remarks Defaul t val ues are substi tuted for empty or omi tted trai l i ng i nput arguments.
gauspuls
6-181
Example Pl ot a 50 kHz Gaussi an RF pul se wi th 60% bandwi dth, sampl ed at a rate of
1 MHz. Truncate the pul se where the envel ope fal l s 40 dB bel ow the peak:
tc = gauspuls('cutoff',50e3,0.6,[],40);
t = tc : 1e6 : tc;
yi = gauspuls(t,50e3,0.6);
plot(t,yi)
See Also
-4 -2 0 2 4
x 10
-5
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
chirp Swept-frequency cosi ne generator.
cos Cosi ne of vector/matri x el ements (see the onl i ne
MATLAB Function Reference).
diric Di ri chl et or peri odi c si nc functi on.
pulstran Pul se trai n generator.
rectpuls Sampl ed aperi odi c rectangl e generator.
sawtooth Sawtooth or tri angl e wave generator.
sin Si ne of vector/matri x el ements (see the onl i ne
MATLAB Function Reference).
sinc Si nc or si n(t)/t functi on.
square Square wave generator.
tripuls Sampl ed aperi odi c tri angl e generator.
grpdelay
6-182
6grpdel ay
Purpose Average fi l ter del ay (group del ay).
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 The group delay of a fi l ter i s a measure of the average del ay of the fi l ter as a
functi on of frequency. I t i s the negati ve fi rst deri vati ve of the phase response
of the fi l ter. I f the compl ex frequency response of a fi l ter i s H(e
j
), then the
group del ay i s
where i s frequency and i s the phase angl e of H(e
j
).
[gd,w] = grpdelay(b,a,n) returns the n-poi nt group del ay, , of the
di gi tal fi l ter
gi ven the numerator and denomi nator coeffi ci ents i n vectors b and a. grpdelay
returns both gd, the group del ay, and w, a vector contai ni ng the n frequency
poi nts i n radi ans. grpdelay eval uates the group del ay at n poi nts equal l y
spaced around the upper hal f of the uni t ci rcl e, so w contai ns n poi nts between
0 and . A val ue for n that i s an exact power of two al l ows fast computati on
usi ng an FFT al gori thm.
[gd,f] = grpdelay(b,a,n,Fs) speci fi es a posi ti ve sampl i ng frequency Fs i n
Hertz. I t returns a l ength n vector f contai ni ng the actual frequency poi nts at
whi ch the group del ay i s cal cul ated, al so i n Hertz. f contai ns n poi nts between
0 and Fs/2.

g
( )
d ( )
d
--------------- =

g
( )
H z ( )
B z ( )
A z ( )
-----------
b 1 ( ) b 2 ( )z
1
L b nb 1 + ( )z
nb
+ + +
a 1 ( ) a 2 ( )z
1
L a na 1 + ( )z
na
+ + +
----------------------------------------------------------------------------------------- = =
grpdelay
6-183
[gd,w] = grpdelay(b,a,n,'whole') and
[gd,f] = grpdelay(b,a,n,'whole',Fs) use n poi nts around the whol e uni t
ci rcl e (from 0 to 2, or from 0 to Fs).
gd = grpdelay(b,a,w) and
gd = grpdelay(b,a,f,Fs) return the group del ay eval uated at the poi nts i n w
(i n radi ans) or f (i n Hertz), respecti vel y, where Fs i s the sampl i ng frequency i n
Hertz.
grpdelay wi th no output arguments pl ots the group del ay versus frequency i n
the current fi gure wi ndow.
grpdelay works for both real and compl ex i nput systems.
Examples Pl ot the group del ay of Butterworth fi l ter b(z)/a(z):
[b,a] = butter(6,0.2);
grpdelay(b,a,128)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
0
2
4
6
8
10
12
Normalized frequency (Nyquist == 1)
G
r
o
u
p

d
e
l
a
y

(
i
n

s
a
m
p
l
e
s
)
grpdelay
6-184
Pl ot both the group and phase del ays of a system on the same graph:
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');
Algorithm grpdelay mul ti pl i es the fi l ter coeffi ci ents by a uni t ramp. After Fouri er
transformati on, thi s process corresponds to di fferenti ati on.
See Also
0 0.5 1 1.5 2 2.5 3 3.5
8
6
4
2
0
2
4
6
8
10
12
Frequency (rads/sec)
Group Delay
Phase Delay
cceps Compl ex cepstral anal ysi s.
fft One-di mensi onal fast Fouri er transform.
freqz Frequency response of di gi tal fi l ters.
hilbert Hi l bert transform.
icceps I nverse compl ex cepstrum.
rceps Real cepstrum and mi ni mum phase reconstructi on.
hamming
6-185
6hammi ng
Purpose Hammi ng wi ndow.
Syntax w = hamming(n)
w = hamming(n,sflag)
Description w = hamming(n) returns an n-poi nt symmetri cal l y sampl ed Hammi ng wi ndow
i n the col umn vector w. n shoul d be a nonnegati ve i nteger. The coeffi ci ents of a
Hammi ng wi ndow are
w = hamming(n,sflag) returns an n-poi nt Hammi ng wi ndow usi ng the
wi ndow sampl i ng speci fi ed by sflag, whi ch can be ei ther 'periodic' or
'symmetric' (the defaul t). When 'periodic' i s speci fi ed, hamming computes a
l ength n+1 wi ndow and returns the fi rst n poi nts.
Diagnostics An error message i s di spl ayed when i ncorrect arguments are used:
Order cannot be less than zero.
Sampling must be either 'symmetric' or 'periodic'.
A warni ng message i s di spl ayed for noni nteger n:
Warning: Rounding order to nearest integer.
See Also
References [1] Oppenhei m, A.V., and R.W. Schafer, Discrete-TimeSignal Processing.
Engl ewood Cl i ffs, NJ: Prenti ce-Hal l , 1989.
w k 1 + [ ] 0.54 0.46 2
k
n 1
------------ -
,
_
cos k 0 = n 1 , , , =
bartlett Bartl ett wi ndow.
blackman Bl ackman wi ndow.
boxcar Rectangul ar wi ndow.
chebwin Chebyshev wi ndow.
hanning Hanni ng wi ndow.
kaiser Kai ser wi ndow.
triang Tri angul ar wi ndow.
hanning
6-186
6hanni ng
Purpose Hanni ng wi ndow.
Syntax w = hanning(n)
w = hanning(n,sflag)
Description w = hanning(n) returns an n-poi nt symmetri cal l y sampl ed Hanni ng wi ndow
i n the col umn vector w. n shoul d be a nonnegati ve i nteger. The coeffi ci ents of a
Hanni ng wi ndow are
w = hanning(n,sflag) returns an n-poi nt Hanni ng wi ndow usi ng the wi ndow
sampl i ng speci fi ed by sflag, whi ch can be ei ther 'periodic' or 'symmetric'
(the defaul t). When 'periodic' i s speci fi ed, hanning computes a l ength n+1
wi ndow and returns the fi rst n poi nts.
Diagnostics An error message i s di spl ayed when i ncorrect arguments are used:
Order cannot be less than zero.
Sampling must be either 'symmetric' or 'periodic'.
A warni ng message i s di spl ayed for noni nteger n:
Warning: Rounding order to nearest integer.
See Also
References [1] Oppenhei m, A.V., and R.W. Schafer, Discrete-TimeSignal Processing.
Engl ewood Cl i ffs, NJ: Prenti ce-Hal l , 1989.
w k [ ] 0.5 1 2
k
n 1 +
-------------
,
_
cos
,
_
k 1 = n , , , =
bartlett Bartl ett wi ndow.
blackman Bl ackman wi ndow.
boxcar Rectangul ar wi ndow.
chebwin Chebyshev wi ndow.
hamming Hammi ng wi ndow.
kaiser Kai ser wi ndow.
triang Tri angul ar wi ndow.
hilbert
6-187
6hi l ber t
Purpose Hi l bert transform.
Syntax y = hilbert(x)
Description y = hilbert(x) returns a compl ex hel i cal sequence, someti mes cal l ed the
analyticsignal, from a real data sequence. The anal yti c si gnal has a real part,
whi ch i s the ori gi nal data, and an i magi nary part, whi ch contai ns the Hi l bert
transform. The i magi nary part i s a versi on of the ori gi nal real sequence wi th a
90 phase shi ft. Si nes are therefore transformed to cosi nes and vi ce versa. The
Hi l bert transformed seri es has the same ampl i tude and frequency content as
the ori gi nal real data and i ncl udes phase i nformati on that depends on the
phase of the ori gi nal data.
I f x i s a matri x, y = hilbert(x) operates col umnwi se on the matri x, fi ndi ng
the Hi l bert transform of each col umn.
The Hi l bert transform i s useful i n cal cul ati ng i nstantaneous attri butes of a
ti me seri es, especi al l y the ampl i tude and frequency. The i nstantaneous
ampl i tude i s the ampl i tude of the compl ex Hi l bert transform; the
i nstantaneous frequency i s the ti me rate of change of the i nstantaneous phase
angl e. For a pure si nusoi d, the i nstantaneous ampl i tude and frequency are
constant. The i nstantaneous phase, however, i s a sawtooth, refl ecti ng the way
i n whi ch the l ocal phase angl e vari es l i nearl y over a si ngl e cycl e. For mi xtures
of si nusoi ds, the attri butes are short term, or l ocal , averages spanni ng no more
than two or three poi nts.
Reference [1] descri bes the Kol mogorov method for mi ni mum phase
reconstructi on, whi ch i nvol ves taki ng the Hi l bert transform of the l ogari thm of
the spectrum of a ti me seri es. The tool box functi on rceps performs thi s
reconstructi on.
Algorithm The anal yti c si gnal for a sequence x has a one-sided Fourier transform, that i s,
negati ve frequenci es are 0. To approxi mate the anal yti c si gnal , hilbert
cal cul ates the FFT of the i nput sequence, repl aces those FFT coeffi ci ents that
correspond to negati ve frequenci es wi th zeros, and cal cul ates the i nverse FFT
of the resul t.
I n detai l , hilbert uses a four-step al gori thm:
hilbert
6-188
1 I t cal cul ates the FFTof the i nput sequence, stori ng the resul t i n a vector y.
Before transformi ng, i t zero pads the i nput sequence so i ts l ength n i s the
cl osest power of two, i f necessary. Thi s ensures the most effi ci ent FFT
computati on.
2 I t creates a vector h whose el ements h(i) have the val ues
- 1 for i = 1, (n/2) + 1
- 2 for i = 2, 3, ..., (n/2)
- 0 for i = (n/2) + 2, ... , n
3 I t cal cul ates the el ement-wi se product of y and h.
4 I t cal cul ates the i nverse FFTof the sequence obtai ned i n step 3 and returns
the fi rst n el ements of the resul t.
I f the i nput data x i s a matri x, hilbert operates i n a si mi l ar manner, extendi ng
each step above to handl e the matri x case.
See Also
References [1] Cl aerbout, J.F. Fundamentals of Geophysical Data Processing. New York:
McGraw-Hi l l , 1976. Pgs. 59-62.
fft One-di mensi onal fast Fouri er transform.
ifft One-di mensi onal i nverse fast Fouri er transform.
rceps Real cepstrum and mi ni mum phase reconstructi on.
icceps
6-189
6i cceps
Purpose I nverse compl ex cepstrum.
Syntax x = icceps(xhat,nd)
Description x = icceps(xhat,nd) returns the i nverse compl ex cepstrum of the (assumed
real ) sequence xhat, removi ng nd sampl es of del ay. I f xhat was obtai ned wi th
cceps(x), then the amount of del ay that was added to x was the el ement of
round(unwrap(angle(fft(x)))/pi) correspondi ng to radi ans.
See Also
References [1] Oppenhei m, A.V., and R.W. Schafer. Digital Signal Processing. Engl ewood
Cl i ffs, NJ: Prenti ce Hal l , 1975.
cceps Compl ex cepstral anal ysi s.
hilbert Hi l bert transform.
rceps Real cepstrum and mi ni mum phase reconstructi on.
unwrap Unwrap phase angl es.
idct
6-190
6i dct
Purpose I nverse di screte cosi ne transform.
Syntax x = idct(y)
x = idct(y,n)
Description The i nverse di screte cosi ne transform reconstructs a sequence from i ts di screte
cosi ne transform (DCT) coeffi ci ents. The idct functi on i s the i nverse of the dct
functi on.
x = idct(y) returns the i nverse di screte cosi ne transform of y
where
and N = length(x), whi ch i s the same as length(y). The seri es i s i ndexed
from n = 1 and k = 1 i nstead of the usual n = 0 and k = 0 because MATLAB
vectors run from 1 to N i nstead of from 0 to N-1.
x = idct(y,n) appends zeros or truncates the vector y to l ength n before
transformi ng.
I f y i s a matri x, idct transforms i ts col umns.
See Also
x n ( ) w k ( )y k ( )
2n 1 ( ) k 1 ( )
2N
------------------------------------------ - cos
k 1 =
N

n 1 N , , = , =
w k ( )
1
N
--------- k 1 = ,
2
N
---- 2 k N ,

'

=
dct Di screte cosi ne transform (DCT).
dct2 Two-di mensi onal DCT (see I mageProcessingToolboxUsers
Guide).
idct2 Two-di mensi onal i nverse DCT (see I mageProcessingToolbox
Users Guide).
ifft One-di mensi onal i nverse fast Fouri er transform.
idct
6-191
References [1] Jai n, A.K. Fundamentalsof Digital I mageProcessing. Engl ewood Cl i ffs, NJ:
Prenti ce-Hal l , 1989.
[2] Pennebaker, W.B., and J.L. Mi tchel l . J PEG Still I mageData Compression
Standard. New York, NY: Van Nostrand Rei nhol d, 1993. Chapter 4.
ifft
6-192
6i fft
Purpose One-di mensi onal i nverse fast Fouri er transform.
Syntax y = ifft(x)
y = ifft(x,n)
Description ifft computes the i nverse Fouri er transform of a vector or array. Thi s functi on
i mpl ements the i nverse transform gi ven by
where W
N
=e
-j(2p/N)
and N = length(x). Note that the seri es i s i ndexed as n + 1
and k+1 i nstead of the usual nand kbecause MATLAB vectors run from 1 to N
i nstead of from 0 to N-1.
y = ifft(x) i s the i nverse Fouri er transform of vector x. I f x i s an array, y i s
the i nverse FFT of each col umn of the matri x.
y = ifft(x,n) i s the n-poi nt i nverse FFT. I f the l ength of x i s l ess than n, ifft
pads x wi th trai l i ng zeros to l ength n. I f the l ength of x i s greater than n, ifft
truncates the sequence x. When x i s an array, ifft adjusts the l ength of the
col umns i n the same manner.
The ifft functi on i s part of the standard MATLAB l anguage.
Algorithm The ifft functi on i s an M-fi l e. The al gori thm for ifft i s the same as that for
fft, except for a si gn change and a scal e factor of n = length(x). The executi on
ti me i s fastest when n i s a power of two and sl owest when n i s a l arge pri me.
See Also
x n 1 + ( )
1
N
---- X k 1 + ( )W
n
kn
k 0 =
N 1

=
fft One-di mensi onal fast Fouri er transform.
fft2 Two-di mensi onal fast Fouri er transform.
fftshift Rearrange the outputs of fft and fft2.
ifft2 Two-di mensi onal i nverse fast Fouri er transform.
ifft2
6-193
6i fft2
Purpose Two-di mensi onal i nverse fast Fouri er transform.
Syntax Y = ifft2(X)
Y = ifft2(X,m,n)
Description Y = ifft2(X) returns the two-di mensi onal i nverse fast Fouri er transform
(FFT) of the array X. I f X i s a vector, Y has the same ori entati on as X.
Y = ifft2(X,m,n) truncates or zero pads X, i f necessary, to create an m-by-n
array before performi ng the i nverse FFT. The resul t Y i s al so m-by-n.
For any X, ifft2(fft2(X)) equal s X to wi thi n roundoff error. I f X i s real ,
ifft2(fft2(X)) may have smal l i magi nary parts.
The ifft2 functi on i s part of the standard MATLAB l anguage.
Algorithm The al gori thm for ifft2 i s the same as that for fft2, except for a si gn change
and scal e factors of [m n]= size(X). The executi on ti me i s fastest when m and
n are powers of two and sl owest when they are l arge pri mes.
See Also
fft One-di mensi onal fast Fouri er transform.
fft2 Two-di mensi onal fast Fouri er transform.
fftn N-di mensi onal fast Fouri er transform (see the onl i ne
MATLAB Function Reference).
fftshift Rearrange the outputs of fft and fft2.
ifft One-di mensi onal i nverse fast Fouri er transform.
ifftn N-di mensi onal i nverse fast Fouri er transform (see
the onl i ne MATLAB Function Reference).
impinvar
6-194
6i mpi nvar
Purpose I mpul se i nvari ance method of anal og-to-di gi tal fi l ter conversi on.
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) creates a di gi tal fi l ter wi th numerator and
denomi nator coeffi ci ents bz and az, respecti vel y, whose i mpul se response i s
equal to the i mpul se response of the anal og fi l ter wi th coeffi ci ents b and a,
scal ed by 1/Fs.
[bz,az] = impinvar(b,a) uses the defaul t val ue of 1 Hz for Fs.
[bz,az] = impinvar(b,a,Fs,tol) uses the tol er ance speci fi ed by tol to
determi ne whether pol es are repeated. A l arger tol erance i ncreases the
l i kel i hood that impinvar wi l l consi der nearby pol es to be repeated. The defaul t
i s 0.001, or 0.1%of a pol es magni tude. Note that the accuracy of the pol e val ues
i s sti l l l i mi ted to the accuracy obtai nabl e by the roots functi on.
Example Convert an anal og l owpass fi l ter to a di gi tal fi l ter usi ng impinvar wi th a
sampl i ng frequency of 10 Hz:
[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 performs the i mpul se-i nvari ant method of anal og-to-di gi tal transfer
functi on conversi on di scussed i n reference [1]:
1 I t fi nds the parti al fracti on expansi on of the system represented by b and a.
2 I t r epl aces the pol es p by the pol es exp(p/Fs).
impinvar
6-195
3 I t fi nds the transfer functi on coeffi ci ents of the system from the resi dues
from step 1 and the pol es from step 2.
See Also
References [1] Parks, T.W., and C.S. Burrus. Digital Filter Design. New York: John Wi l ey
& Sons, 1987. Pgs. 206-209.
bilinear Bi l i near transformati on method of anal og-to-di gi tal
fi l ter conversi on.
lp2bp Lowpass to bandpass anal og fi l ter transformati on.
lp2bs Lowpass to bandstop anal og fi l ter transformati on.
lp2hp Lowpass to hi ghpass anal og fi l ter transformati on.
lp2lp Lowpass to l owpass anal og fi l ter transformati on.
impz
6-196
6i mpz
Purpose I mpul se response of di gi tal fi l ters.
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) computes the i mpul se response of the fi l ter wi th
numerator coeffi ci ents b and denomi nator coeffi ci ents a. impz chooses the
number of sampl es and returns the response i n col umn vector h and ti mes (or
sampl e i nterval s) i n col umn vector t (where t = (0:n1)' and n i s the
computed i mpul se response l ength).
[h,t] = impz(b,a,n) computes n sampl es of the i mpul se response. I f n i s a
vector of i ntegers, impz computes the i mpul se response at those i nteger
l ocati ons where 0 i s the starti ng poi nt of the fi l ter.
[h,t] = impz(b,a,n,Fs) computes n sampl es and scal es t so that sampl es ar e
spaced 1/Fs uni ts apart. Fs i s 1 by defaul t. Leave n empty, [], to l et impz sel ect
the number of sampl es.
impz wi th no output arguments pl ots the i mpul se response i n the current
fi gure wi ndow usi ng stem(t,h).
impz works for both real and compl ex i nput systems.
impz
6-197
Example Pl ot the fi rst 50 sampl es of the i mpul se response of a fourth-order l owpass
el l i pti c fi l ter wi th cutoff frequency of 0.4 ti mes the Nyqui st frequency:
[b,a] = ellip(4,0.5,20,0.4);
impz(b,a,50)
Algorithm impz fi l ters a l ength n i mpul se sequence usi ng
filter(b,a,[1 zeros(1,n1)])
To compute n i n the auto-l ength case, impz ei ther uses n = length(b) for the
FI R case or fi rst fi nds the pol es usi ng p = roots(a), i f length(a) i s greater
than 1.
I f the fi l ter i s unstabl e, n i s chosen to be the poi nt at whi ch the term from the
l argest pol e reaches 10^6 ti mes i ts ori gi nal val ue.
I f the fi l ter i s stabl e, n i s chosen to be the poi nt at whi ch the term due to the
l argest ampl i tude pol e i s 5*10^5 of i ts ori gi nal ampl i tude.
I f the fi l ter i s osci l l atory (pol es on the uni t ci rcl e onl y), impz computes fi ve
peri ods of the sl owest osci l l ati on.
I f the fi l ter has both osci l l atory and damped terms, n i s chosen to equal fi ve
peri ods of the sl owest osci l l ati on or the poi nt at whi ch the term due to the
0 5 10 15 20 25 30 35 40 45
-0.2
-0.1
0
0.1
0.2
0.3
0.4
0.5
impz
6-198
l argest (nonuni ty) ampl i tude pol e i s 5*10^5 of i ts ori gi nal ampl i tude,
whi chever i s greater.
impz al so al l ows for del ay i n the numerator pol ynomi al , whi ch i t adds to the
resul ti ng n.
See Also
impulse Uni t i mpul se response (see Control SystemToolbox
Users Guide).
stem Pl ot di screte sequence data (see the onl i ne MATLAB
Function Reference).
interp
6-199
6i nter p
Purpose I ncrease sampl i ng rate by an i nteger factor (i nterpol ati on).
Syntax y = interp(x,r)
y = interp(x,r,l,alpha)
[y,b] = interp(x,r,l,alpha)
Description I nterpol ati on i ncreases the ori gi nal sampl i ng rate for a sequence to a hi gher
rate. interp performs l owpass i nterpol ati on by i nserti ng zeros i nto the ori gi nal
sequence and then appl yi ng a speci al l owpass fi l ter.
y = interp(x,r) i ncreases the sampl i ng rate of x by a factor of r. The
i nterpol ated vector y i s r ti mes l onger than the ori gi nal i nput x.
y = interp(x,r,l,alpha) speci fi es l (fi l ter l ength) and alpha (cut-off
frequency). The defaul t val ue for l i s 4 and the defaul t val ue for alpha i s 0.5.
[y,b] = interp(x,r,l,alpha) returns vector b contai ni ng the fi l ter
coeffi ci ents used for the i nterpol ati on.
Example I nterpol ate a si gnal by a factor of four:
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');
0 20 40 60 80 100 120
-2
-1.5
-1
-0.5
0
0.5
1
1.5
2
Interpolated Signal
0 5 10 15 20 25 30
-2
-1.5
-1
-0.5
0
0.5
1
1.5
2
Original Signal
interp
6-200
Algorithm interp uses the l owpass i nterpol ati on Al gori thm 8.1 descri bed i n [1]:
1 I t expands the i nput vector to the correct l ength by i nserti ng zeros between
the ori gi nal data val ues.
2 I t desi gns a speci al symmetri c FI R fi l ter that al l ows the ori gi nal data to pass
through unchanged and i nterpol ates between so that the mean-square
errors between the i nterpol ated poi nts and thei r i deal val ues are mi ni mi zed.
3 I t appl i es the fi l ter to the i nput vector to produce the i nterpol ated output
vector.
The l ength of the FI R l owpass i nterpol ati ng fi l ter i s 2*l*r+1. The number of
ori gi nal sampl e val ues used for i nterpol ati on i s 2*l. Ordi nari l y, l shoul d be
l ess than or equal to 10. The ori gi nal si gnal i s assumed to be band l i mi ted wi th
normal i zed cutoff frequency 0 alpha 1, where 1 i s hal f the ori gi nal
sampl i ng frequency (the Nyqui st frequency). The defaul t val ue for l i s 4 and
the defaul t val ue for alpha i s 0.5.
Diagnostics I f r i s not an i nteger, interp gi ves the fol l owi ng error message:
Resampling rate R must be an integer.
See Also
References [1] I EEE. Programsfor Digital Signal Processing. I EEE Press. New York: John
Wi l ey & Sons, 1979. Al gori thm 8.1.
decimate Decrease the sampl i ng rate for a sequence
(deci mati on).
interp1 One-di mensi onal data i nterpol ati on (tabl e l ookup)
(see the onl i ne MATLAB Function Reference).
resample Change sampl i ng rate by any rati onal factor.
spline Cubi c spl i ne i nterpol ati on (see the onl i ne MATLAB
Function Reference).
upfirdn Upsampl e, appl y an FI R fi l ter, and downsampl e.
intfilt
6-201
6i ntfi l t
Purpose I nterpol ati on FI R fi l ter desi gn.
Syntax b = intfilt(r,l,alpha)
b = intfilt(r,n,'Lagrange')
Description b = intfilt(r,l,alpha) desi gns a l i near phase FI R fi l ter that performs i deal
bandl i mi ted i nterpol ati on usi ng the nearest 2*l nonzero sampl es, when used
on a sequence i nterl eaved wi th r1 consecuti ve zeros every r sampl es. I t
assumes an ori gi nal bandl i mi tedness of alpha ti mes the Nyqui st frequency.
The returned fi l ter i s i denti cal to that used by interp.
b = intfilt(r,n,'Lagrange') or b = intfilt(r,n,'l') desi gns an FI R
fi l ter that performs nth-order Lagrange pol ynomi al i nterpol ati on on a sequence
i nterl eaved wi th r1 consecuti ve zeros every r sampl es. b has l ength (n + 1)*r
for n even, and l ength (n + 1)*r1 for n odd.
Both types of fi l ters are basi cal l y l owpass and are i ntended for i nterpol ati on
and deci mati on.
Examples Desi gn a di gi tal i nterpol ati on fi l ter to upsampl e a si gnal by four, usi ng the
bandl i mi ted method:
alpha = 0.5; % "bandlimitedness" factor
h1 = intfilt(4,2,alpha); % bandlimited interpolation
The fi l ter h1 works best when the ori gi nal si gnal i s bandl i mi ted to alpha ti mes
the Nyqui st frequency. Create a bandl i mi ted noi se si gnal :
randn('seed',0)
x = filter(fir1(40,0.5),1,randn(200,1)); % bandlimit
Now zero pad the si gnal wi th three zeros between every sampl e. The resul ti ng
sequence i s four ti mes the l ength of x:
xr = reshape([x zeros(length(x),3)]',4*length(x),1);
I nterpol ate usi ng the filter command:
y = filter(h1,1,xr);
intfilt
6-202
y i s an i nterpol ated versi on of x, del ayed by seven sampl es (the group-del ay of
the fi l ter). Zoom i n on a secti on to see thi s:
plot(100:200,y(100:200),7+(101:4:196),x(26:49),'o')
intfilts other type of fi l ter performs Lagrange pol ynomi al i nterpol ati on of
the ori gi nal si gnal . For exampl e, fi rst-order pol ynomi al i nterpol ati on i s just
l i near i nterpol ati on, whi ch i s accompl i shed wi th a tri angul ar fi l ter:
h2 = intfilt(4,1,'l') % Lagrange interpolation
h2 =
0.2500 0.5000 0.7500 1.0000 0.7500 0.5000 0.2500
Algorithm The bandl i mi ted method uses firls to desi gn an i nterpol ati on FI R equi val ent
to that presented i n [1]. The pol ynomi al method uses Lagranges pol ynomi al
i nterpol ati on formul a on equal l y spaced sampl es to construct the appropri ate
fi l ter.
See Also
References [1] Oetken, Parks, and Schl er. New Resul ts i n the Desi gn of Di gi tal
I nterpol ators. I EEE Trans. Acoust., Speech, Signal Processing. Vol . ASSP-23
(June 1975). Pgs. 301-309.
100 110 120 130 140 150 160 170 180 190 200
-1.5
-1
-0.5
0
0.5
1
1.5
Sample Number
Solid = interpolated, o = original
decimate Decrease the sampl i ng rate for a sequence
(deci mati on).
interp I ncrease sampl i ng rate by an i nteger factor
(i nterpol ati on).
resample Change sampl i ng rate by any rati onal factor.
invfreqs
6-203
6i nvfr eqs
Purpose Conti nuous-ti me (anal og) fi l ter i denti fi cati on from frequency data.
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 i s the i nverse operati on of freqs; i t fi nds a conti nuous-ti me transfer
functi on that corresponds to a gi ven compl ex frequency response. From a
l aboratory anal ysi s standpoi nt, invfreqs i s useful i n converti ng magni tude
and phase data i nto transfer functi ons.
[b,a] = invfreqs(h,w,nb,na) returns the real numerator and denomi nator
coeffi ci ent vectors b and a of the transfer functi on
whose compl ex frequency response i s gi ven i n vector h at the frequency poi nts
speci fi ed i n vector w. Scal ars nb and na speci fy the desi red orders of the
numerator and denomi nator pol ynomi al s.
Frequency i s speci fi ed i n radi ans between 0 and , and the l ength of h must be
the same as the l ength of w. invfreqs uses conj(h) at w to ensure the proper
frequency domai n symmetry for a real fi l ter.
[b,a] = invfreqs(h,w,nb,na,wt) wei ghts the fi t-errors versus frequency. wt
i s a vector of wei ghti ng factors the same l ength as w.
invfreqs(h,w,nb,na,wt,iter) and
invfreqs(h,w,nb,na,wt,iter,tol) provi de a superi or al gori thm that
guarantees stabi l i ty of the resul ti ng l i near system and searches for the best fi t
usi ng a numeri cal , i terati ve scheme. The iter parameter tel l s invfreqs to end
the i ter ati on when the sol uti on has conver ged, or after iter i terati ons,
whi chever comes fi rst. invfreqs defi nes convergence as occurri ng when the
H s ( )
B s ( )
A s ( )
---------- -
b 1 ( )s
nb
b 2 ( )s
nb 1
L b nb 1 + ( ) + + +
a 1 ( )s
na
a 2 ( )s
na 1
L a na 1 + ( ) + + +
---------------------------------------------------------------------------------------------- = =
invfreqs
6-204
norm of the (modi fi ed) gradi ent vector i s l ess than tol. tol i s an opti onal
parameter that defaul ts to 0.01. To obtai n a wei ght vector of al l ones, use
invfreqs(h,w,nb,na,[],iter,tol)
invfreqs(h,w,nb,na,wt,iter,tol,'trace') di spl ays a textual progress
report of the i terati on.
invfreqs(h,w,'complex',nb,na,...) creates a compl ex fi l ter. I n thi s case no
symmetry i s enforced, and the frequency i s speci fi ed i n radi ans between - and
.
Remarks When bui l di ng hi gher order model s usi ng hi gh frequenci es, i t i s i mportant to
scal e the frequenci es, di vi di ng by a factor such as hal f the hi ghest frequency
present i n w, so as to obtai n wel l condi ti oned val ues of a and b. Thi s corresponds
to a rescal i ng of ti me.
Examples Convert a si mpl e transfer functi on to frequency response data and then back
to the ori gi nal fi l ter coeffi ci ents:
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
invfreqs
6-205
Noti ce that bb and aa are equi val ent to b and a, respecti vel y. However, aa has
pol es i n the l eft hal f-pl ane and thus the system i s unstabl e. Use invfreqss
i terati ve al gori thm to fi nd a stabl e approxi mati on to the system:
[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
Suppose you have two vector s, mag and phase, that contai n magni tude and
phase data gathered i n a l aboratory, and a thi rd vector w of frequenci es. You
can convert the data i nto a conti nuous-ti me transfer functi on usi ng invfreqs:
[b,a] = invfreqs(mag.*exp(j*phase),w,2,3);
Algorithm By defaul t, invfreqs uses an equati on error method to i denti fy the best model
from the data. Thi s fi nds b and a i n
by creati ng a system of l i near equati ons and sol vi ng them wi th MATLABs \
operator. Here A(w(k)) and B(w(k)) are the Fouri er transforms of the
pol ynomi al s a and b, respecti vel y, at the frequency w(k), and n i s the number
of frequency poi nts (the l ength of h and w). Thi s al gori thm i s based on Levi [1].
Several vari ants have been suggested i n the l i terature, where the wei ghti ng
functi on wt gi ves l ess attenti on to hi gh fr equenci es.
The superi or (output-error)al gori thm uses the damped Gauss-Newton method
for i terati ve search [2], wi th the output of the fi rst al gori thm as the i ni ti al
esti mate. Thi s sol ves the di rect probl em of mi ni mi zi ng the wei ghted sum of the
squared error between the actual and the desi red frequency response poi nts:
mi n
b a ,
wt k ( ) h k ( )A w k ( ) ( ) B w k ( ) ( )
2
k 1 =
n

mi n
b a ,
wt k ( ) h k ( )
B w k ( ) ( )
A w k ( ) ( )
--------------------
2
k 1 =
n

invfreqs
6-206
See Also
References [1] Levi , E.C. Compl ex-Curve Fi tti ng. I RE Trans. on Automatic Control.
Vol . AC-4 (1959). Pgs. 37-44.
[2] Denni s, J.E., Jr., and R.B. Schnabel . Numerical Methodsfor Unconstrained
Optimization and Nonlinear Equations. Engl ewood Cl i ffs, NJ: Prenti ce Hal l ,
1983.
freqs Frequency response of anal og fi l ters.
freqz Frequency response of di gi tal fi l ters.
invfreqz Di screte-ti me fi l ter i denti fi cati on from frequency
data.
prony Pronys method for ti me domai n I I R fi l ter desi gn.
invfreqz
6-207
6i nvfr eqz
Purpose Di screte-ti me fi l ter i denti fi cati on from frequency data.
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 i s the i nverse operati on of freqz; i t fi nds a di screte-ti me transfer
functi on that corresponds to a gi ven compl ex frequency response. From a
l aboratory anal ysi s standpoi nt, invfreqz can be used to convert magni tude
and phase data i nto transfer functi ons.
[b,a] = invfreqz(h,w,nb,na) returns the real numerator and denomi nator
coeffi ci ents i n vectors b and a of the transfer functi on
whose compl ex frequency response i s gi ven i n vector h at the frequency poi nts
speci fi ed i n vector w. Scal ars nb and na speci fy the desi red orders of the
numerator and denomi nator pol ynomi al s.
Frequency i s speci fi ed i n radi ans between 0 and , and the l ength of h must be
the same as the l ength of w. invfreqz uses conj(h) at w to ensure the proper
frequency domai n symmetry for a real fi l ter.
[b,a] = invfreqz(h,w,nb,na,wt) wei ghts the fi t-errors versus frequency. wt
i s a vector of wei ghti ng factors the same l ength as w.
invfreqz(h,w,nb,na,wt,iter) and
invfreqz(h,w,nb,na,wt,iter,tol) provi de a superi or al gori thm that
guarantees stabi l i ty of the resul ti ng l i near system and searches for the best fi t
usi ng a numeri cal , i terati ve scheme. The iter parameter tel l s invfreqz to end
the i ter ati on when the sol uti on has conver ged, or after iter i terati ons,
whi chever comes fi rst. invfreqz defi nes convergence as occurri ng when the
H z ( )
B z ( )
A z ( )
-----------
b 1 ( ) b 2 ( )z
1
L b nb 1 + ( )z
nb
+ + +
a 1 ( ) a 2 ( )z
1
L a na 1 + ( )z
na
+ + +
----------------------------------------------------------------------------------------- = =
invfreqz
6-208
norm of the (modi fi ed) gradi ent vector i s l ess than tol. tol i s an opti onal
parameter that defaul ts to 0.01. To obtai n a wei ght vector of al l ones, use
invfreqz(h,w,nb,na,[],iter,tol)
invfreqz(h,w,nb,na,wt,iter,tol,'trace') di spl ays a textual progress
report of the i terati on.
invfreqz(h,w,'complex',nb,na,...) creates a compl ex fi l ter. I n thi s case no
symmetry i s enforced, and the frequency i s speci fi ed i n radi ans between - and
.
Example Convert a si mpl e transfer functi on to frequency response data and then back
to the ori gi nal fi l ter coeffi ci ents:
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
Noti ce that bb and aa are equi val ent to b and a, respecti vel y. However, aa has
pol es outsi de the uni t ci rcl e and thus the system i s unstabl e. Use invfreqzs
i terati ve al gori thm to fi nd a stabl e approxi mati on to the system:
[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 defaul t, invfreqz uses an equati on error method to i denti fy the best model
from the data. Thi s fi nds b and a i n
invfreqz
6-209
by creati ng a system of l i near equati ons and sol vi ng them wi th MATLABs \
operator. Here A(w(k)) and B(w(k)) are the Fouri er transforms of the
pol ynomi al s a and b, respecti vel y, at the frequency w(k), and n i s the number
of frequency poi nts (the l ength of h and w). Thi s al gori thm i s a based on Levi [1].
The superi or (output-error) al gori thm uses the damped Gauss-Newton
method for i terati ve search [2], wi th the output of the fi rst al gori thm as the
i ni ti al esti mate. Thi s sol ves the di rect probl em of mi ni mi zi ng the wei ghted sum
of the squared error between the actual and the desi red frequency response
poi nts:
See Also
References [1] Levi , E.C. Compl ex-Curve Fi tti ng. I RE Trans. on Automatic Control.
Vol . AC-4 (1959). Pgs. 37-44.
[2] Denni s, J.E., Jr., and R.B. Schnabel . Numerical Methodsfor Unconstrained
Optimization and Nonlinear Equations. Engl ewood Cl i ffs, NJ: Prenti ce Hal l ,
1983.
mi n
b a ,
wt k ( ) h k ( )A w k ( ) ( ) B w k ( ) ( )
2
k 1 =
n

mi n
b a ,
wt k ( ) h k ( )
B w k ( ) ( )
A w k ( ) ( )
--------------------
2
k 1 =
n

freqs Frequency response of anal og fi l ters.


freqz Frequency response of di gi tal fi l ters.
invfreqs Conti nuous-ti me (anal og) fi l ter i denti fi cati on from
frequency data.
prony Pronys method for ti me domai n I I R fi l ter desi gn.
kaiser
6-210
6kai ser
Purpose Kai ser wi ndow.
Syntax w = kaiser(n,beta)
Description w = kaiser(n,beta) returns an n-poi nt Kai ser ( - si nh) wi ndow i n the
col umn vector w. beta i s the Kai ser wi ndow parameter that affects the
si del obe attenuati on of the Fouri er transform of the wi ndow.
To obtai n a Kai ser wi ndow that desi gns an FI R fi l ter wi th si del obe hei ght
- dB, use the fol l owi ng :
I ncreasi ng beta wi dens the mai nl obe and decreases the ampl i tude of the
si del obes (i ncreases the attenuati on).
See Also
References [1] Kai ser, J.F. Nonrecursi ve Di gi tal Fi l ter Desi gn Usi ng the - si nh Wi ndow
Functi on. Proc. 1974 I EEE Symp. Circuits and Syst. (Apri l 1974). Pgs. 20-23.
[2] I EEE. Digital Signal ProcessingI I . I EEE Press. New York: John Wi l ey &
Sons, 1975.
I
0

0.1102 8.7 ( ), 50 >


0.5842 21 ( )
0.4
0.07886 21 ( ) + , 50 21
0, 21 <

'

=
bartlett Bartl ett wi ndow.
blackman Bl ackman wi ndow.
boxcar Rectangul ar wi ndow.
chebwin Chebyshev wi ndow.
hamming Hammi ng wi ndow.
hanning Hanni ng wi ndow.
kaiserord Esti mate parameters for fir1 wi th Kai ser wi ndow.
triang Tri angul ar wi ndow.
I
0
kaiserord
6-211
6kai ser or d
Purpose Esti mate parameters for an FI R fi l ter desi gn wi th Kai ser wi ndow.
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 returns a fi l ter order n and beta parameter to speci fy a Kai ser
wi ndow for use wi th the fir1 functi on. Gi ven a set of speci fi cati ons i n the
frequency domai n, kaiserord esti mates the mi ni mum FI R fi l ter order that wi l l
approxi matel y meet the speci fi cati ons. kaiserord converts the gi ven fi l ter
speci fi cati ons i nto passband and stopband ri ppl es and converts cutoff
frequenci es i nto the form needed for wi ndowed FI R fi l ter desi gn.
NOTE I f the band ri ppl es are speci fi ed as unequal , the smal l est one i s used,
si nce the Kai ser wi ndow method i s constrai ned to gi ve fi l ters wi th equal ri ppl e
hei ghts i n al l the passbands and stopbands.
[n,Wn,beta,ftype] = kaiserord(f,a,dev) fi nds the approxi mate order n,
normal i zed frequency band edges Wn, and wei ghts that meet i nput
speci fi cati ons f, a, and dev. f i s a vector of band edges and a i s a vector
speci fyi ng the desi red ampl i tude on the bands defi ned by f. The l ength of f i s
twi ce the l ength of a, mi nus 2. Together, f and a defi ne a desi red pi ecewi se
constant response functi on. dev i s a vector the same si ze as a that speci fi es the
maxi mum al l owabl e error or devi ati on between the frequency response of the
output fi l ter and i ts desi red ampl i tude, for each band.
fir1 can use the resul ti ng order n, frequency vector Wn, mul ti band magni tude
type ftype, and the Kai ser wi ndow parameter beta. The ftype stri ng i s
i ntended for use wi th fir1; i t i s equal to 'high' for a hi ghpass fi l ter and 'stop'
for a bandstop fi l ter. For mul ti band fi l ters, i t can be equal to 'dc0' when the
fi rst band i s a stopband (starti ng at f = 0) or 'dc1' when the fi rst band i s a
passband.
To desi gn a fi l ter b that approxi matel y meets the speci fi cati ons gi ven by kaiser
parameters f, a, and dev:
b = fir1(n,Wn,kaiser(n+1,beta),ftype,'noscale')
kaiserord
6-212
[n,Wn,beta,ftype] = kaiserord(f,a,dev,Fs) speci fi es a sampl i ng
frequency Fs. I f not present, Fs defaul ts to 2 Hz, i mpl yi ng a Nyqui st frequency
of 1 Hz. You can therefore speci fy band edges scal ed to a parti cul ar
appl i cati ons sampl i ng frequency.
c = kaiserord(f,a,dev,Fs,'cell') i s a cel l -array whose el ements are the
parameters to fir1.
NOTE I n some cases, kaiserord under esti mates or overesti mates the or der n.
I f the fi l ter does not meet the speci fi cati ons, try a hi gher order such as n+1, n+2,
and so on, or a l ower order.
Resul ts are i naccurate i f the cutoff frequenci es are near 0 or the Nyqui st
frequency, or i f dev i s l arge (greater than 10%).
Algorithm kaiserord uses empi ri cal l y deri ved formul as for esti mati ng the orders of
l owpass fi l ters, as wel l as di fferenti ators and Hi l bert transformers. Esti mates
for mul ti band fi l ters (such as bandpass fi l ters) are deri ved from the l owpass
desi gn formul as.
The desi gn formul as that underl i e the Kai ser wi ndow and i ts appl i cati on to
FI R fi l ter desi gn are
where = -20l og
10
i s the stopband attenuati on expressed i n deci bel s (recal l
that
p
=
s
i s requi red). The desi gn formul a i s:
where n i s the fi l ter order and i s the wi dth of the smal l est transi ti on regi on.

0.1102 8.7 ( ), 50 >


0.5842 21 ( )
0.4
0.07886 21 ( ) + , 50 21
0, 21 <

'

=
n
7.95
2.285 ( )
---------------------------- =
kaiserord
6-213
Examples Desi gn a l owpass fi l ter wi th passband from 0 to 1 kHz and stopband from
1500 Hz to 4 kHz. Speci fy passband ri ppl e of 5% and stopband attenuati on 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)
0 0.2 0.4 0.6 0.8 1
1500
1000
500
0
Normalized Angular Frequency ( rads/sample)
P
h
a
s
e

(
d
e
g
r
e
e
s
)
0 0.2 0.4 0.6 0.8 1
150
100
50
0
50
Normalized Angular Frequency ( rads/sample)
M
a
g
n
i
t
u
d
e

(
d
B
)
kaiserord
6-214
Desi gn an odd-l ength bandpass fi l ter (note that odd l ength means even order,
so the i nput to fir1 must be an even i nteger):
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
Desi gn a l owpass fi l ter wi th a passband cutoff of 1500 Hz, a stopband cutoff of
2000 Hz, passband ri ppl e of 0.01, stopband ri ppl e of 0.1, and a sampl i ng
frequency of 8000 Hz:
[n,Wn,beta,ftype] = kaiserord([1500 2000],[1 0],[0.01 0.1],8000);
b = fir1(n,Wn,ftype,kaiser(n+1,beta),'noscale');
Thi s i s equi val ent to
c = kaiserord([1500 2000],[1 0],[0.01 0.1],8000,'cell');
b = fir1(c{:});
0 500 1000 1500 2000 2500 3000 3500 4000
0
0.2
0.4
0.6
0.8
1
1.2
1.4
kaiserord
6-215
Remarks Be careful to di sti ngui sh between the meani ngs of fi l ter l ength and fi l ter order.
The fi l ter length i s the number of i mpul se response sampl es i n the FI R fi l ter.
General l y, the i mpul se response i s i ndexed from n =0 to n =L-1, where L i s the
fi l ter l ength. The fi l ter order i s the hi ghest power i n a z-transform
representati on of the fi l ter. For an FI R transfer functi on, thi s representati on i s
a pol ynomi al i n z, where the hi ghest power i s z
L-1
and the l owest power i s z
0
.
The fi l ter order i s 1 l ess than the l ength (L-1) and i s al so equal to the number
of zeros of the z pol ynomi al .
Diagnostics The l engths of the frequency, magni tude, and devi ati on vectors must match;
other wi se, kaiserord gi ves the fol l owi ng error message:
Requires M and DEV to be the same length.
Length of F must be 2*length(M)2.
When magni tudes are not speci fi ed correctl y, kaiserord gi ves the fol l owi ng
error messages:
Stopbands must be zero.
All passbands must have the same height.
I f the band edges are not stri ctl y i ncreasi ng, kaiserord gi ves the fol l owi ng
error message:
Bandedges must be strictly increasing.
See Also
References [1] Kai ser, J.F. Nonrecursi ve Di gi tal Fi l ter Desi gn Usi ng the - si nh Wi ndow
Functi on. Proc. 1974 I EEE Symp. Circuits and Syst. (Apri l 1974). Pgs. 20-23.
[2] I EEE. Digital Signal ProcessingI I . I EEE Pr ess. New Yor k: John Wi l ey &
Sons, 1975. Pgs. 123-126.
fir1 Wi ndow-based fi ni te i mpul se response fi l ter desi gn
standard response.
kaiser Kai ser wi ndow.
remezord Par ks-McCl el l an opti mal FI R fi l ter or der esti mati on.
I
0
latc2tf
6-216
6l atc2tf
Purpose Latti ce fi l ter to tr ansfer functi on conver si on.
Syntax [num,den] = latc2tf(k,v)
[num,den] = latc2tf(k,'iir')
num = latc2tf(k,'fir')
num = latc2tf(k)
Description [num,den] = latc2tf(k,v) fi nds the transfer functi on numerator num and
denomi nator den from the I I R l atti ce coeffi ci ents k and l adder coeffi ci ents v.
[num,den] = latc2tf(k,'iir') assumes that k i s associ ated wi th an al l -pol e
I I R l atti ce fi l ter.
num = latc2tf(k,'fir') and
num = latc2tf(k) fi nd the transfer functi on numerators from the FI R l atti ce
coeffi ci ents speci fi ed by k.
See Also
latcfilt Latti ce and l atti ce-l adder fi l ter i mpl ementati on.
tf2latc Conversi on of tr ansfer functi on to l atti ce fi l ter.
latcfilt
6-217
6l atcfi l t
Purpose Latti ce and l atti ce-l adder fi l ter i mpl ementati on.
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) fi l ters x wi th the FI R l atti ce coeffi ci ents i n vector k. f
i s the forward l atti ce fi l ter resul t and g i s the backward fi l ter resul t.
I f k and x are vectors, the resul t i s a (si gnal ) vector.
Matri x arguments are permi tted under the fol l owi ng rul es:
I f x i s a matri x and k i s a vector, each col umn of x i s processed through the
l atti ce fi l ter speci fi ed by k.
I f x i s a vector and k i s a matri x, each col umn of k i s used to fi l ter x, and a
si gnal matri x i s returned.
I f x and k are both matri ces wi th the same number of col umns, then the i-th
col umn of k i s used to fi l ter the i-th col umn of x. A si gnal matri x i s returned.
[f,g] = latcfilt(k,v,x) fi l ters x wi th the I I R l atti ce coeffi ci ents k and
l adder coeffi ci ents v. k and v must be vectors, whi l e x may be a si gnal matri x.
[f,g] = latcfilt(k,1,x) fi l ters x wi th the I I R al l -pol e l atti ce speci fi ed by k.
k and x may be vectors or matri ces accordi ng to the rul es gi ven for the FI R
l atti ce.
[f,g,zf] = latcfilt(...,'ic',zi) accepts a l ength-k vector zi speci fyi ng
the i ni ti al condi ti on of the l atti ce states. Output zf i s a l ength-k vector
speci fyi ng the fi nal condi ti on of the l atti ce states.
See Also
filter Fi l ter data wi th a recursi ve (I I R) or nonrecursi ve
(FI R) fi l ter.
latc2tf Latti ce fi l ter to tr ansfer functi on conver si on.
tf2latc Conversi on of transfer functi on to l atti ce fi l ter.
levinson
6-218
6l evi nson
Purpose Levi nson-Durbi n recursi on.
Syntax a = levinson(r,p)
Description The Levi nson-Durbi n recursi on i s an al gori thm for fi ndi ng an al l -pol e I I R fi l ter
wi th a prescri bed determi ni sti c autocorrel ati on sequence. I t has appl i cati ons i n
fi l ter desi gn, codi ng, and spectral esti mati on. The fi l ter that levinson produces
i s mi ni mum phase.
a = levinson(r,p) fi nds the coeffi ci ents of an pth-order autoregressi ve l i near
process whi ch has r as i ts autocorrel ati on sequence. r i s a real or compl ex
determi ni sti c autocorrel ati on sequence (a vector), and p i s the order of
denomi nator pol ynomi al A(z); that i s, a = [1 a(2) ... a(p+1)]. The fi l ter
coeffi ci ents are ordered i n descendi ng powers of z:
Algorithm levinson sol ves the symmetri c Toepl i tz system of l i near equati ons.
where r = [r(1) ... r(p+1)] i s the i nput autocorrel ati on vector, and r(i)
*
denotes
the compl ex conjugate of r(i). The al gori thm requi res O(p
2
) fl ops and i s thus
much more effi ci ent than the MATLAB \ command for l arge p. However, the
levinson functi on uses \ for l ow orders to provi de the fastest possi bl e
executi on.
See Also
H z ( )
1
A z ( )
---------- -
1
1 a 2 ( )z
1
L a p 1 + ( )z
p
+ + +
-------------------------------------------------------------------------- = =
r 1 ( ) r 2 ( )

L r p ( )

r 2 ( ) r 1 ( ) L r p 1 ( )

M O O M
r p ( ) L r 2 ( ) r 1 ( )
a 2 ( )
a 3 ( )
M
a p 1 + ( )
r 2 ( )
r 3 ( )
M
r p 1 + ( )
=
lpc Li near predi cti on coeffi ci ents.
prony Pronys method for ti me domai n I I R fi l ter desi gn.
rlevinson Reverse Levi nson-Durbi n recursi on.
stmcb Li near model usi ng Stei gl i tz-McBri de i terati on.
levinson
6-219
References [1] Ljung, L. SystemI dentification: Theoryfor theUser. Engl ewood Cl i ffs, NJ:
Prenti ce Hal l , 1987. Pgs. 278-280.
lp2bp
6-220
6l p2bp
Purpose Lowpass to bandpass anal og fi l ter transformati on.
Syntax [bt,at] = lp2bp(b,a,Wo,Bw)
[At,Bt,Ct,Dt] = lp2bp(A,B,C,D,Wo,Bw)
Description lp2bp transforms anal og l owpass fi l ter prototypes wi th a cutoff frequency of
1 rad/sec i nto bandpass fi l ters wi th desi red bandwi dth and center frequency.
The transformati on i s one step i n the di gi tal fi l ter desi gn process for the
butter, cheby1, cheby2, and ellip functi ons.
lp2bp can perform the transformati on on two di fferent l i near system
representati ons: transfer functi on form and state-space form. I n both cases, the
i nput system must be an anal og fi l ter prototype.
Transfer Function Form (Polynomial)
[bt,at] = lp2bp(b,a,Wo,Bw) transforms an anal og l owpass fi l ter prototype
gi ven by pol ynomi al coeffi ci ents i nto a bandpass fi l ter wi th center frequency Wo
and bandwi dth Bw. Row vectors b and a speci fy the coeffi ci ents of the numerator
and denomi nator of the prototype i n descendi ng powers of s:
Scal ars Wo and Bw speci fy the center frequency and bandwi dth i n uni ts of
radi ans/second. For a fi l ter wi th l ower band edge w1 and upper band edge w2,
use Wo = sqrt(w1*w2) and Bw = w2w1.
lp2bp returns the frequency transformed fi l ter i n row vectors bt and at.
State-Space Form
[At,Bt,Ct,Dt] = lp2bp(A,B,C,D,Wo,Bw) converts the conti nuous-ti me
state-space l owpass fi l ter prototype i n matri ces A, B, C, D:
b s ( )
a s ( )
----------
b 1 ( )s
nb
L b nb ( )s b nb 1 + ( ) + + +
a 1 ( )s
na
L a na ( )s a na 1 + ( ) + + +
------------------------------------------------------------------------------------ =
x

Ax Bu + =
y Cx Du + =
lp2bp
6-221
i nto a bandpass fi l ter wi th center frequency Wo and bandwi dth Bw. For a fi l ter
wi th l ower band edge w1 and upper band edge w2, use Wo = sqrt(w1*w2) and
Bw = w2w1.
The bandpass fi l ter i s returned i n matri ces At, Bt, Ct, Dt.
Algorithm lp2bp i s a hi ghl y accurate state-space formul ati on of the cl assi c anal og fi l ter
frequency transformati on. Consi der the state-space system:
where u i s the i nput, x i s the state vector, and y i s the output. The Lapl ace
transform of the fi rst equati on (assumi ng zero i ni ti al condi ti ons) i s
Now i f a bandpass fi l ter i s to have center frequency
0
and bandwi dth B
w
, the
standard s-domai n transformati on i s
where Q =
0
/B
w
and p = s/
0
. Substi tuti ng thi s for s i n the Lapl ace
transformed state-space equati on, and consi deri ng the operator p as d/dt:
or
Now defi ne
whi ch, when substi tuted, l eads to
x

Ax Bu + =
y Cx Du + =
sX s ( ) AX s ( ) BU s ( ) + =
s Q p
2
1 + ( ) p =
Qx

Qx + A

x Bu

+ =
Qx

x B u

Qx =
Q

Qx =
Qx

Ax Q Bu + + =
lp2bp
6-222
The l ast two equati ons gi ve equati ons of state. Wri te them i n standard form
and mul ti pl y the di fferenti al equati ons by
0
to recover the ti me/frequency
scal i ng represented by p and fi nd state matri ces for the bandpass fi l ter:
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;
I f the i nput to lp2bp i s i n transfer functi on form, the functi on transforms i t i nto
state-space form before appl yi ng thi s al gori thm.
See Also
bilinear Bi l i near transformati on method of anal og-to-di gi tal
fi l ter conversi on.
impinvar I mpul se i nvari ance method of anal og-to-di gi tal fi l ter
conversi on.
lp2bs Lowpass to bandstop anal og fi l ter transformati on.
lp2hp Lowpass to hi ghpass anal og fi l ter transformati on.
lp2lp Lowpass to l owpass anal og fi l ter transformati on.
lp2bs
6-223
6l p2bs
Purpose Lowpass to bandstop anal og fi l ter transformati on.
Syntax [bt,at] = lp2bs(b,a,Wo,Bw)
[At,Bt,Ct,Dt] = lp2bs(A,B,C,D,Wo,Bw)
Description lp2bs transforms anal og l owpass fi l ter prototypes wi th a cutoff frequency of
1 rad/sec i nto bandstop fi l ters wi th desi red bandwi dth and center frequency.
The transformati on i s one step i n the di gi tal fi l ter desi gn process for the
butter, cheby1, cheby2, and ellip functi ons.
lp2bs can perform the transformati on on two di fferent l i near system
representati ons: transfer functi on form and state-space form. I n both cases, the
i nput system must be an anal og fi l ter prototype.
Transfer Function Form (Polynomial)
[bt,at] = lp2bs(b,a,Wo,Bw) transforms an anal og l owpass fi l ter prototype
gi ven by pol ynomi al coeffi ci ents i nto a bandstop fi l ter wi th center frequency Wo
and bandwi dth Bw. Row vectors b and a speci fy the coeffi ci ents of the numerator
and denomi nator of the prototype i n descendi ng powers of s:
Scal ars Wo and Bw speci fy the center frequency and bandwi dth i n uni ts of
radi ans/second. For a fi l ter wi th l ower band edge w1 and upper band edge w2,
use Wo = sqrt(w1*w2) and Bw = w2w1.
lp2bs returns the frequency transformed fi l ter i n row vectors bt and at.
State-Space Form
[At,Bt,Ct,Dt] = lp2bs(A,B,C,D,Wo,Bw) converts the conti nuous-ti me
state-space l owpass fi l ter prototype i n matri ces A, B, C, D:
b s ( )
a s ( )
----------
b 1 ( )s
nb
L b nb ( )s b nb 1 + ( ) + + +
a 1 ( )s
na
L a na ( )s a na 1 + ( ) + + +
------------------------------------------------------------------------------------ =
x

Ax Bu + =
y Cx Du + =
lp2bs
6-224
i nto a bandstop fi l ter wi th center frequency Wo and bandwi dth Bw. For a fi l ter
wi th l ower band edge w1 and upper band edge w2, use Wo = sqrt(w1*w2) and
Bw = w2w1.
The bandstop fi l ter i s returned i n matri ces At, Bt, Ct, Dt.
Algorithm lp2bs i s a hi ghl y accurate state-space formul ati on of the cl assi c anal og fi l ter
frequency transformati on. I f a bandstop fi l ter i s to have center frequency
0
and bandwi dth B
w
, the standard s-domai n transformati on i s
where Q =
0
/B
w
and p= s/
0
. The state-space ver si on of thi s transformati on i s
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 i vati on of the bandpass versi on of thi s transformati on.
See Also
s
p
Q p
2
1 + ( )
------------------------ =
bilinear Bi l i near transformati on method of anal og-to-di gi tal
fi l ter conversi on.
impinvar I mpul se i nvari ance method of anal og-to-di gi tal fi l ter
conversi on.
lp2bp Lowpass to bandpass anal og fi l ter transformati on.
lp2hp Lowpass to hi ghpass anal og fi l ter transformati on.
lp2lp Lowpass to l owpass anal og fi l ter transformati on.
lp2hp
6-225
6l p2hp
Purpose Lowpass to hi ghpass anal og fi l ter transformati on.
Syntax [bt,at] = lp2hp(b,a,Wo)
[At,Bt,Ct,Dt] = lp2hp(A,B,C,D,Wo)
Description lp2hp transforms anal og l owpass fi l ter prototypes wi th a cutoff frequency of
1 rad/sec i nto hi ghpass fi l ter s wi th desi red cutoff fr equency. The
transformati on i s one step i n the di gi tal fi l ter desi gn process for the butter,
cheby1, cheby2, and ellip functi ons.
The lp2hp functi on can perform the transformati on on two di fferent l i near
system representati ons: transfer functi on form and state-space form. I n both
cases, the i nput system must be an anal og fi l ter prototype.
Transfer Function Form (Polynomial)
[bt,at] = lp2hp(b,a,Wo) transforms an anal og l owpass fi l ter prototype
gi ven by pol ynomi al coeffi ci ents i nto a hi ghpass fi l ter wi th cutoff frequency Wo.
Row vectors b and a speci fy the coeffi ci ents of the numerator and denomi nator
of the prototype i n descendi ng powers of s:
Scal ar Wo speci fi es the cutoff frequency i n uni ts of radi ans/second. The
frequency transformed fi l ter i s returned i n row vectors bt and at.
State-Space Form
[At,Bt,Ct,Dt] = lp2hp(A,B,C,D,Wo) converts the conti nuous-ti me
state-space l owpass fi l ter prototype i n matri ces A, B, C, D:
i nto a hi ghpass fi l ter wi th cutoff frequency Wo. The hi ghpass fi l ter i s returned
i n matri ces At, Bt, Ct, Dt.
b s ( )
a s ( )
----------
b 1 ( )s
nb
L b nb ( )s b nb 1 + ( ) + + +
a 1 ( )s
na
L a na ( )s a na 1 + ( ) + + +
------------------------------------------------------------------------------------ =
x

Ax Bu + =
y Cx Du + =
lp2hp
6-226
Algorithm lp2hp i s a hi ghl y accurate state-space formul ati on of the cl assi c anal og fi l ter
frequency transformati on. I f a hi ghpass fi l ter i s to have cutoff frequency
0
, the
standard s-domai n transformati on i s
The state-space versi on of thi s transformati on i s
At = Wo*inv(A);
Bt = Wo*(A\B);
Ct = C/A;
Dt = D C/A*B;
See lp2bp for a der i vati on of the bandpass versi on of thi s transformati on.
See Also
s

0
p
------ - =
bilinear Bi l i near transformati on method of anal og-to-di gi tal
fi l ter conversi on.
impinvar I mpul se i nvari ance method of anal og-to-di gi tal fi l ter
conversi on.
lp2bp Lowpass to bandpass anal og fi l ter transformati on.
lp2bs Lowpass to bandstop anal og fi l ter transformati on.
lp2lp Lowpass to l owpass anal og fi l ter transformati on.
lp2lp
6-227
6l p2l p
Purpose Lowpass to l owpass anal og fi l ter transformati on.
Syntax [bt,at] = lp2lp(b,a,Wo)
[At,Bt,Ct,Dt] = lp2lp(A,B,C,D,Wo)
Description lp2lp transforms an anal og l owpass fi l ter prototype wi th a cutoff frequency of
1 rad/sec i nto a l owpass fi l ter wi th any speci fi ed cutoff frequency. The
transformati on i s one step i n the di gi tal fi l ter desi gn process for the butter,
cheby1, cheby2, and ellip functi ons.
The lp2lp functi on can perform the transformati on on two di fferent l i near
system representati ons: transfer functi on form and state-space form. I n both
cases, the i nput system must be an anal og fi l ter prototype.
Transfer Function Form (Polynomial)
[bt,at] = lp2lp(b,a,Wo) transforms an anal og l owpass fi l ter prototype
gi ven by pol ynomi al coeffi ci ents i nto a l owpass fi l ter wi th cutoff frequency Wo.
Row vectors b and a speci fy the coeffi ci ents of the numerator and denomi nator
of the prototype i n descendi ng powers of s:
Scal ar Wo speci fi es the cutoff frequency i n uni ts of radi ans/second. lp2lp
returns the frequency transformed fi l ter i n row vectors bt and at.
State-Space Form
[At,Bt,Ct,Dt] = lp2lp(A,B,C,D,Wo) converts the conti nuous-ti me
state-space l owpass fi l ter prototype i n matri ces A, B, C, D:
i nto a l owpass fi l ter wi th cutoff frequency Wo. lp2lp returns the l owpass fi l ter
i n matri ces At, Bt, Ct, Dt.
b s ( )
a s ( )
----------
b 1 ( )s
nb
L b nb ( )s b nb 1 + ( ) + + +
a 1 ( )s
na
L a na ( )s a na 1 + ( ) + + +
------------------------------------------------------------------------------------ =
x

Ax Bu + =
y Cx Du + =
lp2lp
6-228
Algorithm lp2lp i s a hi ghl y accurate state-space formul ati on of the cl assi c anal og fi l ter
frequency transformati on. I f a l owpass fi l ter i s to have cutoff frequency
0
, the
standard s-domai n transformati on i s
The state-space versi on of thi s transformati on i s
At = Wo*A;
Bt = Wo*B;
Ct = C;
Dt = D;
See lp2bp for a der i vati on of the bandpass versi on of thi s transformati on.
See Also
s p
0
=
bilinear Bi l i near transformati on method of anal og-to-di gi tal
fi l ter conversi on.
impinvar I mpul se i nvari ance method of anal og-to-di gi tal fi l ter
conversi on.
lp2bp Lowpass to bandpass anal og fi l ter transformati on.
lp2bs Lowpass to bandstop anal og fi l ter transformati on.
lp2hp Lowpass to hi ghpass anal og fi l ter transformati on.
lpc
6-229
6l pc
Purpose Li near pr edi cti on coeffi ci ents.
Syntax a = lpc(x,p)
Description lpc determi nes the coeffi ci ents of a forward l i near predi ctor by mi ni mi zi ng the
predi cti on error i n the l east-squares sense. I t has appl i cati ons i n fi l ter desi gn
and speech codi ng.
a = lpc(x,p) fi nds the coeffi ci ents of a pth-order l i near predi ctor (FI R fi l ter)
that predi cts the current val ue of the real ti me seri es x based on past sampl es:
p i s the order of the predi cti on pol ynomi al , a = [1 a(2) ... a(p+1)].
I f p i s unspeci fi ed, lpc uses as a defaul t p = length(x)1. I f x i s a matri x
contai ni ng a separate si gnal i n each col umn, lpc returns a model esti mate for
each col umn i n the rows of matri x a.
Example Esti mate a data seri es usi ng a 3rd-order forward predi ctor, and compare to the
ori gi nal si gnal .
Fi rst, create the si gnal data as the output of an autoregressi ve process dri ven
by whi te noi se. Use the l ast 4096 sampl es of the AR process output to avoi d
start-up transi ents.
noise = randn(50000,1); % Normalized white Gaussian noise
x = filter(1,[1 1/2 1/3 1/4],noise);
x = x(45904:50000);
Compute the predi ctor coeffi ci ents, esti mated si gnal , predi cti on error, and
autocorrel ati on sequence of the predi cti on error.
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
x n ( ) a 2 ( )x n 1 ( ) a 3 ( )x n 2 ( ) L a p 1 + ( )x n p ( ) =
lpc
6-230
The predi cti on error, e(n), can be vi ewed as the output of the predi cti on error
fi l ter A(z) shown bel ow, wher e H(z) i s the opti mal l i near pr edi ctor , x(n) i s the
i nput si gnal , and i s the predi cted si gnal .
Compare the predi cted si gnal to the ori gi nal si gnal .
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')
Look at the autocorrel ati on of the predi cti on error.
plot(lags,acs);
title('Autocorrelation of the Prediction Error');
xlabel('Lags'); ylabel('Normalized Value'); grid;
x n ( )
H z ( ) a 2 ( )z
1
a 3 ( )z
2
L a n 1 + ( )z
p
=
x n ( )
x n ( )

+
e n ( )
Prediction Error Filter
A z ( )
0 20 40 60 80 100
4
3
2
1
0
1
2
3
Original Signal vs. LPC Estimate
Samples
A
m
p
l
i
t
u
d
e
Original Signal
LPC Estimate
lpc
6-231
The predi cti on error i s approxi matel y whi te Gaussi an noi se, as expected for a
3rd-order AR i nput process.
Algorithm lpc uses the autocorrel ati on method of autoregressi ve (AR) model i ng to fi nd
the fi l ter coeffi ci ents. The generated fi l ter mi ght not model the process exactl y
even i f the data sequence i s trul y an AR process of the correct order. Thi s i s
because the autocorrel ati on method i mpl i ci tl y wi ndows the data, that i s, i t
assumes that si gnal sampl es beyond the l ength of x are 0.
lpc computes the l east-squares sol uti on to
where
5000 0 5000
0.2
0
0.2
0.4
0.6
0.8
1
1.2
Autocorrelation of the Prediction Error
Lags
N
o
r
m
a
l
i
z
e
d

V
a
l
u
e
Xa b
X
x 1 ( ) 0 L 0
x 2 ( ) x 1 ( ) O M
M x 2 ( ) O 0
x m ( ) M Ox 1 ( )
0 x m ( ) Ox 2 ( )
M O O M
0 L 0 x m ( )
= a
1
a 2 ( )
M
a p 1 + ( )
= b
1
0
M
0
= , ,
lpc
6-232
and m i s the l ength of x. Sol vi ng the l east-squares probl em vi a the normal
equati ons
l eads to the Yul e-Wal ker equati ons
where r = [r(1) r(2) ... r(p+1)] i s an autocorrel ati on esti mate for x computed
usi ng xcorr. The Yul e-Wal ker equati ons are sol ved i n O(p
2
) fl ops by the
Levi nson-Durbi n al gori thm (see levinson).
See Also
References [1] Jackson, L.B. Digital Filters and Signal Processing. Second Ed. Boston:
Kl uwer Academi c Publ i shers, 1989. Pgs. 255-257.
X
H
Xa X
H
b =
r 1 ( ) r 2 ( )* L r p ( )*
r 2 ( ) r 1 ( ) O M
M O O r 2 ( )*
r p ( ) L r 2 ( ) r 1 ( )
a 2 ( )
a 3 ( )
M
a p 1 + ( )
r 2 ( )
r 3 ( )
M
r p 1 + ( )
=
aryule Compute an esti mate of AR model parameters usi ng
the Yul e-Wal ker method.
levinson Levi nson-Durbi n recursi on.
prony Pronys method for ti me domai n I I R fi l ter desi gn.
pyulear Power spectrum esti mate usi ng Yul e-Wal ker AR
method.
stmcb Li near model usi ng Stei gl i tz-McBri de i terati on.
maxflat
6-233
6maxfl at
Purpose General i zed di gi tal Butterworth fi l ter desi gn.
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) i s a l owpass Butterworth fi l ter wi th numerator
and denomi nator coeffi ci ents b and a of orders nb and na respecti vel y. Wn i s the
cutoff frequency at whi ch the magni tude response of the fi l ter i s equal to
(approx. -3 dB). Wn must be between 0 and 1, where 1 corresponds to hal f
the sampl i ng frequency (the Nyqui st frequency).
b = maxflat(nb,'sym',Wn) i s a symmetri c FI R Butterworth fi l ter. nb must be
even, and Wn i s restri cted to a subi nterval of [0,1]. The functi on rai ses an error
i f Wn i s speci fi ed outsi de of thi s subi nterval .
[b,a,b1,b2] = maxflat(nb,na,Wn) returns two pol ynomi al s b1 and b2 whose
product i s equal to the numerator pol ynomi al b (that i s, b = conv(b1,b2)). b1
contai ns al l the zeros at z = 1, and b2 contai ns al l the other zeros.
[...] = maxflat(nb,na,Wn,'design_flag') enabl es you to moni tor the fi l ter
desi gn, where design_flag i s
trace, for a textual di spl ay of the desi gn tabl e used i n the desi gn
plots, for pl ots of the fi l ters magni tude, group del ay, and zeros and pol es
both, for both the textual di spl ay and pl ots
maxflat
6-234
Examples nb = 10; na = 2; Wn = 0.2*pi;
[b,a,b1,b2] = maxflat(nb,na,Wn,'plots')
Algorithm The method consi sts of the use of formul ae, pol ynomi al root fi ndi ng, and a
transformati on of pol ynomi al roots.
See Also
References [1] Sel esni ck, I .W., and C.S. Burrus. General i zed Di gi tal Butterworth Fi l ter
Desi gn. Proceedingsof theI EEE I nt. Conf. Acoust., Speech, Signal Processing.
Vol . 3 (May 1996).
0 0.2 0.4 0.6 0.8 1
0
0.5
1
w/p
M
a
g
n
i
t
u
d
e
Frequency response
-1 0 1
-1
-0.5
0
0.5
1
Real
I
m
a
g
Pole-zero plot
<- deg 4
0 0.5 1
0
1
2
3
4
5
w/p
S
a
m
p
l
e
s
Group delay
butter Butterworth anal og and di gi tal fi l ter desi gn.
filter Fi l ter data wi th a recursi ve (I I R) or nonrecursi ve
(FI R) fi l ter.
freqz Frequency response of di gi tal fi l ters.
medfilt1
6-235
6medfi l t1
Purpose One-di mensi onal medi an fi l teri ng.
Syntax y = medfilt1(x,n)
y = medfilt1(x,n,blksz)
Description y = medfilt1(x,n) appl i es an order n, one-di mensi onal medi an fi l ter to vector
x. y i s the same l ength as x; the functi on treats the si gnal as i f i t i s 0 beyond
the end poi nts.
For n odd, y(k) i s the medi an of x(k(n1)/2:k+(n1)/2).
For n even, y(k) i s the medi an of x(kn/2), x(k(n/2)+1), ..., x(k+(n/2)1).
I n thi s case, medfilt1 sorts the numbers, then takes the average of the (n
1)/2 and ((n1)/2)+1 el ements.
The defaul t for n i s 3.
y = medfilt1(x,n,blksz) uses a for-l oop to compute blksz (bl ock si ze)
output sampl es at a ti me. Use blksz << length(x) i f you are l ow on memory,
si nce medfilt1 uses a worki ng matri x of si ze n-by-blksz. By defaul t,
blksz = length(x); thi s i s the fastest executi on i f you have suffi ci ent memory.
I f x i s a matri x, medfilt1 medi an fi l ters i ts col umns usi ng
y(:,i) = medfilt1(x(:,i),n,blksz)
i n a l oop over the col umns of x.
See Also
References [1] Pratt, W.K. Digital I mageProcessing. New York: John Wi l ey & Sons, 1978.
Pgs. 330-333.
filter Fi l ter data wi th a recursi ve (I I R) or nonrecursi ve
(FI R) fi l ter.
medfilt2 Two-di mensi onal medi an fi l teri ng (see I mage
ProcessingToolbox Users Guide).
median Medi an val ue (see the onl i ne MATLAB Function
Reference).
modulate
6-236
6modul ate
Purpose Modul ati on for communi cati ons si mul ati on.
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') and
y = modulate(x,Fc,Fs,'method',opt) modul ate the real message si gnal x
wi th a carri er frequency Fc and sampl i ng frequency Fs, usi ng one of the opti ons
l i sted bel ow for method. Note that some methods accept an opti on, opt.
amdsbsc
or
am
Amplitudemodulation, doublesideband, suppressed carrier.
Mul ti pl i es x by a si nusoi d of frequency Fc:
y = x.*cos(2*pi*Fc*t)
amdsbtc Amplitudemodulation, doublesideband, transmitted carrier.
Subtracts scal ar opt from x and mul ti pl i es the resul t by a si nusoi d
of frequency Fc:
y = (xopt).*cos(2*pi*Fc*t)
I f the opt parameter i s not present, modulate uses a defaul t of
min(min(x)) so that the message si gnal (xopt) i s enti rel y
non-negati ve and has a mi ni mum val ue of 0.
amssb Amplitudemodulation, singlesideband. Mul ti pl i es x by a
si nusoi d of frequency Fc and adds the resul t to the Hi l bert transform
of x mul ti pl i ed by a phase shi fted si nusoi d of frequency Fc:
y =
x.*cos(2*pi*Fc*t)+imag(hilbert(x)).*sin(2*pi*Fc*t)
Thi s effecti vel y removes the upper si deband.
modulate
6-237
fm Frequency modulation. Creates a si nusoi d wi th i nstantaneous
frequency that vari es wi th the message si gnal x:
y = cos(2*pi*Fc*t + opt*cumsum(x))
cumsum i s a rectangul ar approxi mati on to the i ntegral of x.
modulate uses opt as the constant of frequency modul ati on. I f opt
i s not present, modulate uses a defaul t of
opt = (Fc/Fs)*2*pi/(max(max(x)))
so the maxi mum frequency excursi on from Fc i s Fc Hz.
pm Phasemodulation. Creates a si nusoi d of frequency Fc whose
phase vari es wi th the message si gnal x:
y = cos(2*pi*Fc*t + opt*x)
modulate uses opt as the constant of phase modul ati on. I f opt i s
not present, modulate uses a defaul t of
opt = pi/(max(max(x)))
so the maxi mum phase excursi on i s radi ans.
pwm Pulse-width modulation. Creates a pul se-wi dth modul ated
si gnal fr om the pul se wi dths i n x. The el ements of x must be
between 0 and 1, speci fyi ng the wi dth of each pul se i n fracti ons of
a peri od. The pul ses start at the begi nni ng of each peri od, that i s,
they are l eft justi fi ed.
modulate(x,Fc,Fs,'pwm','centered')
yi el ds pul ses centered at the begi nni ng of each peri od. y i s l ength
length(x)*Fs/Fc.
ptm Pulsetimemodulation. Creates a pul se ti me modul ated si gnal
from the pul se ti mes i n x. The el ements of x must be between 0
and 1, speci fyi ng the l eft edge of each pul se i n fracti ons of a peri od.
opt i s a scal ar between 0 and 1 that speci fi es the l ength of each
pul se i n fracti ons of a peri od. The defaul t for opt i s 0.1. y i s l ength
length(x)*Fs/Fc.
qam Quadratureamplitudemodulation. Creates a quadrature
ampl i tude modul ated si gnal from si gnal s x and opt:
y = x.*cos(2*pi*Fc*t) + opt.*sin(2*pi*Fc*t)
opt must be the same si ze as x.
modulate
6-238
I f you do not speci fy method, then modulate assumes am. Except for the pwm and
ptm cases, y i s the same si ze as x.
I f x i s an array, modulate modul ates i ts col umns.
[y,t] = modulate(x,Fc,Fs) returns the i nternal ti me vector t that modulate
uses i n i ts computati ons.
See Also
demod Demodul ati on for communi cati ons si mul ati on.
vco Vol tage control l ed osci l l ator.
pburg
6-239
6pburg
Purpose Power spectrum esti mate usi ng the Burg method.
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 esti mates the power spectral densi ty (PSD) of the si gnal vector x[n]
usi ng the Burg method. Thi s method fi ts an autoregressi ve (AR) model to the
si gnal by mi ni mi zi ng (l east squares) the forward and backward predi cti on
errors whi l e constrai ni ng the AR parameters to sati sfy the Levi nson-Durbi n
recursi on. The spectral esti mate returned by pburg i s the magni tude squared
frequency response of thi s AR model . The correct choi ce of the model order p i s
i mportant.
Pxx = pburg(x,p,nfft) returns Pxx, the power spectrum esti mate. x i s the
i nput si gnal , p i s the model or der for the al l -pol e fi l ter , and nfft i s the FFT
l ength (defaul ts to 256 i f not speci fi ed). Pxx has l ength (nfft/2+1) for nfft
even, (nfft+1)/2 for nfft odd, and nfft i f x i s compl ex.
[Pxx,freq] = pburg(x,p,nfft) returns Pxx, the power spectrum esti mate,
and freq, a vector of frequenci es at whi ch the PSD was esti mated. I f the i nput
si gnal i s real -val ued, the range of freq i s [0,). I f the i nput si gnal i s compl ex,
the range of freq i s [0,2).
[Pxx,freq] = pburg(x,p,nfft,Fs) uses the si gnal s sampl i ng frequency, Fs,
to scal e both the PSD vector (Pxx) and the frequency vector (freq). Pxx i s scal ed
by 1/Fs. I f the i nput si gnal i s real -val ued, the range of freq i s [0,Fs/2). I f the
i nput si gnal i s compl ex, the range of freq i s [0,Fs). Fs defaul ts to 1 i f l eft
empty, [].
[Pxx,freq] = pburg(x,p,nfft,Fs,'range') speci fi es the range of frequency
val ues to i ncl ude i n freq. range can be:
half, to compute the PSD over the range [0,Fs/2) for real x, and [0,Fs) for
compl ex x. I f Fs i s l eft bl ank, [], the range i s [0,1/2) for real x, and [0,1)
pburg
6-240
for compl ex x. I f Fs i s omi tted enti rel y, the range i s [0,pi) for real x, and
[0,2*pi) for compl ex x. half i s the defaul t range.
whole, to compute the PSD over the range [0,Fs) for al l x. I f Fs i s l eft
bl ank, [], the range i s [0,1) for al l x. I f Fs i s omi tted enti rel y, the range i s
[0,2*pi) for al l x.
pburg(...) pl ots the power spectral densi ty i n the current fi gure wi ndow. The
frequency range on the pl ot i s the same as the range of output freq for a gi ven
set of parameters.
pburg(...,'squared') pl ots the magni tude of Pxx di rectl y, rather than
converti ng the val ues to dB.
Example Because the method esti mates the spectrum by fi tti ng an AR model to the
si gnal , fi rst defi ne the AR system (al l -pol e fi l ter) that generates the i nput.
Check the magni tude response of the process wi th 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')
0 0.2 0.4 0.6 0.8 1
20
10
0
10
20
30
40
Normalized Angular Frequency ( rads/sample)
M
a
g
n
i
t
u
d
e

(
d
B
)
AR System Magnitude Response
pburg
6-241
Now generate the i nput si gnal x by fi l teri ng whi te noi se through the AR
system. Esti mate the PSD of x based on a fourth-order AR model (si nce we
know that the ori gi nal AR system, a, has order 4).
x = filter(1,a,randn(150,1)); % AR system output
pburg(x,4) % 4th order estimate
Diagnostics The fi rst i nput argument must be a ful l vector; otherwi se pburg generates the
fol l owi ng error message:
Input signal cannot be sparse.
I f you speci fy an empty matri x for the second argument, pburg generates the
fol l owi ng error message:
Model order must be an integer.
0 0.2 0.4 0.6 0.8 1
20
10
0
10
20
30
40
Normalized Angular Frequency ( rads/sample)
P
o
w
e
r

S
p
e
c
t
r
a
l

D
e
n
s
i
t
y

(
d
B
)
Burg Spectral Estimate P
xx
()
pburg
6-242
See Also
References [1] Marpl e, S.L. Digital Spectral Analysis. Engl ewood Cl i ffs, NJ: Prenti ce Hal l ,
1987. Chapter 7.
arburg Compute an esti mate of AR model parameters usi ng
the Burg method.
lpc Li near predi cti on coeffi ci ents.
pcov Power spectrum esti mate usi ng the covari ance
method.
pmcov Power spectrum esti mate usi ng the modi fi ed
covari ance method.
pmtm Power spectrum esti mate usi ng the mul ti taper
method (MTM).
pmusic Power spectrum esti mate usi ng MUSI C ei genvector
method.
prony Pronys method for ti me domai n I I R fi l ter desi gn.
pwelch Esti mate the power spectral densi ty (PSD) of a si gnal
usi ng Wel chs method.
pyulear Power spectrum esti mate usi ng Yul e-Wal ker AR
method.
pcov
6-243
6pcov
Purpose Power spectrum esti mate usi ng the covari ance method.
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 esti mates the power spectral densi ty (PSD) of the si gnal vector x[n] usi ng
the covari ance method. Thi s method fi ts an autoregressi ve (AR) model to the
si gnal by mi ni mi zi ng the forward predi cti on error i n the l east-squares sense.
The spectral esti mate returned by pcov i s the magni tude squared frequency
response of thi s AR model . The correct choi ce of the model order p i s i mportant.
Pxx = pcov(x,p,nfft) returns Pxx, the power spectrum esti mate. x i s the
i nput si gnal , p i s the model or der for the al l -pol e fi l ter , and nfft i s the FFT
l ength (defaul ts to 256 i f not speci fi ed). Pxx has l ength (nfft/2+1) for nfft
even, (nfft+1)/2 for nfft odd, and nfft i f x i s compl ex.
[Pxx,freq] = pcov(x,p,nfft) returns Pxx, the power spectrum esti mate,
and freq, a vector of frequenci es at whi ch the PSD was esti mated. I f the i nput
si gnal i s real -val ued, the range of freq i s [0,). I f the i nput si gnal i s compl ex,
the range of freq i s [0,2).
[Pxx,freq] = pcov(x,p,nfft,Fs) uses the si gnal s sampl i ng frequency, Fs,
to scal e both the PSD vector (Pxx) and the frequency vector (freq). Pxx i s scal ed
by 1/Fs. I f the i nput si gnal i s real -val ued, the range of freq i s [0,Fs/2). I f the
i nput si gnal i s compl ex, the range of freq i s [0,Fs). Fs defaul ts to 1 i f l eft
empty, [].
[Pxx,freq] = pcov(x,p,nfft,Fs,'range') speci fi es the range of frequency
val ues to i ncl ude i n freq. range can be:
half, to compute the PSD over the range [0,Fs/2) for real x, and [0,Fs) for
compl ex x. I f Fs i s l eft bl ank, [], the range i s [0,1/2) for real x, and [0,1)
pcov
6-244
for compl ex x. I f Fs i s omi tted enti rel y, the range i s [0,pi) for real x, and
[0,2*pi) for compl ex x. half i s the defaul t range.
whole, to compute the PSD over the range [0,Fs) for al l x. I f Fs i s l eft
bl ank, [], the range i s [0,1) for al l x. I f Fs i s omi tted enti rel y, the range i s
[0,2*pi) for al l x.
pcov(...) pl ots the power spectral densi ty i n the fi rst avai l abl e fi gure wi ndow.
The frequency range on the pl ot i s the same as the range of output freq for a
gi ven set of parameters.
pcov(...,'squared') pl ots the magni tude of Pxx di rectl y, rather than
converti ng the val ues to dB.
Example Because the method esti mates the spectrum by fi tti ng an AR model to the
si gnal , fi rst defi ne the AR system (al l -pol e fi l ter) that generates the i nput.
Check the magni tude response of the process wi th 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')
0 0.2 0.4 0.6 0.8 1
20
10
0
10
20
30
40
Normalized Angular Frequency ( rads/sample)
M
a
g
n
i
t
u
d
e

(
d
B
)
AR System Magnitude Response
pcov
6-245
Now generate the i nput si gnal x by fi l teri ng whi te noi se through the AR
system. Esti mate the PSD of x based on a fourth-order AR model (si nce we
know that the ori gi nal AR system, a, has order 4).
x = filter(1,a,randn(150,1)); % AR system output
pcov(x,4) % 4th order estimate
Diagnostics The fi rst i nput argument must be a ful l vector; otherwi se pcov generates the
fol l owi ng error message:
Input signal cannot be sparse.
I f you speci fy an empty matri x for the second argument, pcov generates the
fol l owi ng error message:
Model order must be an integer.
0 0.2 0.4 0.6 0.8 1
20
10
0
10
20
30
40
Normalized Angular Frequency ( rads/sample)
P
o
w
e
r

S
p
e
c
t
r
a
l

D
e
n
s
i
t
y

(
d
B
)
Covariance Spectral Estimate P
xx
()
pcov
6-246
See Also
References [1] Marpl e, S.L. Digital Spectral Analysis. Engl ewood Cl i ffs, NJ: Prenti ce Hal l ,
1987. Chapter 7.
arcov Compute an esti mate of AR model parameters usi ng
the covari ance method.
lpc Li near predi cti on coeffi ci ents.
pburg Power spectrum esti mate usi ng the Burg method.
pmcov Power spectrum esti mate usi ng the modi fi ed
covari ance method.
pmtm Power spectrum esti mate usi ng the mul ti taper
method (MTM).
pmusic Power spectrum esti mate usi ng MUSI C ei genvector
method.
prony Pronys method for ti me domai n I I R fi l ter desi gn.
pwelch Esti mate the power spectral densi ty (PSD) of a si gnal
usi ng Wel chs method.
pyulear Power spectrum esti mate usi ng Yul e-Wal ker AR
method.
pmcov
6-247
6pmcov
Purpose Power spectrum esti mate usi ng the modi fi ed covari ance method.
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 esti mates the power spectral densi ty (PSD) of the si gnal vector x[n]
usi ng the modi fi ed covari ance method. Thi s method fi ts an autoregressi ve (AR)
model to the si gnal by mi ni mi zi ng the forward and backward predi cti on errors
i n the l east-squares sense. The spectral esti mate returned by pmcov i s the
magni tude squared frequency response of thi s AR model . The correct choi ce of
the model order p i s i mportant.
Pxx = pmcov(x,p,nfft) returns Pxx, the power spectrum esti mate. x i s the
i nput si gnal , p i s the model or der for the al l -pol e fi l ter , and nfft i s the FFT
l ength (defaul ts to 256 i f not speci fi ed). Pxx has l ength (nfft/2+1) for nfft
even, (nfft+1)/2 for nfft odd, and nfft i f x i s compl ex.
[Pxx,freq] = pmcov(x,p,nfft) returns Pxx, the power spectrum esti mate,
and freq, a vector of frequenci es at whi ch the PSD was esti mated. I f the i nput
si gnal i s real -val ued, the range of freq i s [0,). I f the i nput si gnal i s compl ex,
the range of freq i s [0,2).
[Pxx,freq] = pmcov(x,p,nfft,Fs) uses the si gnal s sampl i ng frequency, Fs,
to scal e both the PSD vector (Pxx) and the frequency vector (freq). Pxx i s scal ed
by 1/Fs. I f the i nput si gnal i s real -val ued, the range of freq i s [0,Fs/2). I f the
i nput si gnal i s compl ex, the range of freq i s [0,Fs). Fs defaul ts to 1 i f l eft
empty, [].
[Pxx,freq] = pmcov(x,p,nfft,Fs,'range') speci fi es the range of frequency
val ues to i ncl ude i n freq. range can be:
half, to compute the PSD over the range [0,Fs/2) for real x, and [0,Fs) for
compl ex x. I f Fs i s l eft bl ank, [], the range i s [0,1/2) for real x, and [0,1)
pmcov
6-248
for compl ex x. I f Fs i s omi tted enti rel y, the range i s [0,pi) for real x, and
[0,2*pi) for compl ex x. half i s the defaul t range.
whole, to compute the PSD over the range [0,Fs) for al l x. I f Fs i s l eft
bl ank, [], the range i s [0,1) for al l x. I f Fs i s omi tted enti rel y, the range i s
[0,2*pi) for al l x.
pmcov(...) pl ots the power spectral densi ty i n the fi rst avai l abl e fi gure
wi ndow. The frequency range on the pl ot i s the same as the range of output
freq for a gi ven set of parameters.
pmcov(...,'squared') pl ots the magni tude of Pxx di rectl y, rather than
converti ng the val ues to dB.
Example Because the method esti mates the spectrum by fi tti ng an AR model to the
si gnal , fi rst create the AR system (al l -pol e fi l ter) that generates the i nput.
Check the magni tude response of the process wi th 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')
0 0.2 0.4 0.6 0.8 1
20
10
0
10
20
30
40
Normalized Angular Frequency ( rads/sample)
M
a
g
n
i
t
u
d
e

(
d
B
)
AR System Magnitude Response
pmcov
6-249
Now generate the i nput si gnal x by fi l teri ng whi te noi se through the AR
system. Esti mate the PSD of x based on a fourth-order AR model (si nce we
know that the ori gi nal AR system, a, has order 4).
x = filter(1,a,randn(150,1)); % AR system output
pmcov(x,4) % 4th order estimate
Diagnostics The fi rst i nput argument must be a ful l vector; otherwi se pmcov generates the
fol l owi ng error message:
Input signal cannot be sparse.
I f you speci fy an empty matri x for the second argument, pmcov generates the
fol l owi ng error message:
Model order must be an integer.
0 0.2 0.4 0.6 0.8 1
30
20
10
0
10
20
30
40
Normalized Angular Frequency ( rads/sample)
P
o
w
e
r

S
p
e
c
t
r
a
l

D
e
n
s
i
t
y

(
d
B
)
Modified Covariance Spectral Estimate P
xx
()
pmcov
6-250
See Also
References [1] Marpl e, S.L. Digital Spectral Analysis. Engl ewood Cl i ffs, NJ: Prenti ce Hal l ,
1987. Chapter 7.
armcov Compute an esti mate of AR model parameters usi ng
the modi fi ed covari ance method.
lpc Li near predi cti on coeffi ci ents.
pburg Power spectrum esti mate usi ng the Burg method.
pcov Power spectrum esti mate usi ng the covari ance
method.
pmtm Power spectrum esti mate usi ng the mul ti taper
method (MTM).
pmusic Power spectrum esti mate usi ng MUSI C ei genvector
method.
prony Pronys method for ti me domai n I I R fi l ter desi gn.
pwelch Esti mate the power spectral densi ty (PSD) of a si gnal
usi ng Wel chs method.
pyulear Power spectrum esti mate usi ng Yul e-Wal ker AR
method.
pmtm
6-251
6pmtm
Purpose Power spectrum esti mate usi ng the mul ti taper method (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 esti mates the power spectral densi ty (PSD) of the real ti me seri es xusi ng
the mul ti taper method (MTM), descri bed i n [1].
Pxx = pmtm(x,nw) esti mates the PSD usi ng nw as the ti me-bandwi dth product
for the di screte prol ate spheroi dal sequences (Sl epi an sequences) that are used
as data wi ndows. The defaul t for nw i s 4; other typi cal choi ces are
2, 5/2, 3, 7/2. The number of sequences used to form Pxx i s 2*nw1.
Pxx = pmtm(x,nw,nfft) defi nes the frequency gri d as l ength nfft. When x i s
real , Pxx i s l ength (nfft/2+1) for nfft even and (nfft+1)/2 for nfft odd;
when x i s compl ex, Pxx i s l ength nfft. The defaul t for nfft i s 256 or the next
power of 2 greater than the l ength of x, whi chever i s l arger.
[Pxx,f] = pmtm(x,nw,nfft,Fs) returns f, the vector of frequenci es at whi ch
the PSD i s esti mated, for the sampl i ng frequency Fs. The defaul t for Fs i s 1 Hz.
[Pxx,f] = pmtm(x,nw,nfft,Fs,'method') speci fi es the al gori thm used for
combi ni ng the i ndi vi dual spectral esti mates, where method i s:
adapt, to speci fy Thomsons adapti ve nonl i near combi nati on (defaul t)
unity, to speci fy a l i near combi nati on wi th uni ty wei ghts
eigen, to speci fy a l i near combi nati on wi th ei genval ue wei ghts
[Pxx,Pxxc,f] = pmtm(x,nw,nfft,Fs,'method') returns Pxxc, the 95%
confi dence i nterval for Pxx, and
[Pxx,Pxxc,f] = pmtm(x,nw,nfft,Fs,'method',p) returns Pxxc, the p*100%
confi dence i nterval for Pxx, where p i s a scal ar between 0 and 1. Confi dence
pmtm
6-252
i nterval s are computed usi ng a chi -squared approach, where Pxxc(:,1) i s the
l ower bound and Pxxc(:,2) i s the upper bound of the confi dence i nterval .
[Pxx,Pxxc,f] = pmtm(x,e,v,nfft,Fs,'method',p) returns the PSD
esti mate Pxx, the confi dence i nterval Pxxc, and the frequency vector f from the
data tapers i n e and thei r concentrati ons v.
[Pxx,Pxxc,f] = pmtm(x,dpss_params,nfft,Fs,'method',p) returns the
PSD esti mate Pxx, the confi dence i nterval Pxxc, and the frequency vector f
from the data tapers computed usi ng dpss wi th parameters from the cel l array
dpss_params, whose fi rst el ement i s the second i nput to dpss. The fi rst dpss
parameter (n) i s determi ned by the l ength of x. For exampl e,
pmtm(x,{3.5,'trace'},512,Fs) cal cul ates the Sl epi an sequences for nw =3.5,
and di spl ays the method that dpss uses. See dpss for other opti ons.
Remarks pmtm wi th no output arguments pl ots the PSD i n the current or next avai l abl e
fi gure, wi th confi dence i nterval s.
To use defaul t parameters for any argument i n an expressi on, i nsert an empty
matri x []. For exampl e, pmtm(x,[],[],1000) uses defaul ts for the second and
thi rd el ements, i n thi s case, nw and nfft.
pmtm
6-253
Example Thi s exampl e anal yzes a si nusoi d i n whi te noi se:
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]))
See Also
0 100 200 300 400 500
-10
-5
0
5
10
15
20
dpss Di screte prol ate spheroi dal sequences (Sl epi an
sequences).
pburg Power spectrum esti mate usi ng the Burg method.
pcov Power spectrum esti mate usi ng the covari ance
method.
pmcov Power spectrum esti mate usi ng the modi fi ed
covari ance method.
pmusic Power spectrum esti mate usi ng MUSI C ei genvector
method.
pwelch Esti mate the power spectral densi ty (PSD) of a si gnal
usi ng Wel chs method.
pyulear Power spectrum esti mate usi ng Yul e-Wal ker AR
method.
pmtm
6-254
References [1] Perci val , D.B., and A.T. Wal den. Spectral Analysis for Physical
Applications: Multitaper andConventional UnivariateTechniques. Cambri dge:
Cambri dge Uni versi ty Press, 1993.
[2] Thomson, D.J. Spectrum esti mati on and harmoni c anal ysi s. I n
Proceedings of theI EEE. Vol . 70 (1982). Pgs. 1055-1096.
pmusic
6-255
6pmusi c
Purpose Power spectrum esti mate usi ng MUSI C ei genvector method.
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 esti mates the power spectral densi ty (PSD) of a si gnal or correl ati on
matri x usi ng Schmi dts ei gen-anal ysi s method [1]. The name MUSI C i s an
acronym for MUl ti pl e SI gnal Cl assi fi cati on. The eigenvector method, whi ch
uses ei genval ue wei ghti ng, i s al so supported [2]. The cal l i ng syntax i s si mi l ar
to that of pwelch, whi ch al so performs spectrum esti mati on. pwelch uses the
cl assi cal FFT-based approach whi l e pmusic performs ei gen-anal ysi s of the
si gnal s correl ati on matri x.
[Pxx,f] = pmusic(x,p) and
[Pxx,f] = pmusic(x,[p thresh]) return Pxx, the power spectrum esti mate,
and f, a vector of frequenci es at whi ch the PSD i s esti mated. x i s the i nput
si gnal , wher e:
A row or col umn vector represents one observati on of the process output (for
exampl e, one si gnal )
A rectangul ar (possi bl y square) array assumes that each col umn of x i s a
separate observati on of the process output (for exampl e, each col umn i s one
output of an array of sensors, as i n array processi ng)
A square matri x, gi ven the trai l i ng argument 'corr', represents a
correl ati on matri x
The second argument i s a one- or two-el ement vector, ei ther p or [p thresh].
I f onl y p i s speci fi ed, the si gnal subspace di mensi on i s p. I f [p thresh] i s
speci fi ed, thresh i s mul ti pl i ed by
mi n
, the smal l est ei genval ue; ei genval ues
bel ow the threshol d
mi n
*thresh are assi gned to the noi se subspace. I n thi s
case, p i s the maxi mum di mensi on of the si gnal subspace.
pmusic
6-256
NOTE pmusic must assi gn ei genvectors to the noi se and si gnal subspaces,
but thi s i s very di ffi cul t to do i n practi ce. The two parameters p and thresh
are provi ded for fl exi bi l i ty and control .
[Pxx,f] = pmusic(x,[p thresh],nfft,Fs,window,noverlap) speci fi es the
FFT l ength nfft (defaul t i s 256) and the sampl i ng frequency for the si gnal Fs
(defaul t i s 1). I f Fs i s speci fi ed, the output frequency vector f i s scal ed by thi s
val ue. I f the i nput si gnal i s real -val ued, the frequency range i s 0 to Fs/2; for
the compl ex case, i t i s 0 to Fs. window i s a scal ar speci fyi ng the rectangul ar
wi ndow l ength, or a vector gi vi ng the actual wi ndow coeffi ci ents. noverlap,
used i n conjuncti on wi th window, i s a scal ar that gi ves the number of poi nts by
whi ch to overl ap successi ve wi ndows.
[Pxx,f] = pmusic(x,...,'corr') forces x to be taken as a correl ati on
matri x. I n thi s case, the arguments window and noverlap are i gnored.
[Pxx,f] = pmusic(x,...,'ev') sel ects the ei genvector vari ant of the MUSI C
esti mator. See the Al gori thm secti on bel ow for an expl anati on of how thi s i s
di fferent from the MUSI C method.
[Pxx,f,evects,svals] = pmusic(x,...) returns two addi ti onal arguments.
evects i s a matri x of ei genvectors spanni ng the noi se subspace (one per
col umn). svals i s ei ther a vector of si ngul ar val ues (squared) from svd or a
vector of ei genval ues of the correl ati on matri x when the 'corr' opti on i s
present.
Remarks The i nput x can be a vector or a matri x. x can be i nter preted as si gnal data or
as a correl ati on matri x, i n one of three ways:
x i s a vector of si gnal val ues (row or col umn). I n thi s case, the di mensi on of
the ei genvectors must be gi ven. Thi s i s done ei ther by taki ng the defaul t
val ue of 2*p or by speci fyi ng a wi ndow l ength usi ng window.
x i s a rectangul ar (m-by-n, possi bl y square) matri x. I n thi s case, each col umn
of x i s a separate observati on si gnal that enters i nto the SVD anal ysi s, n i s
pmusic
6-257
the number of observati ons, and the di mensi on of the ei genvectors i s equal
to m, the l ength of a col umn.
x i s a square matri x and the trai l i ng 'corr' i s present. x i s treated as a
correl ati on matri x. I n thi s case, the matri x must have onl y real , nonnegati ve
ei genval ues.
The i nputs p and thresh can determi ne the number of noi se ei genvectors i n one
of four ways:
I f thresh < 1, or i f i t i s unspeci fi ed, the number of ei genvectors spanni ng the
si gnal subspace wi l l be equal to p. p must be an i nteger sati sfyi ng 0 p < n,
where n i s the di mensi on of the ei genvectors. Thi s di mensi on n i s the col umn
l ength i n the data matri x case, the matri x si ze i n the correl ati on matri x case,
or the wi ndow l ength for si gnal vector s. The val ue of thresh i s unused.
I f p n, thresh must be at l east 1. thresh i s used as the mul ti pl i er to
determi ne an absol ute threshol d for spl i tti ng the ei genval ues between the
si gnal and noi se subspaces:
I f thresh < 1, there wi l l be no noi se ei genvectors. Thi s case i s not al l owed
and gi ves the fol l owi ng er r or message:
Noise subspace dimension cannot be zero.
When p < n and thresh 1, p speci fi es the maxi mum number of si gnal
ei genvectors. However, the threshol d test speci fi ed by thresh can al so take
ei genvectors from the si gnal subspace and assi gn them to the noi se subspace.
Examples Thi s exampl e anal yzes a si gnal vector xx, assumi ng that two real si gnal s are
present i n the si gnal subspace. I n thi s case, the di mensi on of the si gnal
subspace i s 4 because each real si nusoi d i s the sum of two compl ex
exponenti al s:
nn = 0:199;
xx = cos(0.257*pi*nn) + sin(0.2*pi*nn) + 0.01*randn(size(nn));
[PP,ff] = pmusic(xx,4);
Thi s exampl e anal yzes the same si gnal vector xx wi th an ei genval ue cutoff of
10% above the mi ni mum. Setti ng p = Inf forces the si gnal /noi se subspace

k
thresh ( )mi n
k
( )
k
v
k
{ , } bel ong to noi se subspace
pmusic
6-258
deci si on to be based on thresh. Use ei genvectors of di mensi on 7 and a sampl i ng
frequency Fs of 8 kHz:
[PP,ff] = pmusic(xx,[Inf,1.1],[],8000,7); % window length = 7
Wi th the thi rd and fourth outputs, by pl otti ng the zeros of the noi se-ei genvector
pol ynomi al s, i t i s possi bl e to create a Root-MUSI C al gori thm, as the fol l owi ng
zplane pl ot i l l ustrates:
[PP,ff,v_noise] = pmusic(xx,4);
for kk = 1:size(v_noise,2)
rr(:,kk) = roots(v_noise(:,kk));
end
zplane(rr)
Assume that RR i s a square correl ati on matri x (for exampl e, 7-by-7):
RR = toeplitz(cos(0.1*pi*[0:6])) + 0.1*eye(7);
[PP,ff] = pmusic(RR,4,'corr');
Make an observati on matri x xx that i s rectangul ar (100-by-7):
xx = reshape(cos(0.257*pi*(0:699)),7,100) + 0.1*randn(7,100);
[PP,ff] = pmusic(xx,4);
Use the same si gnal , but l et pmusic form the 100-by-7 data matri x usi ng i ts
wi ndow and overl ap i nputs. I n addi ti on, use a l onger FFT:
yy = xx(:);
[PP,ff] = pmusic(yy,4,512,[],7,0);
I f we set p = 0, al l the ei genvectors are assi gned to the noi se subspace. 'ev'
speci fi es the ei genvector wei ghti ng. Thi s turns out to be equi val ent to MVDL
(Capons MLM):
[PP,ff] = pmusic(RR,0,'ev','corr');
Algorithm The MUSI C esti mate i s gi ven by the formul a
P
music
f ( )
1
e
H
f ( ) v
k
v
k
H
k p 1 + =
N

,


_
e f ( )
----------------------------------------------------------------
1
v
k
H
e f ( )
2
k p 1 + =
N

------------------------------------------- = =
pmusic
6-259
where N i s the di mensi on of the ei genvectors and v
k
i s the k-th ei genvector of
the correl ati on matri x of the i nput si gnal . The i nteger pi s the di mensi on of the
si gnal subspace, so the ei genvectors v
k
used i n the sum correspond to the
smal l est ei genval ues and al so span the noi se subspace. The vector e(f) consi sts
of compl ex exponenti al s, so the i nner product
amounts to a Fouri er transform. The second form i s preferred for computati on
because the FFTi s computed for each v
k
and then the squared magni tudes are
summed.
I n the ei genvector method, the summati on i s wei ghted by the ei genval ues
k
of
the correl ati on matri x:
The functi on rel i es on the svd matri x decomposi ti on i n the si gnal case, and i t
uses the eig functi on for anal yzi ng the correl ati on matri x. I f SVD i s used, the
correl ati on matri x i s never expl i ci tl y computed, but the si ngul ar val ues are
the
k
.
Diagnostics There must be at l east one output argument and at l east two i nputs; otherwi se,
pmusic stops and gi ves one of the fol l owi ng error messages:
Must have at least 1 output argument.
Must have at least 2 input arguments.
The fi rst argument must be a ful l matri x, otherwi se pmusic gi ves the fol l owi ng
error message:
Input signal or correlation cannot be sparse.
v
k
H
e f ( )
P
ev
f ( )
1
v
k
H
e f ( )
2
k p 1 + =
N

,


_

----------------------------------------------------------- =
pmusic
6-260
I f the second argument was entered as an empty matri x, or i f i t has more than
two el ements, or i f i t has negati ve or non-i nteger el ements, pmusic gi ves one of
the fol l owi ng er r or messages:
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.
I f the val ue of p i s too l arge wi th respect to the ei genvector di mensi on, and
thresh i s l ess than 1, no ei genvectors can be assi gned to the noi se subspace and
the al gori thm fai l s. I n thi s case, pmusic gi ves the fol l owi ng error message:
Noise subspace dimension cannot be zero.
I f the 'corr' parameter i s used, then the fi rst i nput must be a square
correl ati on matri x. I f i t i s not, pmusic gi ves the fol l owi ng error message:
Correlation matrix (R) is not square.
The correl ati on matri x i s then checked for val i di ty; i f i t fai l s, pmusic gi ves the
fol l owi ng error message:
Correlation matrix (R) has negative or complex eigenvalue.
See Also
lpc Li near predi cti on coeffi ci ents.
pburg Power spectrum esti mate usi ng the Burg method.
pcov Power spectrum esti mate usi ng the covari ance
method.
pmcov Power spectrum esti mate usi ng the modi fi ed
covari ance method.
pmtm Power spectrum esti mate usi ng the mul ti taper
method (MTM).
prony Pronys method for ti me domai n I I R fi l ter desi gn.
pwelch Esti mate the power spectral densi ty (PSD) of a si gnal
usi ng Wel chs method.
pyulear Power spectrum esti mate usi ng Yul e-Wal ker AR
method.
pmusic
6-261
References [1] Schmi dt, R.O. Mul ti pl e Emi tter Locati on and Si gnal Parameter
Esti mati on. I EEE Trans. Antennas Propagation. Vol . AP-34 (March 1986).
Pgs. 276-280.
[2] Marpl e, S.L. Digital Spectral Analysis. Engl ewood Cl i ffs, NJ: Prenti ce Hal l ,
1987. Pgs. 373-378.
poly2ac
6-262
6pol y2ac
Purpose Conversi on of pr edi cti on pol ynomi al to autocor r el ati on sequence.
Syntax r = poly2ac(a,efinal)
Description r = poly2ac(a,efinal) fi nds the autocorrel ati on sequence correspondi ng to
predi cti on pol ynomi al a and fi nal predi cti on error efinal. I f a(1) i s not equal
to 1, poly2ac normal i zes the predi cti on pol ynomi al by a(1). a(1) cannot be 0.
See Also
References [1] Kay, S.M. Modern Spectral Estimation. Engl ewood Cl i ffs, NJ:
Prenti ce-Hal l , 1988.
ac2poly Conversi on of autocorrel ati on sequence to predi cti on
pol ynomi al .
poly2rc Conversi on of predi cti on pol ynomi al to refl ecti on
coeffi ci ents.
rc2ac Conversi on of refl ecti on coeffi ci ents to
autocorrel ati on sequence.
poly2rc
6-263
6pol y2r c
Purpose Conversi on of predi cti on pol ynomi al to refl ecti on coeffi ci ents.
Syntax k = poly2rc(a)
[k,r0] = poly2rc(a,efinal)
Description k = poly2rc(a) fi nds the refl ecti on coeffi ci ents of the AR l atti ce structure
correspondi ng to predi cti on pol ynomi al a. a must be real , and a(1) cannot be 0.
I f a(1) i s not equal to 1, poly2rc normal i zes the predi cti on pol ynomi al by a(1).
k i s a row vector of si ze length(a)1.
[k,r0] = poly2rc(a,efinal) returns the zero-l ag autocorrel ati on, r0, based
on the fi nal predi cti on error, efinal.
A si mpl e, fast way to check i f a has al l of i ts roots i nsi de the uni t ci rcl e i s to
check i f each of the el ements of k has magni tude l ess than 1:
stable = all(abs(poly2rc(a))<1)
Example Consi der an I I R fi l ter gi ven by
a = [1.0000 0.6149 0.9899 0.0000 0.0031 0.0082];
I ts refl ecti on coeffi ci ent representati on i s
k = poly2rc(a)
k =
0.3090
0.9801
0.0031
0.0081
0.0082
Limitations I f abs(k(i)) == 1 for any i, fi ndi ng the refl ecti on coeffi ci ents i s an
i l l -condi ti oned probl em. poly2rc wi l l return some NaNs and provi de a warni ng
message i n thi s case.
Algorithm poly2rc i mpl ements the recursi ve rel ati onshi p:
poly2rc
6-264
Thi s rel ati onshi p i s based on Levi nsons recursi on [1]. To i mpl ement i t,
poly2rc l oops through a i n reverse order after di scardi ng i ts fi rst el ement. For
each l oop i terati on i, the functi on
1 sets k(i) equal to a(i)
2 appl i es the second rel ati onshi p above to el ements 1 through i of the vector a:
a = (ak(i)*fliplr(a))/(1k(i)^2);
See Also
References [1] Kay, S.M. Modern Spectral Estimation: TheoryandApplication. Engl ewood
Cl i ffs, NJ: Prenti ce Hal l , 1988.
k n ( ) a
n
n ( ) =
a
n 1
m ( )
a
n
m ( ) k n ( )a
n
n m ( )
1 k n ( )
2

---------------------------------------------------------- m 1 = 2 n 1 , , , , =
ac2rc Conversi on of autocorrel ati on sequence to refl ecti on
coeffi ci ents.
latc2tf Latti ce fi l ter to transfer functi on conversi on.
latcfilt Latti ce and l atti ce-l adder fi l ter i mpl ementati on.
poly2ac Conversi on of predi cti on pol ynomi al to
autocorrel ati on sequence.
rc2poly Conversi on of refl ecti on coeffi ci ents to predi cti on
pol ynomi al .
tf2latc Conversi on of tr ansfer functi on to l atti ce fi l ter.
polystab
6-265
6pol ystab
Purpose Stabi l i ze pol ynomi al .
Syntax b = polystab(a)
Description polystab stabi l i zes a pol ynomi al wi th respect to the uni t ci rcl e; i t refl ects roots
wi th magni tudes greater than 1 i nsi de the uni t ci rcl e.
b = polystab(a) where a i s a vector of pol ynomi al coeffi ci ents normal l y i n the
z-domai n:
returns a row vector contai ni ng the stabi l i zed pol ynomi al .
Example polystab can convert a l i near-phase fi l ter i nto a mi ni mum-phase fi l ter wi th
the same magni tude response:
h = fir1(25,0.4);
hmin = polystab(h)*norm(h)/norm(polystab(h));
Algorithm polystab fi nds the roots of the pol ynomi al and maps those roots found outsi de
the uni t ci rcl e to the i nsi de of the uni t ci rcl e:
v = roots(a);
vs = 0.5*(sign(abs(v)1)+1);
v = (1vs).*v + vs./conj(v);
b = a(1)*poly(v);
See Also
a z ( ) a 1 ( ) a 2 ( )z
1
L a na 1 + ( )z
na
+ + + =
roots Pol ynomi al roots (see the onl i ne MATLAB Function
Reference).
prony
6-266
6pr ony
Purpose Pronys method for ti me domai n I I R fi l ter desi gn.
Syntax [b,a] = prony(h,nb,na)
Description Pronys method i s an al gori thm for fi ndi ng an I I R fi l ter wi th a prescri bed ti me
domai n i mpul se response. I t has appl i cati ons i n fi l ter desi gn, exponenti al
si gnal model i ng, and system i denti fi cati on (parametri c model i ng).
[b,a] = prony(h,nb,na) fi nds a fi l ter wi th numerator order nb, denomi nator
order na, and the ti me domai n i mpul se response i n h. prony returns the fi l ter
coeffi ci ents i n row vectors b and a, of l ength nb + 1 and na + 1, respecti vel y.
The fi l ter coeffi ci ents are i n descendi ng powers of z:
Example Recover the coeffi ci ents of a Butterworth fi l ter from i ts i mpul se response:
[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 i mpl ements the method descri bed i n reference [1]. Thi s method uses a
vari ati on of the covari ance method of AR model i ng to fi nd the denomi nator
coeffi ci ents a and then fi nds the numerator coeffi ci ents b for whi ch the i mpul se
response of the output fi l ter matches exactl y the fi rst nb + 1 sampl es of x. The
fi l ter i s not necessari l y stabl e, but potenti al l y can recover the coeffi ci ents
H z ( )
B z ( )
A z ( )
-----------
b 1 ( ) b 2 ( )z
1
L b nb 1 + ( )z
nb
+ + +
a 1 ( ) a 2 ( )z
1
L a na 1 + ( )z
na
+ + +
----------------------------------------------------------------------------------------- = =
prony
6-267
exactl y i f the data sequence i s trul y an autoregressi ve movi ng average (ARMA)
process of the correct order.
See Also
References [1] Parks, T.W., and C.S. Burrus. Digital Filter Design. New York: John Wi l ey
& Sons, 1987. Pgs. 226-228.
butter Butterworth anal og and di gi tal fi l ter desi gn.
cheby1 Chebyshev type I fi l ter desi gn (passband ri ppl e).
cheby2 Chebyshev type I I fi l ter desi gn (stopband ri ppl e).
ellip El l i pti c (Cauer) fi l ter desi gn.
invfreqz Di screte-ti me fi l ter i denti fi cati on from frequency
data.
levinson Levi nson-Durbi n recursi on.
lpc Li near pr edi cti on coeffi ci ents.
stmcb Li near model usi ng Stei gl i tz-McBri de i terati on.
psd
6-268
6psd
Superseded The psd functi on for spectral esti mati on by Wel chs method has been
superseded by pwelch.
The pwelch functi on i mproves upon psd i n three ways:
The magni tude of the spectrum i s scal ed by 1/Fs
The defaul t val ue of Fs i s 1
No detrendi ng i s performed
The psd functi on wi l l conti nue to be i ncl uded i n the Si gnal Processi ng Tool box
for backwards compati bi l i ty.
pulstran
6-269
6pul str an
Purpose Pul se trai n generator.
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 generates pul se trai ns from conti nuous functi ons or sampl ed
prototype pul ses.
y = pulstran(t,d,'func') generates a pul se trai n based on sampl es of a
conti nuous functi on, 'func', where func i s:
gauspuls, for Gaussi an-modul ated si nusoi dal pul se generator
rectpuls, for sampl ed aperi odi c rectangl e generator
tripuls, for sampl ed aperi odi c tri angl e generator
pulstran i s eval uated length(d) ti mes and returns the sum of the eval uati ons
y = func(td(1)) + func(td(2)) + ...
The functi on i s eval uated over the range of argument val ues speci fi ed i n array
t, after removi ng a scal ar argument offset taken from the vector d. Note that
func must be a vectori zed functi on that can take an array t as an argument.
An opti onal gai n factor may be appl i ed to each del ayed eval uati on by speci fyi ng
d as a two-col umn matri x, wi th the offset defi ned i n col umn 1 and associ ated
gai n i n col umn 2 of d. Note that a row vector wi l l be i nterpreted as speci fyi ng
del ays onl y.
pulstran(t,d,'func',p1,p2,...) al l ows addi ti onal parameters to be passed
to 'func' as necessary. For exampl e,
func(td(1),p1,p2,...) + func(td(2),p1,p2,...) + ...
pulstran(t,d,p,Fs) generates a pul se trai n that i s the sum of mul ti pl e
del ayed i nterpol ati ons of the prototype pul se i n vector p, sampl ed at the rate
Fs, where p spans the ti me i nterval [0,(length(p)1)/Fs], and i ts sampl es
are i denti cal l y 0 outsi de thi s i nterval . By defaul t, l i near i nterpol ati on i s used
for generati ng del ays.
pulstran
6-270
pulstran(t,d,p) assumes that the sampl i ng rate Fs i s equal to 1 Hz.
pulstran(...,'func') speci fi es al ternati ve i nterpol ati on methods. See
interp1 for a l i st of avai l abl e methods.
Examples Thi s exampl e generates an asymmetri c sawtooth waveform wi th a repeti ti on
frequency of 3 Hz and a sawtooth wi dth of 0.1 sec. I t has a si gnal l ength of 1 sec
and a 1 kHz sampl e rate:
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)
Thi s exampl e generates a peri odi c Gaussi an pul se si gnal at 10 kHz, wi th 50%
bandwi dth. The pul se repeti ti on frequency i s 1 kHz, sampl e rate i s 50 kHz, and
0 0.2 0.4 0.6 0.8 1
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
pulstran
6-271
pul se trai n l ength i s 10 msec. The repeti ti on ampl i tude shoul d attenuate by 0.8
each ti me:
t = 0 : 1/50E3 : 10e3;
d = [0 : 1/1E3 : 10e3 ; 0.8.^(0:10)]';
y = pulstran(t,d,'gauspuls',10e3,0.5);
plot(t,y)
0 0.002 0.004 0.006 0.008 0.01
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
pulstran
6-272
Thi s exampl e generates a trai n of 10 Hammi ng wi ndows:
p = hamming(32);
t = 0:320; d = (0:9)'*32;
y = pulstran(t,d,p);
plot(t,y)
See Also
0 50 100 150 200 250 300 350
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
chirp Swept-frequency cosi ne generator.
cos Cosi ne of vector/matri x el ements (see the onl i ne
MATLAB Function Reference).
diric Di ri chl et or peri odi c si nc functi on.
gauspuls Gaussi an-modul ated si nusoi dal pul se generator.
rectpuls Sampl ed aperi odi c rectangl e generator.
sawtooth Sawtooth or tr i angl e wave gener ator.
sin Si ne of vector/matri x el ements (see the onl i ne
MATLAB Function Reference).
sinc Si nc or si n(t)/t functi on.
square Square wave generator.
tripuls Sampl ed aperi odi c tri angl e generator.
pwelch
6-273
6pwel ch
Purpose Esti mate the power spectral densi ty (PSD) of a si gnal usi ng Wel chs method.
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) esti mates the power spectrum of the sequence x usi ng the
Wel ch method of spectral esti mati on. I f x i s real , pwelch esti mates the
spectrum at posi ti ve frequenci es onl y; i n thi s case, output Pxx i s a col umn
vector of l ength nfft/2+1 for nfft even and (nfft+1)/2 for nfft odd. I f x i s
compl ex, pwelch esti mates the spectrum at both posi ti ve and negati ve
frequenci es and Pxx has l ength nfft.
Pxx = pwelch(x,nfft) uses the speci fi ed FFT l ength nfft i n esti mati ng the
power spectrum for x. Thi s val ue determi nes the number of di fferent
frequenci es at whi ch the power spectrum i s esti mated. Speci fy nfft as a power
of 2 for fastest executi on. Speci fy an empty matri x for nfft, [], to use the
defaul t val ue of min(256,length(x)).
[Pxx,w] = pwelch(x,nfft) returns a vector w of normal i zed angul ar
frequenci es (i n rads/sampl e) at whi ch the functi on eval uates the PSD. The
range of w i s [0,) for real x and [0,2) for compl ex x. Si nce the frequency vector
w i s the same si ze as Pxx, plot(w,Pxx) pl ots the power spectrum versus the
normal i zed angul ar frequency.
[Pxx,f] = pwelch(x,nfft,Fs) returns a vector f of l i near frequenci es (i n Hz)
at whi ch the functi on eval uates the PSD. Fs i s a scal ar that speci fi es the
sampl i ng frequency of x, and Pxx i s scal ed by 1/Fs. The range of f i s [0,Fs/2)
for real x and [0,Fs) for compl ex x. Si nce the frequency vector f i s the same
si ze as Pxx, plot(f,Pxx) pl ots the power spectrum versus the l i near frequency.
Speci fy an empty matri x for Fs, [], to use the defaul t val ue of 1 Hz.
pwelch
6-274
[Pxx,f] = pwelch(x,nfft,Fs,window) speci fi es a wi ndowi ng functi on and
the number of sampl es per wi ndowed secti on of the x vector (e.g., kaiser(64)).
The l ength of the wi ndow must be l ess than or equal to nfft; pwelch zero pads
the secti ons i f the l ength of the wi ndow i s l ess than nfft. Speci fy a scal ar for
window to use a Hanni ng wi ndow of that l ength; speci fy an empty matri x, [],
to use the defaul t val ue of hanning(nfft).
[Pxx,f] = pwelch(x,nfft,Fs,window,noverlap) overl aps the wi ndowed
secti ons of x by noverlap sampl es. Speci fy an empty matri x for noverlap, [],
to use the defaul t val ue of 0.
[Pxx,Pxxc,f] = pwelch(x,nfft,Fs,window,noverlap,p) where p i s a
posi ti ve scal ar between 0 and 1 returns a vector Pxxc that contai ns an esti mate
of the p*100 percent confi dence i nterval for Pxx. Pxxc i s a two-col umn matri x
that i s the same l ength as Pxx. The i nterval [Pxxc(:,1),Pxxc(:,2)] covers the
true PSD wi th probabi l i ty p. plot(f,[Pxx Pxxc]) pl ots the power spectrum
i nsi de the p*100 percent confi dence i nterval . Speci fy an empty matri x for p, [],
to use the defaul t val ue of 0.95.
[Pxx,Pxxc,f] = pwelch(...,'range') speci fi es the range of frequency
val ues to i ncl ude i n f. range can be:
half, to compute the PSD over the range [0,) for real or compl ex x. I f Fs i s
speci fi ed, the range i s [0,Fs/2) for real or compl ex x. I f Fs i s speci fi ed by an
empty matri x, [], the defaul t val ue of 1 i s used, and the range i s [0,1/2) for
real or compl ex x.
whole, to compute the PSD over the range [0,2) for r eal or compl ex x. I f Fs
i s speci fi ed, the range i s [0,Fs) for real or compl ex x. I f Fs i s speci fi ed by an
empty matri x, [], the defaul t val ue of 1 i s used, and the range i s [0,1) for real
or compl ex x.
pwelch(x,...) wi th no output arguments pl ots the PSD agai nst frequency i n
the current fi gure wi ndow. I f p i s speci fi ed, the pl ot i ncl udes the confi dence
i nterval .
pwelch(...,'magunits') speci fi es the uni ts i n whi ch to express to the
magni tude axi s of the PSD pl ot. The opti ons are:
pwelch
6-275
'db', to express the PSD data i n deci bel s (dB). Thi s i s the defaul t.
'squared', to express the PSD i n l i near uni ts (magni tude squared).
Example Generate a col ored noi se si gnal and pl ot i ts PSD wi th a confi dence i nterval of
95%. Speci fy a l ength 1024 FFT, a 512-poi nt Kai ser wi ndow wi th no overl ap,
and a sampl i ng frequency of 10 kHz:
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)
Algorithm pwelch cal cul ates the power spectral densi ty usi ng Wel chs method (see
references [1] and [2]):
1 I t appl i es the wi ndow speci fi ed by the window vector to each successi ve
secti on of i nput x.
2 I t transforms each secti on wi th an nfft-poi nt FFT.
3 I t forms the peri odogram of each secti on by scal i ng the magni tude squared
of each transformed secti on.
0 1000 2000 3000 4000 5000
110
100
90
80
70
60
50
40
30
Welchs Spectral Estimate P
xx
(f) / f
s
Frequency (Hz)
P
o
w
e
r

S
p
e
c
t
r
a
l

D
e
n
s
i
t
y

(
d
B
)
pwelch
6-276
4 I t averages the peri odograms of the overl appi ng secti ons to form Pxx(f).
5 I t scal es Pxx(f) by 1/Fs to form Pxx(f)/Fs, the power spectrum of x.
The number of secti ons that pwelch averages i s
k = fix((length(x)noverlap)/(length(window)noverlap))
Diagnostics An appropri ate di agnosti c message i s di spl ayed when i ncorrect arguments to
pwelch are used:
Requires windows 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 Esti mate magni tude squared coherence functi on
between two si gnal s.
csd Esti mate the cross spectral densi ty (CSD) of two
si gnal s.
pburg Power spectrum esti mate usi ng the Burg method.
pcov Power spectrum esti mate usi ng the covari ance
method.
pmcov Power spectrum esti mate usi ng the modi fi ed
covari ance method.
pmtm Power spectrum esti mate usi ng the mul ti taper
method (MTM).
pmusic Power spectrum esti mate usi ng MUSI C ei genvector
method.
pyulear Power spectrum esti mate usi ng Yul e-Wal ker AR
method.
specgram Ti me-dependent frequency anal ysi s (spectrogram).
tfe Transfer functi on esti mate from i nput and output.
pwelch
6-277
References [1] Rabi ner, L.R., and B. Gol d. Theory and Application of Digital Signal
Processing. Engl ewood Cl i ffs, NJ: Prenti ce Hal l , 1975. Pgs. 399-419.
[2] Wel ch, P.D. The Use of Fast Fouri er Transform for the Esti mati on of Power
Spectra: A Method Based on Ti me Averagi ng Over Short, Modi fi ed
Peri odograms. I EEE Trans. AudioElectroacoust. Vol . AU-15 (June 1967).
Pgs. 70-73.
[3] Oppenhei m, A.V., and R.W. Schafer. Discrete-TimeSignal Processing.
Engl ewood Cl i ffs, NJ: Prenti ce Hal l , 1989. Pgs. 311-312.
pyulear
6-278
6pyul ear
Purpose Power spectrum esti mate usi ng Yul e-Wal ker AR method.
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 esti mates the power spectral densi ty (PSD) of the si gnal vector x[n]
usi ng the Yul e-Wal ker AR method. Thi s method, al so cal l ed the
autocorrel ati on method, fi ts an autoregressi ve (AR) model to the si gnal by
mi ni mi zi ng the forward predi cti on error i n the l east-squares sense. Thi s
for mul ati on l eads to the Yul e-Wal ker equati ons, whi ch ar e sol ved by the
Levi nson-Durbi n recursi on. The spectral esti mate returned by pyulear i s the
magni tude squared frequency response of thi s AR model . The correct choi ce of
the model order p i s i mportant.
Pxx = pyulear(x,p,nfft) returns Pxx, the power spectrum esti mate. x i s the
i nput si gnal , p i s the model order for the al l -pol e fi l ter, and nfft i s the FFT
l ength (defaul ts to 256 i f not speci fi ed). Pxx has l ength (nfft/2+1) for nfft
even, (nfft+1)/2 for nfft odd, and nfft i f x i s compl ex.
[Pxx,freq] = pyulear(x,p,nfft) returns Pxx, the power spectrum
esti mate, and freq, a vector of frequenci es at whi ch the PSD was esti mated. I f
the i nput si gnal i s real -val ued, the range of freq i s [0,). I f the i nput si gnal i s
compl ex, the range of freq i s [0,2).
[Pxx,freq] = pyulear(x,p,nfft,Fs) uses the si gnal s sampl i ng frequency,
Fs, to scal e both the PSD vector (Pxx) and the frequency vector (freq). Pxx i s
scal ed by 1/Fs. I f the i nput si gnal i s real -val ued, the range of freq i s [0,Fs/2).
I f the i nput si gnal i s compl ex, the range of freq i s [0,Fs). Fs defaul ts to 1 i f
l eft empty, [].
[Pxx,freq] = pyulear(x,p,nfft,Fs,'range') speci fi es the range of
frequency val ues to i ncl ude i n freq. range can be:
half, to compute the PSD over the range [0,Fs/2) for real x, and [0,Fs) for
compl ex x. I f Fs i s l eft bl ank, [], the range i s [0,1/2) for real x, and [0,1)
pyulear
6-279
for compl ex x. I f Fs i s omi tted enti rel y, the range i s [0,pi) for real x, and
[0,2*pi) for compl ex x. half i s the defaul t range.
whole, to compute the PSD over the range [0,Fs) for al l x. I f Fs i s l eft
bl ank, [], the range i s [0,1) for al l x. I f Fs i s omi tted enti rel y, the range i s
[0,2*pi) for al l x.
pyulear(...) pl ots the power spectral densi ty i n the fi rst avai l abl e fi gure
wi ndow. The frequency range on the pl ot i s the same as the range of output
freq for a gi ven set of parameters.
pyulear(...,'squared') pl ots the magni tude of Pxx di rectl y, rather than
comnverti ng the val ues to dB.
Example Si nce the method esti mates the spectrum by fi tti ng an AR model to the si gnal ,
fi rst defi ne the AR system (al l -pol e fi l ter) that generates the i nput. Check the
magni tude response of the process wi th 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')
0 0.2 0.4 0.6 0.8 1
20
10
0
10
20
30
40
Normalized Angular Frequency ( rads/sample)
M
a
g
n
i
t
u
d
e

(
d
B
)
AR System Magnitude Response
pyulear
6-280
Now generate the i nput si gnal x by fi l teri ng whi te noi se through the AR
system. Esti mate the PSD of x based on a fourth-order AR model (si nce we
know that the ori gi nal AR system, a, has order 4).
x = filter(1,a,randn(150,1)); % AR system output
pyulear(x,4) % 4th order estimate
Diagnostics The fi rst i nput argument must be a ful l vector; otherwi se pyulear gener ates
the fol l owi ng er r or message:
Input signal cannot be sparse.
I f you speci fy an empty matri x for the second argument, pyulear generates the
fol l owi ng error message:
Model order must be an integer.
0 0.2 0.4 0.6 0.8 1
10
5
0
5
10
15
20
25
Normalized Angular Frequency ( rads/sample)
P
o
w
e
r

S
p
e
c
t
r
a
l

D
e
n
s
i
t
y

(
d
B
)
YuleWalker Spectral Estimate P
xx
()
pyulear
6-281
See Also
References [1] Marpl e, S.L. Digital Spectral Analysis. Engl ewood Cl i ffs, NJ: Prenti ce Hal l ,
1987. Chapter 7.
aryule Compute an esti mate of AR model parameters usi ng
the Yul e-Wal ker method.
lpc Li near pr edi cti on coeffi ci ents.
pburg Power spectrum esti mate usi ng the Burg method.
pcov Power spectrum esti mate usi ng the covari ance
method.
pmcov Power spectrum esti mate usi ng the modi fi ed
covari ance method.
pmtm Power spectrum esti mate usi ng the mul ti taper
method (MTM).
pmusic Power spectrum esti mate usi ng MUSI C ei genvector
method.
prony Pronys method for ti me domai n I I R fi l ter desi gn.
pwelch Esti mate the power spectral densi ty (PSD) of a si gnal
usi ng Wel chs method.
rc2ac
6-282
6rc2ac
Purpose Conversi on of refl ecti on coeffi ci ents to autocorrel ati on sequence.
Syntax r = rc2ac(k,r0)
Description r = rc2ac(k,r0) fi nds the autocorrel ati on coeffi ci ents, r, of the di screte fi l ter
wi th refl ecti on coeffi ci ents k and zero-l ag autocorrel ati on r0.
See Also
References [1] Kay, S.M. Modern Spectral Estimation. Engl ewood Cl i ffs, NJ:
Prenti ce-Hal l , 1988.
ac2rc Conversi on of autocorrel ati on sequence to refl ecti on
coeffi ci ents.
poly2ac Conversi on of predi cti on pol ynomi al to
autocorrel ati on sequence.
rc2poly Conversi on of refl ecti on coeffi ci ents to predi cti on
pol ynomi al .
rc2poly
6-283
6rc2pol y
Purpose Conversi on of refl ecti on coeffi ci ents to predi cti on pol ynomi al .
Syntax a = rc2poly(k)
[a,efinal] = rc2poly(k,r0)
Description a = rc2poly(k) fi nds the predi cti on pol ynomi al a, wi th a(1) = 1, from the
refl ecti on coeffi ci ents k of the correspondi ng l atti ce structure. Output a i s row
vector of l ength k + 1.
[a,efinal] = rc2poly(k,r0) returns the fi nal predi cti on error, efinal,
based on the zero-l ag autocorrel ati on, r0.
Example Consi der an I I R fi l ter gi ven by refl ecti on coeffi ci ents k:
k = [0.3090 0.9800 0.0031 0.0082 0.0082];
I ts pol ynomi al representati on i s
a = rc2poly(k)
a =
1.0000 0.6148 0.9899 0.0000 0.0032 0.0082
Algorithm rc2poly computes output a usi ng Levi nsons recursi on [1]. The functi on:
1 Sets the output vector a to the fi rst el ement of k
2 Loops through the remai ni ng el ements of k
For each l oop i terati on i, a = [a + a(i1:1:1)*k(i) k(i)].
3 I mpl ements a = [1 a]
rc2poly
6-284
See Also
References [1] Kay, S.M. Modern Spectral Estimation. Engl ewood Cl i ffs, NJ:
Prenti ce-Hal l , 1988.
ac2poly Conversi on of autocorrel ati on sequence to predi cti on
pol ynomi al .
latc2tf Latti ce fi l ter to transfer functi on conversi on.
latcfilt Latti ce and l atti ce-l adder fi l ter i mpl ementati on.
poly2rc Conversi on of predi cti on pol ynomi al to refl ecti on
coeffi ci ents.
rc2ac Conversi on of refl ecti on coeffi ci ents to
autocorrel ati on sequence.
tf2latc Conversi on of tr ansfer functi on to l atti ce fi l ter.
rceps
6-285
6rceps
Purpose Real cepstrum and mi ni mum phase reconstructi on.
Syntax y = rceps(x)
[y,ym] = rceps(x)
Description The real cepstrumi s the i nverse Fouri er transform of the real l ogari thm of the
magni tude of the Fouri er transform of a sequence.
rceps(x) returns the real cepstrum of the real sequence x. The real cepstrum
i s a real -val ued functi on.
[y,ym] = rceps(x) returns both the real cepstrum y and a mi ni mum phase
reconstructed versi on ym of the i nput sequence.
Algorithm rceps i s an M-fi l e i mpl ementati on of al gori thm 7.2 i n [2], that i s:
y = real(ifft(log(abs(fft(x)))));
Appropri ate wi ndowi ng i n the cepstral domai n forms the reconstructed
mi ni mum phase si gnal :
w = [1; 2*ones(n/21,1); ones(1 rem(n,2),1); zeros(n/21,1)];
ym = real(ifft(exp(fft(w.*y))));
See Also
References [1] Oppenhei m, A.V., and R.W. Schafer. Digital Signal Processing. Engl ewood
Cl i ffs, NJ: Prenti ce Hal l , 1975.
[2] I EEE. Programsfor Digital Signal Processing. I EEE Press. New York: John
Wi l ey & Sons, 1979.
cceps Compl ex cepstral anal ysi s.
fft One-di mensi onal fast Fouri er transform.
hilbert Hi l bert transform.
icceps I nverse compl ex cepstrum.
unwrap Unwrap phase angl es.
rectpuls
6-286
6rectpul s
Purpose Sampl ed aperi odi c rectangl e generator.
Syntax y = rectpuls(t)
y = rectpuls(t,w)
Description y = rectpuls(t) returns a conti nuous, aperi odi c, uni ty-hei ght rectangul ar
pul se at the sampl e ti mes i ndi cated i n array t, centered about t = 0 and wi th
a defaul t wi dth of 1. Note that the i nterval of non-zero ampl i tude i s defi ned to
be open on the ri ght, that i s, rectpuls(0.5) = 1 whi l e rectpuls(0.5) = 0.
y = rectpuls(t,w) generates a rectangl e of wi dth w.
rectpuls i s typi cal l y used i n conjuncti on wi th the pul se trai n generati ng
functi on, pulstran.
See Also
chirp Swept-frequency cosi ne generator.
cos Cosi ne of vector/matri x el ements (see the onl i ne
MATLAB Function Reference).
diric Di ri chl et or peri odi c si nc functi on.
gauspuls Gaussi an-modul ated si nusoi dal pul se generator.
pulstran Pul se trai n generator.
sawtooth Sawtooth or tr i angl e wave gener ator.
sin Si ne of vector/matri x el ements (see the onl i ne
MATLAB Function Reference).
sinc Si nc or si n(t)/t functi on.
square Square wave generator.
tripuls Sampl ed aperi odi c tri angl e generator.
remez
6-287
6remez
Purpose Parks-McCl el l an opti mal FI R fi l ter desi gn.
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 desi gns a l i near-phase FI R fi l ter usi ng the Parks-McCl el l an
al gor i thm [1]. The Par ks-McCl el l an al gor i thm uses the Remez exchange
al gori thm and Chebyshev approxi mati on theory to desi gn fi l ters wi th an
opti mal fi t between the desi red and actual frequency responses. The fi l ters are
opti mal i n the sense that the maxi mum error between the desi red frequency
response and the actual frequency response i s mi ni mi zed. Fi l ters desi gned thi s
way exhi bi t an equi ri ppl e behavi or i n thei r frequency responses and hence are
someti mes cal l ed equiripplefi l ters.
b = remez(n,f,a) returns row vector b contai ni ng the n+1 coeffi ci ents of the
order n FI R fi l ter whose frequency-ampl i tude characteri sti cs match those
gi ven by vectors f and a.
The output fi l ter coeffi ci ents (taps) i n b obey the symmetry rel ati on
Vectors f and a speci fy the frequency-magni tude characteri sti cs of the fi l ter:
b k ( ) b n 2 k + ( ) k 1 = n 1 + , , , =
remez
6-288
f i s a vector of pai rs of frequency poi nts, speci fi ed i n the range between 0 and
1, where 1 corresponds to hal f the sampl i ng frequency (the Nyqui st
frequency). The frequenci es must be i n i ncreasi ng order.
a i s a vector contai ni ng the desi red ampl i tudes at the poi nts speci fi ed i n f.
The desi red ampl i tude at frequenci es between pai rs of poi nts (f(k), f(k+1)) for
k odd i s the l i ne segment connecti ng the poi nts (f(k), a(k)) and (f(k+1),
a(k+1)).
The desi red ampl i tude at frequenci es between pai rs of poi nts (f(k), f(k+1)) for
k even i s unspeci fi ed. The areas between such poi nts are transi ti on or dont
care regi ons.
f and a must be the same l ength. The l ength must be an even number.
The rel ati onshi p between the f and a vectors i n defi ni ng a desi red frequency
response i s shown bel ow:
remez(n,f,a,w) uses the wei ghts i n vector w to wei ght the fi t i n each frequency
band. The l ength of w i s hal f the l ength of f and a, so there i s exactl y one wei ght
per band.
b = remez(n,f,a,'ftype') and
b = remez(n,f,a,w,'ftype') speci fy a fi l ter type, where ftype i s
1.0
0.0
Desired amplitude
response (a)
Normalized
frequency (f)
0.5
"Don't care"/transition regions
f = [0 .3 .4 .6 .7 .9]
a = [0 1 0 0 .5 .5]
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.0 0.8 0.9 1.0 (Nyquist)
remez
6-289
hilbert, for l i near-phase fi l ters wi th odd symmetry (type I I I and type I V)
The output coeffi ci ents i n b obey the rel ati on b(k) =-b(n +2-k), k =1,...,n + 1.
Thi s cl ass of fi l ters i ncl udes the Hi l bert transformer, whi ch has a desi red
ampl i tude of 1 across the enti re band.
For exampl e,
h = remez(30,[0.1 0.9],[1 1],'hilbert');
desi gns an approxi mate FI R Hi l bert transformer of l ength 31.
differentiator, for type I I I and I V fi l ters, usi ng a speci al wei ghti ng
techni que
For nonzero ampl i tude bands, i t wei ghts the error by a factor of 1/f so that
the error at l ow frequenci es i s much smal l er than at hi gh frequenci es. For
FI R di fferenti ators, whi ch have an ampl i tude characteri sti c proporti onal to
frequency, these fi l ters mi ni mi ze the maxi mum rel ati ve error (the maxi mum
of the rati o of the error to the desi red ampl i tude).
b = remez(...,{lgrid}) uses the i nteger lgrid to control the densi ty of the
frequency gri d, whi ch has roughl y (lgrid*n)/(2*bw) frequency poi nts, where
bw i s the fracti on of the total frequency band i nterval [0,1] covered by f.
I ncreasi ng lgrid often resul ts i n fi l ters that are more exactl y equi ri ppl e, but
whi ch take l onger to compute. The defaul t val ue of 16 i s the mi ni mum val ue
that shoul d be speci fi ed for lgrid. Note that the {lgrid} argument must be a
1-by-1 cel l array.
b = remez(n,f,'fresp',w) returns row vector b contai ni ng the n+1
coeffi ci ents of the order n FI R fi l ter whose frequency-ampl i tude characteri sti cs
best approxi mate the response speci fi ed by functi on fresp. The functi on i s
cal l ed from wi thi n remez wi th the fol l owi ng syntax:
[dh,dw] = fresp(n,f,gf,w)
The arguments are si mi l ar to those for remez:
n i s the fi l ter order.
f i s the vector of frequency band edges that appear monotoni cal l y between
0 and 1, where 1 i s the Nyqui st frequency.
gf i s a vector of gri d poi nts that have been l i nearl y i nterpol ated over each
speci fi ed frequency band by remez. gf determi nes the frequency gri d at
remez
6-290
whi ch the response functi on must be eval uated, and contai ns the same data
returned by cremez i n the fgrid fi el d of the opt structure.
w i s a vector of real , posi ti ve wei ghts, one per band, used duri ng opti mi zati on.
w i s opti onal i n the cal l to remez; i f not speci fi ed, i t i s set to uni ty wei ghti ng
before bei ng passed to 'fresp'.
dh and dw are the desi red compl ex frequency response and band wei ght
vectors, respecti vel y, eval uated at each frequency i n gri d gf.
The predefi ned frequency response functi on (fresp) that remez cal l s i s
remezfrf i n the signal/private di rectory.
b = remez(n,f,{'fresp',p1,p2,...},w) al l ows you to speci fy addi ti onal
parameters (p1, p2, etc.) to pass to fresp. Note that b = remez(n,f,a,w) i s a
synonym for b = remez(n,f,{'remezfrf',a},w), where a i s a vector
contai ni ng the desi red ampl i tudes at the poi nts speci fi ed i n f.
b = remez(n,f,'fresp',w,'ftype') and
b = remez(n,f,{'fresp',p1,p2,...},w,'ftype') desi gn anti symmetri c
(odd) rather than symmetri c (even) fi l ters, where 'ftype' i s ei ther 'd' for a
di fferenti ator or 'h' for a Hi l bert transformer.
I n the absence of a speci fi cati on for ftype, a prel i mi nary cal l i s made to fresp
to determi ne the defaul t symmetry property sym. Thi s cal l i s made usi ng the
syntax:
sym = fresp('defaults',{n,f,[],w,p1,p2,...})
The arguments n, f, w, etc., may be used as necessary i n determi ni ng an
appropri ate val ue for sym, whi ch remez expects to be ei ther 'even' or 'odd'. I f
the fresp functi on does not support thi s cal l i ng syntax, remez defaul ts to even
symmetr y.
[b,delta] = remez(...) returns the maxi mum ri ppl e hei ght i n delta.
remez
6-291
[b,delta,opt] = remez(...) returns a structure, opt, of opti onal resul ts
wi th the fol l owi ng fi el ds.
Example Graph the desi red and actual frequency responses of a 17th-order
Parks-McCl el l an bandpass fi l ter:
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))
opt.fgrid Frequency gri d vector used for the fi l ter desi gn opti mi zati on
opt.des Desi red frequency response for each poi nt i n opt.fgrid
opt.wt Wei ghti ng for each poi nt i n opt.fgrid
opt.H Actual frequency response for each poi nt i n opt.fgrid
opt.error Error at each poi nt i n opt.fgrid (opt.desopt.H)
opt.iextr Vector of i ndi ces i nto opt.fgrid for extremal frequenci es
opt.fextr Vector of extremal frequenci es
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
0
0.2
0.4
0.6
0.8
1
1.2
remez
6-292
Algorithm remez i s a MEX-fi l e versi on of the ori gi nal Fortran code from [1], al tered to
desi gn arbi trari l y l ong fi l ters wi th arbi trari l y many l i near bands.
remez desi gns type I , I I , I I I , and I V l i near-phase fi l ters. Type I and Type I I are
the defaul ts for n even and n odd, respecti vel y, whi l e Type I I I (n even) and
Type I V (n odd) are obtai ned wi th the 'hilbert' and 'differentiator' fl ags.
The di fferent types of fi l ters have di fferent symmetri es and certai n constrai nts
on thei r frequency responses (see [5] for more detai l s).
Diagnostics An appropri ate di agnosti c message i s di spl ayed i f i ncorrect arguments are
used:
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 more seri ous warni ng message i s
Failure to Converge
Probable cause is machine rounding error.
I n the rare event that you see thi s message, i t i s possi bl e that the fi l ter desi gn
may sti l l be correct. Veri fy the desi gn by checki ng i ts frequency response.
Linear
Phase
Filter Type
Filter
Order n Symmetry of Coefficients
Response H(f),
f = 0
Response H(f),
f = 1 (Nyquist)
Type I Even even: No restri cti on No restri cti on
Type I I Odd No restri cti on H(1) = 0
Type I I I Even odd: H(0) = 0 H(1) = 0
Type I V Odd H(0) = 0 No restri cti on
b k ( ) b n 2 k + ( ) k 1 = n 1 + , , , =
b k ( ) b n 2 k + ( ) k 1 = n 1 + , , , =
remez
6-293
See Also
References [1] I EEE. Programsfor Digital Signal Processing. I EEE Press. New York: John
Wi l ey & Sons, 1979. Al gori thm 5.1.
[2] I EEE. Selected Papers in Digital Signal Processing, I I . I EEE Press. New
York: John Wi l ey & Sons, 1979.
[3] Parks, T.W., and C.S. Burrus. Digital Filter Design. New York: John Wi l ey
& Sons, 1987. Pg. 83.
[4] Rabi ner, L.R., J.H. McCl el l an, and T.W. Parks. FI R Di gi tal Fi l ter Desi gn
Techni ques Usi ng Wei ghted Chebyshev Approxi mati ons. Proc. I EEE 63
(1975).
[5] Oppenhei m, A.V., and R.W. Schafer. Discrete-TimeSignal Processing.
Engl ewood Cl i ffs, NJ: Prenti ce Hal l , 1989. Pgs. 256-266.
butter Butterworth anal og and di gi tal fi l ter desi gn.
cheby1 Chebyshev type I fi l ter desi gn (passband ri ppl e).
cheby2 Chebyshev type I I fi l ter desi gn (stopband ri ppl e).
cremez Compl ex and nonl i near-phase equi ri ppl e FI R fi l ter
desi gn.
ellip El l i pti c (Cauer) fi l ter desi gn.
fir1 Wi ndow-based fi ni te i mpul se response fi l ter desi gn
standard response.
fir2 Wi ndow-based fi ni te i mpul se response fi l ter desi gn
arbi trary response.
fircls Constrai ned l east square FI R fi l ter desi gn for
mul ti band fi l ters.
fircls1 Constrai ned l east square fi l ter desi gn for l owpass
and hi ghpass l i near phase FI R fi l ters.
firls Least square l i near-phase FI R fi l ter desi gn.
firrcos Rai sed cosi ne FI R fi l ter desi gn.
remezord Par ks-McCl el l an opti mal FI R fi l ter or der esti mati on.
yulewalk Recursi ve di gi tal fi l ter desi gn.
remezord
6-294
6remezor d
Purpose Parks-McCl el l an opti mal FI R fi l ter order esti mati on.
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) fi nds the approxi mate order, normal i zed
frequency band edges, frequency band ampl i tudes, and wei ghts that meet
i nput speci fi cati ons f, a, and dev, to use wi th the remez command.
f i s a vector of frequency band edges (between 0 and Fs/2, where Fs i s the
sampl i ng frequency), and a i s a vector speci fyi ng the desi red ampl i tude on
the bands defi ned by f. The l ength of f i s twi ce the l ength of a, mi nus 2. The
desi red functi on i s pi ecewi se constant.
dev i s a vector the same si ze as a that speci fi es the maxi mum al l owabl e
devi ati on or ri ppl es between the frequency response and the desi red
ampl i tude of the output fi l ter, for each band.
Use remez wi th the resul ti ng order n, frequency vector fo, ampl i tude response
vector ao, and wei ghts w to desi gn the fi l ter b whi ch approxi matel y meets the
speci fi cati ons gi ven by remezord i nput parameters f, a, and dev:
b = remez(n,fo,ao,w)
[n,fo,ao,w] = remezord(f,a,dev,Fs) speci fi es a sampl i ng frequency Fs.
Fs defaul ts to 2 Hz, i mpl yi ng a Nyqui st frequency of 1 Hz. You can therefore
speci fy band edges scal ed to a parti cul ar appl i cati ons sampl i ng frequency.
I n some cases remezord underesti mates the order n. I f the fi l ter does not meet
the speci fi cati ons, try a hi gher order such as n+1 or n+2.
c = remezord(f,a,dev,Fs,'cell') speci fi es a cel l -array whose el ements are
the parameters to remez.
Examples Desi gn a mi ni mum-order l owpass fi l ter wi th a 500 Hz passband cutoff
frequency and 600 Hz stopband cutoff frequency, wi th a sampl i ng frequency of
remezord
6-295
2000 Hz), at l east 40 dB attenuati on i n the stopband, and l ess than 3 dB of
ri ppl e i n the passband:
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;
Note that the fi l ter fal l s sl i ghtl y short of meeti ng the stopband attenuati on and
passband ri ppl e speci fi cati ons. Usi ng n+1 i n the cal l to remez i nstead of n
achi eves the desi red ampl i tude characteri sti cs.
0 100 200 300 400 500 600 700 800 900 1000
-60
-50
-40
-30
-20
-10
0
10
Frequency (Hz)
M
a
g
n
i
t
u
d
e

(
d
B
)
Lowpass Filter Designed to Specifications
remezord
6-296
Desi gn a l owpass fi l ter wi th a 1500 Hz passband cutoff frequency and 2000 Hz
stopband cutoff frequency, wi th a sampl i ng frequency of 8000 Hz, a maxi mum
stopband ampl i tude of 0.1, and a maxi mum passband error (ri ppl e) of 0.01:
[n,fo,ao,w] = remezord( [1500 2000], [1 0], [0.01 0.1], 8000 );
b = remez(n,fo,ao,w);
Thi s i s equi val ent to
c = remezord( [1500 2000], [1 0], [0.01 0.1], 8000, 'cell');
b = remez(c{:});
NOTE I n some cases, remezord underesti mates or overesti mates the order n.
I f the fi l ter does not meet the speci fi cati ons, try a hi gher order such as n+1
or n+2.
Resul ts are i naccurate i f the cutoff frequenci es are near 0 or the Nyqui st
frequency.
Algorithm remezord uses the al gori thm suggested i n [1]. Thi s method i s i naccurate for
band edges cl ose to ei ther 0 or the Nyqui st frequency (Fs/2).
Diagnostics I f the i nput parameter l engths are not consi stent, remezord gi ves the fol l owi ng
error messages:
Requires M and DEV to be the same length.
Length of F must be length(M)2.
See Also
buttord Butterworth fi l ter order sel ecti on.
cheb1ord Chebyshev type I fi l ter order sel ecti on.
cheb2ord Chebyshev type I I fi l ter or der sel ecti on.
ellipord El l i pti c fi l ter order sel ecti on.
kaiserord Esti mate parameters for an FI R fi l ter desi gn wi th
Kai ser wi ndow.
remez Parks-McCl el l an opti mal FI R fi l ter desi gn.
remezord
6-297
References [1] Rabi ner, L.R., and O. Herrmann. The Predi ctabi l i ty of Certai n Opti mum
Fi ni te I mpul se Response Di gi tal Fi l ters. I EEE Trans. on Circuit Theory.
Vol . CT-20, No. 4 (Jul y 1973). Pgs. 401-408.
[2] Rabi ner, L.R., and B. Gol d. Theory and Application of Digital Signal
Processing. Engl ewood Cl i ffs, NJ: Prenti ce Hal l , 1975. Pgs. 156-157.
resample
6-298
6resampl e
Purpose Change sampl i ng rate by any rati onal factor.
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) resampl es the sequence i n vector x at p/q ti mes the
ori gi nal sampl i ng rate, usi ng a pol yphase fi l ter i mpl ementati on. The l ength of
y i s equal to ceil(length(x)*p/q). p and q must be posi ti ve i ntegers. I f x i s a
matri x, resample works down the col umns of x.
resample appl i es an anti -al i asi ng (l owpass) FI R fi l ter to x duri ng the
resampl i ng process. I t desi gns the fi l ter usi ng firls wi th a Kai ser wi ndow.
y = resample(x,p,q,n) uses n terms on ei ther si de of the current sampl e,
x(k), to perform the resampl i ng. The l ength of the FI R fi l ter resample uses i s
proporti onal to n; l arger val ues of n provi de better accuracy at the expense of
more computati on ti me. The defaul t for n i s 10. I f you l et n = 0, resample
performs a nearest-nei ghbor i nterpol ati on:
y(k) = x(round((k-1)*q/p)+1)
where y(k) = 0 i f the i ndex to x i s greater than length(x).
y = resample(x,p,q,n,beta) uses beta as the desi gn parameter for the
Kai ser wi ndow that resample empl oys i n desi gni ng the l owpass fi l ter . The
defaul t for beta i s 5.
y = resample(x,p,q,b) fi l ters x wi th b, a vector of fi l ter coeffi ci ents.
[y,b] = resample(x,p,q) returns the vector b, whi ch contai ns the
coeffi ci ents of the fi l ter appl i ed to x duri ng the resampl i ng process.
resample
6-299
Examples Resampl e a si mpl e l i near sequence at 3/2 the ori gi nal rate:
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')
Noti ce that the l ast few poi nts of the output y are i naccurate. I n i ts fi l teri ng
process, resample assumes the sampl es at ti mes before and after the gi ven
sampl es i n x are equal to zero. Thus l arge devi ati ons from zero at the end
0.5 0 0.5 1 1.5
0.5
0
0.5
1
1.5
Time
original
resampled
resample
6-300
poi nts of the sequence x can cause i naccuraci es i n y at i ts end poi nts. The
fol l owi ng two pl ots i l l ustrate thi s si de 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');
Diagnostics I f p or q are not posi ti ve i ntegers, resample gi ves the appropri ate error
message:
P must be a positive integer.
Q must be a positive integer.
I f x i s not a vector, resample gi ves the fol l owi ng error message:
Input X must be a vector.
0 5 10 15 20
0
2
4
6
8
10
Edge Effects Not Noticeable
original
resampled
0 5 10 15 20
0
5
10
15
Edge Effects Very Noticeable
original
resampled
resample
6-301
See Also
decimate Decrease the sampl i ng rate for a sequence
(deci mati on).
firls Least square l i near-phase FI R fi l ter desi gn.
interp I ncrease sampl i ng rate by an i nteger factor
(i nterpol ati on).
interp1 One-di mensi onal data i nterpol ati on (tabl e l ookup)
(see the onl i ne MATLAB Function Reference).
intfilt I nterpol ati on FI R fi l ter desi gn.
kaiser Kai ser wi ndow.
spline Cubi c spl i ne i nterpol ati on (see the onl i ne MATLAB
Function Reference).
upfirdn Upsampl e, appl y an FI R fi l ter, and downsampl e.
residuez
6-302
6resi duez
Purpose z-transform parti al -fracti on expansi on.
Syntax [r,p,k] = residuez(b,a)
[b,a] = residuez(r,p,k)
Description residuez converts a di screte ti me system, expressed as the rati o of two
pol ynomi al s, to parti al fracti on expansi on, or resi due, form. I t al so converts the
parti al fracti on expansi on back to the ori gi nal pol ynomi al coeffi ci ents.
[r,p,k] = residuez(b,a) fi nds the resi dues, pol es, and di rect terms of a
parti al fracti on expansi on of the rati o of two pol ynomi al s, b(z) and a(z). Vectors
b and a speci fy the coeffi ci ents of the pol ynomi al s of the di screte-ti me system
b(z)/ a(z) i n descendi ng powers of z:
I f there are no mul ti pl e roots and a > n1,
The returned col umn vector r contai ns the resi dues, col umn vector p contai ns
the pol e l ocati ons, and r ow vector k contai ns the di rect terms. The number of
pol es i s
n = length(a)1 = length(r) = length(p)
The di rect term coeffi ci ent vector k i s empty i f length(b) < length(a);
otherwi se
length(k) = length(b) length(a) + 1
I f p(j) = ... = p(j+s1) i s a pol e of mul ti pl i ci ty s, then the expansi on
i ncl udes terms of the form
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
+ + + + =
b z ( )
a z ( )
----------
r 1 ( )
1 p 1 ( )z
1

---------------------------- L
r n ( )
1 p n ( )z
1

----------------------------- k 1 ( ) k 2 ( )z
1
L k m n 1 + ( )z
m n ( )
+ + + + + + =
r j ( )
1 p j ( )z
1

---------------------------
r j 1 + ( )
1 p j ( )z
1
( )
2
----------------------------------- L
r j s
r
1 + ( )
1 p j ( )z
1
( )
s
r
------------------------------------ + + +
residuez
6-303
[b,a] = residuez(r,p,k) wi th three i nput arguments and two output
arguments, converts the parti al fracti on expansi on back to pol ynomi al s wi th
coeffi ci ents i n row vectors b and a.
The residue functi on i n the standard MATLAB l anguage i s very si mi l ar to
residuez. I t computes the parti al fracti on expansi on of conti nuous-ti me
systems i n the Lapl ace domai n (see reference [1]), rather than di screte-ti me
systems i n the z-domai n as does residuez.
Algorithm residuez appl i es standard MATLAB functi ons and parti al fracti on techni ques
to fi nd r, p, and k from b and a. I t fi nds:
1 The di rect terms a usi ng deconv (pol ynomi al l ong di vi si on) when
length(b)>length(a)1.
2 The pol es usi ng p = roots(a). mpoles fi nds repeated pol es and reorders the
pol es accordi ng to thei r mul ti pl i ci ti es.
3 The resi due for each nonrepeati ng pol e p
i
by mul ti pl yi ng b(z)/ a(z) by
1/(1-p
i
z
-1
) and eval uati ng the resul ti ng rati onal functi on at z =p
i
.
4 The resi dues for the repeated pol es by sol vi ng
S2*r2 = h S1*r1
for r2 usi ng \. h i s the i mpul se response of the reduced b(z)/ a(z), S1 i s a
matri x whose col umns are i mpul se responses of the fi rst-order systems
made up of the nonrepeati ng roots, and r1 i s a col umn contai ni ng the
resi dues for the nonrepeati ng roots. Each col umn of matri x S2 i s an i mpul se
response. For each root p
j
of mul ti pl i ci ty s
j
, S2 contai ns s
j
col umns
representi ng the i mpul se responses of each of the fol l owi ng systems:
The vector h and matri ces S1 and S2 have n + xtra rows, where n i s the total
number of roots and the i nternal parameter xtra, set to 1 by defaul t,
determi nes the degr ee of over deter mi nati on of the system of equati ons.
Diagnostics I f a(1) == 0 whi l e computi ng the parti al fracti on decomposi ti on usi ng
[r,p,k] = residuez(b,a), residuez gi ves the fol l owi ng error message:
First coefficient in A vector must be nonzero.
1
1 pj z
1

-----------------------
1
1 pj z
1
( )
2
------------------------------- L
1
1 pj z
1
( )
s
j
-------------------------------- , , ,
residuez
6-304
I f the number of resi dues r and pol es p i s not the same, residuez gi ves the
fol l owi ng error message:
R and P vectors must be the same size.
See Also
References [1] Oppenhei m, A.V., and R.W. Schafer. Digital Signal Processing. Engl ewood
Cl i ffs, NJ: Prenti ce Hal l , 1975. Pgs. 166-170.
convmtx Convol uti on matri x.
deconv Deconvol uti on and pol ynomi al di vi si on (see the
onl i ne MATLAB Function Reference).
poly Pol ynomi al wi th speci fi ed roots (see the onl i ne
MATLAB Function Reference).
prony Pronys method for ti me domai n I I R fi l ter desi gn.
residue Parti al fracti on expansi on (see the onl i ne MATLAB
Function Reference).
roots Pol ynomi al roots (see the onl i ne MATLAB Function
Reference).
ss2tf Conversi on of state-space to zero-pol e-gai n.
tf2ss Conversi on of tr ansfer functi on to state-space.
tf2zp Conversi on of transfer functi on to zero-pol e-gai n.
zp2ss Conversi on of zer o-pol e-gai n to state-space.
rlevinson
6-305
6rl evi nson
Purpose Reverse Levi nson-Durbi n recursi on.
Syntax r = rlevinson(a,efinal)
[r,u] = rlevinson(a,efinal)
[r,u,k] = rlevinson(a,efinal)
[r,u,k,e] = rlevinson(a,efinal)
Description The reverse Levi nson-Dur bi n recur si on i mpl ements the step-down al gor i thm
for sol vi ng the fol l owi ng symmetri c Toepl i tz system of l i near equati ons for r,
where r = [r(1) ... r(p+1)] and r(i)
*
denotes the compl ex conjugate of r(i).
r = rlevinson(a,efinal) sol ves the above system of equati ons for r gi ven
vector a, where a = [1 a(2) ... a(p+1)]. I n l i near predi cti on appl i cati ons, r
represents the autocorrel ati on sequence of the i nput to the predi cti on error
fi l ter, where r(1) i s the zero-l ag el ement. The fi gure bel ow shows the typi cal
fi l ter of thi s type, where H(z) i s the opti mal l i near predi ctor, x(n) i s the i nput
si gnal , i s the predi cted si gnal , and e(n) i s the predi cti on error.
I nput vector a represents the pol ynomi al coeffi ci ents of thi s predi cti on error
fi l ter i n descendi ng powers of z
r 1 ( ) r 2 ( )

L r p ( )

r 2 ( ) r 1 ( ) L r p 1 ( )

M O O M
r p ( ) L r 2 ( ) r 1 ( )
a 2 ( )
a 3 ( )
M
a p 1 + ( )
r 2 ( )
r 3 ( )
M
r p 1 + ( )
=
x n ( )
H z ( ) a 2 ( )z
1
a 3 ( )z
2
L a n 1 + ( )z
p
=
x n ( )
x n ( )

+
e n ( )
Prediction Error Filter
A z ( )
A z ( ) 1 a 2 ( )z
1
L a n 1 + ( )z
p
+ + + =
rlevinson
6-306
The fi l ter must be mi ni mum phase to generate a val i d autocorrel ati on
sequence. efinal i s the scal ar predi cti on error power, whi ch i s equal to the
vari ance of the predi cti on error si gnal ,
2
(e).
[r,u] = rlevinson(a,efinal) returns upper tri angul ar matri x U from the
UDU
*
decomposi ti on
where
and E i s a di agonal matri x wi th el ements returned i n output e (see bel ow). Thi s
decomposi ti on permi ts the effi ci ent eval uati on of the i nverse of the
autocorrel ati on matri x, R
-1
.
Output matri x u contai ns the predi cti on pol ynomi al , a, from each i terati on of
the reverse Levi nson-Durbi n recursi on
where a
i
(j) i s the jth coeffi ci ent of the ith order predi cti on pol ynomi al (i .e., step
i i n the recursi on). For exampl e, the 5th order predi cti on pol ynomi al i s
a5 = u(5:-1:1,5)'
Note that u(p+1:-1:1,p+1)' i s the i nput pol ynomi al coeffi ci ent vector a.
R
1
UE
1
U

=
R
r 1 ( ) r 2 ( )

L r p ( )

r 2 ( ) r 1 ( ) L r p 1 ( )

M O O M
r p ( ) L r 2 ( ) r 1 ( )
=
U
a
1
1 ( )

a
2
2 ( )

La
p 1 +
p 1 + ( )

0 a
2
1 ( )

O a
p 1 +
p ( )

0 0 Oa
p 1 +
p 1 ( )

M O O M
0 L 0 a
p 1 +
1 ( )

=
rlevinson
6-307
[r,u,k] = rlevinson(a,efinal) returns a vector k of l ength (p+1)contai ni ng
the refl ecti on coeffi ci ents. The refl ecti on coeffi ci ents ar e the conjugates of the
val ues i n the fi rst row of u
k = conj(u(1,2:end))
[r,u,k,e] = rlevinson(a,efinal) returns a vector of l ength (p+1)
contai ni ng the predi cti on errors from each i terati on of the reverse
Levi nson-Durbi n recursi on: e(1) i s the predi cti on error from the fi rst-order
model , e(2) i s the predi cti on error from the second-order model , and so on.
These predi cti on error val ues form the di agonal of the matri x E i n the UDU
*
decomposi ti on of R
-1
,
.
See Also
References [1] Kay, S.M. Modern Spectral Estimation: TheoryandApplication. Engl ewood
Cl i ffs, NJ: Prenti ce Hal l , 1988.
R
1
UE
1
U

=
levinson Levi nson-Durbi n recursi on.
lpc Li near pr edi cti on coeffi ci ents.
prony Pronys method for ti me domai n I I R fi l ter desi gn.
stmcb Li near model usi ng Stei gl i tz-McBri de i terati on.
sawtooth
6-308
6sawtooth
Purpose Sawtooth or tri angl e wave generator.
Syntax x = sawtooth(t)
x = sawtooth(t,width)
Description sawtooth(t) generates a sawtooth wave wi th peri od 2 for the el ements of
ti me vector t. sawtooth(t) i s si mi l ar to sin(t), but i t creates a sawtooth wave
wi th peaks of -1 and 1 i nstead of a si ne wave. The sawtooth wave i s defi ned to
be -1 at mul ti pl es of 2 and to i ncrease l i nearl y wi th ti me wi th a sl ope of 1/ at
al l other ti mes.
sawtooth(t,width) generates a modi fi ed tri angl e wave where width, a scal ar
parameter between 0 and 1, determi nes the fracti on between 0 and 2 at whi ch
the maxi mum occurs. The functi on i ncreases from -1 to 1 on the i nterval 0 to
2*width, then decreases l i nearl y from 1 to -1 on the i nterval 2*width to 2.
Thus a parameter of 0.5 speci fi es a standard tri angl e wave, symmetri c about
ti me i nstant wi th peak-to-peak ampl i tude of 1. sawtooth(t,1) i s equi val ent
to sawtooth(t).
Diagnostics I f the width parameter i s not a scal ar, sawtooth gi ves the fol l owi ng error
message:
Requires WIDTH parameter to be a scalar.
See Also
chirp Swept-frequency cosi ne generator.
cos Cosi ne of vector/matri x el ements (see the onl i ne
MATLAB Function Reference).
diric Di ri chl et or peri odi c si nc functi on.
gauspuls Gaussi an-modul ated si nusoi dal pul se generator.
pulstran Pul se trai n generator.
rectpuls Sampl ed aperi odi c rectangl e generator.
sin Si ne of vector/matri x el ements (see the onl i ne
MATLAB Function Reference).
sinc Si nc or si n(t)/t functi on.
square Square wave generator.
tripuls Sampl ed aperi odi c tri angl e generator.
sgolay
6-309
6sgol ay
Purpose Savi tzky-Gol ay fi l ter desi gn.
Syntax b = sgolay(k,f)
b = sgolay(k,f,w)
Description b = sgolay(k,f) desi gns a Savi tzky-Gol ay FI R smoothi ng fi l ter b. The
pol ynomi al order k must be l ess than the frame si ze, f, whi ch must be odd. I f
k = f1, the desi gned fi l ter produces no smoothi ng. The output, b, i s an f-by-f
matri x whose rows represent the ti me-varyi ng FI R fi l ter coeffi ci ents. I n a
smoothi ng fi l ter i mpl ementati on (for exampl e, sgolayfilt), the l ast (f1)/2
rows (each an FI R fi l ter) are appl i ed to the si gnal duri ng the startup transi ent,
and the fi rst (f1)/2 rows are appl i ed to the si gnal duri ng the termi nal
transi ent. The center row i s appl i ed to the si gnal i n the steady state.
b = sgolay(k,f,w) speci fi es a wei ghti ng vector w wi th l ength f, whi ch
contai ns the real , posi ti ve-val ued wei ghts to be used duri ng the l east-squares
mi ni mi zati on.
Remarks Savi tzky-Gol ay smoothi ng fi l ters (al so cal l ed di gi tal smoothi ng pol ynomi al
fi l ters or l east squares smoothi ng fi l ters) are typi cal l y used to smooth out a
noi sy si gnal whose frequency span (wi thout noi se) i s l arge. I n thi s type of
appl i cati on, Savi tzky-Gol ay smoothi ng fi l ters perform much better than
standard averagi ng FI R fi l ters, whi ch tend to fi l ter out a si gni fi cant porti on of
the si gnal s hi gh frequency content al ong wi th the noi se. Al though
Savi tzky-Gol ay fi l ters are more effecti ve at preservi ng the perti nent hi gh
frequency components of the si gnal , they are l ess successful than standard
averagi ng FI R fi l ters at rejecti ng noi se.
Savi tzky-Gol ay fi l ters are opti mal i n the sense that they mi ni mi ze the
l east-squares error i n fi tti ng a pol ynomi al to each frame of noi sy data.
See Also
fir1 Wi ndow-based fi ni te i mpul se response fi l ter desi gn
standard response.
firls Least square l i near-phase FI R fi l ter desi gn.
filter Fi l ter data wi th a recursi ve (I I R) or nonrecursi ve
(FI R) fi l ter.
sgolayfilt Savi tzky-Gol ay fi l teri ng.
sgolay
6-310
References [1] Orfani di s, S.J. I ntroduction toSignal Processing. Engl ewood Cl i ffs, NJ:
Prenti ce Hal l , 1996.
sgolayfilt
6-311
6sgol ayfi l t
Purpose Savi tzky-Gol ay fi l teri ng.
Syntax y = sgolayfilt(x,k,f)
y = sgolayfilt(x,k,f,w)
Description y = sgolayfilt(x,k,f) appl i es a Savi tzky-Gol ay FI R smoothi ng fi l ter to the
data i n vector x. I f x i s a matri x, sgolayfilt operates on each col umn. The
pol ynomi al order k must be l ess than the frame si ze, f, whi ch must be odd. I f
k = f1, the fi l ter produces no smoothi ng.
y = sgolayfilt(x,k,f,w) speci fi es a wei ghti ng vector w wi th l ength f, whi ch
contai ns the real , posi ti ve-val ued wei ghts to be used duri ng the l east-squares
mi ni mi zati on.
Remarks Savi tzky-Gol ay smoothi ng fi l ters (al so cal l ed di gi tal smoothi ng pol ynomi al
fi l ters or l east-squares smoothi ng fi l ters) are typi cal l y used to smooth out a
noi sy si gnal whose frequency span (wi thout noi se) i s l arge. I n thi s type of
appl i cati on, Savi tzky-Gol ay smoothi ng fi l ters perform much better than
standard averagi ng FI R fi l ters, whi ch tend to fi l ter out a si gni fi cant porti on of
the si gnal s hi gh frequency content al ong wi th the noi se. Al though
Savi tzky-Gol ay fi l ters are more effecti ve at preservi ng the perti nent hi gh
frequency components of the si gnal , they are l ess successful than standard
averagi ng FI R fi l ters at rejecti ng noi se.
Savi tzky-Gol ay fi l ters are opti mal i n the sense that they mi ni mi ze the
l east-squares error i n fi tti ng a pol ynomi al to frames of noi sy data.
sgolayfilt
6-312
Example Smooth the mtlb si gnal by appl yi ng a cubi c Savi tzky-Gol ay fi l ter to data
frames of l ength 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;
See Also
References [1] Orfani di s, S.J. I ntroduction toSignal Processing. Engl ewood Cl i ffs, NJ:
Prenti ce Hal l , 1996.
0 500 1000 1500 2000
4
2
0
2
4
mtlb
0 500 1000 1500 2000
4
2
0
2
4
smtlb
medfilt1 One-di mensi onal medi an fi l teri ng.
filter Fi l ter data wi th a recursi ve (I I R) or nonrecursi ve
(FI R) fi l ter.
sgolay Savi tzky-Gol ay fi l ter desi gn.
sosfilt Second-order (bi quadrati c) I I R fi l teri ng.
sinc
6-313
6si nc
Purpose Si nc functi on.
Syntax y = sinc(x)
Description sinc computes the si nc functi on of an i nput vector or array, where the si nc
functi on i s
Thi s functi on i s the conti nuous i nverse Fouri er transform of the rectangul ar
pul se of wi dth 2 and hei ght 1:
y = sinc(x) returns an array y the same si ze as x, whose el ements ar e the
sinc functi on of the el ements of x.
The space of functi ons bandl i mi ted i n the frequency band i s spanned
by the i nfi ni te (yet countabl e)set of si nc functi ons shi fted by i ntegers. Thus any
such bandl i mi ted functi on g(t) can be reconstructed from i ts sampl es at i nteger
spaci ngs:
si nc t ( )
1 t 0 = ,
t ( ) si n
t
------------------- t 0 ,

'

=
si nc t ( )
1
2
------ e
j t
d

=
[ , ]
g t ( ) g n ( )si nc t n ( )
n =

=
sinc
6-314
Example Perform i deal bandl i mi ted i nterpol ati on by assumi ng that the si gnal to be
i nterpol ated i s 0 outsi de of the gi ven ti me i nterval and that i t has been sampl ed
at exactl y the Nyqui st frequency:
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)
-5 0 5 10 15
-1
-0.5
0
0.5
1
1.5
2
sinc
6-315
See Also
chirp Swept-frequency cosi ne generator.
cos Cosi ne of vector/matri x el ements (see the onl i ne
MATLAB Function Reference).
diric Di ri chl et or peri odi c si nc functi on.
gauspuls Gaussi an-modul ated si nusoi dal pul se generator.
pulstran Pul se trai n generator.
rectpuls Sampl ed aperi odi c rectangl e generator.
sawtooth Sawtooth or tri angl e wave generator.
sin Si ne of vector/matri x el ements (see the onl i ne
MATLAB Function Reference).
square Square wave generator.
tripuls Sampl ed aperi odi c tri angl e generator.
sos2ss
6-316
6sos2ss
Purpose Conversi on of second-order secti ons to state-space.
Syntax [A,B,C,D] = sos2ss(sos)
[A,B,C,D] = sos2ss(sos,g)
Description sos2ss converts a second-order secti on representati on of a gi ven system to an
equi val ent state-space representati on.
[A,B,C,D] = sos2ss(sos) converts the system sos, i n second-order secti on
form, to a si ngl e-i nput, si ngl e-output state-space representati on:
The di screte transfer functi on i n second-order secti on form i s gi ven by
sos i s a L-by-6 matri x organi zed as
The entri es of sos must be real for proper conversi on to state space. The
returned matri x A i s si ze N-by-N, where N =2L-1, B i s a l ength N-1 col umn
vector, C i s a l ength N-1 row vector, and D i s a scal ar.
[A,B,C,D] = sos2ss(sos,g) converts the system sos i n second-order secti on
form wi th gai n g:
x n 1 + [ ] Ax n [ ] Bu n [ ] + =
y n [ ] Cx n [ ] Du n [ ] + =
H z ( ) H
k
z ( )
k 1 =
L

b
0k
b
1k
z
1
b
2k
z
2
+ +
1 a
1k
z
1
a
2k
z
2
+ +
--------------------------------------------------------- -
k 1 =
L

= =
sos
b
01
b
11
b
21
1 a
11
a
21
b
02
b
12
b
22
1 a
12
a
22
M M M M M M
b
0L
b
1L
b
2L
1 a
1L
a
2L
=
H z ( ) g H
k
z ( )
k 1 =
L

=
sos2ss
6-317
Example Compute the state-space representati on of a si mpl e second-order secti on
system wi th a gai n 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 fi rst converts from second-order secti ons to transfer functi on usi ng
sos2tf, and then from transfer functi on to state-space usi ng tf2ss.
See Also
sos2tf Conversi on of second-order secti ons to transfer
functi on.
sos2zp Conversi on of second-order secti ons to zero-pol e-gai n.
ss2sos Conversi on of state-space to second-order secti ons.
tf2ss Conversi on of transfer functi on to state-space.
zp2ss Conversi on of zer o-pol e-gai n to state-space.
sos2tf
6-318
6sos2tf
Purpose Conversi on of second-order secti ons to transfer functi on.
Syntax [b,a] = sos2tf(sos)
[b,a] = sos2tf(sos,g)
Description sos2tf converts a second-order secti on representati on of a gi ven system to an
equi val ent transfer functi on representati on.
[b,a] = sos2tf(sos) returns the numerator coeffi ci ents b and denomi nator
coeffi ci ents a of the transfer functi on that descri bes a di screte-ti me system
gi ven by sos i n second-order secti on form. The second-order secti on format of
H(z) i s gi ven by
sos i s an L-by-6 matri x that contai ns the coeffi ci ents of each second-order
secti on stored i n i ts rows:
Row vectors b and a contai n the numerator and denomi nator coeffi ci ents of
H(z) stored i n descendi ng powers of z:
[b,a] = sos2tf(sos,g) returns the transfer functi on that descri bes a
di scr ete-ti me system gi ven by sos i n second-order secti on form wi th gai n g:
H z ( ) H
k
z ( )
k 1 =
L

b
0k
b
1k
z
1
b
2k
z
2
+ +
1 a
1k
z
1
a
2k
z
2
+ +
--------------------------------------------------------- -
k 1 =
L

= =
sos
b
01
b
11
b
21
1 a
11
a
21
b
02
b
12
b
22
1 a
12
a
22
M M M M M M
b
0L
b
1L
b
2L
1 a
1L
a
2L
=
H z ( )
B z ( )
A z ( )
-----------
b
1
b
2
z
1
L b
n 1 +
z
n
+ + +
a
1
a
2
z
1
L a
m 1 +
z
m
+ + +
--------------------------------------------------------------------- = =
H z ( ) g H
k
z ( )
k 1 =
L

=
sos2tf
6-319
Algorithm sos2tf uses the conv functi on to mul ti pl y al l of the numerator and
denomi nator second-order pol ynomi al s together.
Example Compute the transfer functi on representati on of a si mpl e second-order secti on
system:
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 Latti ce fi l ter to tr ansfer functi on conver si on.
sos2ss Conversi on of second-order secti ons to state-space.
sos2zp Conversi on of second-order secti ons to zero-pol e-gai n.
ss2tf Conversi on of state-space to transfer functi on.
tf2sos Conversi on of transfer functi on to second-order
secti ons.
zp2tf Conversi on of zero-pol e-gai n to transfer functi on.
sos2zp
6-320
6sos2zp
Purpose Conversi on of second-order secti ons to zero-pol e-gai n.
Syntax [z,p,k] = sos2zp(sos)
[z,p,k] = sos2zp(sos,g)
Description sos2zp converts a second-order secti on representati on of a gi ven system to an
equi val ent zero-pol e-gai n representati on.
[z,p,k] = sos2zp(sos) returns the zeros z, pol es p, and gai n k of the system
gi ven by sos i n second-order secti on form. The second-order secti on format of
H(z) i s gi ven by
sos i s an L-by-6 matri x that contai ns the coeffi ci ents of each second-order
secti on stored i n i ts rows:
Col umn vectors z and p contai n the zeros and pol es of the transfer
functi on H(z):
where the orders n and mare determi ned by the matri x sos.
[z,p,k] = sos2zp(sos,g) returns the zeros z, pol es p, and gai n k of the
system gi ven by sos i n second-order secti on form wi th gai n g:
H z ( ) H
k
z ( )
k 1 =
L

b
0k
b
1k
z
1
b
2k
z
2
+ +
1 a
1k
z
1
a
2k
z
2
+ +
--------------------------------------------------------- -
k 1 =
L

= =
sos
b
01
b
11
b
21
1 a
11
a
21
b
02
b
12
b
22
1 a
12
a
22
M M M M M M
b
0L
b
1L
b
2L
1 a
1L
a
2L
=
H z ( ) k
z z
1
( ) z z
2
( )Lz z
n
( )
p p
1
( ) p p
2
( )Lp p
m
( )
------------------------------------------------------------------- =
H z ( ) g H
k
z ( )
k 1 =
L

=
sos2zp
6-321
Example Compute the pol es, zeros, and gai n of a si mpl e system i n second-order secti on
form:
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 fi nds the pol es and zeros of each second-order secti on by repeatedl y
cal l i ng tf2zp.
See Also
sos2ss Conversi on of second-order secti ons to state-space.
sos2tf Conversi on of second-order secti ons to transfer
functi on.
ss2zp Conversi on of state-space to zero-pol e-gai n.
tf2zp Conversi on of transfer functi on to zero-pol e-gai n.
zp2sos Conversi on of zero-pol e-gai n to second-order secti ons.
sosfilt
6-322
6sosfi l t
Purpose Second-order (bi quadrati c) I I R fi l teri ng.
Syntax y = sosfilt(sos,x)
Description y = sosfilt(sos,x) appl i es the second-order secti on fi l ter sos to vector x.
The output, y, i s the same l ength as x.
sos represents the second-order secti on fi l ter H(z)
by an L-by-6 matri x contai ni ng the coeffi ci ents of each second-order secti on i n
i ts rows
I f x i s a matri x, sosfilt appl i es the fi l ter to each col umn of x i ndependentl y.
Output y i s a matri x of the same si ze, contai ni ng the fi l tered data
correspondi ng to each col umn of x.
See Also
References [1] Orfani di s, S.J. I ntroduction toSignal Processing. Engl ewood Cl i ffs, NJ:
Prenti ce Hal l , 1996.
H z ( ) H
k
z ( )
k 1 =
L

b
0k
b
1k
z
1
b
2k
z
2
+ +
1 a
1k
z
1
a
2k
z
2
+ +
--------------------------------------------------------- -
k 1 =
L

= =
sos
b
01
b
11
b
21
1 a
11
a
21
b
02
b
12
b
22
1 a
12
a
22
M M M M M M
b
0L
b
1L
b
2L
1 a
1L
a
2L
=
filter Fi l ter data wi th a recursi ve (I I R) or nonrecursi ve
(FI R) fi l ter.
medfilt1 One-di mensi onal medi an fi l teri ng.
sgolayfilt Savi tzky-Gol ay fi l teri ng.
specgram
6-323
6specgr am
Purpose Ti me-dependent frequency anal ysi s (spectrogram).
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 computes the wi ndowed di screte-ti me Fouri er transform of a si gnal
usi ng a sl i di ng wi ndow. The spectrogram i s the magni tude of thi s functi on.
B = specgram(a) cal cul ates the spectrogram for the si gnal i n vector a. Thi s
syntax uses the defaul t val ues:
nfft = min(256,length(a))
Fs = 2
window = hanning(nfft)
noverlap = length(window)/2
nfft speci fi es the FFT l ength that specgram uses. Thi s val ue determi nes the
frequenci es at whi ch the di screte-ti me Fouri er transform i s computed. Fs i s a
scal ar that speci fi es the sampl i ng frequency. window speci fi es a wi ndowi ng
functi on and the number of sampl es specgram uses i n i ts secti oni ng of vector a.
noverlap i s the number of sampl es by whi ch the secti ons overl ap. Any
arguments that you omi t from the end of the i nput parameter l i st use the
defaul t val ues shown above.
I f a i s real , specgram computes the di screte-ti me Fouri er transform at posi ti ve
frequenci es onl y. I f n i s even, specgram returns nfft/2+1 rows (i ncl udi ng the
zero and Nyqui st frequency terms). I f n i s odd, specgram returns nfft/2 rows.
The number of col umns i n B i s
k = fix((nnoverlap)/(length(window)noverlap))
I f a i s compl ex, specgram computes the di screte-ti me Fouri er transform at both
posi ti ve and negati ve frequenci es. I n thi s case, B i s a compl ex matri x wi th nfft
specgram
6-324
rows. Ti me i ncreases l i nearl y across the col umns of B, starti ng wi th sampl e 1
i n col umn 1. Frequency i ncreases l i nearl y down the rows, starti ng at 0.
B = specgram(a,nfft) uses the speci fi ed FFTl ength nfft i n i ts cal cul ati ons.
Speci fy nfft as a power of 2 for fastest executi on.
[B,f] = specgram(a,nfft,Fs) returns a vector f of frequenci es at whi ch the
functi on computes the di screte-ti me Fouri er transform. Fs has no effect on the
output B; i t i s a frequency scal i ng mul ti pl i er.
[B,f,t] = specgram(a,nfft,Fs) returns frequency and ti me vectors f and t
respecti vel y. t i s a col umn vector of scal ed ti mes, wi th l ength equal to the
number of col umns of B. t(j) i s the earl i est ti me at whi ch the j-th wi ndow
i ntersects a. t(1) i s al ways equal to 0.
B = specgram(a,nfft,Fs,window) speci fi es a wi ndowi ng functi on and the
number of sampl es per secti on of the x vector. I f you suppl y a scal ar for window,
specgram uses a Hanni ng wi ndow of that l ength. The l ength of the wi ndow
must be l ess than or equal tonfft; specgram zero pads the secti ons i f the l ength
of the wi ndow exceeds nfft.
B = specgram(a,nfft,Fs,window,noverlap) overl aps the secti ons of x by
noverlap sampl es.
You can use the empty matri x [] to speci fy the defaul t val ue for any i nput
argument. For exampl e,
B = specgram(x,[],10000)
i s equi val ent to
B = specgram(x)
but wi th a sampl i ng frequency of 10,000 Hz i nstead of the defaul t 2 Hz.
specgram wi th no output arguments di spl ays the scal ed l ogari thm of the
spectrogram i n the current fi gure wi ndow usi ng
imagesc(t,f,20*log10(abs(b))),axis xy,colormap(jet)
specgram
6-325
The axis xy mode di spl ays the l ow-frequency content of the fi rst porti on of the
si gnal i n the l ower-l eft corner of the axes. specgram uses Fs to l abel the axes
accordi ng to true ti me and frequency.
B = specgram(a,f,Fs,window,noverlap) computes the spectrogram at the
frequenci es speci fi ed i n f, usi ng ei ther the chi rp z-transform (for more than 20
evenl y spaced frequenci es) or a pol yphase deci mati on fi l ter bank. f i s a vector
of frequenci es i n Hertz; i t must have at l east two el ements.
Algorithm specgram cal cul ates the spectrogram for a gi ven si gnal as fol l ows:
1 I t spl i ts the si gnal i nto overl appi ng secti ons and appl i es the wi ndow
speci fi ed by the window parameter to each secti on.
2 I t computes the di screte-ti me Fouri er transform of each secti on wi th a
l ength nfft FFTto produce an esti mate of the short-term frequency content
of the si gnal ; these transforms make up the col umns of B. specgram zero
pads the wi ndowed secti ons i f nfft > length(window), so the quanti ty
(length(window) noverlap) speci fi es by how many sampl es specgram
shi fts the wi ndow.
3 For real i nput, specgram truncates the spectrogram to the fi rst nfft/2 + 1
poi nts for nfft even and (nfft + 1)/2 for nfft odd.
specgram
6-326
Example Pl ot the spectr ogr am of a di gi ti zed speech si gnal :
load mtlb
specgram(mtlb,512,Fs,kaiser(500,5),475)
title('Spectrogram')
Diagnostics An appropri ate di agnosti c message i s di spl ayed when i ncorrect arguments are
used:
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
Time
F
r
e
q
u
e
n
c
y
Spectrogram
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45
0
500
1000
1500
2000
2500
3000
3500
cohere Esti mate magni tude squared coherence functi on
between two si gnal s.
csd Esti mate the cross spectral densi ty (CSD) of two
si gnal s.
pwelch Esti mate the power spectral densi ty (PSD) of a si gnal
usi ng Wel chs method.
tfe Transfer functi on esti mate from i nput and output.
specgram
6-327
References [1] Oppenhei m, A.V., and R.W. Schafer. Discrete-TimeSignal Processing.
Engl ewood Cl i ffs, NJ: Prenti ce Hal l , 1989. Pgs. 713-718.
[2] Rabi ner, L.R., and R.W. Schafer. Digital Processingof Speech Signals.
Engl ewood Cl i ffs, NJ: Prenti ce Hal l , 1978.
sptool
6-328
6sptool
Purpose I nteracti ve di gi tal si gnal processi ng tool (SPTool ).
Syntax sptool
Description The sptool command i nvokes a sui te of graphi cal user i nterface (GUI ) tool s
that provi des access to many of the si gnal , fi l ter, and spectral anal ysi s
functi ons i n the tool box i n a powerful , easy-to-use i nteracti ve si gnal di spl ay
and expl orati on envi ronment.
Usi ng SPTool , you can i mport, export, and manage si gnal s, fi l ters, and spectra.
From SPTool , you can acti vate i ts four i ntegrated si gnal processi ng tool s:
The Signal Browser, for vi ewi ng, measuri ng, and anal yzi ng the ti me-domai n
i nformati on of one or more si gnal s.
sptool
6-329
The Filter Designer, for desi gni ng and edi ti ng FI R and I I R fi l ters of vari ous
l engths and types, wi th standard (l owpass, hi ghpass, bandpass, bandstop,
and mul ti band) confi gurati ons.
sptool
6-330
The Filter Viewer, for vi ewi ng the characteri sti cs of a desi gned or i mported
fi l ter, i ncl udi ng i ts magni tude response, phase response, group del ay,
pol e-zero pl ot, i mpul se response, and step response.
sptool
6-331
The SpectrumViewer, for graphi cal anal ysi s of frequency-domai n data usi ng
a vari ety of methods of spectral densi ty esti mati on, i ncl udi ng the Burg
method, the FFT method, the mul ti taper method (MTM), the MUSI C
ei genvector method, Wel chs method, and the Yul e-Wal ker AR method.
See Chapter 5, I nteracti ve Tool s for a ful l di scussi on of how to use SPTool .
square
6-332
6square
Purpose Square wave generator.
Syntax x = square(t)
x = square(t,duty)
Description x = square(t) generates a square wave wi th peri od 2 for the el ements of
ti me vector t. square(t) i s si mi l ar to sin(t), but i t creates a square wave wi th
peaks of 1 i nstead of a si ne wave.
x = square(t,duty) generates a square wave wi th speci fi ed duty cycl e, duty.
The dutycyclei s the percent of the peri od i n whi ch the si gnal i s posi ti ve.
See Also
chirp Swept-frequency cosi ne generator.
cos Cosi ne of vector/matri x el ements (see the onl i ne
MATLAB Function Reference).
diric Di ri chl et or peri odi c si nc functi on.
gauspuls Gaussi an-modul ated si nusoi dal pul se generator.
pulstran Pul se trai n generator.
rectpuls Sampl ed aperi odi c rectangl e generator.
sawtooth Sawtooth or tr i angl e wave gener ator.
sin Si ne of vector/matri x el ements (see the onl i ne
MATLAB Function Reference).
sinc Si nc or si n(t)/t functi on.
tripuls Sampl ed aperi odi c tri angl e generator.
ss2sos
6-333
6ss2sos
Purpose Conversi on of state-space to second-order secti ons.
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 converts a state-space representati on of a gi ven system to an
equi val ent second-order secti on representati on.
[sos,g] = ss2sos(A,B,C,D) fi nds a matri x sos i n second-order secti on form
wi th gai n g that i s equi val ent to the state-space system represented by i nput
arguments A, B, C and D. The i nput system must be si ngl e output and real . sos
i s an L-by-6 matri x
whose rows contai n the numerator and denomi nator coeffi ci ents b
ik
and a
ik
of
the second-order secti ons of H(z):
[sos,g] = ss2sos(A,B,C,D,iu) speci fi es a scal ar iu that determi nes whi ch
i nput of the state-space system A, B, C, D i s used i n the conversi on. The defaul t
for iu i s 1.
[sos,g] = ss2sos(A,B,C,D,'order') and
[sos,g] = ss2sos(A,B,C,D,iu,'order') speci fy the order of the rows i n sos,
where order i s:
sos
b
01
b
11
b
21
1 a
11
a
21
b
02
b
12
b
22
1 a
12
a
22
M M M M M M
b
0L
b
1L
b
2L
1 a
1L
a
2L
=
H z ( ) g H
k
z ( )
k 1 =
L

g
b
0k
b
1k
z
1
b
2k
z
2
+ +
1 a
1k
z
1
a
2k
z
2
+ +
--------------------------------------------------------- -
k 1 =
L

= =
ss2sos
6-334
down, to order the secti ons so the fi rst row of sos contai ns the pol es cl osest to
the uni t ci rcl e
up, to order the secti ons so the fi rst row of sos contai ns the pol es farthest
from the uni t ci rcl e (defaul t)
The zeros are al ways pai red wi th the pol es cl osest to them.
[sos,g] = ss2sos(A,B,C,D,iu,'order','scale') speci fi es the desi red
scal i ng of the gai n and the numerator coeffi ci ents of al l second-order secti ons,
where scale i s:
none, to appl y no scal i ng (defaul t)
inf, to appl y i nfi ni ty-norm scal i ng
two, to appl y 2-norm scal i ng
Usi ng i nfi ni ty-norm scal i ng i n conjuncti on wi th up-orderi ng mi ni mi zes the
probabi l i ty of overfl ow i n the real i zati on. Usi ng 2-norm scal i ng i n conjuncti on
wi th down-orderi ng mi ni mi zes the peak round-off noi se.
sos = ss2sos(...) embeds the overal l system gai n, g, i n the fi rst secti on,
H
1
(z), so that:
Example Fi nd a second-order secti on form of a Butterworth l owpass fi l ter:
[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 uses a four-step al gori thm to determi ne the second-order secti on
representati on for an i nput state-space system:
H z ( ) H
k
z ( )
k 1 =
L

=
ss2sos
6-335
1 I t fi nds the pol es and zeros of the system gi ven by A, B, C and D.
2 I t uses the functi on zp2sos, whi ch fi rst groups the zeros and pol es i nto
compl ex conjugate pai rs usi ng the cplxpair functi on. zp2sos then forms the
second-order secti ons by matchi ng the pol e and zero pai rs accordi ng to the
fol l owi ng rul es:
a Match the pol es cl osest to the uni t ci r cl e wi th the zer os cl osest to those
pol es.
b Match the pol es next cl osest to the uni t ci rcl e wi th the zeros cl osest to
those pol es.
c Conti nue unti l al l of the pol es and zeros are matched.
ss2sos groups real pol es i nto secti ons wi th the real pol es cl osest to them i n
absol ute val ue. The same rul e hol ds for real zeros.
3 I t orders the secti ons accordi ng to the proxi mi ty of the pol e pai rs to the uni t
ci rcl e. ss2sos normal l y orders the secti ons wi th pol es cl osest to the uni t
ci rcl e l ast i n the cascade. You can tel l ss2sos to order the secti ons i n the
reverse order by speci fyi ng the 'down' fl ag.
4 ss2sos scal es the secti ons by the norm speci fi ed i n the 'scale' argument.
For arbi trary H(), the scal i ng i s defi ned by:
where p can be ei ther or 2. See the references for detai l s on the scal i ng.
Thi s scal i ng i s an attempt to mi ni mi ze overfl ow or peak round-off noi se i n
fi xed poi nt fi l ter i mpl ementati ons.
Diagnostics I f there i s more than one i nput to the system, ss2sos gi ves the fol l owi ng error
message:
Statespace system must have only one input.
H
p
1
2
------ H ( )
p
d
0
2

1
p
---
=
ss2sos
6-336
See Also
References [1] Jackson, L.B. Digital Filtersand Signal Processing. 3rd ed. Boston: Kl uwer
Academi c Publ i shers, 1996. Chapter 11.
[2] Mi tra, S.K. Digital Signal Processing: A Computer-Based Approach. New
York: McGraw-Hi l l , 1998. Chapter 9.
[3] Vai dyanathan, P.P. Robust Di gi tal Fi l ter Structures. Handbook for
Digital Signal Processing. S.K. Mi tra and J.F. Kai ser, ed. Chapter 7. New York:
John Wi l ey & Sons, 1993.
cplxpair Group compl ex numbers i nto compl ex conjugate
pai rs.
sos2ss Conversi on of second-order secti ons to state-space.
ss2tf Conversi on of state-space to transfer functi on.
ss2zp Conversi on of state-space to zero-pol e-gai n.
tf2sos Conversi on of transfer functi on to second-order
secti ons.
zp2sos Conversi on of zero-pol e-gai n to second-order secti ons.
ss2tf
6-337
6ss2tf
Purpose Conversi on of state-space to transfer functi on.
Syntax [b,a] = ss2tf(A,B,C,D,iu)
Description ss2tf converts a state-space representati on of a gi ven system to an equi val ent
transfer functi on representati on.
[b,a] = ss2tf(A,B,C,D,iu) returns the transfer functi on
of the system
from the iu-th i nput. Vector a contai ns the coeffi ci ents of the denomi nator i n
descendi ng powers of s. The numerator coeffi ci ents are returned i n array b wi th
as many rows as there are outputs y. ss2tf al so works wi th systems i n di screte
ti me, i n whi ch case i t returns the z-transform representati on.
The ss2tf functi on i s part of the standard MATLAB l anguage.
Algorithm The ss2tf functi on uses poly to fi nd the characteri sti c pol ynomi al det(sI -A)
and the equal i ty
See Also
H s ( )
B s ( )
A s ( )
---------- - C sI A ( )
1
B D + = =
x

Ax Bu + =
y Cx Du + =
H s ( ) C sI A ( )
1
B
det sI A BC + ( ) det sI A ( )
det sI A ( )
------------------------------------------------------------------------------ = =
latc2tf Latti ce fi l ter to tr ansfer functi on conver si on.
sos2tf Conversi on of second-order secti ons to transfer
functi on.
ss2sos Conversi on of state-space to second-order secti ons.
ss2zp Conversi on of state-space to zero-pol e-gai n.
tf2ss Conversi on of transfer functi on to state-space.
zp2tf Conversi on of zero-pol e-gai n to transfer functi on.
ss2zp
6-338
6ss2zp
Purpose Conversi on of state-space to zero-pol e-gai n.
Syntax [z,p,k] = ss2zp(A,B,C,D,iu)
Description ss2zp converts a state-space representati on of a gi ven system to an equi val ent
zero-pol e-gai n representati on. The zeros, pol es, and gai ns of state-space
systems represent the transfer functi on i n factored form.
[z,p,k] = ss2zp(A,B,C,D,iu) cal cul ates the transfer functi on i n factored
form
of the system
from the iu-th i nput. Returned col umn vector p contai ns the pol e l ocati ons of
the denomi nator coeffi ci ents of the transfer functi on. Matri x z contai ns the
numerator zeros i n i ts col umns, wi th as many col umns as there are outputs y.
Col umn vector k contai ns the gai ns for each numerator transfer functi on.
ss2zp al so works wi th systems i n di screte ti me, i n whi ch case i t returns the
z-transform representati on. The i nput state-space system must be real .
The ss2zp functi on i s part of the standard MATLAB l anguage.
H s ( )
Z s ( )
P s ( )
---------- k
s z
1
( ) s z
2
( )Ls z
n
( )
s p
1
( ) s p
2
( )Ls p
n
( )
--------------------------------------------------------------- = =
x

Ax Bu + =
y Cx Du + =
ss2zp
6-339
Example Here are two ways of fi ndi ng the zeros, pol es, and gai ns of a system:
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 fi nds the pol es from the ei genval ues of the A array. The zeros are the
fi ni te sol uti ons to a general i zed ei genval ue probl em:
z = eig([A B;C D], diag([ones(1,n) 0]);
I n many si tuati ons thi s al gori thm produces spuri ous l arge, but fi ni te, zeros.
ss2zp i nterprets these l arge zeros as i nfi ni te.
ss2zp fi nds the gai ns by sol vi ng for the fi rst nonzero Markov parameters.
ss2zp
6-340
See Also
References [1] Laub, A.J., and B.C. Moore. Cal cul ati on of Transmi ssi on Zeros Usi ng QZ
Techni ques. Automatica 14 (1978). Pg. 557.
pzmap Pol e-zero map of LTI system (Control SystemToolbox
Users Guide).
sos2zp Conversi on of second-order secti ons to zero-pol e-gai n.
ss2sos Conversi on of state-space to second-order secti ons.
ss2tf Conversi on of state-space to transfer functi on.
tf2zp Conversi on of transfer functi on to zero-pol e-gai n.
zp2ss Conversi on of zer o-pol e-gai n to state-space.
stmcb
6-341
6stmcb
Purpose Li near model usi ng Stei gl i tz-McBri de i terati on.
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 Stei gl i tz-McBri de i terati on i s an al gori thm for fi ndi ng an I I R fi l ter wi th a
prescri bed ti me domai n i mpul se response. I t has appl i cati ons i n both fi l ter
desi gn and system i denti fi cati on (parametri c model i ng).
[b,a] = stmcb(x,nb,na) fi nds the coeffi ci ents b and a of the system b(z)/ a(z)
wi th approxi mate i mpul se response x, exactl y nb zeros, and exactl y na pol es.
[b,a] = stmcb(x,u,nb,na) fi nds the system coeffi ci ents b and a of the system
that, gi ven u as i nput, has x as output. x and u must be the same l ength.
[b,a] = stmcb(x,nb,na,niter) and
[b,a] = stmcb(x,u,nb,na,niter) use niter i terati ons. The defaul t for niter
i s 5.
[b,a] = stmcb(x,nb,na,niter,ai) and
[b,a] = stmcb(x,u,nb,na,niter,ai) use the vector ai as the i ni ti al esti mate
of the denomi nator coeffi ci ents. I f ai i s not speci fi ed, stmcb uses the output
argument from [b,ai] = prony(x,0,na) as the vector ai.
stmcb returns the I I R fi l ter coeffi ci ents i n l ength nb+1 and na+1 row vectors b
and a. The fi l ter coeffi ci ents are ordered i n descendi ng powers of z:
H z ( )
B z ( )
A z ( )
-----------
b 1 ( ) b 2 ( )z
1
L b nb 1 + ( )z
nb
+ + +
a 1 ( ) a 2 ( )z
1
L a na 1 + ( )z
na
+ + +
----------------------------------------------------------------------------------------- = =
stmcb
6-342
Example Approxi mate the i mpul se response of a Butterworth fi l ter wi th a system of
l ower order:
[b,a] = butter(6,0.2);
h = filter(b,a,[1 zeros(1,100)]);
freqz(b,a,128)
[bb,aa] = stmcb(h,4,4);
freqz(bb,aa,128)
0 0.2 0.4 0.6 0.8 1
600
400
200
0
Normalized Angular Frequency ( rads/sample)
P
h
a
s
e

(
d
e
g
r
e
e
s
)
0 0.2 0.4 0.6 0.8 1
300
200
100
0
Normalized Angular Frequency ( rads/sample)
M
a
g
n
i
t
u
d
e

(
d
B
)
0 0.2 0.4 0.6 0.8 1
800
600
400
200
0
Normalized Angular Frequency ( rads/sample)
P
h
a
s
e

(
d
e
g
r
e
e
s
)
0 0.2 0.4 0.6 0.8 1
60
40
20
0
20
Normalized Angular Frequency ( rads/sample)
M
a
g
n
i
t
u
d
e

(
d
B
)
stmcb
6-343
Algorithm stmcb attempts to mi ni mi ze the squared error between the i mpul se response x'
of b(z)/ a(z) and the i nput si gnal x:
stmcb i terates usi ng two steps:
1 I t prefi l ters x and u usi ng 1/a(z).
2 I t sol ves a system of l i near equati ons for b and a usi ng \.
stmcb repeats thi s process niter ti mes. No checki ng i s done to see i f the b and
a coeffi ci ents have converged i n fewer than niter i terati ons.
Diagnostics I f x and u have di fferent l engths, stmcb gi ves the fol l owi ng error message:
X and U must have same length.
See Also
References [1] Stei gl i tz, K., and L.E. McBri de. A Techni que for the I denti fi cati on of Li near
Systems. I EEE Trans. Automatic Control. Vol . AC-10 (1965). Pgs. 461-464.
[2] Ljung, L. SystemI dentification: Theoryfor theUser. Engl ewood Cl i ffs, NJ:
Prenti ce Hal l , 1987. Pg. 297.
mi n
a b ,
x i ( ) x' i ( )
2
i 0 =

levinson Levi nson-Durbi n recursi on.


lpc Li near pr edi cti on coeffi ci ents.
aryule Compute an esti mate of AR model parameters usi ng
the Yul e-Wal ker method.
prony Pronys method for ti me domai n I I R fi l ter desi gn.
strips
6-344
6str i ps
Purpose Stri p pl ot.
Syntax strips(x)
strips(x,n)
strips(x,sd,Fs)
strips(x,sd,Fs,scale)
Description strips(x) pl ots vector x i n hori zontal stri ps of l ength 250. I f x i s a matri x,
strips(x) pl ots each col umn of x. The l eft-most col umn (col umn 1) i s the top
hori zontal stri p.
strips(x,n) pl ots vector x i n stri ps that are each n sampl es l ong.
strips(x,sd,Fs) pl ots vector x i n stri ps of durati on sd seconds, gi ven a
sampl i ng frequency of Fs sampl es per second.
strips(x,sd,Fs,scale) scal es the ver ti cal axes.
I f x i s a matri x, strips(x,n), strips(x,sd,Fs), and strips(x,sd,Fs,scale)
pl ot the di fferent col umns of x on the same stri p pl ot.
strips i gnores the i magi nary part of x i f i t i s compl ex.
strips
6-345
Example Pl ot two seconds of a frequency modul ated si nusoi d i n 0.25 second stri ps:
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)
See Also
0 0.05 0.1 0.15 0.2 0.25
1.75
1.5
1.25
1
0.75
0.5
0.25
0
plot Li near two-di mensi onal pl ot (see the onl i ne MATLAB
Function Reference).
stem Pl ot di screte sequence data (see the onl i ne MATLAB
Function Reference).
tf2latc
6-346
6tf2l atc
Purpose Conversi on of transfer functi on to l atti ce fi l ter.
Syntax [k,v] = tf2latc(b,a)
k = tf2latc(1,a)
[k,v] = tf2latc(1,a)
k = tf2latc(b)
Description [k,v] = tf2latc(b,a) fi nds the l atti ce parameters k and the l adder
parameters v for an I I R (ARMA) l atti ce-l adder fi l ter, normal i zed by a(1). Note
that an error i s generated i f one or more of the l atti ce parameters are exactl y
equal to 1.
k = tf2latc(1,a) fi nds the l atti ce parameters k for an I I R al l -pol e (AR)l atti ce
fi l ter.
[k,v] = tf2latc(1,a) returns the scal ar l adder coeffi ci ent at the correct
posi ti on i n vector v. Al l other el ements of v are zero.
k = tf2latc(b) fi nds the l atti ce parameters k for an FI R (MA) l atti ce fi l ter,
normal i zed by b(1).
See Also
latc2tf Latti ce fi l ter to transfer functi on conversi on.
latcfilt Latti ce and l atti ce-l adder fi l ter i mpl ementati on.
tf2sos Conversi on of transfer functi on to second-order
secti ons.
tf2ss Conversi on of tr ansfer functi on to state-space.
tf2zp Conversi on of transfer functi on to zero-pol e-gai n.
tf2sos
6-347
6tf2sos
Purpose Conversi on of transfer functi on to second-order secti ons.
Syntax [sos,g] = tf2sos(b,a)
[sos,g] = tf2sos(b,a,'order')
[sos,g] = tf2sos(b,a,'order','scale')
sos = tf2sos(...)
Description tf2sos converts a transfer functi on representati on of a gi ven system to an
equi val ent second-order secti on representati on.
[sos,g] = tf2sos(b,a) fi nds a matri x sos i n second-order secti on form wi th
gai n g that i s equi val ent to the system represented by transfer functi on
coeffi ci ent vectors a and b.
sos i s an L-by-6 matri x
whose rows contai n the numerator and denomi nator coeffi ci ents b
ik
and a
ik
of
the second-order secti ons of H(z):
[sos,g] = tf2sos(b,a,'order') speci fi es the order of the rows i n sos, where
order i s:
H z ( )
B z ( )
A z ( )
-----------
b
1
b
2
z
1
L b
nb 1 +
z
nb
+ + +
a
1
a
2
z
1
L a
na 1 +
z
na
+ + +
------------------------------------------------------------------------- = =
sos
b
01
b
11
b
21
1 a
11
a
21
b
02
b
12
b
22
1 a
12
a
22
M M M M M M
b
0L
b
1L
b
2L
1 a
1L
a
2L
=
H z ( ) g H
k
z ( )
k 1 =
L

g
b
0k
b
1k
z
1
b
2k
z
2
+ +
1 a
1k
z
1
a
2k
z
2
+ +
--------------------------------------------------------- -
k 1 =
L

= =
tf2sos
6-348
down, to order the secti ons so the fi rst row of sos contai ns the pol es cl osest to
the uni t ci rcl e
up, to order the secti ons so the fi rst row of sos contai ns the pol es farthest
from the uni t ci rcl e (defaul t)
[sos,g] = tf2sos(b,a,'order','scale') speci fi es the desi red scal i ng of the
gai n and numerator coeffi ci ents of al l second-order secti ons, where scale i s:
none, to appl y no scal i ng (defaul t)
inf, to appl y i nfi ni ty-norm scal i ng
two, to appl y 2-norm scal i ng
Usi ng i nfi ni ty-norm scal i ng i n conjuncti on wi th up-orderi ng mi ni mi zes the
probabi l i ty of overfl ow i n the real i zati on. Usi ng 2-norm scal i ng i n conjuncti on
wi th down-orderi ng mi ni mi zes the peak round-off noi se.
sos = tf2sos(...) embeds the overal l system gai n, g, i n the fi rst secti on,
H
1
(z), so that
See Also
H z ( ) H
k
z ( )
k 1 =
L

=
cplxpair Group compl ex numbers i nto compl ex conjugate
pai rs.
sos2tf Conversi on of second-order secti ons to transfer
functi on.
ss2sos Conversi on of state-space to second-order secti ons.
tf2ss Conversi on of tr ansfer functi on to state-space.
tf2zp Conversi on of transfer functi on to zero-pol e-gai n.
zp2sos Conversi on of zero-pol e-gai n to second-order secti ons.
tf2sos
6-349
References [1] Jackson, L.B. Digital Filters and Signal Processing. 3rd ed. Boston: Kl uwer
Academi c Publ i shers, 1996. Chapter 11.
[2] Mi tra, S.K. Digital Signal Processing: A Computer-Based Approach. New
York: McGraw-Hi l l , 1998. Chapter 9.
[3] Vai dyanathan, P.P. Robust Di gi tal Fi l ter Structures. Handbook for
Digital Signal Processing. S.K. Mi tra and J.F. Kai ser, ed. Chapter 7. New York:
John Wi l ey & Sons, 1993.
tf2ss
6-350
6tf2ss
Purpose Conversi on of transfer functi on to state-space.
Syntax [A,B,C,D] = tf2ss(b,a)
Description tf2ss converts a transfer functi on representati on of a gi ven system to an
equi val ent state-space representati on.
[A,B,C,D] = tf2ss(b,a) fi nds a state-space representati on:
gi ven a system i n transfer functi on form:
from a si ngl e i nput. I nput vector a contai ns the denomi nator coeffi ci ents i n
descendi ng powers of s. Matri x b contai ns the numerator coeffi ci ents wi th as
many rows as there are outputs y. tf2ss returns the A, B, C, and D matri ces i n
control l er canoni cal form.
tf2ss al so works for di screte systems, but you must pad the numerator wi th
trai l i ng zeros to make i t the same l ength as the denomi nator.
The tf2ss functi on i s part of the standard MATLAB l anguage.
Example Consi der the system
x

Ax Bu + =
y Cx Du + =
H s ( )
B s ( )
A s ( )
---------- - C sI A ( )
1
B D + = =
H s ( )
2s 3 +
s
2
2s 1 + +
s
2
0.4s 1 + +
--------------------------------- =
tf2ss
6-351
To convert thi s system to state-space:
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
There i s di sagreement i n the l i terature on nami ng conventi ons for the
canoni cal forms. I t i s easy, however, to generate si mi l ari ty transformati ons
that convert to other forms. For exampl e:
T = fliplr(eye(n));
A = T\A*T;
Algorithm tf2ss wri tes the output i n control l er canoni cal form by i nspecti on.
See Also
sos2ss Conversi on of second-order secti ons to state-space.
ss2tf Conversi on of state-space to transfer functi on.
tf2sos Conversi on of transfer functi on to second-order
secti ons.
tf2zp Conversi on of transfer functi on to zero-pol e-gai n.
zp2ss Conversi on of zer o-pol e-gai n to state-space.
tf2zp
6-352
6tf2zp
Purpose Conversi on of transfer functi on to zero-pol e-gai n.
Syntax [z,p,k] = tf2zp(b,a)
Description tf2zp fi nds the zeros, pol es, and gai ns of a system i n pol ynomi al transfer
functi on form.
[z,p,k] = tf2zp(b,a) fi nds the si ngl e-i nput, mul ti -output (SI MO) factored
transfer functi on form:
gi ven a SI MO system i n pol ynomi al transfer functi on form:
Vector a speci fi es the coeffi ci ents of the denomi nator i n descendi ng powers of
s. Matri x b i ndi cates the numerator coeffi ci ents wi th as many rows as there are
outputs. The zero l ocati ons are returned i n the col umns of matri x z, wi th as
many col umns as there are rows i n b. The pol e l ocati ons are returned i n col umn
vector p and the gai ns for each numerator transfer functi on i n vector k.
The tf2zp functi on al so works for di screte systems, and i s part of the standard
MATLAB l anguage.
H s ( )
Z s ( )
P s ( )
---------- k
s Z
1
( ) s Z
2
( )Ls Z
m
( )
s p
1
( ) s p
2
( )Ls p
n
( )
------------------------------------------------------------------ = =
B s ( )
A s ( )
---------- -
b
1
s
nb 1 ( )
L b
nb 1 ( )
s b
nb ( )
+ + +
a
1
s
na 1 ( )
L a
na 1 ( )
s a
na ( )
+ + +
-------------------------------------------------------------------------------------- - =
tf2zp
6-353
Example Fi nd the zeros, pol es, and gai ns of the system
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
Algorithm The system i s conver ted to state-space usi ng tf2ss and then to zer os, pol es,
and gai ns usi ng ss2zp.
See Also
H s ( )
2s 3 +
s
2
0.4s 1 + +
--------------------------------- =
sos2zp Conversi on of second-order secti ons to zero-pol e-gai n.
ss2zp Conversi on of state-space to zero-pol e-gai n.
tf2sos Conversi on of transfer functi on to second-order
secti ons.
tf2ss Conversi on of transfer functi on to state-space.
zp2tf Conversi on of zero-pol e-gai n to transfer functi on.
tfe
6-354
6tfe
Purpose Transfer functi on esti mate from i nput and output.
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) fi nds a transfer functi on esti mate Txy gi ven i nput si gnal
vector x and output si gnal vector y. The transfer function i s the quoti ent of the
cross spectrum of x and y and the power spectrum of x:
The rel ati onshi p between the i nput x and output y i s model ed by the l i near,
ti me-i nvari ant transfer functi on Txy.
Vectors x and y must be the same l ength. Txy = tfe(x,y) uses the fol l owi ng
defaul t val ues:
nfft = min(256,(length(x))
Fs = 2
window = hanning(nfft)
noverlap = 0
nfft speci fi es the FFT l ength that tfe uses. Thi s val ue determi nes the
frequenci es at whi ch the power spectrum i s esti mated. Fs i s a scal ar that
speci fi es the sampl i ng frequency. window speci fi es a wi ndowi ng functi on and
the number of sampl es tfe uses i n i ts secti oni ng of the x and y vectors.
noverlap i s the number of sampl es by whi ch the secti ons overl ap. Any
arguments that are omi tted from the end of the parameter l i st use the defaul t
val ues shown above.
I f x i s real , tfe esti mates the transfer functi on at posi ti ve frequenci es onl y; i n
thi s case, the output Txy i s a col umn vector of l ength nfft/2+1 for nfft even
and (nfft+1)/2 for nfft odd. I f x or y i s compl ex, tfe esti mates the transfer
functi on for both posi ti ve and negati ve frequenci es and Txy has l ength nfft.
T
xy
f ( )
P
xy
f ( )
P
xx
f ( )
--------------- =
tfe
6-355
Txy = tfe(x,y,nfft) uses the speci fi ed FFT l ength nfft i n esti mati ng the
transfer functi on. Speci fy nfft as a power of 2 for fastest executi on.
[Txy,f] = tfe(x,y,nfft,Fs) returns a vector f of frequenci es at whi ch tfe
esti mates the transfer functi on. Fs i s the sampl i ng frequency. f i s the same si ze
as Txy, so plot(f,Txy) pl ots the transfer functi on esti mate versus properl y
scal ed frequency. Fs has no effect on the output Txy; i t i s a frequency scal i ng
mul ti pl i er.
Txy = tfe(x,y,nfft,Fs,window) speci fi es a wi ndowi ng functi on and the
number of sampl es per secti on of the x vector. I f you suppl y a scal ar for window,
Txy uses a Hanni ng wi ndow of that l ength. The l ength of the wi ndow must be
l ess than or equal to nfft; tfe zero pads the secti ons i f the l ength of the wi ndow
exceeds nfft.
Txy = tfe(x,y,nfft,Fs,window,noverlap) overl aps the secti ons of x by
noverlap sampl es.
You can use the empty matri x [] to speci fy the defaul t val ue for any i nput
argument except x or y. For exampl e,
Txy = tfe(x,y,[],[],kaiser(128,5))
uses 256 as the val ue for nfft and 2 as the val ue for Fs.
Txy = tfe(x,y,...,'dflag') speci fi es a detrend opti on, where dflag i s:
linear, to remove the best str ai ght-l i ne fi t fr om the pr ewi ndowed secti ons of
x and y
mean, to remove the mean from the prewi ndowed secti ons of x and y
none, for no detrendi ng (defaul t)
The dflag parameter must appear l ast i n the l i st of i nput arguments. tfe
recogni zes a dflag stri ng no matter how many i ntermedi ate arguments are
omi tted.
tfe(...) wi th no output arguments pl ots the magni tude of the transfer
functi on esti mate i n deci bel s versus frequency i n the current fi gure wi ndow.
tfe
6-356
Example Compute and pl ot the transfer functi on esti mate between two col ored noi se
sequences x and 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')
Algorithm tfe uses a four-step al gori thm:
1 I t mul ti pl i es the detrended secti ons by window.
2 I t takes the l ength nfft FFT of each secti on.
3 I t averages the squares of the spectra of the x secti ons to form Pxx and
averages the products of the spectra of the x and y secti ons to form Pxy.
4 I t cal cul ates Txy:
Txy = Pxy./Pxx
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-45
-40
-35
-30
-25
-20
-15
-10
-5
0
5
Frequency
T
r
a
n
f
e
r

F
u
n
c
t
i
o
n

E
s
t
i
m
a
t
e

(
d
B
)
Transfer Function Estimate
tfe
6-357
Diagnostics An appropri ate di agnosti c message i s di spl ayed when i ncorrect arguments are
used:
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 Compute empi ri cal transfer functi on esti mate and
peri odogram (see SystemI dentification Toolbox
Users Guide).
cohere Esti mate magni tude squared coherence functi on
between two si gnal s.
csd Esti mate the cross spectral densi ty (CSD) of two
si gnal s.
pwelch Esti mate the power spectral densi ty (PSD) of a si gnal
usi ng Wel chs method.
spa Perform spectral anal ysi s for i nput-output data (see
SystemI dentification ToolboxUsers Guide).
triang
6-358
6tri ang
Purpose Tri angul ar wi ndow.
Syntax w = triang(n)
Description triang(n) returns an n-poi nt tri angul ar wi ndow i n the col umn vector w. The
coeffi ci ents of a tri angul ar wi ndow are
For n odd:
For n even:
The tri angul ar wi ndow i s very si mi l ar to a Bartl ett wi ndow. The Bartl ett
wi ndow al ways ends wi th zeros at sampl es 1 and n, whi l e the tri angul ar
wi ndow i s nonzero at those poi nts. For n odd, the center n2 poi nts of
triang(n2) are equi val ent to bartlett(n).
See Also
References [1] Oppenhei m, A.V., and R.W. Schafer, Discrete-TimeSignal Processing.
Engl ewood Cl i ffs, NJ: Prenti ce-Hal l , 1989.
w k [ ]
2k
n 1 +
------------- 1 k
n 1 +
2
------------- ,
2 n k 1 + ( )
n 1 +
-------------------------------
n 1 +
2
------------- k n ,

'

=
w k [ ]
2k 1
n
---------------- 1 k
n
2
--- ,
2 n k 1 + ( )
n
-------------------------------
n
2
--- 1 + k n ,

'

=
bartlett Bartl ett wi ndow.
blackman Bl ackman wi ndow.
boxcar Rectangul ar wi ndow.
chebwin Chebyshev wi ndow.
hamming Hammi ng wi ndow.
hanning Hanni ng wi ndow.
kaiser Kai ser wi ndow.
tripuls
6-359
6tr i pul s
Purpose Sampl ed aperi odi c tri angl e generator.
Syntax y = tripuls(T)
y = tripuls(T,w)
y = tripuls(T,w,s)
Description y = tripuls(T) returns a conti nuous, aperi odi c, symmetri c, uni ty-hei ght
tri angul ar pul se at the ti mes i ndi cated i n array T, centered about T=0 and wi th
a defaul t wi dth of 1.
y = tripuls(T,w) generates a tri angul ar pul se of wi dth w.
y = tripuls(T,w,s) generates a tri angul ar pul se wi th skew s, where 1<s<1.
When s i s 0, a symmetri c tri angul ar pul se i s generated.
See Also
chirp Swept-frequency cosi ne generator.
cos Cosi ne of vector/matri x el ements (see the onl i ne
MATLAB Function Reference).
diric Di ri chl et or peri odi c si nc functi on.
gauspuls Gaussi an-modul ated si nusoi dal pul se generator.
pulstran Pul se trai n generator.
rectpuls Sampl ed aperi odi c rectangl e generator.
sawtooth Sawtooth or tri angl e wave generator.
sin Si ne of vector/matri x el ements (see the onl i ne
MATLAB Function Reference).
sinc Si nc or si n(t)/t functi on.
square Square wave generator.
unwrap
6-360
6unwr ap
Purpose Unwrap phase angl es.
Syntax p = unwrap(p)
Description p = unwrap(p) corrects the phase angl es i n vector p by addi ng mul ti pl es of
, where needed, to smooth the transi ti ons across branch cuts. When p i s a
matri x, unwrap corrects the phase angl es down each col umn. The phase must
be i n radi ans.
The unwrap functi on i s part of the standard MATLAB l anguage.
Limitations unwrap tri es to detect branch cut crossi ngs, but i t can be fool ed by sparse,
rapi dl y changi ng phase val ues.
See Also
2 t
abs Absol ute val ue (magni tude).
angle Phase angl e.
upfirdn
6-361
6upfi rdn
Purpose Upsampl e, appl y an FI R fi l ter, and downsampl e.
Syntax yout = upfirdn(xin,h)
yout = upfirdn(xin,h,p)
yout = upfirdn(xin,h,p,q)
Description upfirdn performs a cascade of three operati ons:
1 Upsampl i ng by p (zero i nserti ng)
2 FI R fi l teri ng wi th the i mpul se response gi ven i n h
3 Downsampl i ng by q (throwi ng away sampl es)
upfirdn has been i mpl emented as a MEX-fi l e for maxi mum speed, so onl y the
outputs actual l y needed are computed. The FI R fi l ter i s usual l y a l owpass
fi l ter, whi ch you must desi gn usi ng another functi on such as remez or fir1.
NOTE The functi on resample performs an FI R desi gn usi ng firls, fol l owed
by rate changi ng i mpl emented wi th upfirdn.
yout = upfirdn(xin,h) returns the output si gnal yout. I f yout i s a row or
col umn vector, then i t represents one si gnal ; i f yout i s an array, then each
col umn i s a separate output. xin i s the i nput si gnal . I f xin i s a row or col umn
vector, then i t represents one si gnal ; i f xin i s an array, then each col umn i s
fi l tered. h i s the i mpul se response of the FI R fi l ter. I f h i s a row or col umn
vector, then i t represents one fi l ter; i f h i s an array, then each col umn i s a
separate i mpul se response.
yout = upfirdn(xin,h,p) speci fi es the upsampl i ng factor p. p i s an i nteger
wi th a defaul t of 1.
yout = upfirdn(xin,h,p,q) speci fi es the downsampl i ng factor q. q i s an
i nteger wi th a defaul t of 1.
upfirdn
6-362
NOTE Si nce upfirdn performs convol uti on and rate changi ng, the yout
si gnal s have a di fferent l ength than xin. The l ength of y[n] i s approxi matel y
p/q ti mes the l ength of x[n].
Remarks Usual l y the i nputs xin and the fi l ter h are vectors, i n whi ch case onl y one
output si gnal i s produced. However, when these arguments are arrays, each
col umn i s treated as a separate si gnal or fi l ter. Val i d combi nati ons are
1 xin i s a vector and h i s a vector.
There i s one fi l ter and one si gnal , so the functi on convol ves xin wi th h. The
output si gnal yout i s a row vector i f xin i s a row; otherwi se, i t i s a col umn
vector.
2 xin i s an array and h i s a vector.
There i s one fi l ter and many si gnal s, so the functi on convol ves h wi th each
col umn of xin. The resul ti ng yout wi l l be an array wi th the same number of
col umns as xin.
3 xin i s a vector and h i s an array.
There are many fi l ters and one si gnal , so the functi on convol ves each col umn
of h wi th xin. The resul ti ng yout wi l l be an array wi th the same number of
col umns as h.
4 xin i s an array and h i s an array, both wi th the same number of col umns.
There are many fi l ters and many si gnal s, so the functi on convol ves
correspondi ng col umns of xin and h. The resul ti ng yout i s an array wi th the
same number of col umns as xin and h.
Examples I f both p and q are equal to 1 (that i s, there i s no rate changi ng), the resul t i s
ordi nary convol uti on of two si gnal s (equi val ent to conv):
yy = upfirdn(xx,hh);
Thi s exampl e i mpl ements a seven-channel fi l ter bank by convol vi ng seven
di fferent fi l ters wi th one i nput si gnal , then downsampl es by fi ve:
% Assume that hh is an L-by-7 array of filters.
yy = upfirdn(xx,hh,1,5);
upfirdn
6-363
I mpl ement a rate change from 44.1 kHz (CD sampl i ng rate) to 48 kHz (DAT
rate), a rati o of 160/147. Thi s requi res a l owpass fi l ter wi th cutoff frequency at

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);
I n thi s exampl e, the fi l ter desi gn and resampl i ng are separate steps. Note that
resample woul d do both steps as one.
Algorithm upfirdn uses a pol yphase i nterpol ati on structure. The number of mul ti pl y-add
operati ons i n the pol yphase structure i s approxi matel y (L
h
L
x
-pL
x
)/q where L
h
and L
x
are the l engths of h[n] and x[n], respecti vel y.
A more accurate fl ops count i s computed i n the program, but the actual count
i s sti l l approxi mate. For l ong si gnal s x[n], the formul a i s qui te often exact.
Diagnostics There must be one output argument and at l east two i nput arguments. I f ei ther
of these condi ti ons ar e vi ol ated, upfirdn gi ves the appropri ate error message:
UPFIRDN needs at least two input arguments.
UPFIRDN should have exactly one output argument.
I f the arrays are sparse, upfirdn gi ves the error message
H must be full numeric matrix.
When the i nput si gnal s are i n the col umns of a matri x and there are mul ti pl e
fi l ters al so i n the col umns of a matri x, the number of si gnal s and fi l ters must
be the same. I f they are not, upfirdn gi ves the error message
X and H must have the same number of columns, if more than one.
The arguments p and q must be i ntegers. I f they are not, upfirdn gi ves the
error message
P and/or Q must be greater than zero
I f the arguments p and q are not rel ati vel y pri me, upfirdn gi ves the warni ng
message
WARNING (upfirdn) p & q have common factor
upfirdn
6-364
See Also
References [1] Crochi ere, R.E., and L.R. Rabi ner. Multi-RateSignal Processing.
Engl ewood Cl i ffs, NJ: Prenti ce Hal l , 1983. Pgs. 88-91.
[2] Crochi ere, R.E. A General Program to Perform Sampl i ng Rate Conversi on
of Data by Rati onal Rati os. I n Programs for Digital Signal Processing. I EEE
Press. New York: John Wi l ey & Sons, 1979. Pgs. 8.2-1 to 8.2-7.
conv Convol uti on and pol ynomi al mul ti pl i cati on.
decimate Decrease the sampl i ng rate for a sequence
(deci mati on).
filter Fi l ter data wi th a recursi ve (I I R) or nonrecursi ve
(FI R) fi l ter.
interp I ncrease sampl i ng rate by an i nteger factor
(i nterpol ati on).
intfilt I nterpol ati on FI R fi l ter desi gn.
resample Change sampl i ng rate by any rati onal factor.
vco
6-365
6vco
Purpose Vol tage control l ed osci l l ator.
Syntax y = vco(x,Fc,Fs)
y = vco(x,[Fmin Fmax],Fs)
Description y = vco(x,Fc,Fs) creates a si gnal that osci l l ates at a frequency determi ned
by the real i nput vector or array x wi th sampl i ng frequency Fs. Fc i s the carri er
or reference frequency; when x i s 0, y i s an Fc Hz cosi ne wi th ampl i tude 1
sampl ed at Fs Hz. x r anges from -1 to 1, wher e -1 corr esponds to a 0 fr equency
output, 0 to Fc, and 1 to 2*Fc. y i s the same si ze as x.
y = vco(x,[Fmin Fmax],Fs) scal es the frequency modul ati on range so that -1
and 1 val ues of x yi el d osci l l ati ons of Fmin Hz and Fmax Hz respecti vel y. For
best resul ts, Fmin and Fmax shoul d be i n the range 0 to Fs/2.
By defaul t, Fs i s 1 and Fc i s Fs/4.
I f x i s a matri x, vco produces a matri x whose col umns osci l l ate accordi ng to the
col umns of x.
Example Generate two seconds of a si gnal sampl ed at 10,000 sampl es/second whose
i nstantaneous frequency i s a tri angl e functi on of ti me:
Fs = 10000;
t = 0:1/Fs:2;
x = vco(sawtooth(2*pi*t,0.75),[.1 0.4]*Fs,Fs);
vco
6-366
Pl ot the spectrogram of the generated si gnal .
specgram(x,512,Fs,kaiser(256,5),220)
Algorithm vco performs FM modul ati on usi ng the modulate functi on.
Diagnostics I f any val ues of x l i e outsi de [-1,1], vco gi ves the fol l owi ng error message:
X outside of range [1,1].
See Also
Time
F
r
e
q
u
e
n
c
y
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8
0
500
1000
1500
2000
2500
3000
3500
4000
4500
5000
demod Demodul ati on for communi cati ons si mul ati on.
modulate Modul ati on for communi cati ons si mul ati on.
xcorr
6-367
6xcor r
Purpose Cross-correl ati on functi on esti mate.
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 esti mates the cross-correl ati on sequence of a random process.
Autocorrel ati on i s handl ed as a speci al case.
The true cross-correl ati on sequence i s
where x
n
and y
n
are stati onary random processes, , and E {}i s the
expected val ue operator. xcorr must esti mate the sequence because, i n
practi ce, onl y a fi ni te segment of the i nfi ni te-l ength random process i s
avai l abl e.
c = xcorr(x,y) returns the cross-correl ati on sequence i n a l ength 2N-1
vector, where x and y are l ength N vectors (N>1). I f x and y are not the same
l ength, the shorter vector i s zero-padded to the l ength of the l onger vector.
By defaul t, xcorr computes raw correl ati ons wi th no normal i zati on:
The output vector c has el ements gi ven by c(m) = c
xy
(m-N), m=1, ..., 2N-1.
I n general , the correl ati on functi on requi res normal i zati on to produce an
accurate esti mate (see bel ow).

xy
m ( ) E{x
n
y
*
n m +
} =
n < <
c
xy
m ( )
x
n
y
n m +
*
n 0 =
N m 1

m 0
c
yx
*
m ( ) m 0 <

'

=
xcorr
6-368
c = xcorr(x) i s the autocorrel ati on sequence for the vector x. I f x i s an N-by-P
matri x, c i s a matri x wi th 2N-1 rows whose P
2
col umns contai n the
cross-correl ati on sequences for al l combi nati ons of the col umns of x.
c = xcorr(x,y,'option') speci fi es a normal i zati on opti on for the
cross-correl ati on, where 'option' i s:
biased, for bi ased esti mates of the cross-correl ati on functi on
unbiased, for unbi ased esti mates of the cross-correl ati on functi on
coeff, to normal i ze the sequence so the autocorrel ati ons at zero l ag are
i denti cal l y 1.0
none, to use the raw, unscal ed cross-correl ati ons (defaul t)
See reference [1] for more i nformati on on the properti es of bi ased and unbi ased
correl ati on esti mates.
c = xcorr(x,'option') speci fi es one of the above normal i zati on opti ons for
the autocorrel ati on.
c = xcorr(x,y,maxlags) returns the cross-correl ati on sequence over the l ag
range [maxlags:maxlags]. Output c has l ength 2*maxlags+1.
c = xcorr(x,maxlags) returns the autocorrel ati on sequence over the l ag
range [maxlags:maxlags]. Output c has l ength 2*maxlags+1. I f x i s an
N-by-P matri x, c i s a matri x wi th 2*maxlags+1 rows whose P
2
col umns contai n
the autocorrel ati on sequences for al l combi nati ons of the col umns of x.
c = xcorr(x,y,maxlags,'option') speci fi es both a maxi mum number of l ags
and a scal i ng opti on for the cross-correl ati on.
c = xcorr(x,maxlags,'option') speci fi es both a maxi mum number of l ags
and a scal i ng opti on for the autocorrel ati on.
c
xy biased ,
m ( )
1
N
----c
xy
m ( ) =
c
xy unbiased ,
m ( )
1
N m
-------------------c
xy
m ( ) =
xcorr
6-369
[c,lags] = xcorr(...) returns a vector of the l ag i ndi ces at whi ch c was
esti mated, wi th the range [maxlags:maxlags]. When maxlags i s not
speci fi ed, the range of lags i s [N+1:N1].
I n al l cases, the cross-correl ati on or autocorrel ati on computed by xcorr has the
0-th l ag i n the mi ddl e of the sequence, at el ement or row maxlags+1 (el ement
or row N i f maxlags i s not speci fi ed).
Examples The second output, lags, i s useful for pl otti ng the cross-correl ati on or
autocorrel ati on. For exampl e, the esti mated autocorrel ati on of zero-mean
Gaussi an whi te noi se c
ww
(m) can be di spl ayed for -10 m 10 usi ng
ww = randn(1000,1);
[c_ww,lags] = xcorr(ww,10,'coeff');
stem(lags,c_ww)
Swappi ng the x and y i nput arguments reverses (and conjugates) the output
correl ati on sequence. For row vectors, the resul ti ng sequences are reversed l eft
to ri ght; for col umn vectors, up and down. The fol l owi ng exampl e i l l ustrates
thi s pr oper ty (mat2str i s used for a compact di spl ay of compl ex numbers).
x = [1,2i,3]; y = [4,5,6];
[c1,lags] = xcorr(x,y);
c1 = mat2str(c1,2), lags
c1 =
[12i*8.9e016 15i*8 22i*10 5i*12 6+i*8.9e016]
lags =
2 1 0 1 2
c2 = conj(fliplr(xcorr(y,x)));
c2 = mat2str(c2,2)
c2 =
[12i*8.9e016 15i*8 22i*10 5i*12 6+i*8.9e016]
For the case where i nput argument x i s a matri x, the output col umns are
arranged so that extracti ng a row and rearrangi ng i t i nto a square array
xcorr
6-370
produces the cross-correl ati on matri x correspondi ng to the l ag of the chosen
row. For exampl e, the cross-correl ati on at zero l ag can be retri eved 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 can cal cul ate the matri x of correl ati on coeffi ci ents that the MATLAB
functi on corrcoef generates by substi tuti ng
c = xcov(X,'coef')
i n the l ast exampl e. The functi on xcov subtracts the mean and then cal l s
xcorr.
Use fftshift to move the second hal f of the sequence starti ng at the zeroth l ag
to the front of the sequence. fftshift swaps the fi rst and second hal ves of a
sequence.
Algorithm For more i nformati on on esti mati ng covari ance and correl ati on functi ons, see
[1] and [2].
Diagnostics There must be at l east one vector i nput argument; otherwi se, xcorr gi ves the
fol l owi ng error message:
1st arg must be a vector or matrix.
The stri ng 'option' must be the l ast argument; otherwi se, xcorr gi ves the
fol l owi ng error message:
Argument list not in correct order.
I f the second argument was entered as a scal ar, i t i s taken to be maxlags and
no succeedi ng i nput can be a scal ar. When the second argument i s a vector, the
fi rst must al so be a si gnal vector. The thi rd argument, when present, must be
xcorr
6-371
a scal ar or a stri ng. I f they are not, xcorr gi ves the appropri ate error
message(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.
Normal l y the l engths of the vector i nputs shoul d be the same; i f they are not,
then the onl y al l owabl e scal i ng opti on i s 'none'. I f i t i s not, xcorr gi ves the
fol l owi ng error message:
OPTION must be 'none' for different length vectors A and B.
See Also
References [1] Bendat, J.S., and A.G. Pi ersol . RandomData: Analysis and Measurement
Procedures. New York: John Wi l ey & Sons, 1971. Pg. 332.
[2] Oppenhei m, A.V., and R.W. Schafer. Digital Signal Processing. Engl ewood
Cl i ffs, NJ: Prenti ce Hal l , 1975. Pgs. 63-67, 746-747, 839-842.
conv Convol uti on and pol ynomi al mul ti pl i cati on.
corrcoef Correl ati on coeffi ci ent matri x.
cov Covari ance matri x.
xcorr2 Two-di mensi onal cross-correl ati on.
xcov Cross-covari ance functi on esti mate (equal to
mean-removed cross-correl ati on).
xcorr2
6-372
6xcor r 2
Purpose Two-di mensi onal cross-correl ati on.
Syntax C = xcorr2(A)
C = xcorr2(A,B)
Description C = xcorr2(A,B) returns the cross-correl ati on of matri ces A and B wi th no
scal i ng. xcorr2 i s the two-di mensi onal versi on of xcorr. I t has i ts maxi mum
val ue when the two matri ces are al i gned so that they are shaped as si mi l arl y
as possi bl e.
xcorr2(A) i s the autocorrel ati on matri x of i nput matri x A. I t i s i denti cal to
xcorr2(A,A).
See Also
conv2 Two-di mensi onal convol uti on.
filter2 Two-di mensi onal di gi tal fi l teri ng.
xcorr Cross-correl ati on functi on esti mate.
xcov
6-373
6xcov
Purpose Cross-covari ance functi on esti mate (equal to mean-removed cross-correl ati on).
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 esti mates the cross-covari ance sequence of random processes.
Autocovari ance i s handl ed as a speci al case.
The true cross-covari ance sequence i s the mean-removed cross-correl ati on
sequence
where m
x
and m
y
are the mean val ues of the two stati onary random processes,
and E{}i s the expected val ue operator. xcov esti mates the sequence because, i n
practi ce, access i s avai l abl e to onl y a fi ni te segment of the i nfi ni te-l ength
random process.
v = xcov(x,y) returns the cross-covari ance sequence i n a l ength 2N-1 vector,
where x and y are l ength N vectors.
v = xcov(x) i s the autocovari ance sequence for the vector x. Where x i s an
N-by-P array, v = xcov(X) returns am array wi th 2N-1 rows whose P
2
col umns
contai n the cross-covari ance sequences for al l combi nati ons of the col umns of X.
By defaul t, xcov computes raw covari ances wi th no normal i zati on. For a l ength
N vector:
The output vector c has el ements gi ven by c(m) = c
xy
(m-N), m=1,...,2N-1.

xy
m ( ) E x
n
m
x
( ) y
n m +
m
y
( )
*
{ } =
c
xy
m ( )
x n ( )
1
N
---- x
i
i 0 =
N 1

,


_
y
n m +
*
1
N
---- y
i
*
=

,


_
n 0 =
N m 1

m 0
c
yx
*
m ( ) m 0 <

'

=
xcov
6-374
The covari ance functi on requi res normal i zati on to esti mate the functi on
properl y.
v = xcov(x,'option') speci fi es a scal i ng opti on, where option i s:
biased, for bi ased esti mates of the cross-covari ance functi on
unbiased, for unbi ased esti mates of the cross-covari ance functi on
coeff, to normal i ze the sequence so the auto-covari ances at zero l ag are
i denti cal l y 1.0
none, to use the raw, unscal ed cross-covari ances (defaul t)
See [1] for more i nformati on on the properti es of bi ased and unbi ased
correl ati on and covari ance esti mates.
[c,lags] = xcov(x,y,maxlags) where x and y are l ength m vectors, returns
the cross-covari ance sequence i n a l ength 2*maxlags+1 vector c. lags i s a
vector of the l ag i ndi ces where c was esti mated, that i s, [maxlags:maxlags].
[c,lags] = xcov(x,maxlags) i s the autocovari ance sequence over the range
of l ags [maxlags:maxlags].
[c,lags] = xcov(x,maxlags) where x i s an m-by-p array, returns array c wi th
2*maxlags+1 rows whose P
2
col umns contai n the cross-covari ance sequences
for al l combi nati ons of the col umns of x.
[c,lags] = xcov(x,y,maxlags,'option') speci fi es a scal i ng opti on, where
option i s the l ast i nput argument.
I n al l cases, xcov gi ves an output such that the zeroth l ag of the covari ance
vector i s i n the mi ddl e of the sequence, at el ement or row maxlag+1 or at m.
Examples The second output lags i s useful when pl otti ng. For exampl e, the esti mated
autocovari ance of uni form whi te noi se c
ww
(m) can be di spl ayed for -10 m 10
usi ng
ww = randn(1000,1); % generate uniform noise with mean = 1/2
[cov_ww,lags] = xcov(ww,10,'coeff');
stem(lags,cov_ww)
xcov
6-375
Algorithm xcov computes the mean of i ts i nputs, subtracts the mean, and then cal l s
xcorr. For more i nformati on on esti mati ng covari ance and correl ati on
functi ons, see [1] and [2].
Diagnostics xcov does not check for any errors other than the correct number of i nput
arguments. I nstead, i t rel i es on the error checki ng i n xcorr, whi ch i t cal l s.
See Also
References [1] Bendat, J.S., and A.G. Pi ersol . RandomData: Analysis and Measurement
Procedures. New York: John Wi l ey & Sons, 1971. Pg. 332.
[2] Oppenhei m, A.V., and R.W. Schafer. Digital Signal Processing. Engl ewood
Cl i ffs, NJ: Prenti ce Hal l , 1975. Pgs. 63-67, 746-747, 839-842.
conv Convol uti on and pol ynomi al mul ti pl i cati on.
corrcoef Correl ati on coeffi ci ent matri x.
cov Covari ance matri x.
xcorr Cross-correl ati on functi on esti mate.
xcorr2 Two-di mensi onal cross-correl ati on.
yulewalk
6-376
6yul ewal k
Purpose Recursi ve di gi tal fi l ter desi gn.
Syntax [b,a] = yulewalk(n,f,m)
Description yulewalk desi gns recursi ve I I R di gi tal fi l ters usi ng a l east-squares fi t to a
speci fi ed frequency response.
[b,a] = yulewalk(n,f,m) returns row vectors b and a contai ni ng the n+1
coeffi ci ents of the order n I I R fi l ter whose frequency-magni tude characteri sti cs
appr oxi matel y match those gi ven i n vectors f and m:
f i s a vector of frequency poi nts, speci fi ed i n the range between 0 and 1,
where 1 corresponds to hal f the sampl e frequency (the Nyqui st frequency).
The fi rst poi nt of f must be 0 and the l ast poi nt 1, wi th al l i ntermedi ate
poi nts i n i ncreasi ng order. Dupl i cate frequency poi nts are al l owed,
correspondi ng to steps i n the frequency response.
m i s a vector contai ni ng the desi red magni tude response at the poi nts
speci fi ed i n f.
f and m must be the same l ength.
plot(f,m) di spl ays the fi l ter shape.
The output fi l ter coeffi ci ents are ordered i n descendi ng powers of z,
When speci fyi ng the frequency response, avoi d excessi vel y sharp transi ti ons
from passband to stopband. You may need to experi ment wi th the sl ope of the
transi ti on regi on to get the best fi l ter desi gn.
Example Desi gn an 8th-order l owpass fi l ter and overpl ot the desi red frequency response
wi th the actual frequency response:
f = [0 0.6 0.6 1];
m = [1 1 0 0];
B z ( )
A z ( )
-----------
b 1 ( ) b 2 ( )z
1
L b n 1 + ( )z
n
+ + +
a 1 ( ) a 2 ( )z
1
L a n 1 + ( )z
n
+ + +
---------------------------------------------------------------------------------- =
yulewalk
6-377
[b,a] = yulewalk(8,f,m);
[h,w] = freqz(b,a,128);
plot(f,m,w/pi,abs(h),'--')
Algorithm yulewalk performs a l east-squares fi t i n the ti me domai n. I t computes the
denomi nator coeffi ci ents usi ng modi fi ed Yul e-Wal ker equati ons, wi th
correl ati on coeffi ci ents computed by i nverse Fouri er transformati on of the
speci fi ed frequency response. To compute the numerator, yulewalk takes the
fol l owi ng steps:
1 Computes a numerator pol ynomi al correspondi ng to an addi ti ve
decomposi ti on of the power frequency response.
2 Eval uates the compl ete frequency response correspondi ng to the numerator
and denomi nator pol ynomi al s.
3 Uses a spectral factori zati on techni que to obtai n the i mpul se response of the
fi l ter.
4 Obtai ns the numerator pol ynomi al by a l east-squares fi t to thi s i mpul se
response.
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
0
0.2
0.4
0.6
0.8
1
1.2
yulewalk
6-378
See Also
References [1] Fri edl ander, B., and B. Porat. The Modi fi ed Yul e-Wal ker Method of ARMA
Spectral Esti mati on. I EEE Transactions on AerospaceElectronic Systems.
AES-20, No. 2 (March 1984). Pgs. 158-173.
butter Butterworth anal og and di gi tal fi l ter desi gn.
cheby1 Chebyshev type I fi l ter desi gn (passband ri ppl e).
cheby2 Chebyshev type I I fi l ter desi gn (stopband ri ppl e).
ellip El l i pti c (Cauer) fi l ter desi gn.
fir2 Wi ndow-based fi ni te i mpul se response fi l ter desi gn
arbi trary response.
firls Least square l i near-phase FI R fi l ter desi gn.
maxflat General i zed di gi tal Butterworth fi l ter desi gn.
remez Parks-McCl el l an opti mal FI R fi l ter desi gn.
zp2sos
6-379
6zp2sos
Purpose Conversi on of zero-pol e-gai n to second-order secti ons.
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 converts a zero-pol e-gai n representati on of a gi ven system to an
equi val ent second-order secti on representati on.
[sos,g] = zp2sos(z,p,k) fi nds a matri x sos i n second-order secti on form
wi th gai n g equi val ent to the zero-pol e-gai n system represented by i nput
arguments z, p, and k. Vectors z and p contai n the zeros and pol es of the system
H(z), not necessari l y i n any order:
where n and mare the l engths of z and p, respecti vel y, and k i s a scal ar gai n.
The zer os and pol es must be r eal or compl ex conjugate pai r s. sos i s an L-by-6
matri x:
whose rows contai n the numerator and denomi nator coeffi ci ents b
ik
and a
ik
of
the second-order secti ons of H(z):
The number of rows L of matri x sos i s the maxi mum of the cei l i ng of n/2 and
the cei l i ng of m/2.
H z ( ) k
z z
1
( ) z z
2
( )Lz z
n
( )
z p
1
( ) z p
2
( )Lz p
m
( )
----------------------------------------------------------------- =
sos
b
01
b
11
b
21
1 a
11
a
21
b
02
b
12
b
22
1 a
12
a
22
M M M M M M
b
0L
b
1L
b
2L
1 a
1L
a
2L
=
H z ( ) g H
k
z ( )
k 1 =
L

g
b
0k
b
1k
z
1
b
2k
z
2
+ +
1 a
1k
z
1
a
2k
z
2
+ +
--------------------------------------------------------- -
k 1 =
L

= =
zp2sos
6-380
[sos,g] = zp2sos(z,p,k,'order') speci fi es the order of the rows i n sos,
where order i s:
down, to order the secti ons so the fi rst row of sos contai ns the pol es cl osest to
the uni t ci rcl e
up, to order the secti ons so the fi rst row of sos contai ns the pol es farthest
from the uni t ci rcl e (defaul t)
[sos,g] = zp2sos(z,p,k,'order','scale') speci fi es the desi red scal i ng of
the gai n and the numerator coeffi ci ents of al l second-order secti ons, where
scale i s:
none, to appl y no scal i ng (defaul t)
inf, to appl y i nfi ni ty-norm scal i ng
two, to appl y 2-norm scal i ng
Usi ng i nfi ni ty-norm scal i ng i n conjuncti on wi th up-orderi ng mi ni mi zes the
probabi l i ty of overfl ow i n the real i zati on. Usi ng 2-norm scal i ng i n conjuncti on
wi th down-orderi ng mi ni mi zes the peak round-off noi se.
sos = zp2sos(...) embeds the overal l system gai n, g, i n the fi rst secti on,
H
1
(z), so that
Example Fi nd a second-order secti on form of a Butterworth l owpass fi l ter:
[z,p,k] = butter(5,0.2);
sos = zp2sos(z,p,k);
Algorithm zp2sos uses a four-step al gori thm to determi ne the second-order secti on
representati on for an i nput zero-pol e-gai n system:
1 I t groups the zeros and pol es i nto compl ex conjugate pai rs usi ng the
cplxpair functi on.
2 I t forms the second-order secti on by matchi ng the pol e and zero pai rs
accordi ng to the fol l owi ng rul es:
H z ( ) H
k
z ( )
k 1 =
L

=
zp2sos
6-381
a Match the pol es cl osest to the uni t ci r cl e wi th the zer os cl osest to those
pol es.
b Match the pol es next cl osest to the uni t ci rcl e wi th the zeros cl osest to
those pol es.
c Conti nue unti l al l of the pol es and zeros are matched.
zp2sos groups real pol es i nto secti ons wi th the real pol es cl osest to them i n
absol ute val ue. The same rul e hol ds for real zeros.
3 I t orders the secti ons accordi ng to the proxi mi ty of the pol e pai rs to the uni t
ci rcl e. zp2sos normal l y orders the secti ons wi th pol es cl osest to the uni t
ci rcl e l ast i n the cascade. You can tel l zp2sos to order the secti ons i n the
reverse order by speci fyi ng the down fl ag.
4 zp2sos scal es the secti ons by the norm speci fi ed i n the 'scale' argument.
For arbi trary H(), the scal i ng i s defi ned by:
where p can be ei ther or 2. See the references for detai l s on the scal i ng.
Thi s scal i ng i s an attempt to mi ni mi ze overfl ow or peak round-off noi se i n
fi xed poi nt fi l ter i mpl ementati ons.
See Also
H
p
1
2
------ H ( )
p
d
0
2

1
p
---
=
cplxpair Group compl ex numbers i nto compl ex conjugate
pai rs.
sos2zp Conversi on of second-order secti ons to zero-pol e-gai n.
ss2sos Conversi on of state-space to second-order secti ons.
tf2sos Conversi on of transfer functi on to second-order
secti ons.
zp2ss Conversi on of zer o-pol e-gai n to state-space.
zp2tf Conversi on of zero-pol e-gai n to transfer functi on.
zp2sos
6-382
References [1] Jackson, L.B. Digital Filtersand Signal Processing. 3rd ed. Boston: Kl uwer
Academi c Publ i shers, 1996. Chapter 11.
[2] Mi tra, S.K. Digital Signal Processing: A Computer-Based Approach. New
York: McGraw-Hi l l , 1998. Chapter 9.
[3] Vai dyanathan, P.P. Robust Di gi tal Fi l ter Structures. Handbook for
Digital Signal Processing. S.K. Mi tra and J.F. Kai ser, ed. Chapter 7. New York:
John Wi l ey & Sons, 1993.
zp2ss
6-383
6zp2ss
Purpose Conversi on of zero-pol e-gai n to state-space.
Syntax [A,B,C,D] = zp2ss(z,p,k)
Description zp2ss converts a zer o-pol e-gai n r epr esentati on of a gi ven system to an
equi val ent state-space representati on.
[A,B,C,D] = zp2ss(z,p,k) fi nds a si ngl e i nput, mul ti pl e output, state-space
representati on
gi ven a system i n factored transfer functi on form
Col umn vector p speci fi es the pol e l ocati ons, and matri x z the zero l ocati ons
wi th as many col umns as there are outputs. The gai ns for each numerator
transfer functi on are i n vector k. The A, B, C, and D matri ces are returned i n
control l er canoni cal form.
Inf val ues may be used as pl ace hol ders i n z i f some col umns have fewer zeros
than others.
Algorithm zp2ss, for si ngl e-i nput systems, groups compl ex pai rs together i nto two-by-two
bl ocks down the di agonal of the A matri x. Thi s requi res the zeros and pol es to
be real or compl ex conjugate pai rs.
See Also
x

Ax Bu + =
y Cx Du + =
H s ( )
Z s ( )
P s ( )
---------- k
s z
1
( ) s z
2
( )Ls z
n
( )
s p
1
( ) s p
2
( )Ls p
n
( )
--------------------------------------------------------------- = =
sos2ss Conversi on of second-order secti ons to state-space.
ss2zp Conversi on of state-space to zero-pol e-gai n.
tf2ss Conversi on of transfer functi on to state-space.
zp2sos Conversi on of zero-pol e-gai n to second-order secti ons.
zp2tf Conversi on of zero-pol e-gai n to transfer functi on.
zp2tf
6-384
6zp2tf
Purpose Conversi on of zero-pol e-gai n to transfer functi on.
Syntax [b,a] = zp2tf(z,p,k)
Description zp2tf forms transfer functi on pol ynomi al s from the zeros, pol es, and gai ns of a
system i n factored form.
[b,a] = zp2tf(z,p,k) fi nds a rati onal transfer functi on:
gi ven a system i n factored transfer functi on for m:
Col umn vector p speci fi es the pol e l ocati ons, and matri x z the zero l ocati ons,
wi th as many col umns as there are outputs. The gai ns for each numerator
transfer functi on are i n vector k. The zeros and pol es must be real or come i n
compl ex conjugate pai rs. The pol ynomi al coeffi ci ents are returned i n vectors:
the denomi nator coeffi ci ents i n row vector a and the numerator coeffi ci ents i n
matri x b, wi th as many rows as there are col umns of z.
Inf val ues can be used as pl ace hol ders i n z i f some col umns have fewer zeros
than others.
Algorithm The system i s converted to transfer functi on form usi ng poly wi th p and the
col umns of Z.
See Also
B s ( )
A s ( )
---------- -
b
1
s
nb 1 ( )
L b
nb 1 ( )
s b
nb
+ + +
a
1
s
na 1 ( )
L a
na 1 ( )
s a
na
+ + +
---------------------------------------------------------------------------------- - =
H s ( )
Z s ( )
P s ( )
---------- k
s z
1
( ) s z
2
( )Ls z
m
( )
s p
1
( ) s p
2
( )Ls p
n
( )
--------------------------------------------------------------- = =
sos2tf Conversi on of second-order secti ons to transfer
functi on.
ss2tf Conversi on of state-space to transfer functi on.
tf2zp Conversi on of transfer functi on to zero-pol e-gai n.
zp2sos Conversi on of zero-pol e-gai n to second-order secti ons.
zp2ss Conversi on of zer o-pol e-gai n to state-space.
zplane
6-385
6zpl ane
Purpose Zero-pol e pl ot.
Syntax zplane(z,p)
zplane(b,a)
[hz,hp,ht] = zplane(z,p)
Description Thi s functi on di spl ays the pol es and zeros of di screte-ti me systems.
zplane(z,p) pl ots the zeros speci fi ed i n col umn vector z and the pol es speci fi ed
i n col umn vector p i n the current fi gure wi ndow. The symbol 'o' represents a
zero and the symbol 'x' represents a pol e. The pl ot i ncl udes the uni t ci rcl e for
reference. I f z and p are arrays, zplane pl ots the pol es and zeros i n the col umns
of z and p, respecti vel y, i n di fferent col ors.
You can overri de the automati c scal i ng of zplane usi ng
axis([xmin xmax ymin ymax])
or
set(gca,'ylim',[ymin ymax])
or
set(gca,'xlim',[xmin xmax])
after cal l i ng zplane. Thi s i s useful i n the case where one or a few of the zeros
or pol es have such a l arge magni tude that the others are grouped ti ghtl y
around the ori gi n and are hard to di sti ngui sh.
zplane(b,a) where b and a are row vectors, fi rst uses roots to fi nd the zeros
and pol es of the transfer functi on represented by numerator coeffi ci ents b and
denomi nator coeffi ci ents a.
[hz,hp,ht] = zplane(z,p) returns vectors of handl es to the zero l i nes, hz,
and the pol e l i nes, hp. ht i s a vector of handl es to the axes/uni t ci rcl e l i ne and
to text objects, whi ch are present when there are mul ti pl e zeros or pol es. I f
there are no zeros or no pol es, hz or hp i s set to the empty matri x [].
zplane
6-386
Examples Pl ot the pol es and zer os of a 5th-or der Butterwor th l owpass di gi tal fi l ter wi th
cutoff frequency of 0.2:
[z,p,k] = butter(5,0.2);
zplane(z,p);
title('5th-Order Butterworth Lowpass Digital Filter');
To gener ate the same pl ot wi th a tr ansfer functi on r epr esentati on of the fi l ter:
[b,a] = butter(5,0.2); % transfer function
zplane(b,a)
See Also
1 0.5 0 0.5 1
1
0.8
0.6
0.4
0.2
0
0.2
0.4
0.6
0.8
1
5
Real Part
I
m
a
g
i
n
a
r
y

P
a
r
t
5thOrder Butterworth Lowpass Digital Filter
freqz Frequency response of di gi tal fi l ters.
I-1
Index
A
abs 6-2, 6-12
ac2poly 6-3, 6-13
ac2rc 6-3, 6-14
al gori thm, fi l teri ng i n SPTool 5-18
al i ased si nc functi on. SeeDi ri chl et functi on
al i asi ng
and i mpul se i nvari ance 2-42
preventi ng duri ng resampl i ng 4-21
reduci ng wi th anal yti c si gnal 4-38
al l -pol e fi l ter. SeeI I R fi l ter
al l -zero fi l ter. SeeFI R fi l ter
am 4-29
AM. Seeampl i tude modul ati on
amdsbsc 4-29, 6-236
amdsbtc 4-29, 6-236
ampl i tude demodul ati on
doubl e si de-band, suppressed carri er 6-114
doubl e si de-band, transmi tted carri er 6-114
si ngl e si de-band 6-114
ampl i tude modul ati on 4-29
doubl e si de-band, suppressed carri er 6-236
doubl e si de-band, transmi tted carri er 6-236
si ngl e si de-band 6-236
amssb 4-30, 6-236
anal og fi l ter
Bessel 6-22
Butterworth 6-44
Chebyshev type I 6-66
Chebyshev type I I 6-71
converti ng to di gi tal 2-41, 6-194
desi gn 2-7
Bessel 2-11, 6-22
Butter worth 6-43
Chebyshev type I 6-65
Chebyshev type I I 6-71
el l i pti c 6-125, 6-126
i nverse 6-203
frequency response 1-26, 6-173
order esti mati on
Butter worth 6-49
Chebyshev type I 6-56
Chebyshev type I I 6-61
el l i pti c 6-133
representati onal model s 1-40
anal og fr equency xvi i
anal og prototype 2-38
Bessel fi l ter 2-11, 6-21
Butter worth fi l ter 2-8, 6-42
Chebyshev type I fi l ter 2-9, 6-54
Chebyshev type I I fi l ter 2-10, 6-59
conversi on to bandpass 6-220
conversi on to bandstop 6-223
conversi on to hi ghpass 6-225
conversi on to l owpass 6-227
el l i pti c fi l ter 6-131
frequency response 2-12
pl otti ng 2-12
anal og prototype desi gn
Bessel 2-38
bi l i near tr ansformati on 2-43
Butter worth 2-38
Chebyshev 2-38
el l i pti c 2-38
fi l ter di screti zati on 2-41
frequency tr ansfor mati on 2-38
i mpul se i nvari ance 2-42
Index
I-2
SeealsoI I R fi l ter desi gn
anal og si gnal . Seesi gnal
anal yti c si gnal 2-26, 6-187
appl i cati ons 4-38
properti es 4-38
angle 6-2, 6-15
anti -symmetri c fi l ter 2-25
Appl y button, Spectrum Vi ewer 5-97
Appl y Fi l ter button 5-18
appl yi ng parameters wi th Appl y button 5-100
arburg 4-11, 6-16
arcov 4-11, 6-17
ARMA fi l ter 1-15
SeealsoI I R fi l ter
ARMA model 4-13, 4-15
Pr onys method 4-13
Stei gl i tz-McBri de method 4-15
armcov 4-11, 6-18
array
di spl ay i n Si gnal Browser 5-47, 5-51
i n SPTool 5-14
Array Si gnal s button, Si gnal Browser 5-47, 5-51
ARX model 4-13
aryule 4-11, 6-19
ASCI I fi l e, i mporti ng 1-13
attenuati on, stopband 5-70
attri butes, i nstantaneous 6-187
autocorrel ati on 6-368
mul ti pl e channel s 3-4
two-di mensi onal 6-372
autocorrel ati on sequence
converti ng from fi l ter coeffi ci ents 6-262
converti ng from refl ecti on coeffi ci ents 6-282
converti ng to fi l ter coeffi ci ents 6-13
converti ng to refl ecti on coeffi ci ents 6-14
autocovar i ance 6-373
mul ti pl e channel s 3-4
autoregressi ve (AR) fi l ter 1-15
SeealsoI I R fi l ter
autoregressi ve (AR) model
vi a Burg method 6-16, 6-239
vi a covari ance method 6-17, 6-243
vi a modi fi ed covari ance method 6-18, 6-247
vi a Yul e-Wal ker AR method 6-19, 6-278
autoregressi ve movi ng average (ARMA) fi l ter 1-15
SeealsoI I R fi l ter
auto-spectr um, i n SPTool 5-15
averagi ng fi l ter 1-14
axi s l abel s, i n Si gnal Browser 5-20, 5-23
axi s par ameters
i n Fi l ter Vi ewer 5-20
i n Spectrum Vi ewer 5-20
axi s scal i ng r ange
i n Fi l ter Vi ewer 5-25, 5-87
i n Spectrum Vi ewer 5-24, 5-100, 5-102
axi s scal i ng uni ts
i n Fi l ter Vi ewer 5-25, 5-87
i n Spectrum Vi ewer 5-24, 5-100, 5-102
B
band edges, prewarpi ng 2-44
bandl i mi ted i nterpol ati on 6-314
bandpass fi l ter
anal og prototype desi gn 2-6
and i mpul se i nvari ance 2-42
Bessel 6-22
Butterworth 6-43, 6-44
Chebyshev type I 6-65, 6-66
Chebyshev type I I 6-70, 6-71
el l i pti c 6-125, 6-126
exampl e, Chebyshev type I 2-40
FI R desi gn, wi th wi ndow method 2-21, 6-154
transformati on from l owpass to 6-220
Index
I-3
bandstop fi l ter
anal og prototype desi gn 2-6
Bessel 6-22
Butterworth 6-44, 6-45
Chebyshev type I 6-66, 6-67
Chebyshev type I I 6-71, 6-72
el l i pti c 6-126, 6-127
FI R desi gn, wi th wi ndow method 2-21, 6-153
transformati on from l owpass to 6-223
bandwi dth 2-40
bartlett 4-2, 6-8, 6-20
compared to triang 6-20
exampl e 4-2
Bartl ett wi ndow 4-2
coeffi ci ents 6-20
Bessel fi l ter
anal og 6-22
anal og prototype 2-11, 2-38, 6-21
bandpass confi gurati on, anal og 6-22
bandstop confi gurati on, anal og 6-22
characteri sti cs 2-11
hi ghpass confi gurati on, anal og 6-22
l i mi tati ons 6-24
l owpass confi gurati on, anal og 6-22
besselap 2-5, 6-10, 6-21
exampl e 2-11
besself 2-5, 2-6, 6-5, 6-22
beta parameter, of Kai ser wi ndow 5-75
bi as
correl ati on 3-3, 4-12
power spectral densi ty 3-12
spectral densi ty 3-12
vari ance tr ade-off 3-4
bilinear 2-5, 2-42, 2-43, 6-11, 6-25
bi l i near transformati on 2-43, 6-25
defi ned 2-43
output representati on 6-26
prewarpi ng 2-44, 6-25
blackman 4-2, 6-8, 6-30
Bl ackman wi ndow 4-4, 6-30
defi ned 4-4
boxcar 4-2, 6-8, 6-32
exampl e 4-2
boxcar wi ndow. Seerectangul ar wi ndow
brackets, i ndi cati ng cl osed i nterval xvi i
buffer i ng 6-33
Bur g method 3-5, 3-6, 3-20
compared to Wel chs method 3-22
defi ned 3-20
exampl e 3-21
i n Spectrum Vi ewer 5-104
buttap 2-5, 6-10, 6-42
exampl e 2-8
butter 2-5, 2-6, 6-5, 6-43
Butter worth fi l ter
anal og 6-44
anal og prototype 2-8, 2-38, 6-42
bandpass confi gurati on
anal og 6-44
di gi tal 6-43
bandstop confi gurati on
anal og 6-45
di gi tal 6-44
characteri sti cs 2-8
desi gn 6-43
di gi tal 6-43
general i zed 2-14
hi ghpass confi gurati on
anal og 6-45
di gi tal 6-44
l i mi tati ons 6-47
l owpass confi gurati on
anal og 6-44
di gi tal 6-43
Index
I-4
order esti mati on 2-7, 6-48
buttord 2-5, 6-5, 6-48
C
canoni cal forms 1-17, 6-351
carri er frequency 4-29, 6-236, 6-365
carri er si gnal 4-29, 6-114
cascade, di gi tal fi l ter 1-37
Cauer fi l ter. Seeel l i pti c fi l ter
cceps 4-23, 6-9, 6-52
exampl e 4-23
center fr equency 2-40
centr al featur es 1-2
cepstrum
appl i cati ons 4-23
compl ex 4-23
i nverse 4-23, 4-25
overvi ew 4-23
real 4-23
Seealsoreal cepstrum, compl ex cepstrum
cepstrum anal ysi s 4-23
cheb1ap 2-5, 6-10, 6-54
exampl e 2-9, 2-40
cheb1ord 2-5, 6-5, 6-55
cheb2ap 2-5, 6-10, 6-59
exampl e 2-10
cheb2ord 2-5, 6-5, 6-60
chebwin 4-2, 6-8, 6-64
cheby1 2-5, 2-6, 6-5, 6-65
exampl e 2-45
cheby2 2-5, 2-6, 6-5, 6-70
Chebyshev error mi ni mi zati on 2-22, 6-287
Chebyshev type I fi l ter
anal og 6-66
anal og prototype 2-9, 2-38, 6-54
bandpass confi gur ati on
anal og 6-66
di gi tal 6-65
bandstop confi gurati on
anal og 6-67
di gi tal 6-66
characteri sti cs 2-9
desi gn 6-65
di gi tal 6-65
hi ghpass confi gurati on
anal og 6-67
di gi tal 6-66
l owpass confi gurati on
anal og 6-66
di gi tal 6-65
order esti mati on 2-7, 6-55
Chebyshev type I I fi l ter
anal og 6-71
anal og prototype 2-38, 6-59
bandpass confi gur ati on
anal og 6-71
di gi tal 6-70
bandstop confi gurati on
anal og 6-72
di gi tal 6-71
characteri sti cs 2-10
desi gn 6-70
di gi tal 6-70
hi ghpass confi gurati on
anal og 6-72
di gi tal 6-71
l i mi tati ons 6-69
l owpass confi gurati on
anal og 6-71
di gi tal 6-70
order esti mati on 2-7, 6-60
Chebyshev wi ndow 4-9, 6-64
Index
I-5
frequency response 4-9
chirp 1-9, 6-2, 6-75
chi rp si gnal 1-9
chi rp z-transform (CZT) 4-34, 6-105
compared to di screte Fouri er transform 4-34
executi on ti me 4-35
for nar rowband frequency anal ysi s 6-105
cl assi cal I I R fi l ter desi gn 2-8
cl i ck-and-drag panni ng, i n Si gnal Browser 5-48
coeffi ci ents
correl ati on 6-88
fi l ter 1-15, 5-79, 6-13, 6-262, 6-263, 6-283
l i near predi cti on 6-229
refl ecti on 1-37, 6-14, 6-263, 6-282, 6-283
sequence 6-282
cohere 3-6, 3-16, 6-7, 6-79
coherence 3-15, 6-79
defi ned 3-15
coherence functi on 3-15
Col or button 5-35
col or order
i n Si gnal Browser 5-22
i n Spectrum Vi ewer 5-22
Col or Order text box 5-22
col or, customi zi ng i n SPTool 5-20
col umn i ndex vector, enteri ng i n Si gnal Browser
5-47
col umn, array 5-47
communi cati ons 4-10
communi cati ons si mul ati on 4-29, 6-114, 6-236
Seealsomodul ati on, demodul ati on, vol tage
control l ed osci l l ati on
Compact Di sc standard 4-20
compl ex cepstrum, defi ned 4-23
compl ex conjugate 6-90
Compl ex Di spl ay mode 5-47
compl ex envel ope 4-38
compl ex numbers, groupi ng by conjugate 6-90
compl ex si gnal s, i n Si gnal Browser 5-47
computati on parameters, i n Spectrum Vi ewer
5-103, 5-104
Conf. I nt. check box 5-107
confi dence i nterval
for cross spectr al densi ty 3-14
for power spectral densi ty 3-14, 5-107
setti ng i n Spectrum Vi ewer 5-107
conservati on of total power, usi ng pmtm 3-19
context sensi ti ve hel p i n SPTool 5-7
conti nuous si gnal . Seesi gnal
conti nuous-ti me fi l ter. Seeanal og fi l ter
control systems 1-35
Control Systems Tool box 1-35, 6-198
conv 1-14, 1-20, 6-2, 6-83
conv2 1-14, 6-2, 6-84
conversi on
autocorrel ati on sequence to fi l ter coeffi ci ents
6-13
autocorrel ati on sequence to refl ecti on
coeffi ci ents 6-14
fi l ter coeffi ci ents to autocorrel ati on sequence
6-262
fi l ter coeffi ci ents to refl ecti on coeffi ci ents 6-263,
6-283
refl ecti on coeffi ci ents to autocorrel ati on
sequence 6-282
second-or der secti ons to state-space 6-316
second-or der secti ons to transfer functi on
6-318
second-or der secti ons to zero-pol e-gai n 6-320
state-space to second-order secti ons 6-333
state-space to zero-pol e-gai n 6-338
transfer functi on to l atti ce 6-346
transfer functi on to second-order secti ons
6-347
Index
I-6
tr ansfer functi on to state-space 6-350
zero-pol e-gai n to second-or der secti on 6-379
zero-pol e-gai n to state-space 6-383
convmtx 1-39, 1-42, 6-3, 6-86
convol uti on
and cr oss-cor rel ati on 3-3
and fi l teri ng 1-14, 6-148
convol uti on matri x 1-39, 6-86
defi ned 6-83
exampl e 1-14
two-di mensi onal 6-84
obtai ni ng subsecti on 6-84
convol uti on matri x 1-42, 6-86
defi ned 1-39
exampl e 6-86
corrcoef 6-7, 6-88
corr el ati on 3-2
coeffi ci ent matri x 6-88
Seealsoautocorrel ati on, cross-correl ati on
cosi ne wi ndow 4-4
cov 6-7, 6-89
covari ance 3-2
matri x 6-89
Seealsoautocovari ance, cross-covari ance
covari ance method 3-6, 3-22
defi ned 3-22
exampl e 3-23
covari ance method, i n Spectrum Vi ewer 5-105
cplxpair 6-9, 6-90
Create button, i n Spectra panel 5-19, 5-97
cremez 2-17, 6-5, 6-91
cross spectral densi ty 3-14, 6-100
confi dence i nter val 3-14
defi ned 3-5
cross-correl ati on 6-367
bi ased 3-3
mul ti pl e channel s 3-4
normal i zati on 3-4
two-di mensi onal 6-372
unbi ased 3-3
cross-covari ance 6-373
mul ti pl e channel s 3-4
csd 3-6, 3-14, 6-7, 6-100
CSD. Seecross spectral densi ty
cutoff frequency 2-38
defi ned 6-22
for Kai ser wi ndow fi l ter 5-75
czt 4-35, 6-6, 6-105
CZT. Seechi rp z-transform
D
data
dupl i cati ng i n SPTool 5-16
edi ti ng i n SPTool 5-13, 5-15
enteri ng 1-13
exporti ng from SPTool 5-6
i mporti ng 1-13
i mporti ng i nto SPTool 5-3, 5-6, 5-7
measuri ng i n SPTool 5-31
mul ti channel 1-4, 1-7
vi ewi ng i n SPTool 5-31
data compressi on 4-10
data matri x 1-4, 1-7
data vector 1-4
dct 4-36, 6-6, 6-108
exampl e 4-37
decimate 6-9, 6-110
deci mati on 6-110
FI R fi l ter for 6-201
deconv 4-33, 6-9, 6-113
exampl e 4-33
deconvol uti on 4-33, 6-113
defaul t pl ot, i n Spectrum Vi ewer 5-102
Index
I-7
Defaul t Sessi on check box, i n Prefer ences di al og
box 5-28
Defaul t SPTool sessi on fi l e 5-20, 5-28
defaul t val ues, usi ng empty matr i x 3-11
del ay
addi ng to si gnal 2-25
group 1-28
noni nteger 2-26
phase 1-28
demod 4-29, 4-30, 6-9, 6-114
exampl e 4-30
demodul ati on 4-30, 6-114
exampl e 4-30
methods 4-30, 6-114
desi gn, general i zed fi l ter 2-5
desi gned fi l ter, i n SPTool 5-14
DFT. Seedi screte Fouri er transform
dftmtx 6-6, 6-117
di fference equati on, rel ati on to transfer functi on
1-32
di fferenti ator 2-26, 6-167, 6-289
Di gi tal Audi o Tape standard 4-20
di gi tal fi l ter
anti -causal 1-20
as convol uti on matri x 1-40
Butterworth 6-43
cascade 1-37
Chebyshev type I 6-65
Chebyshev type I I 6-70
coeffi ci ents 1-15
desi gn 2-2
el l i pti c 6-125
FI R 2-16
compared to I I R 2-16
fi xed-poi nt i mpl ementati on 1-37
frequency response 1-24
group del ay 1-28, 6-182
i denti fi cati on from frequency data 6-207
I I R 2-4
compared to FI R 2-4
i mpl ementati on 1-14, 6-142, 6-145
FFT-based (FI R) 6-142
overl ap-add method 1-22
usi ng convol uti on 1-14
usi ng filter functi on 1-16
i mpul se response 1-14, 1-23, 6-196
i ni ti al condi ti ons 1-17
l i near system model s 1-32
names 1-15
order 1-15
i n state-space representati on 1-34
order esti mati on
Butter worth 6-48
Chebyshev type I 6-55
Chebyshev type I I 6-60
el l i pti c 6-132
equi ri ppl e FI R 6-294
phase del ay 1-28, 6-182
pol es 1-30, 1-33
representati onal model s 1-32
representi ng i n MATLAB 1-32
second-or der secti ons 1-37
speci fi cati ons 2-7
startup transi ents 1-21, 1-22
structure
l atti ce 1-37
transposed di rect form I I 1-17
ti me-domai n representati on 1-16
transfer functi on r epr esentati on 1-15
two-di mensi onal 6-148
zero-phase 1-20, 6-149
zeros 1-30, 1-33
zeros and pol es 1-33
SeealsoFI R fi l ter, I I R fi l ter
Index
I-8
di gi tal fi l ter desi gn
FI R 2-16
I I R 2-4
di gi tal frequency xvi i
di rect desi gn 2-13
descri bed 2-13
summary 2-5
diric 6-2, 6-118
Di ri chl et functi on 1-11, 6-118
defi ned 1-11
exampl e 1-12
di screte cosi ne transfor m (DCT) 6-108
appl i cati ons 4-36
energy compacti on property 4-37
exampl e 4-37
i nverse 4-36, 6-190
reconstructi ng si gnal from few coeffi ci ents
4-37
di screte Fouri er transform (DFT) 1-2, 1-43
al gori thms 1-45
and I I R fi l ter i mpl ementati on 1-22
and spectral anal ysi s 3-6
appl i cati ons 6-137
dependence on si gnal l ength 1-45
exampl e 1-44
executi on ti me, usi ng chi rp z-transform 4-35
i nverse 1-43, 6-192
matri x 6-117
two-di mensi onal 1-45, 6-193
matri x 6-117
two-di mensi onal 1-45, 6-141
Seealsofast Fouri er transform (FFT), fft
di screte prol ate spheroi dal sequences (DPSSs)
3-19
di screte-ti me Fouri er transform 3-5
di screti zati on 2-41, 6-194
bi l i near transfor mati on 2-43
pr ewarpi ng 2-44
i mpul se i nvari ance 2-42
di sk, l oadi ng vari abl es from 5-8
dpss 6-9, 6-119
dpss.mat 3-19
dpssclear 3-19, 6-9, 6-121
dpssdir 3-19, 6-9, 6-122
dpssload 3-19, 6-9, 6-123
DPSSs. Seedi screte prol ate spher oi dal sequences
dpsssave 3-19, 6-9, 6-124
duty cycl e, speci fyi ng 1-8
E
echo detecti on 4-23
edge effects 1-22
edge fr equenci es, setti ng i n Fi l ter Desi gner 5-70
Edi t Desi gn button 5-18, 5-59
eig, i n pmusic functi on 3-25
ei genanal ysi s
defi ned 3-24
fr equency esti mator functi ons 3-24
ei genvector method 3-5, 3-23
Seealsomul ti pl e si gnal cl assi fi cati on method
ellip 2-5, 2-6, 6-5, 6-125
ellipap 2-5, 6-10, 6-131
exampl e 2-10
ellipord 2-5, 6-5, 6-132
el l i pti c fi l ter
anal og 6-126
anal og prototype 2-38, 6-131
bandpass confi gur ati on
anal og 6-126
di gi tal 6-125
Index
I-9
bandstop confi gurati on
anal og 6-127
di gi tal 6-126
characteri sti cs 2-10
desi gn 6-125
di gi tal 6-125
hi ghpass confi gurati on
anal og 6-127
di gi tal 6-126
l i mi tati ons 6-129
l owpass confi gurati on
anal og 6-126
di gi tal 6-125
order esti mati on 2-7, 6-132
energy compacti on 4-37
equi ri ppl e characteri sti cs
Chebyshev type I fi l ter (passband) 2-9
Chebyshev type I I fi l ter (stopband) 2-10
Chebyshev wi ndow 4-9
el l i pti c fi l ter 2-10, 6-125, 6-131
from Parks-McCl el l an desi gn 6-287
equi ri ppl e fi l ter 2-22
error mi ni mi zati on
between desi red and actual response 2-22
for equi ri ppl e fi l ter 5-75
for l east squares fi l ter 5-75
i ntegral of square 2-22
mi ni max 2-22
wei ghti ng i n frequency bands 2-24
esti mati on
cross spectrum 3-14
power spectrum 3-6
transfer functi on 3-14
Seealsopar ametri c model i ng
esti mati on methods
i n Spectrum Vi ewer 5-103, 5-104
nonparametri c
FFT method 5-105
mul ti pl e si gnal cl assi fi cati on method
(MUSI C) 3-5, 5-106
mul ti taper method (MTM) 3-5, 5-105
Wel chs method 3-5, 5-106
parametri c 3-5
Bur g method 5-104, 6-16
covari ance method 6-17
modi fi ed covar i ance method 6-18
Yul e-Wal ker AR method 5-107
Yul e-Wal ker method 6-19
Expor t Fi l ters as TF objects check box, i n
Preferences di al og box 5-29
Expor t menu i tem 5-6
Expor ti ng Components check box, i n Preferences
di al og box 5-29
exporti ng data from MATLAB 1-13
extensi ons to SPTool 5-30
F
Factory Setti ngs button, i n Preferences di al og box
5-30
fast Fouri er transform (FFT) 1-22, 1-43
and frequency r esponse 1-24
fft 1-22
pri me factor al gori thm 1-45, 6-139
radi x-2 al gori thm 1-45, 6-139
rol e i n si gnal processi ng 1-43
two-di mensi onal 6-141
fft 1-2, 1-22, 1-43, 6-6, 6-137
compl ex i nputs 1-45
exampl e 1-44
executi on ti me 1-45, 6-140
pri me factor al gori thm 1-45, 6-139
radi x-2 al gori thm 1-45, 6-139
Index
I-10
real i nputs 1-45
rearr angi ng output 1-45, 6-144
speci fyi ng number of poi nts 1-44
FFT l ength
i n Fi l ter Desi gner 5-20, 5-27
i n Fi l ter Vi ewer 5-25
FFT Length edi t box, i n Preferences di al og box
5-25, 5-27
FFT method, i n Spectrum Vi ewer 5-105
FFT. Seefast Fouri er transform
fft2 1-45, 6-6, 6-141
rearr angi ng output 1-45
FFT-based fi l teri ng 1-22
fftfilt 1-19, 6-2, 6-142
compared to filter 6-142
fftshift 1-45, 6-6, 6-144
Fi l e Contents l i st 5-8
fi l ter
anal og prototype 2-8, 2-11, 6-21, 6-42, 6-54,
6-59, 6-131
anal yzi ng i n Fi l ter Vi ewer 5-17
appl yi ng to a si gnal 5-18
Butterwor th 2-7, 6-43
general i zed 2-14
Chebyshev 2-7
Chebyshev type I 6-65
Chebyshev type I I 6-70
coeffi ci ents 1-15, 2-17, 5-79
desi gn
FI R 6-287
general i zed 2-5
I I R 2-5
i nverse 6-203, 6-207
di screti zati on 2-41
el l i pti c 2-7, 6-125
equi r i ppl e 2-22
exporti ng as TF objects for Contr ol System
Tool box 5-29
group del ay 5-17
i denti fi cati on from frequency data 6-203
i mpl ementati on 1-22, 6-142, 6-145
i mporti ng i nto SPTool 5-7, 5-8, 5-11
i mpul se response 5-17
l i near ti me-i nvar i ant di gi tal 1-2
magni tude response 5-17
measurements 5-37
medi an 4-28, 6-235
mi ni max 2-22
mi ni mum phase 6-265
mul ti band FI R 2-22
names 1-15
nami ng i n SPTool 5-16
order 1-15, 2-7, 6-48, 6-55, 6-60, 6-132
order sel ecti on 2-7
phase response 5-17
pr i nci pal suppor ted 1-2
Savi tzky-Gol ay 6-309, 6-311
second-order secti ons 6-322
si ngl e band FI R 2-20
speci fi cati ons 2-7
step r esponse 5-17
transposed di rect form I I structure 1-17
two-di mensi onal 6-148
types 2-17
vi ewi ng i n Fi l ter Vi ewer 5-17
zeros and pol es 5-17
SeealsoFI R fi l ter , I I R fi l ter, di gi tal fi l ter ,
anal og fi l ter
filter 1-2, 1-16, 1-20, 6-2, 6-145
compar ed to fftfilt 6-142
compar ed to filtfilt 1-21
fi nal condi ti on parameters 1-17
i mpl ementati on 1-17
Index
I-11
i ni ti al condi ti on parameter s 1-17
i ni ti al condi ti ons 6-150
fi l ter coeffi ci ents
converti ng from autocorr el ati on sequence
6-13
converti ng to autocorr el ati on sequence 6-262
converti ng to refl ecti on coeffi ci ents 6-263,
6-283
fi l ter desi gn
i n Fi l ter Desi gner 5-59, 5-73, 5-76
standard band confi gur ati ons 5-59
usi ng speci fi cati on l i nes 5-70
Fi l ter Desi gner 5-2, 5-17, 5-59, 6-329
acti vati ng 5-17, 5-59
changi ng pl ot properti es 5-27
cl assi cal I I R fi l ter desi gn 5-76
cl osi ng 5-60
customi zi ng 5-20
magni tude pl ot 5-63, 5-69, 5-78
measuri ng response character i sti cs 5-70
savi ng data to wor kspace 5-79, 5-110
setti ng edge frequenci es 5-70
setti ng passband ri ppl e 5-70
setti ng stopband attenuati on 5-70
si ngl e band FI R fi l ter desi gn 5-73
wi ndow 5-60
fi l ter parameter s, i n Fi l ter Vi ewer 5-20
fi l ter response, peaks and val l eys 5-37
fi l ter type
desi gn 5-14
i mported 5-14, 5-18
Fi l ter Vi ewer 5-2, 5-17, 5-84, 6-330
acti vati ng 5-17, 5-84
customi zi ng 5-20
defaul t pl ot 5-85
pl ots 5-86
preferences 5-86
setti ngs 5-86
subpl ots 5-86
vi ewi ng fr equency response 5-82
vi ewi ng group del ay 5-93
vi ewi ng i mpul se response 5-94
vi ewi ng magni tude response 5-89
vi ewi ng phase response 5-91
vi ewi ng step r esponse 5-95
vi ewi ng zero-pol e pl ot 5-94
wi ndow 5-85
filter2 6-3, 6-148
fi l ter i ng
and convol uti on 1-14
anti -causal 1-20
frequency domai n 1-22
i ni ti al condi ti ons 1-17
generati ng 1-18
zero-phase 1-20
fi l ter i ng al gori thm 5-18
filtfilt 1-19, 1-20, 2-4, 6-3, 6-149
compared to filter 1-21
exampl e 1-20
i ni ti al condi ti ons 1-21
filtic 1-18, 6-3, 6-150
FI R fi l ter
arbi trary frequency response 6-157
compared to I I R 2-16
desi gn 2-16
deci mati on 6-201
i nterpol ati on 6-201
l east squares method 6-166
l i near phase 6-166
mul ti band frequency response 6-157
Parks-McCl el l an method 6-287
wi ndow method 6-152
di ffer enti ator 2-26, 6-167, 6-289
Hi l bert transformer 2-25, 6-167, 6-289
Index
I-12
i mpl ementati on 1-17, 6-145
FFT-based 1-22, 6-142
overl ap-add method 1-22, 6-142
l i near phase 2-17, 6-287
order esti mati on, remez functi on 6-294
types 6-169, 6-292
FI R fi l ter desi gn 2-16
anti -symmetri c 2-25
arbi tr ary responses 2-31
compl ex fi l ter s 2-17, 6-91
nonl i near phase 2-17, 6-91
reduced del ay 2-34
constrai ned l east squares 2-16, 2-27
l i near phase 2-28
mul ti band 2-28, 2-29
wei ghted 2-30
equi r i ppl e 2-16, 2-22, 2-23, 5-73, 5-75
exampl e 5-73, 5-113
i n Fi l ter Desi gner 5-59, 5-73
Kai ser wi ndow 5-73, 5-75
l east squar es 2-16, 2-22, 2-23, 5-73, 5-75
l east squar es compared to equi ri ppl e 2-23
l i near phase fi l ters 2-17, 2-22
mul ti band 2-16, 2-21, 2-22
order sel ecti on 5-75
parameters i n Fi l ter Desi gner 5-75
Par ks-McCl el l an method 2-22
rai sed cosi ne method 2-17
rol e of Kai ser wi ndow 4-7
standard band 2-20
wi ndowi ng method 2-16, 2-18
FI R fi l teri ng, i n frequency domai n 1-19
FI R l atti ce fi l ter, i mpl ementati on 1-38
fir1 2-16, 2-20, 6-5, 6-152
accessi ng from Fi l ter Desi gner 5-73, 5-75
fir2 2-16, 2-20, 6-5, 6-157
exampl e 2-21
fircls 2-16, 6-5, 6-160
fircls1 2-16, 6-6, 6-163
firls 2-16, 2-22, 6-6, 6-166
accessi ng from Fi l ter Desi gner 5-73, 5-75
compar ed to remez 2-23
fi l ter characteri sti cs 6-169
for di fferenti ator desi gn 2-26
wei ght vector 2-24
firrcos 2-17, 6-6, 6-171
fi xed-poi nt i mpl ementati on, di gi tal fi l ter 1-37
fm 4-30
FM. Seefrequency modul ati on
fopen 1-13
Fouri er transform, ei genvector equi val ent 3-24
Fouri er transform, ti me dependent. See
ti me-dependent Fouri er transform
Fouri er transform. Seedi screte Fouri er transform,
fast Four i er transform
fread 1-13
freqs 1-26, 6-3, 6-173
freqspace 6-176
fr equency 6-287
anal og xvi i
angul ar 2-2
carri er 4-29, 6-236, 6-365
center 2-40
cutoff 2-38
di gi tal xvi i
normal i zati on 2-2
Nyqui st xvi i , 2-2
pr ewarpi ng 6-25
transformati on 6-220, 6-223, 6-225, 6-227
vector 2-24, 6-157, 6-160, 6-376
fr equency anal ysi s
i n Fi l ter Vi ewer 5-84
ti me-dependent 6-323
Index
I-13
Frequency Axi s Range pop-up menu, i n
Prefer ences di al og box 5-24, 5-25
Frequency Axi s Scal i ng pop-up menu, i n
Prefer ences di al og box 5-24, 5-25
frequency axi s scal i ng, i n Spectrum Vi ewer 5-100
frequency demodul ati on 6-115
frequency domai n
dual i ty wi th ti me domai n 1-22
FI R fi l teri ng 1-19
for fi l ter i mpl ementati on 1-22
frequency domai n based model i ng. Seeparametri c
model i ng
frequency esti mator functi ons, i n ei genanal ysi s
3-24
frequency esti mator techni ques
ei genvector (EV) method 3-23
mul ti pl e si gnal cl assi fi cati on (MUSI C) method
3-23
frequency modul ati on 6-237
frequency poi nts
freqz 1-24, 1-26
range 1-26
spaci ng 1-26
Frequency Range pop-up menu, Spectrum Vi ewer
5-100
frequency response 1-24
arbi trary 2-13, 6-157
exampl e 1-25
i n Fi l ter Vi ewer 5-82, 5-84, 5-89
i nver se 6-203
Kai ser wi ndow 4-6
l i near phase 2-17
magni tude 1-26
mi ni mi zed er ror between desi red and actual
2-22
monotoni c 2-9
mul ti band 2-13
of Bessel prototype 2-11
of Butterworth prototype 2-8
of Chebyshev type I prototype 2-9
of Chebyshev type I I prototype 2-10
of Chebyshev wi ndow 4-9
of el l i pti c prototype 2-10
phase 1-26
unwrappi ng 1-27
pl otti ng 1-25
poi nts at whi ch eval uated 1-24
spaci ng 6-176
speci fyi ng sampl i ng frequency 1-24
Frequency Scal e pop-up menu, Spectrum Vi ewer
5-100
frequency tr ansfor mati on 2-38
exampl e 2-40
l owpass to bandpass 6-220
l owpass to bandstop 6-223
l owpass to hi ghpass 6-225
l owpass to l owpass 6-227
frequency vector 6-287
freqz 1-24, 6-3, 6-177
frequency poi nts 1-24
sampl i ng frequency 1-24
spaci ng 6-176
From Di sk radi o button, i n I mpor t di al og box 5-8
From Workspace r adi o button, i n I mport di al og
box 5-8
fscanf 1-13
Ful l Vi ew button 5-32
G
gauspuls 1-8, 1-10, 6-2, 6-180
Gauss-Newton method 6-205, 6-209
general i zed Butterwor th fi l ter 2-14
general i zed cosi ne wi ndow 4-4
Index
I-14
Gi bbs effect 2-19
reduced by wi ndow 4-2
graphi cal user i nterface (GUI ) xi i , 1-3
gri d l i nes, i n Fi l ter Desi gner 5-20, 5-27
group del ay 1-28, 5-17, 6-182
defi ned 1-28
exampl e 1-29
of l i near response fi l ter 2-17
passband 2-11
vi ewi ng i n Fi l ter Vi ewer 5-93
Group Del ay check box, Fi l ter Vi ewer 5-86
group del ay pl ot 5-86, 5-93
grpdelay 1-28, 6-3, 6-182
GUI . Seegraphi cal user i nterface
GUI -based tool s. Seei nteracti ve tool s
H
hamming 4-2, 6-8, 6-185
Hammi ng wi ndow 2-20, 4-4, 6-185
HandleVisibility property 5-57, 5-110
hanning 4-2, 6-8, 6-186
Hanni ng wi ndow 4-4, 6-186
hi ghpass fi l ter
anal og prototype desi gn 2-6
Bessel 6-22
Butterwor th 6-44, 6-45
Chebyshev type I 6-66, 6-67
Chebyshev type I I 6-71, 6-72
el l i pti c 6-126, 6-127
FI R desi gn
wi th wi ndow method 2-21, 6-154
tr ansformati on from l owpass to 6-225
hilbert 2-26, 4-38, 6-6, 6-187
exampl e 4-39
Hi l bert transfor m 4-34, 4-38, 6-187
and anal yti c si gnal 2-26
and i nstantaneous attri butes 4-39
exampl e 4-39
Hi l bert transformer 6-167, 6-289
homomorphi c systems 4-23
Hori zontal button, for rul ers 5-36, 5-38, 5-39
I
icceps 4-23, 4-25, 6-9, 6-189
exampl e 4-26
idct 4-36, 6-6, 6-190
i deal l owpass fi l ter 2-18
ifft 1-43, 6-6, 6-192
speci fyi ng number of poi nts 1-45
ifft2 1-45, 6-6, 6-193
I I R fi l ter
arbi trary frequency response 2-13
Bessel 2-11
Butterworth 2-8
Chebyshev type I 2-9
Chebyshev type I I 2-10
compar ed to FI R 2-4
desi gn 2-4
di r ect 2-13
Levi nson-Durbi n recursi on 6-218
mul ti band 2-13
Pronys method 6-266
Stei gl i tz-McBr i de i terati on 6-341
Yul e-Wal ker 6-376
el l i pti c 2-10
i mpl ementati on 6-145
fr equency domai n 1-22
zero-phase 1-20
I I R fi l ter desi gn 2-4, 2-5
anal og prototype 2-5
Butterworth 2-7, 2-8, 5-76, 5-77
Chebyshev 2-7, 2-9, 2-10, 5-76, 5-77
Index
I-15
cl assi cal (anal og prototype) 2-5, 2-8
compari son of fi l ter types 2-8
general steps 2-37
i l l ustrati on 2-37
i n Fi l ter Desi gner 5-76
order esti mati on 2-7
pl otti ng prototypes 2-12
si ngl e step 2-6
si ngl e step order esti mati on 2-7
system model 2-7
di r ect methods 2-13
Yul e-Wal ker 2-13
el l i pti c 2-7, 2-10, 5-76, 5-77
exampl e 5-76, 5-77
general i zed Butter worth 2-14
i n Fi l ter Desi gner 5-59, 5-76
maxi mal l y fl at 2-14
parameters i n Fi l ter Desi gner 5-77
to speci fi cati ons 2-7
Seealsodi rect desi gn, parametri c model i ng
I I R l atti ce fi l ter, i mpl ementati on 1-38
i mage processi ng 6-84
wi th fft2 and ifft2 1-45
impinvar 2-5, 2-42, 6-11, 6-194
I mport As pop-up menu, i n I mport di al og box 5-9
I mport menu i tem 5-4, 5-6
i mported fi l ter, i n SPTool 5-14
i mpul se i nvari ance 2-42, 6-194
l i mi tati ons 2-42
i mpul se response 1-23, 5-17, 6-196
and i mpul se i nvari ance 2-42
computi ng wi th filter 1-23
computi ng wi th impz 1-23
defi ned 1-23
exampl e 1-23
of i deal l owpass fi l ter 2-18
vi ewi ng i n Fi l ter Vi ewer 5-94
I mpul se Response check box, Fi l ter Vi ewer 5-86
i mpul se response pl ot 5-86, 5-94
impz 6-3, 6-196
exampl e 1-23
i ndexi ng, of vectors 1-15
I nheri t fr om pop-up menu, Spectrum Vi ewer
5-100
i nheri ti ng parameters 5-100
i ni ti al condi ti ons 1-17, 1-21, 6-150
generati ng 1-18
I ni ti al Type pop-up menu, i n Preferences di al og
box 5-21
i nstantaneous attri butes 4-39, 6-187
i nteracti ve tool s 5-2
extended exampl e 5-113
Fi l ter Desi gner 5-2, 5-59, 6-329
Fi l ter Vi ewer 5-2, 5-84, 6-330
Si gnal Br owser 5-2, 5-43, 6-328
Spectrum Vi ewer 5-2, 5-97, 6-331
SPTool 5-2, 6-328
interp 6-9, 6-199
i nterpol ati on 6-199
FI R fi l ter desi gn 6-201
i nterval notati on xvi i
intfilt 6-6, 6-201
i nverse compl ex cepstrum 4-25
i nverse di screte cosi ne transform 6-190
accur acy of si gnal reconstructi on 4-38
i nverse di screte Fouri er transform 1-43, 6-192
ifft 1-43
matri x 6-117
two-di mensi onal 1-45, 6-193
i nverse fi l ter desi gn 6-207, 6-266
anal og 6-203
di gi tal 6-207
i nverse Fouri er transform, conti nuous. Seesinc
functi on
Index
I-16
invfreqs 2-5, 4-11, 4-16, 6-8, 6-203
invfreqz 2-5, 4-11, 4-16, 6-8, 6-207
K
kaiser 4-2, 6-8, 6-210
accessi ng from Fi l ter Desi gner 5-73
exampl e 4-5
Kai ser wi ndow 4-4, 6-210
and FI R fi l ter desi gn 4-7, 5-73
beta parameter 4-4, 6-210
exampl e 4-5
frequency r esponse 4-6
kaiserord 2-16, 6-6, 6-211
accessi ng from Fi l ter Desi gner 5-75
L
l adder coeffi ci ents 1-38
Lagrange i nterpol ati on fi l ter 6-201
Lapl ace transform 1-41
equi val ent to state-space representati on 1-41
latc2tf 1-39, 1-42, 6-3, 6-216
latcfilt 1-19, 1-39, 6-3, 6-217
l atti ce coeffi ci ents 1-38
l atti ce fi l ter 1-42
i mpl ementati on 1-38
i mpl ementati on wi th latcfilt 1-39
l atti ce form
converti ng from transfer functi on 6-346
l atti ce structure 1-37
l atti ce/l adder fi l ter
i mpl ementati on 1-38
i mpl ementati on wi th latcfilt 1-39
l east squar es method, FI R fi l ter desi gn 6-166
fi l ter characteri sti cs 6-169
levinson 4-11, 6-8, 6-218, 6-305
and parametri c model i ng 4-12
Levi nson-Durbi n recursi on 4-12, 6-218, 6-305
l i ne col or
i n Fi l ter Vi ewer 5-35
i n Si gnal Browser 5-35
i n Spectrum Vi ewer 5-35
l i ne sel ecti on
i n Fi l ter Vi ewer 5-34, 5-35
i n Si gnal Browser 5-34, 5-35
i n Spectrum Vi ewer 5-34, 5-35
l i ne styl e
customi zi ng i n SPTool 5-20
i n Fi l ter Vi ewer 5-22, 5-35
i n Si gnal Browser 5-22, 5-35
i n Spectrum Vi ewer 5-22, 5-35
Li ne Styl e Order edi t box, i n Preferences di al og box
5-22
l i near phase 2-16, 2-17, 6-166
fi l ter desi gn 6-287
rel ated characteri sti cs 2-17
l i near predi cti on coeffi ci ents 6-229
l i near predi cti on model i ng 4-12
l i near predi cti ve codi ng
l i near swept-fr equency cosi ne. Seechi rp
l i near system model s 1-32
l i near system transformati ons 1-41
conversi on chart 1-41
l i near ti me-i nvar i ant di fferenti al equati ons,
represented i n state-space form 1-40
load 1-13
l owpass fi l ter
anal og prototype desi gn 2-6
and i mpul se i nvari ance 2-42
Bessel 6-22
Butterworth 6-43, 6-44
Chebyshev type I 6-65, 6-66
Chebyshev type I I 6-70, 6-71
Index
I-17
el l i pti c 6-125, 6-126
FI R desi gn, wi th wi ndow method 2-21
for deci mati on 6-110
for i nterpol ati on 6-199
i deal i mpul se response 2-18
transl ati on of cutoff frequency 6-227
lp2bp 2-5, 2-39, 6-10, 6-220
exampl e 2-40
lp2bs 2-5, 2-39, 6-10, 6-223
lp2hp 2-5, 2-39, 6-10, 6-225
lp2lp 2-5, 2-39, 6-10, 6-227
lpc 2-5, 4-11, 6-8, 6-229
Seealsol i near predi cti ve codi ng, Pr onys
method
LPC. Seel i near pr edi cti on coeffi ci ents
M
magni tude
of Fouri er transform of sequence 1-44
of fr equency response 1-26
vi ewi ng i n Fi l ter Vi ewer 5-89
of transfer functi on esti mate 3-15
vector 2-24, 6-157, 6-160, 6-376
Magni tude Axi s Scal i ng pop-up menu, i n
Prefer ences di al og box 5-24, 5-25
Magni tude check box, Fi l ter Vi ewer 5-86
magni tude pl ot 5-78
magni tude pl ot, i n Fi l ter Desi gner 5-69, 5-78
magni tude response 5-17
magni tude response pl ot 5-86, 5-89
i n Fi l ter Desi gner 5-63
Magni tude Scal e pop-up menu, Spectr um Vi ewer
5-100
magni tude scal e, i n Spectrum Vi ewer 5-100
manufacturi ng 4-10
Marker Si ze edi t box, i n Preferences di al og box
5-21
match frequency (for prewarpi ng) 6-25
MAT-fi l e
dpss.mat 3-19
i mporti ng 1-13
i mporti ng i nto SPTool 5-4, 5-6
l oadi ng i nto SPTool 5-8
MAT-fi l e for mat, converti ng to 1-13
matri ces
convol uti on 1-39, 6-86
correl ati on coeffi ci ent 6-88
covari ance 6-89
data 1-4, 1-7
di screte Fouri er transform 6-117
for second-or der secti ons form 1-37
i nverse di screte Fouri er transform 6-117
matri x for m. Seestate-space form
maxflat 2-5, 2-14, 6-5, 6-233
maxi ma, l ocal 5-37
maxi mal l y fl at 2-14
measurement l i nes 5-70
measurements
i n Fi l ter Vi ewer 5-37
i n Si gnal Browser 5-37
i n Spectrum Vi ewer 5-37, 5-101
savi ng i n Fi l ter Vi ewer 5-37
savi ng i n Si gnal Br owser 5-37
savi ng i n Spectrum Vi ewer 5-37
medfilt1 4-28, 6-9, 6-235
medi an fi l ter 4-28, 6-235
message si gnal 4-29, 6-236
Method pop-up menu, Spectrum Vi ewer 5-103
MEX-fi l e 1-13
M-fi l es 1-3
creati ng xi i , 1-3
modi fyi ng xi i
Index
I-18
vi ewi ng xi i
mi ni ma, l ocal 5-37
mi ni max method, FI R fi l ter desi gn 2-22
SeealsoParks-McCl el l an method
mi ni mum phase fi l ter 6-265
model s
autoregr essi ve 6-16, 6-17, 6-18, 6-19
vi a Bur g method 6-239
vi a covari ance method 6-243
vi a modi fi ed covari ance method 6-247
vi a Yul e-Wal ker AR method 6-278
model s, system repr esentati on 1-32
modi fi ed covari ance method 3-6, 3-22
defi ned 3-22
exampl e 3-23
modi fi ed peri odogram 3-9
modulate 4-29, 6-9
exampl e 4-30
method fl ags 4-29
modul ati on 6-236
ampl i tude
defi ned 4-29
exampl e 4-30
frequency
methods 4-29, 6-236
phase 4-30
pul se ti me 4-30
pul se wi dth 4-30
quadrature ampl i tude 4-30
mouse zoom 5-32
i n Fi l ter Desi gner 5-20
i n Fi l ter Vi ewer 5-20, 5-88
i n Si gnal Br owser 5-20
i n Spectrum Vi ewer 5-20
turni ng off 5-33
Mouse Zoom button 5-32
movi ng average (MA) fi l ter 1-15
SeealsoFI R fi l ter
MTM. Seemul ti taper method
mul ti band fi l ter
FI R 2-21
FI R, wi th tr ansi ti on bands 2-22
I I R 2-13
mul ti channel data 1-4, 1-7
mul ti channel si gnal 3-4
mul ti pl e si gnal cl assi fi cati on method (MUSI C) 3-5,
3-6, 3-23
defi ned 3-23
i n Spectrum Vi ewer 5-106
mul ti pl i ci ty, of zeros and pol es 5-71
mul ti rate fi l ter bank, i mpl ementati on 1-19
mul ti rate fi l teri ng 1-19
mul ti taper method (MTM) 3-5, 3-6, 3-16
compar ed to Wel chs method 3-19
defi ned 3-16
exampl e 3-17
i n Spectrum Vi ewer 5-105
MUSI C. Seemul ti pl e si gnal cl assi fi cati on method
N
New Desi gn button 5-17, 5-59
noni nteger del ay 2-26
nonrecur si ve fi l ter. SeeFI R fi l ter
normal i zati on 3-3
correl ati on 3-4, 6-367, 6-368
power spectral densi ty 3-12
Nyqui st frequency xvi i , 2-2
O
objects, edi ti ng i n SPTool 5-15
one-ti me mouse zoomi ng 5-32
Open Sessi on menu i tem 5-6
Index
I-19
order esti mati on 2-7, 6-294
Butterworth 6-48
Chebyshev type I 6-55
Chebyshev type I I 6-60
el l i pti c 6-132
i n Fi l ter Desi gner 5-75, 5-78
order sel ecti on 2-7
i n Fi l ter Desi gner 5-75, 5-78
order, of fi l ter 1-15, 2-7
orthogonal wi ndows, i n PSD esti mates 3-16
osci l l ator , vol tage control l ed 6-365
overl ap-add method, FI R fi l ter i mpl ementati on
1-22, 6-142
P
Page Setup di al og box 5-45, 5-99
panner 5-52
i n Si gnal Browser 5-20, 5-23, 5-48
Panner check box, i n Preferences di al og box 5-23
parameters
i n Spectrum Vi ewer 5-99, 5-100, 5-103
i nheri ti ng i n Spectrum Vi ewer 5-100
parametri c model i ng 4-10, 6-207
appl i cati ons 4-10
frequency domai n based 4-16
summary 2-5
techni ques 4-10
ti me domai n based
l i near predi cti ve codi ng 4-12, 4-13
Stei gl i tz-McBri de method 4-15
ti me-domai n based 4-11
Burg method 6-16
covari ance method 6-17
modi fi ed covari ance method 6-18
Yul e-Wal ker method 6-19
parentheses, i ndi cati ng open i nter val xvi i
Parks-McCl el l an method, FI R fi l ter desi gn 2-22,
6-287
parti al fracti on 1-42
parti al fracti on expansi on 1-40
defi ned 1-35
determi ni ng wi th residue 1-41
exampl e 1-35
parti al fracti on form 1-35, 6-302
passband
equi ri ppl e 2-9, 2-10
gr oup del ay 2-11
passband ri ppl e, setti ng i n Fi l ter Desi gner 5-70
passband zoom 5-33
Passband Zoom button 5-33
pburg 3-6, 3-21, 6-7, 6-239
exampl e 3-21
pcov 3-6, 3-22, 6-7, 6-243
exampl e 3-23
Peaks button, Si gnal Browser 5-37
peri odi c si nc functi on 6-118
SeealsoDi ri chl et functi on
peri odogram 3-7
modi fi ed 3-9
persi stent mouse zoomi ng 5-32
phase
computi ng wi th angle 6-15
of Four i er transform of sequence 1-44
of frequency response 1-26
vi ewi ng i n Fi l ter Vi ewer 5-91
of transfer functi on esti mate 3-15
unwrappi ng 1-27, 6-360
Phase check box, Fi l ter Vi ewer 5-86
phase del ay 1-28, 6-182
defi ned 1-28
exampl e 1-29
of l i near response fi l ter 2-17
phase demodul ati on 6-115
Index
I-20
phase di storti on
el i mi nati ng
dur i ng fi l teri ng 1-19
exampl e 1-20
usi ng filtfilt 1-20
i n FI R fi l ter s 1-20
nonl i near
i n I I R fi l ters 1-20
phase modi fi cati on
data dependent, usi ng >cceps 4-25
phase modul ati on 4-30, 6-237
phase response 5-17
phase response pl ot 5-86, 5-91
Phase Uni ts pop-up menu, i n Prefer ences di al og
box 5-25
phase uni ts, i n Fi l ter Vi ewer 5-25
Pl ay menu i tem, Si gnal Browser 5-46
pl ayi ng a si gnal 5-46
pl ot
anal og prototypes 2-12
coherence functi on 3-16
compl ex cepstr um 4-24
DFT 1-44
frequency r esponse 1-25
magni tude 1-26
phase 1-26
group del ay 1-29, 5-86, 5-93
i mpul se response 5-86, 5-94
i n Fi l ter Vi ewer 5-84, 5-86, 5-88, 5-89
magni tude response 5-78, 5-86, 5-89
modi fi ed peri odogram 3-10
mul ti taper esti mate 3-17, 3-18
peri odogram 3-7
phase del ay 1-29
phase response 5-86, 5-91
power spectral densi ty 3-11
spectral densi ty 5-101
step r esponse 5-86, 5-95
str i p pl ot 6-344
ti l i ng i n Fi l ter Vi ewer 5-88
transfer functi on 3-15
zero-pol e 1-30, 5-86, 5-94, 6-385
pl ug-i ns 5-20, 5-30
pm 4-30
pmcov 3-6, 3-22, 6-7, 6-247
exampl e 3-23
p-model . Seepar ametri c model i ng
pmtm 3-6, 6-7, 6-251
exampl e 3-17
pmusic 3-6, 3-23, 6-7, 6-255
pol e-zer o fi l ter. SeeI I R fi l ter
poly 1-33, 1-42
poly2ac 6-4, 6-262
poly2rc 6-4, 6-263
pol ynomi al
di vi si on 4-33, 6-113
mul ti pl i cati on 6-83
roots 1-33
stabi l i zati on 6-265
pol yphase fi l teri ng techni ques 1-19
polystab 6-9, 6-265
power spectral densi ty 6-273
bi as 3-12
computati on par ameters 5-103, 5-104
confi dence i nterval 3-14
defaul t pl ot 5-102
defi ned 3-5
esti mati on by Burg method 3-6, 3-20, 5-104,
6-239
esti mati on by covari ance method 3-6, 3-22,
5-105, 6-243
esti mati on by FFT method 5-105
esti mati on by modi fi ed covari ance method 3-6,
6-247
Index
I-21
esti mati on by mul ti taper method 3-6, 3-16,
5-105
esti mati on by MUSI C method 3-6, 3-23, 5-106
esti mati on by Wel chs method 3-6, 3-10, 5-106
esti mati on by Yul e-Wal ker AR method 3-6,
3-19, 5-107, 6-278
esti mati on methods 5-103, 5-104
i n SPTool 5-13
normal i zati on 3-12
uni ts of 3-11
vi ewi ng i n Spectrum Vi ewer 5-97, 5-102,
5-104
preferences
rul ers 5-21
savi ng i n Si gnal Browser 5-45
preferences fi l e
i n SPTool 5-31
sigprefs.mat 5-31
Prefer ences menu i tem 5-6, 5-20, 5-30
prewarpi ng 6-25
Pri nt di al og box 5-45, 5-55, 5-99, 5-108, 5-120,
5-124
Pri nt Previ ew wi ndow
Handl e Graphi cs 5-57, 5-110
Si gnal Browser 5-45, 5-55, 5-56
preferences 5-56, 5-120
Spectrum Vi ewer 5-99, 5-108, 5-124
preferences 5-109
pri nti ng
from Si gnal Br owser 5-2, 5-21, 5-22, 5-31, 5-33,
5-38, 5-117
from Spectrum Vi ewer 5-2, 5-21, 5-22, 5-31,
5-33, 5-38, 5-98
prol ate-spheroi dal wi ndow 4-4
prony 2-5, 4-11, 4-13, 6-8, 6-266
Pronys method 4-13, 6-266
model i ng 4-13
prototype
Bessel fi l ter 2-11, 6-21
Butter worth fi l ter 2-8, 6-42
Chebyshev type I fi l ter 6-54
Chebyshev type I I fi l ter 6-59
el l i pti c fi l ter 6-131
PSD. Seepower spectral densi ty
psd. Seepwelch 6-268
ptm 4-30
pul se ti me demodul ati on 6-115
pul se ti me modul ati on 4-30, 6-237
pul se trai n generator 6-269
pul se trai ns
generati ng 1-9
pulstran 1-9
pul se wi dth demodul ati on 6-115
pul se wi dth modul ati on 4-30, 6-237
pulstran 1-9, 6-2, 6-75, 6-119, 6-121, 6-122, 6-123,
6-124, 6-269, 6-286, 6-346, 6-359
pwelch 3-6, 3-10, 6-7, 6-273
exampl e 3-12
pwm 4-30
pyulear 3-6, 3-20, 6-7, 6-278
exampl e 3-20, 3-21
Q
qam 4-30
quadrature ampl i tude demodul ati on 6-115
quadrature ampl i tude modul ati on 4-30, 6-237
R
radar appl i cati ons 4-27
radi x-2 al gori thm 1-45
rai sed cosi ne fi l ter desi gn 6-171
randn xi v
Index
I-22
random number, generati on xi v
range notati on xvi i
Range pop-up menu, Fi l ter Vi ewer 5-87
rc2poly 6-4, 6-283
rceps 4-23, 4-25, 6-9, 6-285
real cepstrum 6-285
defi ned 4-24
reconstructi ng si gnal (mi ni mum-phase) 4-25
rebufferi ng 6-33
rectangul ar wi ndow 2-18, 4-2, 6-32
rectpuls 6-2, 6-286
recursi ve fi l ter. SeeI I R fi l ter
references 1-46, 3-27, 4-40
refl ecti on coeffi ci ents 1-37, 1-39
converti ng from autocorrel ati on sequence
6-14
converti ng from fi l ter coeffi ci ents 6-263,
6-283
converti ng to autocorrel ati on sequence 6-282
remez 2-16, 2-22, 6-6, 6-287
accessi ng from Fi l ter Desi gner 5-73, 5-75
compared to firls 2-23
fi l ter characteri sti cs 6-292
for di fferenti ator desi gn 2-26
for Hi l bert transfor mer desi gn 2-25
order esti mati on 6-294
wei ght vector 2-24
Remez exchange al gori thm 2-22, 6-287
remezord 2-16, 6-6, 6-294
accessi ng from Fi l ter Desi gner 5-75
resample 6-10, 6-298
resampl i ng 4-20, 6-298
i n FI R fi l ter i ng 1-19
Seealsodeci mati on, i nterpol ati on
residue 1-41, 1-42
resi due form. Seeparti al fracti on form
residuez 1-42, 6-4, 6-302
Revert panel 5-31
ri ppl e, passband 5-70
rlevinson 6-9, 6-305
roots
of Bessel fi l ter 6-21
pol ynomi al 1-33
roots 1-33, 1-42
rul er col or 5-21
Rul er Col or edi t box, i n Prefer ences di al og box
5-21
Rul er Marker pop-up menu, i n Preferences di al og
box 5-21
rul er mar kers 5-21, 5-36
rul er type
i n Si gnal Browser 5-21
i n Spectrum Vi ewer 5-21
rul ers
bri ngi ng to center 5-35
customi zi ng i n SPTool 5-20
dr aggi ng 5-36
fi nd rul er buttons 5-35
hori zontal 5-36
hori zontal mode 5-40
i n Fi l ter Vi ewer 5-26, 5-33
i n Si gnal Browser 5-20, 5-21, 5-23, 5-33
i n Spectrum Vi ewer 5-20, 5-21, 5-24, 5-33
par ameters 5-36
posi ti oni ng 5-38
pr eferences 5-21
savi ng measurements 5-37
sl ope 5-36
sl ope mode 5-42
track 5-36
track mode 5-41
verti cal 5-36
verti cal mode 5-39
Index
I-23
Rul ers check box, i n Preferences di al og box 5-23,
5-24, 5-26
S
sampl i ng fr equency
changi ng i n SPTool 5-9
i n SPTool 5-16
Sampl i ng Frequency edi t box, i n I mpor t di al og box
5-4, 5-9
Sampl i ng Frequency menu i tem 5-16
sampl i ng rate
changi ng by noni nteger factor 4-20, 6-298
changi ng for i rregul ar l y spaced data 4-22
changi ng wi th upfirdn 1-19
decreasi ng by i nteger factor 6-110
i ncreasi ng by i nteger factor 6-199
Save Rul ers button 5-37
Save Sessi on menu i tem 5-6
savi ng changes i n SPTool 5-30
savi ng data
from Fi l ter Desi gner 5-79, 5-110
from Si gnal Browser 5-57
savi ng data, fr om Fi l ter Desi gner 5-79, 5-110
savi ng data, fr om Si gnal Browser 5-57
savi ng setti ngs, i n Fi l ter Vi ewer 5-86
Savi tzky-Gol ay
fi l ter desi gn 6-309
fi l teri ng 6-311
sawtooth 1-8, 6-2, 6-308
sawtooth wave 1-8
scal ar
for state-space form 1-34
representi ng gai n 1-33
Scal e pop-up menu, Fi l ter Vi ewer 5-87
Search for Pl ug-I ns at start-up check box, i n
Prefer ences di al og box 5-30
second-or der secti on form
converti ng from transfer functi on 6-347
converti ng from zer o-pol e-gai n 6-379
second-or der secti ons 1-42
second-or der secti ons form 1-36
converti ng from state-space for m 6-333
converti ng to state-space 6-316
converti ng to transfer functi on 6-318
converti ng to zer o-pol e-gai n 6-320
defi ned 1-36
fi l ter i ng 6-322
speci fyi ng i n SPTool 5-12
sel ecti ng data objects i n SPTool 5-15
sequence
autocorrel ati on 6-13, 6-14, 6-262
setti ngs
restori ng i n SPTool 5-30
rul ers 5-21
savi ng i n Si gnal Br owser 5-45
savi ng i n SPTool 5-31
sgolay 6-309, 6-311
sgolayfilt 6-311
si gnal
addi ng noi se 1-6
anal yti c 4-38, 6-187
buffer i ng 6-33
carri er 4-29, 6-114
compl ex 5-47
conti nuous (anal og) 1-2
di ffer enti ati on 2-26
di screte (di gi tal ) 1-2
generati ng 1-7
i mporti ng i nto SPTool 5-3, 5-7, 5-8, 5-10
l i nki ng to spectr um 5-100
measurements 5-37
measurements i n Si gnal Browser 5-36
message 4-29, 6-236
Index
I-24
mul ti channel 3-4
nami ng i n SPTool 5-16
peaks 5-37
pl ayi ng 5-46
pl otti ng 1-6
rebufferi ng 6-33
reconstructi on
from DCT coeffi ci ents 4-37
mi ni mum phase 4-25, 6-285
representi ng
i n MATLAB 1-4
mul ti channel 1-4
si ngl e channel 1-4
sel ecti ng i n Si gnal Browser 5-48
val l eys 5-37
vi ewi ng i n Si gnal Browser 5-17, 5-48
Seealsowaveform
Si gnal Browser 5-2, 5-17, 5-43, 6-328
acti vati ng 5-17, 5-43
customi zi ng 5-20
pri nti ng from 5-23, 5-43, 5-44, 5-54
savi ng data to workspace 5-57
wi ndow 5-44
Si gnal Processi ng Tool box 1-2
si gnal type
array 5-14
vector 5-14
sigprefs.mat 5-31
sinc 1-10, 6-2, 6-313
bandl i mi ted i nterpol ati on exampl e 6-314
si nc functi on 1-10, 6-313
and bandl i mi ted i nterpol ati on 6-314
basi c exampl e 1-10
defi ned 1-10
si nusoi dal wave 1-8
Sl epi an sequences. Seedi screte prol ate
spheroi dal sequences
Sl ope button, for rul ers 5-36
Sl ope control 5-38, 5-41
sonar appl i cati ons 4-27
sos2ss 1-42, 6-4, 6-316
sos2tf 1-42, 6-4, 6-318
sos2zp 1-42, 6-4, 6-320
specgram 4-27, 6-10, 6-323
exampl e 4-27, 6-365
speci fi cati on l i nes 5-78
dr aggi ng to edi t fi l ter 5-70
speci fi cati ons for fi l ter desi gn 2-7
spectral anal ysi s 3-5
cross spectral densi ty 3-14
defi ned 3-5
power spectral densi ty 3-5
usi ng Spectr um Vi ewer 5-97
spectral densi ty 3-5
Seealsopower spectral densi ty, cross spectral
densi ty
spectral densi ty pl ot
i n Spectrum Vi ewer 5-101
spectrogram 4-27, 6-323
exampl e 4-27, 6-365
spectrum
computi ng i n SPTool 5-19
i mporti ng i nto SPTool 5-7, 5-8, 5-13
l i nki ng to si gnal 5-100
measurements 5-37
measurements i n Spectrum Vi ewer 5-36, 5-101
nami ng i n SPTool 5-16
peaks 5-37
updati ng i n SPTool 5-19
val l eys 5-37
vi ewi ng i n Spectrum Vi ewer 5-97
vi ewi ng i n SPTool 5-19
spectrum type, auto 5-15
Spectrum Vi ewer 5-2, 5-19, 5-97, 6-331
Index
I-25
acti vati ng 5-19, 5-97
changi ng pl ot properti es 5-102
customi zi ng 5-20
defaul t pl ot 5-102
pri nti ng from 5-24, 5-97, 5-98, 5-107, 5-108
setti ng confi dence i nterval s 5-107
vi ewi ng power spectral densi ty pl ots 5-102
wi ndow 5-98
speech processi ng 4-10, 4-21
spline 4-22
spt extensi on 5-6
SPTool 5-2, 6-328
acti vati ng from Si gnal Browser 5-54
cl osi ng 5-6
customi zi ng 5-6, 5-20
l oadi ng 5-3
preferences 5-6
wi ndow 5-5
sptool command 6-11, 6-328
square 1-8, 6-2, 6-332
square wave 1-8
ss2sos 1-42, 6-4, 6-333
ss2tf 1-42, 6-337
ss2zp 1-42, 6-4, 6-338
stabi l i zati on, pol ynomi al 6-265
standards
Compact Di sc 4-20
Di gi tal Audi o Tape 4-20
startup transi ents 1-22
reduci ng 1-21, 6-149
state-space form 1-40, 1-42
converti ng from second-order secti ons 6-316
converti ng from transfer functi on 6-350
converti ng from zero-pol e-gai n 6-383
converti ng to second-order secti on 6-333
converti ng to zero-pol e-gai n 6-338
defi ned 1-34
representi ng i n MATLAB 1-34
speci fyi ng i n SPTool 5-11
stati sti cal operati ons 3-2
Stay i n Zoom-mode After Zoom check box, i n
Preferences di al og box 5-23, 5-24, 5-26,
5-27
Stei gl i tz-McBri de method 4-15, 6-341
step response 5-17
vi ewi ng i n Fi l ter Vi ewer 5-95
Step Response check box, Fi l ter Vi ewer 5-86
step response pl ot 5-86, 5-95
stmcb 2-5, 4-11, 4-15, 6-9, 6-341
stopband
attenuati on, setti ng i n Fi l ter Desi gner 5-70
equi ri ppl e 2-10
stri p pl ot 6-344
defi ned 6-344
strips 6-2, 6-344
structure, di gi tal fi l ter
l atti ce 1-37
transposed di rect form I I 1-17
subpl ots 5-84
i n Fi l ter Vi ewer 5-86
subspace threshol ds, contr ol l i ng i n pmusic
functi on 3-25
svd, i n pmusic functi on 3-25
swept-frequency cosi ne generator. Seechi rp
system i denti fi cati on 4-13
system model s 1-32
and bi l i near transformati on 2-44
and fi l ter desi gn functi ons 2-7
and frequency transformati on functi ons 2-39
T
tapers, i n PSD esti mates 3-16
taps 2-17
Index
I-26
texts, rel ated 1-46
tf2latc 1-39, 1-42, 6-4, 6-346
tf2ss 1-42, 6-4, 6-350
tf2zp 1-42, 6-339, 6-352
tfe 3-6, 3-14, 6-7, 6-354
thresh 3-25
ti l i ng 5-88
ti l i ng di spl ay, i n Fi l ter Vi ewer 5-26
ti l i ng preferences, i n Fi l ter Vi ewer 5-20
Ti me Response Length edi t box, i n Preferences
di al og box 5-25
ti me response l ength, i n Fi l ter Vi ewer 5-25
ti me vector 1-6
retur ned by modulate 4-30
ti me-dependent Four i er transform 4-27
ti me-domai n anal ysi s, i n Fi l ter Vi ewer 5-84
ti me-domai n based model i ng. Seeparametri c
model i ng
tool box
Contr ol Systems Tool box 1-35, 6-198, 6-340
I mage Processi ng Tool box 6-109, 6-190, 6-235
Si gnal Processi ng Tool box 1-2
Symbol i c Math Tool box 6-21
System I denti fi cati on Tool box 6-357
Tr ack button, for rul ers 5-36, 5-38, 5-40
tr ansfer functi on 1-32, 1-35, 1-40, 1-42
coeffi ci ents 1-15, 5-79
defi ned 1-15
deri vati on 1-15
esti mate fr om i nput and output 6-354
esti mati ng usi ng Wel chs method 3-14
exporti ng from SPTool 5-79
factor ed form 1-33
for anal og fi l ter 1-41
representi ng i n MATLAB 1-32
zero-pol e-gai n form 1-33
tr ansfer functi on form
converti ng from second-or der secti ons 6-318
converti ng to l atti ce 6-346
converti ng to second-or der secti ons 6-347
converti ng to state-space 6-350
speci fyi ng i n SPTool 5-11
transform 4-34
chi r p z-transform (CZT) 4-34, 6-105
di screte cosi ne 6-108
di screte Fouri er 1-43
Hi l bert 4-38, 6-187
i nverse di screte cosi ne 4-36, 6-190
i nverse di screte Fouri er 6-192
transformati ons
between system model s 1-41
bi l i near 2-43, 6-25
fr equency 2-38, 6-220, 6-223, 6-225, 6-227
transi ti on band 2-23
transposed di rect form I I 6-145
i ni ti al condi ti ons 6-150
triang 4-2, 6-8, 6-358
compar ed to bartlett 6-20
exampl e 4-2
tri angul ar wi ndow 6-358
tripuls 6-2, 6-359
two-di mensi onal operati ons
autocorr el ati on 6-372
convol uti on 6-84
obtai ni ng subsecti on 6-84
cross-correl ati on 6-372
di screte Fouri er transform 1-45, 6-141
fi l teri ng 6-148
i nverse di screte Fouri er transform 1-45, 6-193
two-di mensi onal si gnal processi ng, wi th fft2 and
ifft2 1-45
Index
I-27
U
uni t ci rcl e 6-265
uni t i mpul se functi on 1-7
uni t r amp functi on 1-7
uni t sampl e, mul ti channel representati on 1-7
uni t step functi on 1-7
uni ts of power spectral densi ty (PSD) functi on
3-11
unwrap 1-27, 6-3, 6-360
Update button 5-19, 5-97
upfirdn 1-19, 4-22, 6-10, 6-361
V
Val l eys button, Si gnal Browser 5-37
vari ance
of correl ati on sequence esti mate 3-4
of power spectrum esti mate 3-8
vco 4-29, 4-31, 6-10, 6-365
vector
data 1-4
di spl ay, i n Si gnal Browser 5-50
for fi l ter coeffi ci ents 1-16, 1-32
frequency 2-24, 6-157, 6-160, 6-287, 6-376
i n SPTool 5-14
i ndexi ng xvi i , 1-15
magni tude 2-24, 6-157, 6-160, 6-376
ti me 1-6
wei ghti ng 2-24, 6-167, 6-288
Verti cal button, for rul ers 5-36, 5-38
Vi ew button 5-17, 5-19
vol tage control l ed osci l l ator 4-31, 6-365
W
waveform
aperi odi c 1-8
chi rp 1-9
chi rp, exampl e 1-9
from si nusoi ds 1-6
generati ng wi th diric functi on 1-11
generati ng wi th pulstran 1-9
generati ng wi th sinc functi on 1-10
l i near swept-frequency cosi ne. Seechi rp
peri odi c 1-7
sawtooth 1-8, 6-308
exampl e 1-8
si nusoi dal pul se, Gaussi an-modul ated 1-8
square 1-8, 6-332
tri angl e 6-308
Wel chs method 3-6
bi as 3-12
compared to the Burg method 3-22
compared to the MTM method 3-19
compared to the Yul e-Wal ker AR method 3-20
for cross spectr al densi ty esti mati on 3-14,
6-102
for nonparametri c system i denti fi cati on 3-14
for power spectral densi ty esti mati on 3-5, 3-10,
6-81, 6-275
i n Spectrum Vi ewer 5-106
normal i zati on 3-12
whi te noi se 1-6
wi ndow
appl i ed to peri odogram 3-9
Bartl ett 4-2, 6-20
Bl ackman 4-4, 6-30
boxcar 2-18
Chebyshev 4-9, 6-64
for fi l ter desi gn 2-18
general i zed cosi ne 4-4
Hammi ng 2-20, 4-4, 6-185
Hanni ng 4-4, 6-186
Kai ser 4-4, 6-210
Index
I-28
rectangul ar 2-18, 6-32
shapes, overvi ew 4-2
speci fyi ng for fir1 2-21
tr i angul ar 6-358
wi ndow method
FI R fi l ter desi gn 2-18
mul ti band desi gn 2-21
si ngl e band desi gn 2-20
wi ndow method, FI R fi l ter desi gn
bandpass confi gurati on 6-152
bandstop confi gurati on 6-152
hi ghpass confi gurati on 6-152
l owpass confi gurati on 6-152
Workspace Contents l i st, i n I mport di al og box
5-7
workspace, l oadi ng var i abl es from 5-7
X
X Label edi t box, i n Preferences di al og box 5-23
xcorr 3-2, 6-7, 6-367
and parametr i c model i ng 4-12
xcorr2 6-7, 6-372
xcov 3-2, 6-7, 6-373
Y
Y Label edi t box, i n Preferences di al og box 5-23
yulewalk 2-5, 2-13, 6-5, 6-376
exampl e 2-14
Yul e-Wal ker AR method 3-5, 3-6, 3-19
compared to Wel chs method 3-20
defi ned 3-19
exampl e 3-20, 3-21
Yul e-Wal ker AR method, i n Spectr um Vi ewer
5-107
Yul e-Wal ker equati ons 2-13
Yul e-Wal ker fi l ter desi gn 6-376
Z
zero frequency component, centeri ng wi th fftshift
1-45
zero-order hol d. Seeaveragi ng fi l ter
zero-phase fi l teri ng 6-149
zero-pol e anal ysi s
exampl e 1-30
zero-pol e pl ots 6-385
zero-pol e gai n 1-42
zero-pol e pl ot 5-86, 5-94
vi ewi ng i n Fi l ter Vi ewer 5-94
zero-pol e-gai n form 1-40
converti ng from second-or der secti ons 6-320
converti ng from state-space form 6-338
converti ng to second-or der secti on 6-379
converti ng to state-space 6-383
defi ned 1-33
representi ng i n MATLAB 1-33
speci fyi ng i n SPTool 5-11
zeros and pol es 5-17
i n transfer functi on 1-33
mul ti pl i ci ty of 5-71
Zeros and Pol es check box, Fi l ter Vi ewer 5-86
zoom control s
i n Fi l ter Desi gner 5-31
i n Fi l ter Vi ewer 5-31
i n Si gnal Browser 5-31
i n Spectrum Vi ewer 5-31
i n SPTool 5-31
Zoom I n-X button 5-32
Zoom I n-Y button 5-32
Zoom Out-X button 5-32
Zoom Out-Y button 5-32
zoom per si stence 5-32
Index
I-29
changi ng 5-32
i n Fi l ter Desi gner 5-27
i n Fi l ter Vi ewer 5-26, 5-87
i n Si gnal Browser 5-23, 5-46
i n Spectrum Vi ewer 5-24
zoomi ng
i n Fi l ter Desi gner 5-77
i n Fi l ter Vi ewer 5-87
i n Si gnal Browser 5-46
i n Spectrum Vi ewer 5-103
one-ti me 5-32
persi stent 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-transform 1-15, 1-32
chi rp z-transform (CZT) 4-34, 6-105
di screte Fouri er transform 1-43
Index
I-30

Das könnte Ihnen auch gefallen