You are on page 1of 632

MATLAB

Users Gui de

Si gnal Processi ng

Version 4.0

Tool box



Computation
Programming
Visualization

How to Conta ct The Ma thW orks:

508-647-7000 Phone
508-647-7001 Fax
The MathWorks, I nc. Mai l
24 Pri me Park Way
Nati ck, MA 01760-1500

ht t p: //www. mat hwor ks . com

Web

f t p. mat hwor ks . com

Anonymous FTP server

comp. s of t - s y s . mat l ab

Newsgroup

s uppor t @mat hwor ks . com

Techni cal support

s ugges t @mat hwor ks . com

Product enhancement suggesti ons

bugs @mat hwor ks . com

Bug reports

doc@mat hwor ks . com

Documentati on error reports

s ubs cr i be@mat hwor ks . com

Subscri bi ng user regi strati on

s er v i ce@mat hwor ks . com

Order status, l i cense renewal s, passcodes

i nf o@mat hwor ks . com

Sal es, pri ci ng, and general i nformati on

Signal Processing Toolbox Users Guide

(December 1996)


COPYRI GHT 1988 - 1996 by The MathWorks, I nc. Al l Ri ghts Reserved.

The software descri bed i n thi s document i s furni 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 agreement. No part of thi s manual may be photocopi ed or repro-
duced i n any form wi thout pri or wri tten consent from The MathWorks, I nc

.

U.S. GOVERNMENT: I f Li censee i s acqui ri ng the software on behal f of any uni t or agency of the U. S.
Government, the fol l owi ng shal l appl y:
(a) for uni ts of the Department of Defense:
RESTRI CTED RI GHTS LEGEND: Use, dupl i cati on, or di scl osure by the Government i s subject to restri c-
ti ons as set forth i n subparagraph (c)(1)(i i ) of the Ri ghts i n Techni cal Data and Computer Software Cl ause
at DFARS 252.227-7013.
(b) for any other uni t or agency:
NOTI CE - Notwi thstandi ng any other l ease or l i cense agreement that may pertai n to, or accompany the
del i very of, the computer software and accompanyi ng documentati on, the ri ghts of the Government
regardi ng i ts use, reproducti on and di scl osure are as set forth i n Cl ause 52.227-19(c)(2) of the FAR.
Contractor/manufacturer i s The MathWorks I nc., 24 Pri me Park Way, Nati ck, MA 01760-1500.
M

ATLAB

, S

I MULI NK, Handl e Graphi cs,

and Real -Ti me Workshop are regi stered trademarks of The
MathWorks, I nc.
Other product or brand names are trademarks or regi stered trademarks of thei r respecti ve hol ders.

Pri nti ng Hi story: December 1996 Fi rst pri nti ng for MATLAB 5
PHO NE
FAX
u
M
A
I
L
I NTERNET
@
E-M AI L

i

Contents

Before You Begin

What Is the Signal Processing Toolbox?

. . . . . . . . . . . . . . . . . . . .

xii
How to Use This Manual

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

xiii
Installation

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

xiv
Typographical Conventions

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

xv

Techni cal Notati ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

xvi

1

Signal Processing Basics

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

GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1-3

Extensi bi l i ty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1-3
Representing Signals

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1-4

Vector Representati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1-4
Basic Waveform Generation: Time Vectors 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-8

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

Working with 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 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-19

Frequency Domai n Fi l ter I mpl ementati on . . . . . . . . . . . . . . . .

1-21
Impulse Response

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

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-Pole Analysis

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1-30
Linear System Models

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1-31

Di screte-Ti me System Model s . . . . . . . . . . . . . . . . . . . . . . . . . .

1-31

Transfer Functi on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1-31

Zero-Pol e-Gai n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1-32

State-Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1-33

Parti al Fracti on Expansi on (Resi due Form) . . . . . . . . . . . .

1-34

Second-Order Secti ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1-36

Latti ce Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1-37

Convol uti on Matri x . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1-38

Conti nuous-Ti me System Model s . . . . . . . . . . . . . . . . . . . . . . .

1-39

Li near System Transformati ons . . . . . . . . . . . . . . . . . . . . . . . .

1-40
Discrete Fourier Transform

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1-42
References

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1-45

iii

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

Butterworth Fi l ter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2-9

Chebyshev Type I Fi l ter . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2-10

Chebyshev Type I I Fi l ter . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2-11

El l i pti c Fi l ter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2-12

Bessel Fi l ter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2-13

Di rect I I R Fi l ter Desi gn . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2-14

General i zed Butterworth Fi l ter Desi gn . . . . . . . . . . . . . . . .

2-15
FIR Filter Design

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2-17

Li near Phase Fi l ters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2-18

Wi ndowi ng Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2-19

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

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

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

iv

Contents

Fi l ter Di screti zati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2-41

I mpul se I nvari ance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2-42

Bi l i near Transformati on . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2-42
References

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2-45

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-11
Parseval s Rel ati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-13
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
Maxi mum Entropy Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-19
MUSI C and Ei genvector Anal ysi s Methods . . . . . . . . . . . . . . . 3-21
Ei genanal ysi s Overvi ew . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-21
Control l i ng Subspace Threshol ds . . . . . . . . . . . . . . . . . . . . . 3-23
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-24
v
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-8
Parametric Modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10
Ti me-Domai n Based Model i ng . . . . . . . . . . . . . . . . . . . . . . . . . 4-11
Li near Predi cti on (AR Model i ng) . . . . . . . . . . . . . . . . . . . . . 4-11
Pronys Method (ARMA Model i ng) . . . . . . . . . . . . . . . . . . . . 4-12
Stei gl i tz-McBri de Method (ARMA Model i ng) . . . . . . . . . . . 4-14
Frequency-Domai n Based Model i ng . . . . . . . . . . . . . . . . . . . . . 4-16
Resampling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-20
Cepstrum Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-23
I nverse Compl ex Cepstrum . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-25
Time-Dependent Fourier Transforms and Spectrograms . 4-26
Median Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-27
Communications Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-28
Deconvolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-32
Specialized Transforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-33
Chi rp z-Transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-33
Di screte Cosi ne Transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-35
Hi l bert Transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-37
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-39
vi Contents
5
Interactive Tools
sptool: An Interactive Signal Processing Environment . . . . . 5-2
Overvi ew . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
Using sptool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3
Loadi ng sptool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3
Qui ck Start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3
Exampl e: I mporti ng Si gnal Data from a MAT-Fi l e . . . . . . . . 5-4
Basi c sptool Functi ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-5
Fi l e Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-6
Hel p Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-7
I mporti ng Si gnal s, Fi l ters, and Spectra . . . . . . . . . . . . . . . . . . . 5-8
Loadi ng Vari abl es from the Workspace . . . . . . . . . . . . . . . . . 5-8
Loadi ng Vari abl es from Di sk . . . . . . . . . . . . . . . . . . . . . . . . . 5-9
I mporti ng Workspace Contents and Fi l e Contents . . . . . . . . 5-9
Worki ng wi th Si gnal s, Fi l ters, and Spectra . . . . . . . . . . . . . . . 5-14
Li st Di spl ays i n sptool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-14
Sel ecti ng Data Objects i n sptool . . . . . . . . . . . . . . . . . . . . . . 5-15
Edi ti ng Data Objects i n sptool . . . . . . . . . . . . . . . . . . . . . . . 5-16
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-18
Appl yi ng a Fi l ter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19
Creati ng a Spectrum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19
Vi ewi ng a Spectrum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20
Updati ng a Spectrum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20
Customi zi ng Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-21
Rul er Setti ngs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-22
Col or Setti ngs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-23
Si gnal Browser Setti ngs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-24
Spectrum Vi ewer Setti ngs . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-25
Fi l ter Vi ewer Setti ngs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26
Fi l ter Vi ewer Ti l i ng Setti ngs . . . . . . . . . . . . . . . . . . . . . . . . 5-27
Fi l ter Desi gner Setti ngs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-28
Pl ug-I ns Setti ngs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-29
Savi ng and Di scardi ng Changes to Preferences Setti ngs . . 5-29
vii
Control s for Vi ewi ng and Measuri ng . . . . . . . . . . . . . . . . . . . . 5-30
Zoom Control s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-30
Rul er Control s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-32
Maki ng Si gnal Measurements . . . . . . . . . . . . . . . . . . . . . . . 5-38
Using the Signal Browser:
Interactive Signal Exploration . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-43
Openi ng the Si gnal Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-43
Basi c Si gnal Browser Functi ons . . . . . . . . . . . . . . . . . . . . . . . . 5-44
Si gnal Browser Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-45
Zoom Control s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-45
Rul er and Li ne Di spl ay Control s . . . . . . . . . . . . . . . . . . . . . 5-45
Hel p Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-45
Di spl ay Management Control s . . . . . . . . . . . . . . . . . . . . . . . 5-46
Mai n Axes Di spl ay Area . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-47
The Panner . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-48
Maki ng Si gnal Measurements . . . . . . . . . . . . . . . . . . . . . . . 5-48
Vi ewi ng and Expl ori ng Si gnal s . . . . . . . . . . . . . . . . . . . . . . . . . 5-48
Sel ecti ng and Di spl ayi ng a Si gnal . . . . . . . . . . . . . . . . . . . . 5-48
Panner Di spl ay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-52
Mani pul ati ng Di spl ays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-53
Worki ng wi th Si gnal s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-54
Using the Filter Designer:
Interactive Filter Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-55
Openi ng the Fi l ter Desi gner . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-56
Basi c Fi l ter Desi gner Functi ons . . . . . . . . . . . . . . . . . . . . . . . . 5-57
Fi l ter Desi gner Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-58
Fi l ter Desi gn Panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-59
Zoom Control s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-60
Hel p Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-60
Magni tude Pl ot (Di spl ay) Area . . . . . . . . . . . . . . . . . . . . . . . 5-60
Speci fi cati ons Li nes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-61
Desi gni ng FI R (Fi ni te I mpul se Response) Fi l ters . . . . . . . . . . 5-61
Exampl e: FI R Fi l ter Desi gn, Standard Band Confi gurati on 5-62
Fi l ter Desi gn Opti ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-63
Order Sel ecti on for FI R Fi l ter Desi gn . . . . . . . . . . . . . . . . . 5-63
viii Contents
Desi gni ng I I R (I nfi ni te I mpul se Response) Fi l ters . . . . . . . . . 5-64
Exampl e: Cl assi cal I I R Fi l ter Desi gn . . . . . . . . . . . . . . . . . . 5-64
Fi l ter Desi gn Opti ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-66
Order Sel ecti on for I I R Fi l ter Desi gn . . . . . . . . . . . . . . . . . . 5-66
Savi ng Fi l ter Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-67
Redesi gni ng a Fi l ter Usi ng the Magni tude Pl ot . . . . . . . . . . . . 5-67
Vi ewi ng Frequency Response Pl ots . . . . . . . . . . . . . . . . . . . . . 5-68
Using the Filter Viewer:
Interactive Filter Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-69
Openi ng the Fi l ter Vi ewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-69
Basi c Fi l ter Vi ewer Functi ons . . . . . . . . . . . . . . . . . . . . . . . . . . 5-70
Fi l ter Vi ewer Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-71
Fi l ter I denti fi cati on Panel . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-71
Pl ots Panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-71
Frequency Axi s Setti ngs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-72
Zoom Control s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-72
Hel p Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-72
Mai n Pl ots Area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-73
Vi ewi ng Fi l ter Pl ots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-74
Vi ewi ng Magni tude Response . . . . . . . . . . . . . . . . . . . . . . . . 5-74
Vi ewi ng Phase Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-76
Vi ewi ng Group Del ay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-78
Vi ewi ng a Zero-Pol e Pl ot . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-79
Vi ewi ng I mpul se Response . . . . . . . . . . . . . . . . . . . . . . . . . . 5-80
Vi ewi ng Step Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-81
Using the Spectrum Viewer:
Interactive Spectral Density Analysis . . . . . . . . . . . . . . . . . . . . . 5-82
Openi ng the Spectrum Vi ewer . . . . . . . . . . . . . . . . . . . . . . . . . 5-82
Basi c Spectrum Vi ewer Functi ons . . . . . . . . . . . . . . . . . . . . . . 5-84
Spectrum Vi ewer Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-84
Si gnal I D Panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-85
Spectrum Management Buttons . . . . . . . . . . . . . . . . . . . . . . 5-86
Zoom Control s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-86
Rul er and Li ne Di spl ay Control s . . . . . . . . . . . . . . . . . . . . . 5-86
Hel p Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-86
Mai n Axes Di spl ay Area . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-86
Maki ng Spectrum Measurements . . . . . . . . . . . . . . . . . . . . . 5-87
Vi ewi ng Spectral Densi ty Pl ots . . . . . . . . . . . . . . . . . . . . . . . . . 5-87
ix
Control l i ng and Mani pul ati ng Pl ots . . . . . . . . . . . . . . . . . . . . . 5-88
Changi ng Pl ot Properti es . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-88
Choosi ng Computati on Parameters . . . . . . . . . . . . . . . . . . . 5-88
Computati on Methods and Parameters . . . . . . . . . . . . . . . . 5-90
Setti ng Confi dence I nterval s . . . . . . . . . . . . . . . . . . . . . . . . . 5-92
Example: Generation of Bandlimited Noise . . . . . . . . . . . . . . . 5-93
Create, I mport, and Name a Si gnal . . . . . . . . . . . . . . . . . . . . . 5-93
Create a Fi l ter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-95
Appl y the Fi l ter to a Si gnal . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-97
Vi ew and Pl ay the Si gnal s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-98
Compare Spectra of Both Si gnal s . . . . . . . . . . . . . . . . . . . . . . 5-100
6
Reference
x Contents





Before You Begi n

xii What Is the Signal Processing Toolbox?
xiii How to Use This Manual
xiv Installation
xv Typographical Conventions
xvi

Techni cal Notati ons



Before You Begi n

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 e-
mentati 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 func-
ti ons usi ng the statement

t y pe

f unct i on_name

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.
Secondl y, 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 e-
mentati 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 mea-
sure 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
usi ng drop-down menus

How to Use Thi s M anual

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, 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. See


Chapter 2, Fi l ter Desi gn, for a detai l ed expl anati on of usi ng the Si gnal Pro-
cessi 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. See


Chapter 5, I nteracti ve Tool s, for an overvi ew of the i nteracti ve, graphi cal
user i nterface (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 fi l ter and spectral anal ysi s
Fi nal l y, for a di scussi on of vari ous speci al i zed tool box functi ons, see


Chapter 4, Speci al Topi cs, for a vari ety of 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 nteracti ve Tool s, for an overvi ew of the i nteracti ve, graphi cal
user i nterface (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 fi l ter and spectral anal ysi s



Before You Begi n

xiv
All toolbox users

shoul d use Chapter 6, Reference, for i nformati on on spe-
ci 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 on. Many ref-
erence descri pti ons al so i ncl ude hel pful exampl es, a descri pti on of the func-
ti 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

r andn

. I n
these cases, to dupl i cate the resul ts i n the exampl e, type

r andn( ' s eed' , 0)

before runni ng the exampl e.

Installation

To i nstal l thi s tool box on a workstati on or l arge machi ne, see the

MATLAB
I nstallation Guide for UNI X

. To i nstal l the tool box on a PC or Maci ntosh, see
the

MATLAB I nstallation Guide for PC and Macintosh

.
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

s i gnal

wi thi n the mai n tool box di rec-
tory or fol der.

Typographi cal C onventi ons

xv

Typographical Conventions

To Indicate... This Manual Uses... Example

Exampl e code

Monos pace t y pe.

To assi gn the val ue 5 to

A

, enter

A = 5

MATLAB
output

Monos pace t y pe.

MATLAB responds wi th

A =
5

Functi on names

Monos pace t y pe.

The

cos

functi on 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 nforma-
ti on.
Keys

Boldface

wi th an
i ni ti al capi tal l etter.
Press the

Return

key.
Menu names,
i tems, and GUI
control s

Boldface

wi th an
i ni ti al capi tal l etter.
Choose the

File

menu.
Mathemati cal
expressi ons
Vari abl es i n

italics.


Functi ons, opera-
tors, and constants
i n standard type.
Thi s vector represents
the pol ynomi al

p =x

2

+ 2

x

+ 3



Before You Begi n

xvi

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 rst el ement of a data sequence or
l ter, correspondi ng to zero l ag.




Anal og frequency i n radi ans per second.

w

Di gi tal frequency i n radi ans per second.

f

Di gi tal frequency i n Hertz.



1

Si gnal Processi ng Basi cs

1-2 Signal Processing Toolbox Central Features
1-4 Representing Signals
1-6 Basic Waveform Generation: Time Vectors and Sinusoids
1-13 Working with Data
1-14 Filter Implementation and Analysis
1-17 filter Function Implementation and Initial Conditions
1-19 Other Functions for Filtering
1-23 Impulse Response
1-24 Frequency Response
1-30 Zero-Pole Analysis
1-31 Linear System Models
1-42 Discrete Fourier Transform
1-45 References

1

Si gnal Processi ng Basi cs

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.
There are many exampl es throughout the chapter that 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:


f i l t er

appl i es a di gi tal fi l ter to a data sequence.


f f t

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 work-
horses 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 sec-
ti on) and convert between representati ons.

Si gnal Processi ng Toolbox C entral 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 sup-
port for the key areas of fi l ter desi gn and spectral anal ysi s. I t i s easy to i mpl e-
ment 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 s-
crete 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.

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 (GUI ). 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 graph-
i cal envi ronment for si gnal vi ewi ng, fi l ter desi gn and i mpl ementati on, and
fi l ter 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 compu-
tati 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

Si gnal Processi ng Basi cs

1-4

Representing Signals

The central data construct i n MATLAB i s the

numeric array

, an ordered col l ec-
ti 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 state-
ment

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 ]

Representi ng Si gnals

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

Si gnal Processi ng Basi cs

1-6

Basic Waveform Generation: Time Vectors and Sinusoids

There are a vari ety of tool box functi ons for generati ng waveforms. Most requi re
that you begi n wi th a vector that represents 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: . 001: 1) ' ;

where MATLABs col on operator creates a 1001-el ement row vector that repre-
sents 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 to 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 = s i n( 2*pi *50*t ) + 2*s i n( 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

y n = y + 0. 5*r andn( s i z e( t ) ) ;
pl ot ( t ( 1: 50) , y n( 1: 50) )
0 0.01 0.02 0.03 0.04 0.05
-4
-3
-2
-1
0
1
2
3
4

Basi c Waveform G enerati on: Ti me Vectors and Si nusoi ds

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 g-
nal 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: . 001: 1) ' ;
y = [ 1; z er os ( 99, 1) ] ; % i mpul s e
y = ones ( 100, 1) ; % s t ep ( f i l t er as s umes 0 i ni t i al cond. )
y = t ; % r amp
y = t . ^2;
y = s quar e( 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 s quar e( 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 z er os ( 1, 5) ] ' ;

To dupl i cate col umn vector

a

i nto a matri x wi thout performi ng any mul ti pl i ca-
ti on, use MATLABs col on operator and the

ones

functi on:

c = a( : , ones ( 1, 3) ) ;

1

Si gnal Processi ng Basi cs

1-8

Common Periodic Waveforms

The tool box provi des functi ons for generati ng wi del y used peri odi c waveforms:


s awt oot h

generates a sawtooth wave wi th peaks at


1 and a peri od of 2


. An
opti onal

wi dt h

parameter speci fi es a fracti onal mul ti pl e of 2


at whi ch the
si gnal s maxi mum occurs.


s quar e

generates a square wave wi th a peri od of 2


. An opti onal parameter
speci fi es

duty cycle

, 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 = s awt oot h( 2*pi *50*t ) ;
pl ot ( t , x ) , ax i s ( [ 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:


gaus pul s

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

Basi c Waveform G enerati on: Ti me Vectors and Si nusoi ds

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.


chi r p

generates a l i near swept-frequency cosi ne si gnal . An opti onal param-
eter 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 = chi r p( t , 0, 1, 150) ;

To pl ot the spectrogram, use

s pecgr am( y , 256, 1000, 256, 250)

The Pulstran Function

The

pul s t r an

functi on generates pul se trai ns from ei ther conti nuous or sam-
pl 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 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.
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

Si gnal Processi ng Basi cs

1-10

The pul se trai n i s constructed by passi ng the name of the

gaus pul s

functi on to
pul s t r an, 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 = pul s t r an( T, D, ' gaus pul s ' , 10E3, 0. 5) ;
pl ot ( T, Y)
The Sinc Function
The s i nc 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
si nc t ( )
1
2
------ e
j t
d

=
sin( )

x
x
Basi c Waveform G enerati on: Ti me Vectors and Si nusoi ds
1-11
To pl ot the s i nc functi on for a l i nearl y spaced vector wi th val ues rangi ng from
5 to 5,
x = l i ns pace( 5, 5) ; y = s i nc( x ) ;
pl ot ( x , y )
The Dirichlet Function
The tool box functi on di r i c 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
diric( )
, , , , ...
sin( / )
sin( / )
( )
x
x k k
nx
n x
k n

t t

'

1 2 0 1 2
2
2
1

otherwise

1 Si gnal Processi ng Basi cs


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 = l i ns pace( 0, 4*pi , 300) ;
pl ot ( x , di r i c( x , 7) )
pl ot ( x , di r i c( 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
Worki ng wi th Data
1-13
Working with Data
The exampl es i n the precedi 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
Usi ng a MATLAB or tool box functi on, such as s i n, cos , s awt oot h, s quar e, or
s i nc
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:
Loadi ng data from an ASCI I fi l e or MAT-fi l e wi th MATLABs l oad command
Readi ng the data i nto MATLAB wi th a l ow-l evel fi l e I /O functi on, such as
f open, f r ead, and f s canf
Devel opi ng 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 For-
tran or C, for exampl e) that converts your data i nto MAT-fi l e formatsee the
MATLAB Application Programming I nterface reference manual for detai l s.
MATLAB reads such fi l es usi ng the l oad command.
Si mi l ar techni ques are avai l abl e for exporti ng data generated wi thi n
MATLAB. See Using MATLAB for more detai l s on i mporti ng and exporti ng
data, and see the onl i ne MATLAB Functi on Reference for descri pti ons of fi l e
l oadi ng and I /O routi nes.
1 Si gnal Processi ng Basi cs
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 f i l t er
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 func-
ti 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 conv 2 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 = r andn( 5, 1) ; % a r andom v ect or of l engt h 5
h = [ 1 1 1 1] /4; % l engt h 4 av er agi ng f i l t er
y = conv ( h, x ) ;
y n h n x n h n m x m
m
( ) ( ) ( ) ( ) ( )

Fi lter Implementati on and Analysi s


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. 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.
NOTE The l ter coefci ents start wi th subscri pt 1, rather than 0. Thi s reects
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 coef-
fi ci ents.
Filter Coefcients and Filter Names
Many standard names for l ters reect the number of a and b coef-
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 names AR, MA, and ARMA are usual l y appl i ed to l ters associ ated
wi th l tered stochasti c processes.
Y z H z X z
b b z b nb z
a a z a na z
X z
nb
na
( ) ( ) ( )
( ) ( )
...
( )
( ) ( )
...
( )
( )
+ + + +
+ + + +


1 2 1
1 2 1
1
1
1 Si gnal Processi ng Basi cs
1-16
Filtering with the lter 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 f i l t er functi on. For
exampl e, a si mpl e si ngl e-pol e fi l ter (l owpass) i s:
b = 1; % numer at or
a = [ 1 0. 9] ; % denomi nat or
where the vectors b and a represent the coeffi ci ents of a fi l ter i n transfer func-
ti on form. To appl y thi s fi l ter to your data:
y = f i l t er ( b, a, x ) ;
f i l t er 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,
f i l t er di vi des the coeffi ci ents by a( 1) pri or to i mpl ementi ng the di fference
equati on.
y n a y n a na y n na b x n b x n b nb x n nb ( ) ( ) ( )
...
( ) ( ) ( ) ( ) ( ) ( )
...
( ) ( ) + + + + + + + + 2 1 1 1 2 1 1
y n b x n b x n b nb x n nb a y n a na y n na ( ) ( ) ( ) ( ) ( )
...
( ) ( ) ( ) ( )
...
( ) ( ) + + + + + 1 2 1 1 2 1 1

y b x
y b x b x a y
y b x b x b x a y a y
( ) ( ) ( )
( ) ( ) ( ) ( ) ( ) ( )
( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( )
1 1 1
2 1 2 2 1 2 1
3 1 3 2 2 3 1 2 2 3 1

( ) +
+ +
M
fi lter Functi on Implementati on and Ini ti al C ondi ti ons
1-17
filter Function Implementation and Initial Conditions
f i l t er 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, f i l t er computes the di fference equati ons
I n i ts most basi c form, f i l t er 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 f i l t er , or access
the fi nal del ay outputs usi ng a second output parameter:
[ y , z f ] = f i l t er ( b, a, x , z i )
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:
x 1 = r andn( 5000, 1) ; % t wo r andom s equences t o
x 2 = r andn( 5000, 1) ; % s er v e as s i mul at ed dat a
Perhaps the fi rst sequence, x 1, corresponds to the fi rst 10 mi nutes of data and
the second, x 2, to an addi ti onal 10 mi nutes. The whol e sequence i s
x = [ x 1; x 2] . I f there i s not suffi ci ent memory to hol d the combi ned sequence,
fi l ter the subsequences x 1 and x 2 one at a ti me. To ensure conti nui ty of the fi l -
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
z m
z m
z m
b x m z m
b x m z m a y m
b n x m z m a n y m
b n x m a n
n
n
n
( )
( )
( )
( )
( ) ( ) ( )
( ) ( ) ( ) ( ) ( )
( ) ( ) ( ) ( ) ( )
( ) ( ) (
1
2
1
1
2
1
1 1
2 1 2
1 1 1
M M M

+
+
+


)) ( ) y m
1 Si gnal Processi ng Basi cs
1-18
tered sequences, use the fi nal condi ti ons from x 1 as i ni ti al condi ti ons to fi l ter
x 2:
[ y 1, z f ] = f i l t er ( b, a, x 1) ;
y 2 = f i l t er ( b, a, x 2, z f ) ;
The f i l t i c functi on generates i ni ti al condi ti ons for f i l t er . f i l t i c computes
the del ay vector to make the behavi or of the fi l ter refl ect past i nputs and out-
puts that you speci fy. To obtai n the same output del ay val ues z f as above usi ng
f i l t i c:
z f = f i l t i c( b, a, f l i pud( y 1) , f l i pud( x 1) ) ;
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.
O ther Functi ons for Fi lteri ng
1-19
Other Functions for Filtering
I n addi ti on to f i l t er , there are several other functi ons i n the Si gnal Pro-
cessi ng Tool box that perform the basi c fi l teri ng operati on. These functi ons are
upf i r dn, whi ch performs FI R fi l teri ng wi th resampl i ng, f i l t f i l t , whi ch el i m-
i nates phase di storti on i n the fi l teri ng process, and f f t f i l t , whi ch performs
the FI R fi l teri ng operati on i n the frequency domai n.
Multirate Filter Bank Implementation
The functi on upf i r dn 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) down-
sampl 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 accom-
pl i shed by y = upf i r dn( 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 upf i r dn 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 ndepen-
dentl y through each FI R fi l ter, resul ti ng i n a matri x of output si gnal s.
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 f i l t er or conv ), si mpl y del ay the output by a fi xed
P
x(n) y(n)
FIR
H
Q
1 Si gnal Processi ng Basi cs
1-20
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 f i l t f i l t 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 f i l t f i l t 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). Con-
si der the processi ng scheme
When | z| = 1, that i s z =e
jw
, the output reduces to X(e
jw
)| H(e
jw
)|
2
. Gi ven al l
the sampl es of the sequence x(n), a doubl y fi l tered versi 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 = s i n( 2*pi *t *3) +. 25*s i n( 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
O ther Functi ons for Fi lteri ng
1-21
Now create a 10-poi nt averagi ng FI R fi l ter, and fi l ter x usi ng both f i l t er and
f i l t f i l t for compari son:
b = ones ( 1, 10) /10; % 10 poi nt av er agi ng f i l t er
y = f i l t f i l t ( b, 1, x ) ; % noncaus al f i l t er i ng
y y = f i l t er ( b, 1, x ) ; % nor mal f i l t er i ng
pl ot ( t , x , t , y , ' ' , t , y y , ' : ' )
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 f i l t er and f i l t f i l t di ffer; the dashed
(f i l t f i l t ) l i ne i s i n phase wi th the ori gi nal 3 Hz si nusoi d, whi l e the dotted
(f i l t er ) 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 f i l t f i l t .
f i l t f i l t 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 resul ts, make sure the sequence you are fi l teri ng has
l ength at l east three ti mes the fi l ter order, and that i t tapers to zero on both
edges.
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
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 Si gnal Processi ng Basi cs
1-22
more conveni ent for a parti cul ar operati on, but you can al ways accompl i sh a
gi ven operati 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 s-
crete Fouri er transform (DFT) of the i nput sequence wi th the quoti ent of the
DFT of the fi l ter,
n = l engt h( x ) ;
y = i f f t ( f f t ( x ) . *f f t ( b, n) . /f f t ( a, n) ) ;
Thi s computes resul ts that are i denti cal to f i l t er , 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 = f f t f i l t ( 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 v-
al ent to f i l t er ( 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
i mp = [ 1; z er os ( 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 = f i l t er ( b, a, i mp) ;
The i mpz 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 s t em functi on):
i mpz ( b, a)
The pl ot shows the exponenti al decay h( n) = 0. 9n of the si ngl e pol e system.
x n
n
n
( )
,
,

'

1 1
0 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 Si gnal Processi ng Basi cs
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
f r eqz 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] = f r eqz ( b, a, n)
returns the n-poi nt compl ex frequency response, H(e
jw
), of the di gi tal fi l ter:
I n i ts si mpl est form, f r eqz 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. f r eqz 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.
f r eqz 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-order Chebyshev type I fi l ter. The cal l to f r eqz speci fi es a
sampl i ng frequency Fs of 1000 Hz:
[ b, a] = cheby 1( 12, 0. 5, 200/500) ;
[ h, f ] = f r eqz ( b, a, 256, 1000) ;
Because the parameter l i st i ncl udes a sampl i ng frequency, f r eqz 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
b b e b nb e
a a e a na e
j
j j nb
j j na
( )
( ) ( )
...
( )
( ) ( )
...
( )
( )
( )

+ + + +
+ + + +


1 2 1
1 2 1
Frequency Response
1-25
Frequency Normalization Thi s tool box uses the conventi on that uni t fre-
quency i s the Nyqui st frequency, dened as hal f the sampl i ng frequency. The
cutoff frequency parameter for al l basi c 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 f r eqz 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] = but t er ( 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 f r eqz :
f r eqz ( 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 Si gnal Processi ng Basi cs
1-26
f r eqz can al so accept a vector of arbi trary frequency poi nts for use i n the fre-
quency response cal cul ati on. For exampl e,
w = l i ns pace( 0, pi ) ;
h = f r eqz ( 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
f r eqs 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 f r eqz ; 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;
angl e returns the phase angl e i n radi ans. To extract and pl ot the magni tude
and phase of a Butterworth fi l ter:
[ b, a] = but t er ( 6, 300/500) ; [ h, w] = f r eqz ( b, a, 512, 1000) ;
m = abs ( h) ; p = angl e( h) ;
s emi l ogy ( w, com) ;
pl ot ( 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 unwr ap functi on i s al so useful i n frequency anal ysi s. unwr ap 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 360, as needed. To see how unwr ap i s useful , desi gn a 25th-order l ow-
pass FI R fi l ter:
h = f i r 1( 25, 0. 4) ;
Obtai n the fi l ters frequency response wi th f r eqz , and pl ot the phase i n
degrees:
[ H, f ] = f r eqz ( h, 1, 512, 2) ;
pl ot ( f , angl e( H) *180/pi ) ; gr i d
I t i s di ffi cul t to di sti ngui sh the 360jumps (an arti fact of the arctangent func-
ti on i nsi de angl e) from the 180jumps 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 Si gnal Processi ng Basi cs
1-28
Use unwr ap to el i mi nate the 360jumps:
pl ot ( f , unwr ap( angl e( H) ) *180/pi ) ; gr i d
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
jw
), then the
group del ay i s
where i s the phase angl e of H(e
jw
). Compute group del ay wi th
[ gd, w] = gr pdel ay ( 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 phase delay 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] = but t er ( 10, 200/1000) ;
gd = gr pdel ay ( b, a, 128) ;
[ h, f ] = f r eqz ( b, a, 128, 2000) ;
pd = unwr ap( angl e( h) ) *( 2000/( 2*pi ) ) . /f ;
pl ot ( f , gd, ' ' , f , pd, ' ' )
ax i s ( [ 0 1000 30 30] )
0 100 200 300 400 500 600 700 800 900 1000
-30
-20
-10
0
10
20
30
Solid = Group Delay, Dashed = Phase Delay
1 Si gnal Processi ng Basi cs
1-30
Zero-Pole Analysis
The zpl ane 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
z er = 0. 5;
pol = . 9*ex p( j *2*pi *[ 0. 3 . 3] ' ) ;
The zero-pol e pl ot for the fi l ter i s:
z pl ane( z er , pol )
For a system i n zero-pol e form, suppl y col umn vector arguments z and p to zpl ane:
z pl ane( z , p)
For a system i n transfer functi on form, suppl y row vectors b and a as argu-
ments to z pl ane:
z pl ane( b, a)
I n thi s case z pl ane fi nds the roots of b and a usi ng the r oot s functi on and pl ots
the resul ti ng zeros and pol es.
See Li near System Model s on page 1-31 for detai l s on zero-pol e and transfer
functi on representati on of systems.
0 9
2 0 3
.
( . )
e
j
0 9
2 0 3
.
( . )
e
j
-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
Li near System M odels
1-31
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 sta-
bi 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
Tra nsfer 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 s-
crete-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 b z b nb z
a a z a na z
X z
nb
na
( )
( ) ( )
...
( )
( ) ( )
...
( )
( )
+ + + +
+ + + +


1 2 1
1 2 1
1
1
1 Si gnal Processi ng Basi cs
1-32
Zero- Pole- Ga in
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 pol y and r oot s 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 zeros and pol es of thi s fi l ter are
q = r oot s ( b)
q =
0. 7500 + 1. 1990i
0. 7500 1. 1990i
p = r oot s ( 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 z q z q n
z p z p z p n
( )
( )
( )
( ( ))( ( ))...( ( ))
( ( ))( ( ))...( ( ))



1 2
1 2
Li near System M odels
1-33
Returni ng to the ori gi nal pol ynomi al s,
bb = k*pol y ( q)
bb =
2. 0000 3. 0000 4. 0000
aa = pol y ( 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 r oot s functi on mi sses the zero for z equal to 0. I n fact, i t
mi sses pol es and zeros for z equal 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 r-
cumvent the probl em, however, si mpl y append zeros to make the vectors the
same l ength before usi ng the r oot s functi on, for exampl e, b = [ b 0] .
Sta te- Spa ce
I t i s al ways possi bl e to represent a di gi tal fi l ter, or a system of di fference equa-
ti 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 order 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.
H z
z z
z z z
z z z
z z z
( )
+ +
+ + +

+ +
+ + +


2 3 4
1 3 3
2 3 4
3 3 1
1 2
1 2 3
3 2
3 2
x n Ax n Bu n
y n Cx n Du n
( ) ( ) ( )
( ) ( ) ( )
+ +
+
1
1 Si gnal Processi ng Basi cs
1-34
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.
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 form:
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 processi ng
extensi vel y, however, consul t the Control System Tool box for a comprehensi ve
l i brary of state-space tool s.
Pa r tia l Fra ction Ex pa nsion (Residue For m)
Each transfer functi on al so has a correspondi ng partial fraction expansion or
residue form 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 r es i duez functi on i n the Si gnal Processi ng Tool box converts transfer func-
ti ons to and from the parti al fracti on expansi on form. The z on the end of r es -
i duez stands for z-domai n, or di screte domai n. r es i duez 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. r es -
i duez determi nes that two pol es are the same i f the magni tude of thei r di ffer-
ence i s smal l er than 0.1 percent of ei ther of the pol es magni tudes.
Y z H z U z H z C zI A B D ( ) ( ) ( ) ( ) ( ) +

, where
1

b z
a z
r
p z
r n
p n z
k k z k m n z
m n
( )
( )
( )
( )
( )
( )
( ) ( ) ( )
( )

+ +

+ + + + +


1
1 1 1
1 2 1
1 1
1
L L

r j
p j z
r j
p j z
r j s
p j z
r
s
r
( )
( )
( )
( ( ) )
( )
( ( ) ) 1
1
1
1
1
1 1 2 1

+
+

+ +
+


L
Li near System M odels
1-35
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
i s
b = [ 4 8] ;
a = [ 1 6 8] ;
[ r , p, k] = r es i duez ( 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:
H z
z
z z
( )
+
+ +


4 8
1 6 8
1
1 2
H z
z z
( )

+
+
+

12
1 4
8
1 2
1 1
h n n
n n
( ) ( ) ( ) , , , , ... + 12 4 8 2 0 1 2
1 Si gnal Processi ng Basi cs
1-36
To veri fy thi s i n MATLAB,
i mp = [ 1 0 0 0 0] ;
r es pt f = f i l t er ( b, a, i mp)
r es pt f =
4 32 160 704 2944
r es pr es = f i l t er ( r ( 1) , [ 1 p( 1) ] , i mp) + f i l t er ( r ( 2) , [ 1 p( 2) ] , i mp)
r es pr es =
4 32 160 704 2944
Second- O rder Sections
Any transfer functi on H(z) has a second-order secti ons representati on,
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 s os . Each row of s os contai ns a si ngl e second-order secti on,
where the row el ements are the three numerator and three denomi nator coef-
fi 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 ons 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 pos-
si 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 z p2s os and s s 2s os , 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.
H z H z
b b z b z
a a z a z
k
k
L
k k k
k k k
k
L
( ) ( )
+ +
+ +


1
0 1
1
2
2
0 1
1
2
2
1

sos
b b b a a a
b b b a a a
b b b a a a
L L L L L L

1
]
1
1
1
1
01 11 21 01 11 21
02 12 22 02 12 22
0 1 2 0 1 2
M M M M M M
Li near System M odels
1-37
La ttice Str ucture
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
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)
1 Si gnal Processi ng Basi cs
1-38
The tool box functi on t f 2l at c 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 = t f 2l at c( 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 l at c2t f 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 = l at c2t f ( 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 l at cf i l t .
Convolution M a trix
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 conv mt x 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
Li near System M odels
1-39
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 = r andn( 3, 1) ;
C = conv mt x ( 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
y 1 = C*x ;
y 2 = conv ( b, x ) ;
Type thi s exampl e i nto MATLAB; the resul ts for y 1 and y 2 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 equa-
ti ons as a set of fi rst-order di fferenti al equati ons. I n matri x or state-space form,
you can express the equati ons as
x Ax Bu
y Cx Du
+
+
1 Si gnal Processi ng Basi cs
1-40
where u i s a vector of nu i nputs, x i s an nx-el ement state vector, and y i 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 trans-
form 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, r es i due deter-
mi nes the parti al fracti on expansi on of the system. See the descri pti on of r es -
i due i n the MATLAB Language Reference Manual 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 to on the top
Y s H s U s ( ) ( ) ( )
H s C sI A B D ( ) ( ) +
1

H s
b s
a s
b s b s b nb
a s a s a na
nb nb
na na
( )
( )
( )
( ) ( ) ( )
( ) ( ) ( )

+ + + +
+ + + +

1 2 1
1 2 1
1
1
L
L
H s
z s
p s
k
s z s z s z n
s p s p s p n
( )
( )
( )
( ( ))( ( ))...( ( ))
( ( ))( ( ))...( ( ))



1 2
1 2
Li near System M odels
1-41
of the chart and read the functi on name(s) at the i ntersecti on of the row and
col umn:
Many of the tool box fi l ter desi gn functi ons use these functi ons i nternal l y. For
exampl e, the z p2s s functi on converts the pol es and zeros of an anal og proto-
type i nto the state-space form requi red for creati on of a Butterworth, Cheby-
shev, 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 2 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
lter
Second-
order
sections
Convol-
ution
matrix
Transfer
function
t f 2s s t f 2z p
r oot s
r es i duez
r es i due
t f 2l at c convmt x
State space s s 2t f s s 2z p s s 2s os
Zero-pole
gain
z p2t f
pol y
z p2s s z p2s os
Partial
fraction
r es i duez
r es i due
Lattice lter l at c2t f
Second-order
sections
s os 2t f s os 2s s s os 2z p
Convolution
matrix
1 Si gnal Processi ng Basi cs
1-42
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 f f t and i f f t to compute the di screte Fouri er
transform and i ts i nverse, respecti vel y. For the i nput sequence x and i ts trans-
formed versi on X (the di screte-ti me Fouri er transform at equal l y spaced fre-
quenci 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, whi ch was wri tten by an appl i ed mathemati ci an, uses the
negati ve j for the f f t 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.
f f t , 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, f f t computes the DFT of the vector; i f x i s a rectangul ar
array, f f t computes the DFT of each array col umn.
X k x n W
N
kn
n
N
( ) ( ) + +

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

1
1
1
0
1
W e
N
j
N

_
,
2
Di screte Fouri er Transform
1-43
For exampl e, create a ti me vector and si gnal :
t = ( 0: 1/99: 1) ; % t i me v ect or
x = s i n( 2*pi *15*t ) + s i n( 2*pi *40*t ) ; % s i gnal
The DFT of the si gnal , and the magni tude and phase of the transformed
sequence, are then
y = f f t ( x ) ; % Comput e DFT of x .
m = abs ( y ) ; p = unwr ap( angl e( y ) ) ; % mag. and phas e
To pl ot the magni tude and phase,
f = ( 0: l engt h( y ) 1) *99/l engt h( y ) ; % f r equency v ect or
pl ot ( f , m)
s et ( gca, ' XTi ck' , [ 15 40 60 85] ) ;
pl ot ( f , p*180/pi )
s et ( gca, ' XTi ck' , [ 15 40 60 85] ) ;
A second argument to f f t speci fi es a number of poi nts n for the transform, rep-
resenti ng DFT l ength:
y = f f t ( x , n) ;
I n thi s case, f f t 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.
Executi on ti me for f f t depends on the l ength n of the DFT i t performs:
For any n that i s a power of two, f f t 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
15 40 60 85
0
10
20
30
40
50
15 40 60 85
-1500
-1000
-500
0
1 Si gnal Processi ng Basi cs
1-44
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, f f t 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, f f t 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, f f t cannot use an FFT al gori thm, and i nstead per-
forms the sl ower, computati on-i ntensi ve DFT di rectl y.
The i nverse di screte Fouri er transform functi on i f f t 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 = s i n( 2*pi *120*t ) ;
y = r eal ( i f f t ( f f t ( x ) ) ) ;
Thi s tool box al so i ncl udes functi ons for the two-di mensi onal FFT and i ts
i nverse, f f t 2 and i f f t 2. 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 f f t or f f t 2 functi on
so the zero frequency component i s at the center of the sequence. The MATLAB
functi on f f t s hi f t moves the zero frequency component to the center of a vector
or matri x.
References
1-45
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-Rate Signal Processing. Engl ewood
Cl i ffs, NJ: Prenti ce Hal l , 1983. Pgs. 88-91.
2 I EEE. Programs for 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-Time Signal 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 mage Processing. New York: John Wi l ey & Sons, 1991.
8 Perci val , D.B., and A.T. Wal den. Spectral Analysis for Physical Applica-
tions: Multitaper and Conventional Univariate Techniques. 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 Pro-
cessing. 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 Averagi ng Over Short, Modi fi ed Peri -
odograms. I EEE Trans. Audio Electroacoust. Vol . AU-15 (June 1967).
Pgs. 70-73.
1 Si gnal Processi ng Basi cs
1-46



2

Fi l ter Desi gn

2-2 Filter Requirements and Specification
2-4 IIR Filter Design
2-6

Cl assi cal I I R Fi l ter Desi gn Usi ng Anal og Prototypi ng

2-9

Compari son of Cl assi cal I I R Fi l ter Types

2-17 FIR Filter Design
2-18

Li near Phase Fi l ters

2-19

Wi ndowi ng Method

2-22

Mul ti band FI R Fi l ter Desi gn wi th Transi ti on Bands

2-27

Constrai ned Least Squares FI R Fi l ter Desi gn

2-31

Arbi trary-Response Fi l ter Desi gn

2-37 Special Topics in IIR Filter Design
2-38

Anal og Prototype Desi gn

2-39

Frequency Transformati on

2-41

Fi l ter Di screti zati on

2-45 References

2

Fi lter Desi gn

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 nfinite I mpulse Response

(I I R) and

Finite I mpulse Response

(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] = but t er ( 5, 30/50) ;
y = f i l t er ( b, a, x ) ;

The second i nput argument to

but t er

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 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 argu-
ment. Thi s tool box uses the conventi on that uni t frequency i s the
Nyqui st frequency, dened as hal f the sampl i ng frequency. The normal -
i zed frequency, therefore, i s al ways i n the i nterval 0


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.

Fi lter Requi rements and Speci fi cati on

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 (

Ws Wp

,
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 ec-
ti 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.
Wp Ws
Rp/20
10
Frequency
Fi l ter
Magni tude
0
Rs /20
10
1

2

Fi lter Desi gn

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

f i l t f i l t

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 gura-
ti 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

y ul ewal k

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

max f l at

i s di scussed i n the sec-
ti on General i zed Butterworth Fi l ter Desi gn on page 2-15.
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 Fi lter Desi gn

2-5

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

Method Description Functions

Anal og Proto-
typi ng
Usi ng the pol es and zeros of
a cl assi cal l owpass proto-
type l ter i n the conti nuous
(Lapl ace) domai n, obtai n a
di gi tal l ter through fre-
quency transformati on and
l ter di screti zati on.
Compl ete desi gn functi ons:

bes s el f

,

but t er

,

cheby 1

,

cheby 2

,

el l i p

Order esti mati on functi ons:

but t or d

,

cheb1or d

,

cheb2or d

,

el l i por d

Lowpass anal og prototype functi ons:

bes s el ap

,

but t ap

,

cheb1ap

,

cheb2ap

,

el l i pap

Frequency transformati on functi ons:

l p2bp

,

l p2bs

,

l p2hp

,

l p2l p

Fi l ter di screti zati on functi ons:

bi l i near

,

i mpi nv ar

Di rect Desi gn Desi gn di gi tal 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.

y ul ewal k

Parametri c
Model i ng

*

Fi nd a di gi tal l ter that
approxi mates a prescri bed
ti me or frequency domai n
response.
Ti me-domai n model i ng functi ons:

l pc

,

pr ony

,

s t mcb

Frequency-domai n model i ng functi ons:

i nv f r eqs

,

i nv f r eqz

General i zed
Butterworth
Desi gn
Desi gn l owpass Butter-
worth l ters wi th more
zeros than pol es.

max f l at

2

Fi lter Desi gn

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 char-
acteri 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 Cla ssica l 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 fre-
quency = 1 Hz). For a hi ghpass fi l ter, append the stri ng

' hi gh'

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

' s t op'


for the bandstop confi gurati on.

Filter Type Design Function

Butterworth

[ b, a] = but t er ( n, Wn,

opt i ons

)
[ z , p, k] = but t er ( n, Wn,

opt i ons

)
[ A, B, C, D] = but t er ( n, Wn,

opt i ons

)
Chebyshev type I [ b, a] = cheby 1( n, Rp, Wn, opt i ons)
[ z , p, k] = cheby 1( n, Rp, Wn, opt i ons)
[ A, B, C, D] = cheby 1( n, Rp, Wn, opt i ons)
Chebyshev type I I [ b, a] = cheby 2( n, Rs , Wn, opt i ons)
[ z , p, k] = cheby 2( n, Rs , Wn, opt i ons)
[ A, B, C, D] = cheby 2( n, Rs , Wn, opt i ons)
El l i pti c [ b, a] = el l i p( n, Rp, Rs , Wn, opt i ons)
[ z , p, k] = el l i p( n, Rp, Rs , Wn, opt i ons)
[ A, B, C, D] = el l i p( n, Rp, Rs , Wn, opt i ons)
Bessel (anal og onl y) [ b, a] = bes s el f ( n, Wn, opt i ons)
[ z , p, k] = bes s el f ( n, Wn, opt i ons)
[ A, B, C, D] = bes s el f ( n, Wn, opt i ons)
IIR Fi lter Desi gn
2-7
Here are some exampl e di gi tal fi l ters:
[ b, a] = but t er ( 5, . 4) ; % l owpas s But t er wor t h
[ b, a] = cheby 1( 4, 1, [ . 4 . 7] ) ; % bandpas s Cheby s hev t y pe I
[ b, a] = cheby 2( 6, 60, . 8, ' hi gh' ) ; %hi ghpas s Cheby s hev t y pe I I
[ b, a] = el l i p( 3, 1, 60, [ . 4 . 7] , ' s t op' ) ; % bands t op el l i pt i c
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] = but t er ( 5, . 4, ' s ' ) ; % anal og But t er wor t h f i l t er
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.
Designing IIR Filters to Frequency Doma in Specica tions
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] = but t or d( Wp, Ws , Rp, Rs )
Chebyshev type I [ n, Wn] = cheb1or d( Wp, Ws , Rp, Rs )
Chebyshev type I I [ n, Wn] = cheb2or d( Wp, Ws , Rp, Rs )
El l i pti c [ n, Wn] = el l i por d( Wp, Ws , Rp, Rs )
2 Fi lter Desi gn
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 but t er functi on:
[ n, Wn] = but t or d( [ 1000 2000] /5000, [ 500 2500] /5000, 1, 60)
n =
12
Wn =
0. 1951 0. 4080
[ b, a] = but t er ( n, Wn) ;
An el l i pti c fi l ter that meets the same requi rements i s gi ven by
[ n, Wn] = el l i por d( [ 1000 2000] /5000, [ 500 2500] /5000, 1, 60)
n =
5
Wn =
0. 2000 0. 4000
[ b, a] = el l i p( 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.
IIR Fi lter Desi gn
2-9
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.
Butter w orth 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 response at = 0 and = ; for any order N, the magni tude
squared response has 2N1 zero deri vati ves at these l ocati ons (maximally flat
at = 0 and = ). Response i s monotoni c overal l , decreasi ng smoothl y from
= 0 to = . | H(j)| = s qr t ( 1/2) 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
2 Fi lter Desi gn
2-10
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 Butter-
worth 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
IIR Fi lter Desi gn
2-11
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 pass-
band, however, i s often an i mportant advantage. | H(j)| = 10
-Rs/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
2 Fi lter Desi gn
2-12
Elliptic Filter
El l i pti c fi l ters are equi ri ppl e i n both the passband and stopband. They gener-
al 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 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.
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 Fi lter Desi gn
2-13
Bessel Filter
Anal og Bessel l owpass fi l ters have maxi mal l y fl at group del ay at zero fre-
quency 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 com-
pl ete Bessel fi l ter desi gn functi on.
Bessel fi l ters general l y requi re a hi gher fi l ter order than other fi l ters for sati s-
factory stopband attenuati on. | H(j)| < at = 1 and decreases as n
i ncreases.
NOTE The l owpass l ters shown above were created wi th the anal og proto-
type functi ons bes s el ap, but t ap, cheb1ap, cheb2ap, and el l i pap. These func-
ti ons nd the zeros, pol es, and gai n of an order n anal og l ter of the
appropri ate type wi th cutoff frequency of 1 rad/sec. The compl ete l ter desi gn
functi ons (bes s el f , but t er , cheby 1, cheby 2, and el l i p) cal l the prototypi ng
functi ons as a 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.
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
2 Fi lter Desi gn
2-14
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] = el l i pap( 5, . 5, 20) ;
w = l ogs pace( 1, 1, 1000) ;
h = f r eqs ( k*pol y ( z ) , pol y ( p) , w) ;
s emi l ogx ( w, abs ( h) ) , gr i d
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 y ul ewal k functi on, whi ch i s i ntended spe-
ci 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.
y ul ewal k desi gns recursi ve I I R di gi tal fi l ters by fi tti ng a speci fi ed frequency
response. y ul ewal ks 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 autocor-
rel ati on functi on sampl es. The statement
[ b, a] = y ul ewal k( 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 f i r 2, 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-17 for detai l s.
Note that y ul ewal k 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.
IIR Fi lter Desi gn
2-15
Desi gn a mul ti band fi l ter wi th y ul ewal k, and pl ot the desi red and actual fre-
quency 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] = y ul ewal k( 10, f , m) ;
[ h, w] = f r eqz ( b, a, 128) ;
pl ot ( f , m, w/pi , abs ( h) )
Genera lized Butter w or th Filter Design
The tool box functi on max f l at 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. max f l at i s just l i ke the but t er functi on, except
that i t you can speci fy two orders (one for the numerator and one for the denom-
i nator) i nstead of just one. These fi l ters are maximally flat. 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
2 Fi lter Desi gn
2-16
For exampl e, when the two orders are the same, max f l at i s the same as but t er :
[ b, a] = max f l at ( 3, 3, 0. 25)
b =
0. 0317 0. 0951 0. 0951 0. 0317
a =
1. 0000 1. 4590 0. 9104 - 0. 1978
[ b, a] = but t er ( 3, 0. 25)
b =
0. 0317 0. 0951 0. 0951 0. 0317
a =
1. 0000 1. 4590 0. 9104 - 0. 1978
However, max f l at i s more versati l e, because you can desi gn a fi l ter wi th more
zeros than pol es:
[ b, a] = max f l at ( 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 ' s y m' opti on:
max f l at ( 4, ' s y m' , 0. 3)
ans =
0. 0331 0. 2500 0. 4337 0. 2500 0. 0331
For compl ete detai l s of the max f l at al gori thm, see Sel esni ck and Burrus [2].
1 2
FIR Fi lter Desi gn
2-17
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. Cor-
respondi 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 l ter
f i r 1, f i r 2, kai s er or d
Mul ti band
wi th Transi -
ti on Bands
Equi ri ppl e or l east squares
approach over sub-bands of the
frequency range
f i r l s , r emez , r emez or d
Constrai ned
Least
Squares
Mi ni mi ze squared i ntegral
error over enti re frequency
range subject to maxi mum
error constrai nts
f i r cl s , f i r cl s 1
Arbi trary
Response
Arbi trary responses, i ncl udi ng
nonl i near phase and compl ex
l ters
cr emez
Rai sed
Cosi ne
Lowpass response wi th
smooth, si nusoi dal transi ti on
f i r r cos
2 Fi lter Desi gn
2-18
Linear Phase Filters
Except for cr emez , 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 (stored 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 con-
stant 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 f i r 1, f i r 2, f i r l s , r emez , f i r cl s , f i r cl s 1, and f i r r cos al l
desi gn type I and I I l i near phase FI R fi l ters by defaul t. Both f i r l s and r emez
desi gn type I I I and I V l i near phase FI R fi l ters gi ven a ' hi l ber t ' or
' di f f er ent i at or ' fl ag. cr emez can desi gn any type of l i near phase fi l ter, and
nonl i near phase fi l ters as wel l .
NOTE Because the frequency response of a type I I l ter i s zero at the Nyqui st
rate (hi gh frequency), f i r 1 does not desi gn type I I hi ghpass and bandstop
l ters. For odd-val ued n i n these cases, f i r 1 adds 1 to the order and returns a
type I l ter.
Linear Phase
Filter Type
Filter
Order n Symmetry of Coefcients
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 k k n ( ) ( ), , , + + 2 1 1 K

b k b n k k n ( ) ( ), , , + + 2 1 1 K
FIR Fi lter Desi gn
2-19
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 non-
causal . 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 trunca-
ti 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*s i nc( 0. 4*( 25: 25) ) ;
The wi ndow appl i ed here i s a si mpl e rectangul ar or boxcar wi ndow. By
Parseval s theorem, thi s i s the l ength 51 fi l ter that best approxi mates the i deal
l owpass fi l ter, i n the i ntegrated l east squares sense. To vi ew i ts frequency
response,
[ H, w] = f r eqz ( b, 1, 512, 2) ;
pl ot ( w, abs ( H) ) , gr i d
h n H e d e d n
j n j n
( ) ( ) sinc( )


1
2
1
2
0
0
0 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
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 Fi lter Desi gn
2-20
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 nonrect-
angul ar wi ndow reduces i ts magni tude. Mul ti pl i cati on by a wi ndow i n 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. *hammi ng( 51) ' ;
[ H, w] = f r eqz ( b, 1, 512, 2) ;
pl ot ( w, abs ( H) ) , gr i d
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 f i r 1 and f i r 2 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.
Sta nda rd Ba nd FIR Filter Design: r1
f i r 1 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
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 Fi lter Desi gn
2-21
to desi gn fi l ters i n standard band confi gurati ons: l owpass, bandpass, hi ghpass,
and bandstop.
The statements
n = 50;
Wn = 0. 4;
b = f i r 1( n, Wn) ;
create row vector b contai ni ng the coeffi ci ents of the order n Hammi ng-wi n-
dowed 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 ' hi gh' to the func-
ti ons parameter l i st. For a bandpass or bandstop fi l ter, speci fy Wn as a two-el e-
ment vector contai ni ng the passband edge frequenci es; append the stri ng
' s t op' for the bandstop confi gurati on.
b = f i r 1( n, Wn, wi ndow) uses the wi ndow speci fi ed i n col umn vector wi ndow for
the desi gn. The vector wi ndow must be n+1 el ements l ong. I f you do not speci fy
a wi ndow, f i r 1 appl i es a Hammi ng wi ndow.
Ka iser W indow Order Estima tion. The kai s er or d 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 corre-
spondi ng vector of magni tudes, as wel l as maxi mum al l owabl e ri ppl e,
kai s er or d returns appropri ate i nput parameters for the f i r 1 functi on. For
detai l s on kai s er or d, see the reference descri pti on i n Chapter 6.
M ultiba nd FIR Filter Design: r2
The functi on f i r 2 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 f i r 1, 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 = f i r 2( n, f , m) ;
2 Fi lter Desi gn
2-22
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
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 y ul ewal k,
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 f i r l s and r emez functi ons provi de a more general means of speci fyi ng the
i deal desi red fi l ter than the f i r 1 and f i r 2 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 tran-
si 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.
f i r l s i s an extensi on of the f i r 1 and f i r 2 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.
r emez 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 some-
ti 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 equiripple
fi 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 f i r l s and r emez 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 f i r l s
and r emez refl ect these di fferent schemes.
Ba sic Congura tions
The defaul t mode of operati on of f i r l s and r emez 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,
FIR Fi lter Desi gn
2-23
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; % f i l t er or der
f = [ 0 . 4 . 5 1] ; % f r equency band edges
a = [ 1 1 0 0] ; % des i r ed ampl i t udes
b = r emez ( n, f , a) ;
From 0.4 to 0.5 Hz, r emez 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 care about, at the expense of a sl ower transi ti on rate. I n thi s
way, these types of fi l ters have an i nherent trade-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 f i r l s to create a si m-
i l ar fi l ter:
bb = f i r l s ( n, f , a) ;
and compare thei r frequency responses:
[ H, w] =f r eqz ( b) ;
[ HH, w] =f r eqz ( bb) ;
pl ot ( w/pi , abs ( H) , w/pi , abs ( HH) , ' ' ) , gr i d
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
Solid = remez, Dashed = firls
2 Fi lter Desi gn
2-24
You can see that the fi l ter desi gned wi th r emez exhi bi ts equi ri ppl e behavi or.
Al so note that the f i r l s fi l ter has a better response over most of the passband
and stopband, but at the band edges (f = 0. 4 and f = 0. 5), the response i s fur-
ther away from the i deal than the r emez fi l ter. Thi s shows that the r emez
fi l ters maximum error 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. r emez and
f i r l s use thi s scheme to represent any pi ecewi se l i near desi red functi on wi th
any transi ti on bands. f i r l s and r emez desi gn l owpass, hi ghpass, bandpass,
and bandstop fi l ters; a bandpass exampl e i s
f = [ 0 . 3 . 4 . 7 . 8 1] ; % band edges i n pai r s
a = [ 0 0 1 1 0 0] ; % bandpas s f i l t er ampl i t ude
Techni cal l y, these f and a vectors 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 . 7 . 8 1] ; % band edges i n pai r s
a = [ 0 0 1 1] ; % hi ghpas s f i l t er ampl i t ude
f = [ 0 . 3 . 4 . 5 . 8 1] ; % band edges i n pai r s
a = [ 1 1 0 0 1 1] ; % bands t op f i l t er ampl i t ude
An exampl e mul ti band bandpass fi l ter i s
f = [ 0 . 1 . 15 . 25 . 3 . 4 . 45 . 55 . 6 . 7 . 75 . 85 . 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 transi ti on regi ons:
f = [ 0 . 4 . 42 . 48 . 5 1] ;
a = [ 1 1 . 8 . 2 0 0] ; % pas s band, l i near t r ans i t i on, s t opband
FIR Fi lter Desi gn
2-25
The Weight Vector
Both f i r l s and r emez 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 l ow-
pass equi ri ppl e fi l ter wi th 10 ti mes l ess ri ppl e i n the stopband than the pass-
band i s
n = 20; % f i l t er or der
f = [ 0 . 4 . 5 1] ; % f r equency band edges
a = [ 1 1 0 0] ; % des i r ed ampl i t udes
w = [ 1 10] ; % wei ght v ect or
b = r emez ( 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 / Hilber t Tra nsfor mers
When cal l ed wi th a trai l i ng ' h' or ' Hi l ber t ' opti on, r emez and f i r l s 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 -sym-
metry 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 = r emez ( 21, [ . 05 1] , [ 1 1] , ' h' ) ; % hi ghpas s Hi l ber t
bb = r emez ( 20, [ . 05 . 95] , [ 1 1] , ' h' ) ; % bandpas s Hi l ber t
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 Fi lter Desi gn
2-26
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; % s ampl i ng f r equency
t = ( 0: 1/Fs : 2) ' ; % t wo s econd t i me v ect or
x = s i n( 2*pi *300*t ) ; % 300 Hz s i ne wav e ex ampl e s i gnal
x h = f i l t er ( bb, 1, x ) ; % Hi l ber t t r ans f or m of x
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 hi l ber t functi on), you must del ay x by hal f the
fi l ter order to create the anal yti c si gnal :
x d = [ z er os ( 10, 1) ; x ( 1: l engt h( x ) 10) ] ; % del ay 10 s ampl es
x a = x d + j *x h; % anal y t i c s i gnal
Thi s method does not work di rectl y for fi l ters of odd order, whi ch requi re a non-
i nteger del ay. I n thi s case, the hi l ber t 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 ternatel y,
use the r es ampl e functi on to del ay the si gnal by a noni nteger number of sam-
pl es.
Dif ferentia tors
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 f-
ferenti 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 r emez or f i r l s wi th
a ' d' or ' di f f er ent i at or ' opti on:
b = r emez ( 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 sam-
pl 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 = r emez ( 20, [ 0 . 9] , [ 0 . 9*pi *Fs ] , ' d' ) ;
I n the ' d' mode, r emez wei ghts the error by 1/w i n nonzero ampl i tude bands to
mi ni mi ze the maxi mum relative error. f i r l s wei ghts the error by (1/w)
2
i n non-
zero ampl i tude bands i n the ' d' mode.
FIR Fi lter Desi gn
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 ca-
ti 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 Fi lter Desi gn
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 p-
ti ons i n Chapter 6.
Ba sic Low pa ss a nd Highpa ss CLS Filter Design
The most basi c of the CLS desi gn functi ons, f i r cl s 1, 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 l ter desi gn. f i r cl s
Constrai ned l east square l ter desi gn for l owpass and
hi ghpass l i near phase l ters
f i r cl s 1
0
ds = 0. 008
1
dp = 0. 02
FIR Fi lter Desi gn
2-29
To approach thi s desi gn probl em usi ng f i r cl s 1:
n = 61;
wo = 0. 3;
dp = 0. 02;
ds = 0. 008;
h = f i r cl s 1( n, wo, dp, ds , ' pl ot ' ) ;
M ultiba nd CLS Filter Design
f i r cl s 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 Fi lter Desi gn
2-30
Desi gn a CLS fi l ter wi th i mpul se response order 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] ;
l o = [ 0. 005 0. 49 0. 03 0. 98 0. 05] ;
h = f i r cl s ( n, f , a, up, l o, ' pl ot ' ) ;
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 f i r cl s 1 func-
ti 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 max-
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 Fi lter Desi gn
2-31
i 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:
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 pass-
band
To approach thi s usi ng f i r cl s 1:
n = 55;
wo = 0. 3;
dp = 0. 02;
ds = 0. 004;
wp = 0. 28;
ws = 0. 32;
k = 10;
h = f i r cl s 1( n, wo, dp, ds , wp, ws , k, ' pl ot ' ) ;
Arbitrary-Response Filter Design
The cr emez 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 passes the name of a
functi on to cr emez , whi ch returns the fi l ter response cal cul ated over a gri d of
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 Fi lter Desi gn
2-32
frequenci es. Thi s capabi l i ty makes cr emez a hi ghl y versati l e and powerful
techni que for fi l ter desi gn.
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 cr emez , see the reference descri pti on i n
Chapter 6.
M ultiba nd Filter Design
Consi der a mul ti band fi l ter wi th the fol l owi ng speci al frequency-domai n char-
acteri sti cs:
A l i near-phase mul ti band fi l ter may be desi gned usi ng the predefi ned fre-
quency-response functi on mul t i band, as fol l ows:
b = cr emez ( 38, [ 1 0. 5 0. 4 0. 3 0. 4 0. 8] , . . .
{ mul t i band , [ 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 r emez :
b = cr emez ( 38, [ 1 0. 5 0. 4 0. 3 0. 4 0. 8] , . . .
[ 5 1 2 2 2 1] , [ 1 10 5] ) ;
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 Fi lter Desi gn
2-33
As wi th r emez , a vector of band edges i s passed to cr emez . 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.
I n ei ther case, the frequency response i s obtai ned and pl otted usi ng l i near
scal e:
[ h, w] = f r eqz ( b, 1, 512, whol e ) ;
pl ot ( w/pi 1, f f t s hi f t ( 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 ' whol e' to f r eqz . 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 f f t s hi f t :
-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 Fi lter Desi gn
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 w ith Reduced Dela y
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 l owpas s 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 = cr emez ( 61, [ 0 0. 5 0. 55 1] , { l owpas s , 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 Fi lter Desi gn
2-35
The resul ti ng magni tude response i s:
[ h, w] = f r eqz ( b, 1, 512, whol e ) ;
pl ot ( w/pi 1, f f t s hi f t ( 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
-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
2 Fi lter Desi gn
2-36
the passband regi on (pl otted over the normal i zed frequency range 0 to 0.5 for
cl ari ty):
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 = cr emez ( 29, [ 0 0. 5 0. 55 1] , l owpas s ) , the passband and stop-
band 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.
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
)
Speci al Topi cs i n IIR Fi lter Desi gn
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 gura-
ti 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 but t er , cheby 1, cheby 2, and el l i p 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
but t ap
el l i pap
cheb1ap
cheb2ap
bes s el ap l p2l p
l p2bp
l p2hp
l p2bs
bi l i near
i mpi nv ar
but t er cheby 1 cheby 2 el l i p bes s el f
Minimum Order Computation for Classical IIR Filter Design
but t or d cheb1or d cheb2or d el l i por d
Complete Design
2 Fi lter Desi gn
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 func-
ti 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.
Filter Type Analog Prototype Function
Bessel [ z , p, k] = bes s el ap( n)
Butterworth [ z , p, k] = but t ap( 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] = el l i pap( n, Rp, Rs )
Speci al Topi cs i n IIR Fi lter Desi gn
2-39
Frequency Transformation
The second step i n the anal og prototypi ng desi gn techni que i s the frequency
transformati on of a l owpass prototype. The tool box provi des a set of functi ons
to transform anal og l owpass prototypes (wi th cutoff frequency of 1 rad/sec) i nto
bandpass, hi ghpass, bandstop, and l owpass fi l ters of the desi red cutoff fre-
quency:
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.
Freq. Transformation Transformation Function
Lowpass to l owpass [ numt , dent ] = l p2l p( num, den, Wo)
[ At , Bt , Ct , Dt ] = l p2l p( A, B, C, D, Wo)
Lowpass to hi ghpass [ numt , dent ] = l p2hp( num, den, Wo)
[ At , Bt , Ct , Dt ] = l p2hp( A, B, C, D, Wo)
Lowpass to bandpass [ numt , dent ] = l p2bp( num, den, Wo, Bw)
[ At , Bt , Ct , Dt ] = l p2bp( A, B, C, D, Wo, Bw)
Lowpass to bandstop [ numt , dent ] = l p2bs ( num, den, Wo, Bw)
[ At , Bt , Ct , Dt ] = l p2bs ( A, B, C, D, Wo, Bw)
s s ' /
0
s
s
'

0
s
B
s
s
w
'
/
/

( ) +

0 0
2
0
1
s
B s
s
w
'
/
/

( ) +

0
0
0
2
1

0 1 2

B
w

2 1
2 Fi lter Desi gn
2-40
The frequency transformati on functi ons perform frequency vari abl e substi tu-
ti on. I n the case of l p2bp and l p2bs , 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 l p2l p and l p2hp, the output
fi l ter i s the same order as the i nput.
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 l p2bp 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 l p2bp functi on can
accept i t:
[ A, B, C, D] = z p2s s ( z , p, k) ; % Conv er t t o s t at es pace f or m.
Now, fi nd the bandwi dth and center frequency, and cal l l p2bp:
u1 = 0. 1*2*pi ; u2 = 0. 5*2*pi ; % i n r adi ans per s econd
Bw = u2u1;
Wo = s qr t ( u1*u2) ;
[ At , Bt , Ct , Dt ] = l p2bp( A, B, C, D, Wo, Bw) ;
Speci al Topi cs i n IIR Fi lter Desi gn
2-41
Fi nal l y, cal cul ate the frequency response and pl ot i ts magni tude:
[ b, a] = s s 2t f ( At , Bt , Ct , Dt ) ; % Conv er t t o TF f or m.
w = l i ns pace( . 01, 1, 500) *2*pi ; % Gener at e f r equency v ect or .
h = f r eqs ( b, a, w) ; % Comput e f r equency r es pons e.
s emi l ogy ( w/2/pi , abs ( h) ) , gr i d % Pl ot l og magni t ude v s . f r eq.
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
but t er , cheby 1, cheby 2, and el l i p use the bi l i near transformati on for di scret-
i zati on i n thi s step.
Analog to Digital
Transformation
Transformation Function
I mpul se i nvari ance [ numd, dend] = i mpi nv ar ( num, den, Fs )
Bi l i near transform [ z d, pd, kd] = bi l i near ( z , p, k, Fs , Fp)
[ numd, dend] = bi l i near ( num, den, Fs , Fp)
[ Ad, Bd, Cd, Dd] = bi l i near ( At , Bt , Ct , Dt , Fs , Fp)
pi/5 pi
10
-7
10
-6
10
-5
10
-4
10
-3
10
-2
10
-1
10
0
Frequency (rad/sec)
2 Fi lter Desi gn
2-42
Impulse Inva ria nce
The tool box functi on i mpi nv ar 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 func-
ti on onl y works 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 fre-
quency, 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.
Desi gn a Chebyshev type I fi l ter and pl ot i ts frequency response:
[ bz , az ] = i mpi nv ar ( b, a, 2) ;
f r eqz ( bz , az )
I mpul se i nvari ance retai ns the cutoff frequenci es of 0.1 Hz and 0.5 Hz.
Bilinea r Tra nsfor ma tion
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
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
z
( ) ( )


+
1
1
Speci al Topi cs i n IIR Fi lter Desi gn
2-43
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 bi l i near 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/t an( pi *Fp/Fs ) i f you gi ve bi l i near a trai l i ng argument
that represents a match frequency Fp. I f a match frequency Fp (i n Hertz) i s
present, bi l i near 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 bi l i near 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 bi l i near 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] = bi l i near ( 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 ] = s s 2t f ( Ad, Bd, Cd, Dd) ; % conv er t t o TF
f r eqz ( bz , az )

_
,

2
1
tan

k
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
)
2 Fi lter Desi gn
2-44
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 transforma-
ti 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 upon
bi l i near transformati on. Here the prewarped frequenci es u1 and u2 generate Bw
and Wo for the l p2bp functi on:
Fs = 2; % s ampl i ng f r equency ( Her t z )
u1 = 2*Fs *t an( . 1*( 2*pi /Fs ) /2) ; %l ower band edge ( r adi ans /s econd)
u2 = 2*Fs *t an( . 5*( 2*pi /Fs ) /2) ; %upper band edge ( r adi ans /s econd)
Bw = u2u1; % bandwi dt h
Wo = s qr t ( u1*u2) ; % cent er f r equency
[ At , Bt , Ct , Dt ] = l p2bp( 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] = bi l i near ( 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 cheby 1. For i nstance,
an anal og versi on of the exampl e Chebyshev fi l ter i s
[ b, a] = cheby 1( 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 ] = cheby 1( 5, 3, [ 0. 1 0. 5] ) ;
Al l of the compl ete desi gn functi ons cal l bi l i near 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.
References
2-45
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 the I EEE I nt. Conf. Acoust., Speech, Signal Pro-
cessing. 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
the I EEE I nt. Conf. Acoust., Speech, Signal Processing. Vol . 2 (May 1995).
Pgs. 1260-1263.
2 Fi lter Desi gn
2-46



3

Stati sti cal Si gnal

Processi ng

3-2 Correlation and Covariance
3-3

Bi as and Normal i zati on

3-4

Mul ti pl e Channel s

3-5 Spectral Analysis
3-6

Wel chs Method

3-16

Mul ti taper Method

3-19

Maxi mum Entropy Method

3-21

MUSI C and Ei genvector Anal ysi s Methods

3-24 References

3

Stati sti cal Si gnal Processi ng

3-2

Correlation and Covariance

The Si gnal Processi ng Tool box provi des tool s for esti mati ng i mportant func-
ti 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

x cor r

and

x cov

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 +

y
( ) { } =
C
xy
m ( )
xy
m ( )
x

y
=

( )

( )
*
| |
*
R m
x y m
R m m
xy
n n m
n
N m
yx


<

'

0
1
0
0

C orrelati on and C ovari ance

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

x cor r

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

vec-
tors

x

and

y

. I ts operati on i s equi val ent to convol uti on wi th one of the two sub-
sequences reversed i n ti me.
For exampl e,

x = [ 1 1 1 1 1] ' ;
y = x ;
x y c = x cor r ( x , y )
x y c =
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

N

th 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

x cov

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

x cor r

, 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 quan-
ti ty i t esti mates. The expected val ue of the output of

x cor r

i s

( ) R m
xy
E R
xy

m ( ) { } E x
n
y

n m +
{ } N m ( )
xy
m ( ) =
n 0 =
N m 1

=

3

Stati sti cal Si gnal Processi ng

3-4

x cor r

provi des the unbi ased esti mate, di vi di ng by

N

-|

m

| , when you speci fy an

' unbi as ed'

fl ag after the i nput sequences:

x cor r ( x , y , ' unbi as ed' )

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

x cor r

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

' bi as ed'

fl ag:

x cor r ( x , y , ' bi as ed' )

Wi th thi s scheme, onl y the sampl e of the correl ati on at 0 l ag (the

N

th 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 a-
ti on sequence.

x cor r provi des one other normal i zati on scheme. The syntax
x cor r ( x , y , ' coef f ' )
di vi des the output by nor m( x ) *nor m( 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 , x cor r and x cov 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, x cor r ( 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 = [ s 1 s 2 s 3]
then the resul t of x cor r ( S) i s organi zed as
R = [ Rs 1s 1 Rs 1s 2 Rs 1s 3 Rs 2s 1 Rs 2s 2 Rs 2s 3 Rs 3s 1 Rs 3s 2 Rs 3s 3]
Two rel ated functi ons, cov and cor r coef , 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 Analysi s
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 trans-
form:
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 esti-
mates the PSD and CSD because si gnal l engths are fi ni te.
The many di fferent methods of esti mati ng the PSD can be grouped as para-
metri c and nonparametri c. The pri nci pal techni que i n the Si gnal Processi ng
Tool box i s a popul ar nonparametri c scheme devel oped by Wel ch [4]. Thi s i s
compl emented by the more modern nonparametri c multitaper method (MTM).
The maximum entropy method (MEM) i s a parametri c method that maxi mi zes
the entropy of a ti me seri es expressed as an autocorrel ati on sequence. Another
nonparametri c approach, the multiple signal classification (MUSI C) method,
al so cal l ed the eigenvector (EV) method, i s wel l sui ted for l i ne spectra (data
made up of si nusoi ds). These methods are l i sted i n the tabl e bel ow wi th the
M-fi l e functi ons used to i mpl ement them. The fol l owi ng secti ons descri be the
methods i n more detai l . See Parametri c Model i ng i n Chapter 4 for detai l s
P
xx
( )
xx
m ( ) e
j m
m =

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

=
3 Stati sti cal Si gnal Processi ng
3-6
about l pc and other functi ons for parametri c esti mati on that can be appl i ed to
spectral anal ysi s.
Welchs Method
One way of esti mati ng the power spectrum of a process i s to si mpl y fi nd the di s-
crete-ti me Fouri er transform of the sampl es of the process (usual l y done on 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 x n, whi ch consi sts of two si nusoi ds pl us noi se, i s gi ven by
Fs = 1000; % s ampl i ng f r equency
t = 0: 1/Fs : 1; % one s econd wor t h of s ampl es
x n = s i n( 2*pi *50*t ) + 2*s i n( 2*pi *120*t ) + r andn( s i z e( t ) ) ;
A crude esti mate of the PSD of x n i s
Px x = abs ( f f t ( x n, 1024) ) . ^2/1001;
Thi s esti mate i s cal l ed the periodogram. Scal e the magni tude squared of the
FFT by 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 asymp-
totically unbiased. 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
Method Description Functions
Wel chs Average peri odograms of over-
l apped, wi ndowed si gnal secti ons
ps d, cs d, t f e, coher e
Mul ti taper Spectral esti mate from combi na-
ti on of mul ti pl e orthogonal wi n-
dows (or tapers)
pmt m
Maxi mum
entropy
Spectrum from parametri c model
of autocorrel ati on functi on
pmem
MUSI C Mul ti pl e si gnal cl assi cati on or
ei genvector method
pmus i c
Spectral Analysi s
3-7
exampl es show thi s; as FFT l ength i ncreases, the peri odogram does not become
smoother:
Px x _s hor t = abs ( f f t ( x n, 256) ) . ^2/256;
pl ot ( ( 0: 255) /256*Fs , 10*l og10( Px x _s hor t ) )
pl ot ( ( 0: 1023) /1024*Fs , 10*l og10( Px x ) )
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
3 Stati sti cal Si gnal Processi ng
3-8
Reduce the vari ance of the PSD esti mate by breaki ng the si gnal i nto nonover-
l appi ng secti ons and averagi ng the peri odograms of these secti ons:
Px x = ( abs ( f f t ( x n( 1: 256) ) ) . ^2 + abs ( f f t ( x n( 257: 512) ) ) . ^2 + . . .
abs ( f f t ( x n( 513: 768) ) ) . ^2 ) / ( 256*3) ;
pl ot ( ( 0: 255) /256*Fs , 10*l og10( Px x ) )
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 possi bl e
(to three secti ons of l ength 256 i n the previ ous exampl e). To obtai n more sec-
ti ons, break the si gnal i nto overl appi ng secti ons:
Px x = ( abs ( f f t ( x n( 1: 256) ) ) . ^2 + abs ( f f t ( x n( 129: 384) ) ) . ^2 + . . .
abs ( f f t ( x n( 257: 512) ) ) . ^2 + abs ( f f t ( x n( 385: 640) ) ) . ^2 + . . .
abs ( f f t ( x n( 513: 768) ) ) . ^2 + . . .
abs ( f f t ( x n( 641: 896) ) ) . ^2 ) / ( 256*6) ;
pl ot ( ( 0: 255) /256*Fs , 10*l og10( Px x ) )
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)
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)
Spectral Analysi s
3-9
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 overl 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 pri or to 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 nonrectan-
gul 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 Ham-
mi 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.
The appl i cati on of a Hanni ng wi ndow resul ts i n
w = hanni ng( 256) ' ;
Px x = ( abs ( f f t ( w. *x n( 1: 256) ) ) . ^2 + . . .
abs ( f f t ( w. *x n( 129: 384) ) ) . ^2 + . . .
abs ( f f t ( w. *x n( 257: 512) ) ) . ^2 + . . .
abs ( f f t ( w. *x n( 385: 640) ) ) . ^2 + . . .
abs ( f f t ( w. *x n( 513: 768) ) ) . ^2 + . . .
abs ( f f t ( w. *x n( 641: 896) ) ) . ^2 ) / ( nor m( w) ^2*6) ;
pl ot ( ( 0: 255) /256*Fs , 10*l og10( Px x ) )
Noti ce i n thi s pl ot that the spectral peaks have wi dened, and the noise floor, 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 ps d and cs d provi de control over al l the parameters di scussed so
far (FFT l ength, wi ndow, and amount of overl ap) i n computi ng the PSD and
CSD of one or two si gnal s usi ng Wel chs method.
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)
3 Stati sti cal Si gnal Processi ng
3-10
For a more detai l ed di scussi on of Wel chs method of PSD esti mati on, see
Kay [1] and Wel ch [4].
Pow er Spectra l Density Function
The ps d functi on averages and scal es the modi fi ed peri odograms of detrended
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 x n usi ng ps ds defaul t FFT l ength (256),
wi ndow (Hanni ng of l ength 256), overl ap sampl es (none), and detrendi ng
opti on (remove best l i near fi t from secti ons) i s
Px x = ps d( x n) ;
I f the ori gi nal sequence x n has uni ts of vol ts, Px x has uni ts of vol ts
2
.
To recreate the l ast exampl e accuratel y, speci fy 128 as the number of sampl es
to overl ap and ask for no detrendi ng:
nf f t = 256; % l engt h of FFT
Fs = 1000; % s ampl i ng f r equency
wi ndow = hanni ng( 256) ; % wi ndow f unct i on
nov er l ap = 128; % number of s ampl es ov er l ap
df l ag = ' none' ; % det r endi ng opt i on
Px x = ps d( x n, nf f t , Fs , wi ndow, nov er l ap, df l ag) ;
The order of the i nputs to ps d i s i mportant, except for the df l ag stri ng, whi ch
can be i n any posi ti on as l ong as i t i s l ast. The sampl i ng frequency doesnt affect
the PSD esti mate but hel ps ps d scal e the frequency axi s for pl otti ng. ps d
wi thout any outputs generates a pl ot:
ps d( x n, nf f t , Fs , wi ndow, nov er l ap, df l ag)
0 50 100 150 200 250 300 350 400 450 500
-10
-5
0
5
10
15
20
25
Frequency
P
o
w
e
r

S
p
e
c
t
r
u
m

M
a
g
n
i
t
u
d
e

(
d
B
)
Spectral Analysi s
3-11
I f you want to pl ot the PSD yoursel f, obtai n a frequency vector through an addi -
ti onal output argument:
[ Px x , f ] = ps d( x n, nf f t , Fs , 256, nov er l ap, df l ag) ;
pl ot ( f , 10*l og10( Px x ) )
Si nce the si gnal x n i s real , ps d 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 the sampl i ng frequency.
Bia s a nd N or ma liza tion in Welchs M ethod
I n studyi ng the output of ps d shown earl i er, several reveal i ng characteri sti cs
about the si gnal x n 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 x n i s con-
centrated 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 some
more anal ysi s.
To obtai n useful i nformati on about the peak ampl i tudes of the underl yi ng si nu-
soi ds, note that the expected val ue of the esti mated PSD i s
Si nce 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 of the hei ght of the ori gi nal
peaks, mul ti pl y the resul t of ps d by nor m( w) ^2/s um( w) ^2, where w i s the
E P
w
P W d
xx xx

( ) ( ) ( )

{ }

1
2
2
2
w w n
2 2

( )
W w ( ) / 0
2 2
3 Stati sti cal Si gnal Processi ng
3-12
wi ndow vector. Thi s scal i ng i s i ndependent of wi ndow l ength and shape. For
exampl e:
w1 = hanni ng( 256) ; w2 = hanni ng( 500) ;
[ Px x 1, f 1] = ps d( x n, 256, Fs , w1, 128, ' none' ) ;
[ Px x 2, f 2] = ps d( x n, 1024, Fs , w2, 250, ' none' ) ;
pl ot ( f 1, 10*l og10( Px x 1*nor m( w1) ^2/s um( w1) ^2) )
pl ot ( f 2, 10*l og10( Px x 2*nor m( w2) ^2/s um( w2) ^2) )
I n both pl ots, whi ch show the spectrum at posi ti ve frequenci es onl y (the nega-
ti 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 (
1
/2)
2
=
1
/4,
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 50 100 150 200 250 300 350 400 450 500
-40
-30
-20
-10
0
10
0 50 100 150 200 250 300 350 400 450 500
-40
-30
-20
-10
0
10
Spectral Analysi s
3-13
Pa rseva ls Rela tion
Accordi ng to Parseval s rel ati on, the i ntegral of the PSD across the enti re band
i s a measure of the total energy of the si gnal . The resul ts of ps d can approxi -
matel y veri fy thi s:
[ Px x , f ] = ps d( x n, 256, Fs , 256, 128, ' none' ) ;
f or mat l ong
s um( x n. ^2) /l engt h( x n)
ans =
3. 60376766505040
s um( Px x ) /l engt h( Px x )
ans =
3. 68430077838701
To approxi mate the percentage of energy the si gnal has i n a gi ven frequency
band, sum the PSD esti mate at the desi red frequency poi nts onl y. The per-
centage of energy of x n i n the band from 40 to 60 Hz i s
i nd = f i nd( f >40 & f <60)
i nd =
12
13
14
15
16
s um( Px x ( i nd) ) /s um( Px x )
ans =
0. 13369450463404
3 Stati sti cal Si gnal Processi ng
3-14
Cross- Spectra l 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 cs d 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. cs d handl es the secti oni ng, detrendi ng, and wi n-
dowi ng of x and y i n the same way as the ps d functi on:
Px y = cs d( x , y , nf f t , Fs , wi ndow, nov er l ap, df l ag)
Condence Inter va ls
Both the ps d and cs d functi ons can compute confi dence i nterval s. Si mpl y pro-
vi de an i nput argument p, whi ch speci fi es the percentage of the confi dence
i nterval :
[ Px x , Px x c, f ] = ps d( x , nf f t , Fs , wi ndow, nov er l ap, p, df l ag)
[ Px y , Px y c, f ] = cs d( x , y , nf f t , Fs , wi ndow, nov er l ap, p, df l ag)
p must be a scal ar between 0 and 1. The functi ons assume chi -squared di stri b-
uted 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 [ Px x Px x c( : , 1) Px x +Px x c( : , 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.
Tra nsfer Function Estima te
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) as
An esti mate of the transfer functi on between x(n) and y(n) i s
Thi s method esti mates both magni tude and phase i nformati on. The t f e func-
ti on uses Wel chs method to compute the CSD and PSD and then forms thei r
P H P
xy xx
( ) ( ) ( )

( )

( )

( )
H
P
P
xy
xx

Spectral Analysi s
3-15
quoti ent for the transfer functi on esti mate. Use t f e the same way that you use
the cs d functi on.
Fi l ter the si gnal x n 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; % mov i ng av er age f i l t er
y n = f i l t er ( h, 1, x n) ;
[ HEST, f ] = t f e( x n, y n, 256, Fs , 256, 128, ' none' ) ;
H = f r eqz ( h, 1, f , Fs ) ;
pl ot ( f , abs ( H) ) ; pl ot ( f , abs ( HEST) ) ;
Coherence Function
The magni tude-squared coherence between two si gnal s x(n) and y(n) i s
0 50 100 150 200 250 300 350 400 450 500
0
0.2
0.4
0.6
0.8
1
Frequency (Hz)
Transfer Function Magnitude Estimate
0 50 100 150 200 250 300 350 400 450 500
0
0.2
0.4
0.6
0.8
1
Frequency (Hz)
Actual Transfer Function Magnitude
C
P
P P
xy
xy
xx yy
( )
( )
( ) ( )

2
3 Stati sti cal Si gnal Processi ng
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 coher e 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 cs d and t f e functi ons.
The coherence functi on of x n and the fi l ter output y n versus frequency i s
coher e( x n, y n, 256, Fs , 256, 128, ' none' )
I f the i nput sequence l ength, wi ndow l ength, and overl ap are such that coher e
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 tapers) to obtai n
approxi matel y i ndependent esti mates of the power spectrum and then com-
bi nes them to yi el d an esti mate. Thi s esti mate exhi bi ts more degrees 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 nfor-
mati 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 thor-
ough 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 NW i 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 Analysi s
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 NW i 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 NW that al l ows an opti mal trade-off between bi as
and vari ance.
Usi ng pmt m on the data from the previ ous secti on, x n, yi el ds
Fs = 1000;
t = 0: 1/Fs : 1;
r andn( ' s eed' , 0)
x n = s i n( 2*pi *50*t ) + 2*s i n( 2*pi *120*t ) + r andn( s i z e( t ) ) ;
[ P, f ] = pmt m( x n, 4, 1024, Fs ) ;
pl ot ( f , 10*l og10( P) ) % pl ot i n deci bel s
ax i s ( [ 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 Stati sti cal Si gnal Processi ng
3-18
By l oweri ng the ti me-bandwi dth product, the peaks become narrower:
[ P1, f ] = pmt m( x n, 3/2, 1024, Fs ) ;
pl ot ( f , 10*l og10( P1) ) % pl ot i n deci bel s
ax i s ( [ 30 150 - 20 30] )
Note that the area under the peaks remai ns about the same, as can be seen
when both are pl otted together on a l i near scal e:
pl ot ( f , [ P P1] )
ax i s ( [ 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 Analysi s
3-19
Thi s conservati on of total power i s veri fi abl e numeri cal l y:
s um( P)
ans =
1. 8447e+03
s um( 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
dps s s av e, dps s l oad, dps s di r , and dps s cl ear are provi ded, to keep a database
of saved DPSSs i n the MAT-fi l e dps s . mat .
Maximum Entropy Method
The maximum entropy method (MEM) i s an autoregressi ve techni que for spec-
tral densi ty anal ysi s (see Marpl e [2], Chapter 7). Thi s method maxi mi zes the
uncertai nty, or entropy, of a ti me seri es expressed as an autocorrel ati on
sequence.
The maxi mum entropy method makes the assumpti on that the basi c process of
the spectral densi ty esti mate i s Gaussi an. Gi ven thi s assumpti on, and appl yi ng
Autoregressive Sequences and Maximum Entropy
One way to represent an autoregressi ve sequence r
xx
[0], ..., r
xx
[p] i s as
an autocorrel ati on sequence that i s posi ti ve, deni te, and ni te. From
thi s known sequence, you can determi ne the remai ni ng l ags r
xx
[p+1],
r
xx
[p+2],.... i n such a way that you maxi mi ze the entropy of the ti me
seri es that the whol e sequence represents. Thi s concept i s the founda-
ti on for the maxi mum entropy method of spectral anal ysi s.
3 Stati sti cal Si gnal Processi ng
3-20
the Lagrange mul ti pl i er techni que, the al gori thm defi nes the formul a for the
MEM esti mate as
Here, a i s a vector of al l -pol e fi l ter coeffi ci ents and the sol uti on of the autocor-
rel ati on normal equati ons:
where R i s the autocorrel ati on matri x (a Hermi ti an Toepl i tz matri x), and the
el ements of vector r are al so correl ati ons. e(f) i s a compl ex si nusoi d vector.
The tool box functi on pmem i mpl ements the maxi mum entropy method.
For exampl e, compare the spectrum of a speech si gnal usi ng Wel chs method
and MEM:
l oad mt l b
[ P1, f ] =ps d( mt l b, 1024, Fs , 256) ;
[ P2, f ] =pmem( mt l b, 14, 1024, Fs ) ; % 14t h or der model
pl ot ( f , 10*l og10( P1) , ' : ' , f , 10*l og10( P2) )
The sol i d MEM spectrum i s smoother than the peri odogram because of the
si mpl e underl yi ng al l -pol e model .
P
mem
f ( )
1
a
H
e f ( )
2
-------------------------- =
Ra r =
0 500 1000 1500 2000 2500 3000 3500 4000
-50
-40
-30
-20
-10
0
10
20
Frequency (Hz)
M
a
g
n
i
t
u
d
e

(
d
b
)
Welch
MEM
Spectral Analysi s
3-21
MUSIC and Eigenvector Analysis Methods
The pmus i c functi on provi 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.
Eigena na lysis O ver view
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 autocorre-
l 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 com-
pl 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 Estima tor 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 sub-
spaces. 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.
R S = W +
3 Stati sti cal Si gnal Processi ng
3-22
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 expo-
nenti al s). Thi s form i s useful for numeri c computati on because the FFT can be
computed for each v
k
and then the squared magni tudes can be summed.
The EV method wei ghts the summati on by the ei genval ues of the correl ati on
matri x:
The pmus i c functi on i n thi s tool box uses the s v d (si ngul ar val ue decomposi ti on)
functi on i n the si gnal case and the ei g 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 s v d
i s used, pmus i c never computes the correl ati on matri x expl i ci tl y, but the si n-
gul ar val ues are the ei genval ues.
1
v
k
H
e f ( )
2
k p 1 + =
N

--------------------------------------------- = P
music
f ( )
1
e
H
f ( ) v
k
v
k
H
k p = 1 +
N




e f ( )
--------------------------------------------------------------------- =
e f ( ) 1 j2f ( ) exp j2f 2 ( ) exp j2f 4 ( ) j2 n 1 ( ) ( ) exp exp [ ]

=
v
k
H
e f ( )
P
ev
f ( )
1
v
k
H
e f ( )
2
k p 1 + =
N

---------------------------------------------------------------- =
Spectral Analysi s
3-23
Controlling Subspa ce Thresholds
To provi de user control over the assi gnments of ei genvectors to the si gnal and
noi se subspaces, the pmus i c functi on accepts a threshol d argument t hr es h.
t hr es h i s a two-el ement vector where the fi rst el ement i s the number of ei gen-
vectors spanni ng the si gnal subspace and the second el ement i s a threshol d
test:
I f t hr es h( 2) 1, then t hr es h( 1) speci fi es the number of ei genvectors span-
ni ng the si gnal subspace. I n thi s case the val ues of t hr es h( 1) must be i n the
range [0, N), where N i s
- The col umn l ength of x R i f x R i s a data matri x
- The matri x si ze i f x R i s a correl ati on matri x
- The wi ndow l ength i f x R i s a si gnal vector
I f t hr es h( 1) N, then t hr es h( 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 t hr es h( 2) mi n{
k
}, then the gi ven ei genvector i s assi gned to
the noi se subspace.
I f t hr es h( 1) < N and t hr es h( 2) 1, t hr es h( 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 t hr es h( 2) can al so assi gn ei genvectors to the noi se subspace.
I f t hr es h( 1) N and t hr es h( 2) < 1, there are no noi se ei genvectors. Thi s i s
an i nval i d case and pmus i c generates an error.
For compl ete detai l s on usi ng the t hr es h parameter, see the reference descri p-
ti on of pmus i c i n Chapter 6.
3 Stati sti cal Si gnal Processi ng
3-24
References
1 Kay, S.M. Modern Spectral 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 Analysis for Physical Applica-
tions: Multitaper and Conventional Univariate Techniques. Cambri dge:
Cambri dge Uni versi ty Press, 1993.
4 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. Audio Electroacoust. Vol . AU-15 (June 1967).
Pgs. 70-73.



4

Speci al Topi cs

4-2 Windows
4-2

Basi c Shapes

4-4

General i zed Cosi ne Wi ndows

4-4

Kai ser Wi ndow

4-8

Chebyshev Wi ndow

4-10 Parametric Modeling
4-11

Ti me-Domai n Based Model i ng

4-16

Frequency-Domai n Based Model i ng

4-20 Resampling
4-23 Cepstrum Analysis
4-25

I nverse Compl ex Cepstrum

4-26 Time-Dependent Fourier Transforms and Spectrograms
4-27 Median Filtering
4-28 Communications Applications
4-32 Deconvolution
4-33 Specialized Transforms
4-33

Chi rp z-Transform

4-35

Di screte Cosi ne Transform

4-37

Hi l bert Transform

4-39 References

4

Speci al Topi cs

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 n-
dowi 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 are

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 = box car ( 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)

window

i s the convol uti on of two rectangul ar wi n-
dows. The functi ons

bar t l et t

and

t r i ang

compute si mi l ar tri angul ar wi n-
dows, wi th three i mportant di fferences. The

bar t l et t

functi on al ways returns

Window Function

Bartl ett wi ndow

bar t l et t

Bl ackman wi ndow

bl ackman

Rectangul ar wi ndow

box car

Chebyshev wi ndow

chebwi n

Hammi ng wi ndow

hammi ng

Hanni ng wi ndow

hanni ng

Kai ser wi ndow

kai s er

Tri angul ar wi ndow

t r i ang

Wi ndows

4-3

a wi ndow wi th two zeros on the ends of the sequence, so that for

n

odd, the
center secti on of

bar t l et t ( n+2)

i s equi val ent to

t r i ang( n)

:

bar t l et t ( 7)
ans =
0
0. 3333
0. 6667
1. 0000
0. 6667
0. 3333
0
t r i ang( 5)
ans =
0. 3333
0. 6667
1. 0000
0. 6667
0. 3333

For

n

even,

bar t l et t

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

t r i ang

s resul t are sl i ghtl y steeper than those of

bar t l et t

s i n thi s case:

w = bar t l et t ( 8) ;
[ w( 2: 7) t r i ang( 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

4

Speci al Topi cs

4-4

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
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 auto-
correl ati on sequence. The resul ti ng esti mate mi ght be negati ve at some fre-
quenci 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 cosine window

. These wi ndows are combi nati ons of si nuso-
i 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

i nd = ( 0: n1) ' *2*pi /( n1) ;
w = A B*cos ( i nd) + C*cos ( 2*i nd) ;

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 n-
dows, 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

hammi ng

and

hanni ng

functi ons, respecti vel y, com-
pute 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 m-
i nate these zeros on the edges of the wi ndow, hanni ng uses a cosi ne of fre-
quency 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 bl ackman functi on computes thi s wi ndow.
Kaiser Window
The Kaiser window i 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
Wi ndows
4-5
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.
The statement kai s er ( n, bet a) computes a l ength n Kai ser wi ndow wi th
parameter bet a.
Exampl es of Kai ser wi ndows wi th l ength 50 and vari ous val ues for the bet a
parameter are
n = 50;
w1 = kai s er ( n, 1) ;
w2 = kai s er ( n, 4) ;
w3 = kai s er ( n, 9) ;
[ W1, f ] = f r eqz ( w1/s um( w1) , 1, 512, 2) ;
[ W2, f ] = f r eqz ( w2/s um( w2) , 1, 512, 2) ;
[ W3, f ] = f r eqz ( w3/s um( w3) , 1, 512, 2) ;
pl ot ( f , 20*l og10( 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 Speci al Topi cs
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 = kai s er ( 50, 4) ;
w2 = kai s er ( 20, 4) ;
w3 = kai s er ( 101, 4) ;
[ W1, f ] = f r eqz ( w1/s um( w1) , 1, 512, 2) ;
[ W2, f ] = f r eqz ( w2/s um( w2) , 1, 512, 2) ;
[ W3, f ] = f r eqz ( w3/s um( w3) , 1, 512, 2) ;
pl ot ( f , 20*l og10( 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
Wi ndows
4-7
Ka iser W indow s 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 bet a 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 fre-
quency 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, bet a] = kai s er or d( [ 0. 4 0. 6] *pi , [ 1 0] , [ 0. 01 0. 01] , 2*pi ) ;
h = f i r 1( n, wn, kai s er ( n+1, bet a) , ' nos cal e' ) ;
The kai s er or d 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 frequency domai n speci -
fi cati ons.

>
+
<

'

0 1102 8 7 50
0 5842 21 0 07886 21 50 21
0 21
0 4
. ( . ),
. ( ) . ( ),
,
.
n

+

8
2 285
1
.
4 Speci al Topi cs
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 ] = f r eqz ( h, 1, 512, 2) ;
pl ot ( f , 20*l og10( abs ( H) ) ) , gr i d
For detai l s on kai s er or d, see the reference descri pti on i n Chapter 6.
Chebyshev Window
The Chebyshev wi ndow mi ni mi zes the mai nl obe wi dth, gi ven a parti cul ar si de-
l 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
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
Wi ndows
4-9
al l have the same hei ght. The chebwi n functi on, wi th l ength and si del obe
hei ght parameters, computes a Chebyshev wi ndow:
n = 51;
Rs = 40; % s i del obe hei ght i n deci bel s
w = chebwi n( n, Rs ) ;
s t em( w)
As shown i n the pl ot, the Chebyshev wi ndow has l arge spi kes at i ts outer sam-
pl es. Chebyshev wi ndows are defi ned onl y for odd l engths; i f n i s not odd,
chebwi n i ncreases i t by 1, desi gni ng a l ength n+1 Chebyshev wi ndow.
Pl ot the frequency response to see the equi ri ppl es at -40 dB:
[ W, f ] = f r eqz ( w, 1, 512, 2) ;
pl ot ( f , 20*l og10( abs ( W) /s um( w) ) ) , gr i d
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 Oppenhei m and Schafer [2], pgs. 444-462, and Parks and
Burrus [3], 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 Speci al Topi cs
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 nforma-
ti 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 u-
ti 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 func-
ti ons provi de a data-ori ented al ternati ve to the I I R and FI R fi l ter desi gn func-
ti 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.
Domain Functions Description
Ti me l pc, l ev i ns on Li near Predi cti ve Codi ng. Generate al l -pol e recur-
si ve l ter whose i mpul se response matches a gi ven
sequence.
pr ony Generate I I R l ter whose i mpul se response
matches a gi ven sequence.
s t mcb Fi nd I I R l ter whose output, gi ven a speci ed i nput
sequence, matches a gi ven output sequence.
Frequency i nv f r eqz ,
i nv f r eqs
Generate di gi tal or anal og l ter coefci ents gi ven
compl ex frequency response data.
y ul ewal k Generate I I R l ter that matches pi ecewi se l i near
magni tude response by sol vi ng modi ed
Yul e-Wal ker equati ons (see Chapter 2).
Parametri c M odeli ng
4-11
Because y ul ewal k i s geared expl i ci tl y for fi l ter desi gn, i t i s di scussed i n
Chapter 2.
Time-Domain Based Modeling
The l pc, pr ony , and s t mcb 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.
l pc i s restri cted to al l -pol e model s, and s t mcb can accept an i nput (besi des an
i mpul se) that causes the output response. The al gori thms di ffer i n compl exi ty
and accuracy of the resul ti ng model .
Linea r Prediction (AR M odeling)
Li near predi cti on model s a gi ven si gnal x as the i mpul se response of an al l -pol e
fi l ter. I t 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 = l pc( x , n)
l pc uses the autocorrel ati on method of al l -pol e model i ng to fi nd the l i near pre-
di cti on coeffi ci ents. Thi s techni que i s al so cal l ed the maxi mum entropy method
(MEM) of spectral anal ysi s. The fi l ter generated i s stabl e, but i t mi ght not
model the process exactl y even i f the data sequence i s trul y an autoregressi ve
(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.
To i l l ustrate l pc, create a sampl e si gnal that i s the i mpul se response of an
al l -pol e fi l ter wi th addi ti ve whi te noi se:
r andn( ' s eed' , 0)
x = i mpz ( 1, [ 1 0. 1 0. 1 0. 1 0. 1] , 10) + r andn( 10, 1) /10;

x k a x k a x k a n x k n ( ) ( ) ( ) ( ) ( ) ( ) ( ) + 2 1 3 2 1 L
4 Speci al Topi cs
4-12
The coeffi ci ents for a fourth-order al l -pol e fi l ter that model s the system are
a = l pc( x , 4)
a =
1. 0000 0. 0395 0. 0338 0. 0668 0. 1264
l pc fi rst cal l s x cor r 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 l ev i ns on
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.
l pcs enti re al gori thm for n = 4 i s
r = x cor r ( x ) ;
r ( 1: l engt h( x ) 1) = [ ] ; % r emov e cor r . at negat i v e l ags
a = l ev i ns on( r , 4)
a =
1. 0000 0. 0395 0. 0338 0. 0668 0. 1264
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 l ev i ns on, such as the unbi ased cor-
rel ati on esti mate:
r = x cor r ( x , ' unbi as ed' ) ;
r ( 1: l engt h( x ) 1) = [ ] ; % r emov e cor r . at negat i v e l ags
a = l ev i ns on( r , 4)
a =
1. 0000 0. 0554 0. 0462 0. 0974 0. 2115
Pronys M ethod (ARM A M odeling)
The pr ony 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, respec-
ti vel y, the statement
[ b, a] = pr ony ( x , nb, na)
Parametri c M odeli ng
4-13
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 .
pr ony i mpl ements the method descri bed i n Parks and Burrus [3]
(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 pr ony and s t mcb (descri bed next) are more accuratel y
descri bed as ARX model s i n system i denti cati on termi nol ogy. ARMA mod-
el i ng assumes noi se onl y at the i nputs, whi l e ARX assumes an external i nput.
pr ony and s t mcb know the i nput si gnal : i t i s an i mpul se for pr ony and i s arbi -
trary for s t mcb.
A model for the test sequence x (from the earl i er l pc exampl e) usi ng a
thi rd-order I I R fi l ter i s
[ b, a] = pr ony ( x , 3, 3)
b =
1. 1165 0. 2181 0. 6084 0. 5369
a =
1. 0000 0. 1619 0. 4765 0. 4940
4 Speci al Topi cs
4-14
The i mpz command shows how wel l thi s fi l ters i mpul se response matches the
ori gi nal sequence:
f or mat l ong
[ x i mpz ( 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] = but t er ( 4, . 2) ;
h = i mpz ( b, a, 26) ;
[ bb, aa] = pr ony ( 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
.
Steiglitz- M cBride M ethod (ARM A M odeling)
s t mcb determi 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
Parametri c M odeli ng
4-15
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, s t mcb works l i ke pr ony :
[ b, a] = s t mcb( x , 3, 3)
b =
1. 1165 0. 6213 0. 8365 1. 3331
a =
1. 0000 0. 5401 0. 6109 1. 1298
s t mcb al so fi nds systems that match gi ven i nput and output sequences:
y = f i l t er ( 1, [ 1 1] , x ) ; % Cr eat e an out put s i gnal .
[ b, a] = s t mcb( y , x , 0, 1)
b =
1. 0000
a =
1 1
I n thi s exampl e, s t mcb 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 n-
i 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 pr ony , s t mcbs resul ti ng fi l ter i s not necessari l y stabl e
due to i ts exact model i ng approach.
s t mcb 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 i t er at i ons
a = l pc( x , 3) ; % i ni t i al es t i mat es f or denomi nat or
[ b, a] = s t mcb( x , 3, 3, n, a) ;
4 Speci al Topi cs
4-16
The functi on uses an al l -pol e model created wi th pr ony as an i ni ti al esti mate
when you do not provi de one of your own.
To compare the functi ons l pc, pr ony , and s t mcb, compute the si gnal error i n
each case:
a1 = l pc( x , 3) ;
[ b2, a2] = pr ony ( x , 3, 3) ;
[ b3, a3] = s t mcb( x , 3, 3) ;
[ x i mpz ( 1, a1, 10) x i mpz ( b2, a2, 10) x i mpz ( b3, a3, 10) ]
ans =
0. 1165 0 0. 0000
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
s um( 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, s t mcb performs best, fol l owed by pr ony , then l pc.
Thi s rel ati ve performance i s typi cal of the model i ng functi ons.
Frequency-Domain Based Modeling
The i nv f r eqs and i nv f r eqz functi ons i mpl ement the i nverse operati ons of
f r eqs and f r eqz ; 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 i nv f r eqz , the di scussi on al so appl i es to i nv f r eqs .
Parametri c M odeli ng
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] = but t er ( 4, . 4) % des i gn But t er wor t h l owpas s
b =
0. 0466 0. 1863 0. 2795 0. 1863 0. 0466
a =
1. 0000 0. 7821 0. 6800 0. 1827 0. 0301
[ h, w] = f r eqz ( b, a, 64) ; % comput e f r equency r es p.
[ bb, aa] = i nv f r eqz ( 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 frequenci es w has the uni ts i n radi ans/second, and the frequenci es
need not be equal l y spaced. i nv f r eqz fi nds a fi l ter to fi t the frequency data for
any order fi l ter; a thi rd-order exampl e i s
[ bb, aa] = i nv f r eqz ( h, w, 3, 3) % f i nd t hi r d- or der I I R
bb =
0. 0464 0. 1785 0. 2446 0. 1276
aa =
1. 0000 0. 9502 0. 7382 0. 2006
Both i nv f r eqs and i nv f r eqz 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 Speci al Topi cs
4-18
By defaul t i nv f r eqz 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 yno-
mi al s a and b respecti vel y at the frequency w(k), and n i s the number of fre-
quency 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
i nv f r eqz ( 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 i nv f r eqz i s
not guaranteed to be stabl e.
i nv f r eqz 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 ( s i z e( w) ) ; % cr eat e uni t y wei ght i ng v ect or
[ bbb, aaa] = i nv f r eqz ( h, w, 3, 3, wt , 30) % 30 i t er at i ons
bbb =
0. 0464 0. 1829 0. 2572 0. 1549
aaa =
1. 0000 0. 8664 0. 6630 0. 1614
min ( ) ( ) ( ( )) ( ( ))
, b a
k
n
wt k h k A w k B w k

2
1
min ( ) ( )
( ( ))
( ( ))
, b a
k
n
wt k h k
B w k
A w k

2
1
Parametri c M odeli ng
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:
To veri fy the superi ori ty of the fi t numeri cal l y:
s um( abs ( hf r eqz ( bb, aa, w) ) . ^2) % t ot al er r or , al gor i t hm 1
ans =
0. 0200
s um( abs ( hf r eqz ( bbb, aaa, w) ) . ^2) % t ot al er r or , al gor i t hm 2
ans =
0. 0096
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
Original
1st Estimate
2nd Estimate
4 Speci al Topi cs
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 r es ampl e 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 r es ampl e i s
y = r es ampl e( x , p, q)
where the functi on resampl es the sequence x at p/q ti mes the ori gi nal sam-
pl 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 r es ampl e
Deci mati on deci mat e
I nterpol ati on i nt er p
Appl y FI R l ter wi th resampl i ng upf i r dn
Cubi c spl i ne i nterpol ati on s pl i ne
Other 1-D i nterpol ati on i nt er p1
Resampli ng
4-21
The exampl e fi l e contai ns a l ength 4001 vector of speech sampl ed at 7418 Hz:
cl ear
l oad mt l b
whos
Name Si z e By t es Cl as s
Fs 1x 1 8 doubl e ar r ay
mt l b 4001x 1 32008 doubl e ar r ay
Gr and t ot al i s 4002 el ement s us i ng 32016 by t es
l eav i ng 11106880 by t es of memor y f r ee.
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 r at functi on to fi nd i ntegers p and q that yi el d the correct resam-
pl i ng factor:
[ p, q] = r at ( 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 = r es ampl e( mt l b, p, q) ;
4 Speci al Topi cs
4-22
r es ampl e 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 f i r 1 functi on wi th a Kai ser
wi ndow. The syntax
r es ampl e( x , p, q, l , bet a)
control s the fi l ters l ength and the beta parameter of the Kai ser wi ndow. Al ter-
nati vel y, use the functi on i nt f i l t to desi gn an i nterpol ati on fi l ter b and use i t
wi th
r es ampl e( x , p, q, b)
The deci mat e and i nt er p functi ons do the same thi ng as r es ampl e 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 i nt er p func-
ti on i s si gni fi cantl y l ess effi ci ent than the r es ampl e functi on wi th q = 1.
The tool box al so contai ns a functi on, upf i r dn, 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 the reference descri pti on of upf i r dn i n Chapter 6 for
detai l s.
The standard MATLAB envi ronment contai ns a functi on, s pl i ne, that works
wi th i rregul arl y spaced data. The MATLAB functi on i nt er p1 performs i nter-
pol 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 Functi on Reference for i nformati on on
s pl i ne and i nt er p1.
C epstrum Analysi s
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 Pro-
cessi ng Tool box provi des three functi ons for cepstrum anal ysi s:
The compl ex cepstrum for a sequence x i 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 trans-
form 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,
x hat = 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 Oppenhei m and Schafer [2] 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;
s 1 = s i n( 2*pi *45*t ) ;
Add an echo of the si gnal , wi th hal f the ampl i tude, 0.2 seconds after the begi n-
ni ng of the si gnal :
s 2 = s 1 + 0. 5*[ z er os ( 1, 20) s 1( 1: 108) ] ;
Operation Function
Compl ex cepstrum cceps
Real cepstrum r ceps
I nverse compl ex cepstrum i cceps
log x X e e d
j j n

( )

1
]
1

1
2


4 Speci al Topi cs
4-24
The compl ex cepstrum of thi s new si gnal i s
c = cceps ( s 2) ;
pl ot ( t , c)
Note that the compl ex cepstrum shows a peak at 0.2 seconds, i ndi cati ng the
echo.
The real cepstrum of 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 [2]:
The tool box functi on r ceps performs thi s operati on, returni ng the real cep-
strum for a sequence x . The returned sequence i s a real -val ued vector the same
si ze as the i nput vector:
y = r ceps ( x )
By defi ni ti on, you cannot reconstruct the ori gi nal sequence from i ts real cep-
strum 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 r ceps functi on, however,
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 e e d
x
j j n

( )

1
2

log
C epstrum Analysi s
4-25
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 , y m] = r ceps ( x )
where y i s the real cepstrum and y m i s the mi ni mum phase reconstructi on of x .
Inverse Complex Cepstrum
To i nvert the compl ex cepstrum, use the i cceps 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 fre-
quency. 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;
[ x h, nd] =cceps ( x )
x h =
Col umns 1 t hr ough 7
2. 2428 - 0. 0420 - 0. 0210 0. 0045 0. 0366 0. 0788 0. 1386
Col umns 8 t hr ough 10
0. 2327 0. 4114 0. 9249
nd =
1
To i nvert the compl ex cepstrum, use i cceps wi th the ori gi nal del ay parameter:
i cceps ( x h, nd)
ans =
Col umns 1 t hr ough 7
1. 0000 2. 0000 3. 0000 4. 0000 5. 0000 6. 0000 7. 0000
Col umns 8 t hr ough 10
8. 0000 9. 0000 10. 0000
NOTE Wi th any modi cati on of the compl ex cepstrum, the ori gi nal del ay term
may no l onger be val i d. Use the i cceps functi on wi th care.
4 Speci al Topi cs
4-26
Time-Dependent Fourier Transforms and Spectrograms
The Si gnal Processi ng Tool box provi des a functi on, s pecgr am, 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 transform i s the wi ndowed, di s-
crete-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 trans-
form (STFT), has numerous appl i cati ons i n speech, sonar, and radar pro-
cessi ng. The spectrogram of 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 = v co( s awt oot h( 2*pi *t , . 75) , [ 0. 1 0. 4] *Fs , Fs ) ;
s pecgr am( x , 512, Fs , kai s er ( 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
M edi an Fi lteri ng
4-27
Median Filtering
The functi on medf i l t 1 i mpl ements one-di mensi onal medi an fi l teri ng, a non-
l 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, medf i l t 1 assumes zeros
beyond the i nput poi nts.
When the number of el ements n i n the wi ndow i s even, medf i l t 1 sorts the num-
bers, 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
medf i l t 1( [ 4 3 5 2 8 9 1] , 4)
ans =
1. 500 3. 500 3. 500 4. 000 6. 500 5. 000 4. 500
medf i l t 1( [ 4 3 5 2 8 9 1] , 3)
ans =
3 4 3 5 8 8 1
See the I mage Processing Toolbox Users Manual for i nformati on on
two-di mensi onal medi an fi l teri ng.
4 Speci al Topi cs
4-28
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 message signal. The modul at e functi on modul ates a message
si gnal wi th a speci fi ed modul ati on method.
The basi c syntax for the modul at e functi on i s
y = modul at e( x , Fc, Fs , ' met hod' , opt )
where:
x i s the message si gnal .
Fc i s the carri er frequency.
Fs i s the sampl i ng frequency.
met hod 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 a-
ti on methods requi re an opti on argument.)
Operation Function
Modul ati on modul at e
Demodul ati on demod
Vol tage control l ed osci l l ati on v co
C ommuni cati ons Appli cati ons
4-29
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.
I f the i nput x i s an array rather than a vector, modul at e modul ates each
col umn of the array.
To obtai n the ti me vector that modul at e uses to compute the modul ated si gnal ,
speci fy a second output parameter:
[ y , t ] = modul at e( x , Fc, Fs , ' met hod' , opt )
The demod functi on performs demodulation, that i s, i t obtai ns the ori gi nal mes-
sage si gnal from the modul ated si gnal .
The syntax for demod i s
x = demod( y , Fc, Fs , ' met hod' , opt )
demod uses any of the methods shown for modul at e, but the syntax for quadra-
ture 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.
Method Description
amds bs c or am Ampl i tude modul ati on, doubl e si de-band, suppressed
carri er
amds bt c Ampl i tude modul ati on, doubl e si de-band, transmi tted
carri er
ams s b Ampl i tude modul ati on, si ngl e si de-band
f m Frequency modul ati on
pm Phase modul ati on
pt m Pul se ti me modul ati on
pwm Pul se wi dth modul ati on
qam Quadrature ampl i tude modul ati on
4 Speci al Topi cs
4-30
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 = s i n( 2*pi *50*t ) ;
Wi th a carri er frequency of 200 Hz, the modul ated and demodul ated versi ons
of thi s si gnal are
y = modul at e( 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 :
pl ot ( t ( 1: 150) , x ( 1: 150) )
pl ot ( t ( 1: 150) , y ( 1: 150) )
pl ot ( t ( 1: 150) , z ( 1: 150) )
The vol tage control l ed osci l l ator functi on v co creates a si gnal that osci l l ates at
a frequency determi ned by the i nput vector. The basi c syntax for v co i s
y = v co( x , Fc, Fs )
where Fc i s the carri er frequency and Fs i s the sampl i ng frequency.
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
C ommuni cati ons Appli cati ons
4-31
To scal e the frequency modul ati on range:
y = v co( x , [ Fmi n Fmax ] , Fs )
I n thi s case, v co 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 [ Fmi n Fmax ] .
I f the i nput x i s an array, v co produces an array whose col umns osci l l ate
accordi ng to the col umns of x .
See Ti me-Dependent Fouri er Transforms and Spectrograms for an exampl e
usi ng the v co functi on.
4 Speci al Topi cs
4-32
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 System I dentification Toolbox Users Manual for advanced appl i cati ons
of si gnal deconvol uti on.
Speci ali zed Transforms
4-33
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 con-
tours 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 DFT for 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 such as 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 con-
strai ned to operate al ong the uni t ci rcl e, but can eval uate the z-transform al ong
contours descri bed by
z AW l M
l
l

, , ... 0 1
4 Speci al Topi cs
4-34
where A i s the compl ex starti ng poi nt, W i 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 trans-
form. One possi bl e spi ral i s
A = 0. 8*ex p( j *pi /6) ;
W= 0. 995*ex p( j *pi *. 05) ;
M = 91;
z = A*( W. ^( ( 0: M1) ) ) ;
z pl ane( [ ] , z . ' )
cz t ( 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= ex p( j *pi /M) . The z-transform on thi s
contour i s si mpl y the DFT, obtai ned by
y = cz t ( x )
cz t i s faster than the f f t 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 f f t and cz t 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
Speci ali zed Transforms
4-35
Discrete Cosine Transform
The tool box functi on dct computes the di screte cosi ne transform, or DCT, for
an i nput vector or matri x. Mathemati cal l y, the DCT of an i nput sequence x i s
The DCT i s cl osel y rel ated to the di screte Fouri er transform; the DFT i s actu-
al 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 coef-
fi 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 i dct computes the i nverse DCT for an i nput sequence, recon-
structi 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
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 DCT coeffi ci ents. For exampl e, generate a 10
Hz si nusoi dal sequence, sampl ed at 1000 Hz:
t = ( 0: 1/999: 1) ;
x = s i n( 2*pi *25*t ) ;
y k x n
N
k n k N
n
N
( ) ( ) cos ( ), , ..., + +

1 2
2
2 1 0 1
1

x n
N
w k y k
N
k n n N
k
N
( ) ( ) ( ) + ( )

1
2
2 1 0 1
1
cos , , ...,

w k
k
k N
( )
,
,

'

1
2
0
1 1 1


4 Speci al Topi cs
4-36
Compute the DCT of 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 ) ; % comput e DCT
y 2 = f i nd( abs ( y ) < 53) ; % us e 12 coef s .
y ( y 2) = z er os ( s i z e( y 2) ) ; % z er o out poi nt s < 53
z = i dct ( y ) ; % r econs t r uct s i gnal us i ng i nv er s e DCT
Pl ot the ori gi nal and reconstructed sequences.
pl ot ( t , x )
pl ot ( t , z ) , ax i s ( [ 0 1 1 1] )
One measure of the accuracy of the reconstructi on i s
nor m( x z ) /nor m( x )
that i s, the norm of the di fference between the ori gi nal and reconstructed si g-
nal 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 .
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
Speci ali zed Transforms
4-37
Hilbert Transform
The tool box functi on hi l ber t 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 = hi l ber t ( 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 analytic signal, i n reference
to the conti nuous-ti me anal yti c si gnal . A key property of the di screte-ti me ana-
l 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
ori gi nal si gnal .
The Hi l bert transform i s rel ated to the actual data by a 90phase 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 = s i n( 2*pi *60*t ) ;
y = hi l ber t ( x ) ;
pl ot ( t ( 1: 50) , r eal ( y ( 1: 50) ) ) , hol d on
pl ot ( t ( 1: 50) , i mag( y ( 1: 50) ) , ' : ' ) , hol d of f
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 Speci al Topi cs
4-38
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) angl e 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 di f f , as descri bed i n the onl i ne MATLAB Functi on Reference.
References
4-39
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-Time Signal 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 mage Processing. New York: John Wi l ey & Sons, 1991.
4 Speci al Topi cs
4-40



5

I nteracti ve Tool s

5-2 sptool: An Interactive Signal Processing Environment
5-3 Using sptool
5-3

Loadi ng sptool

5-3

Qui ck Start

5-5

Basi c sptool Functi ons

5-8

I mporti ng Si gnal s, Fi l ters, and Spectra

5-14

Worki ng wi th Si gnal s, Fi l ters, and Spectra

5-21

Customi zi ng Preferences

5-30

Control s for Vi ewi ng and Measuri ng

5-43 Using the Signal Browser: Interactive Signal Exploration
5-43

Openi ng the Si gnal Browser

5-44

Basi c Si gnal Browser Functi ons

5-48

Vi ewi ng and Expl ori ng Si gnal s

5-55 Using the Filter Designer: Interactive Filter Design
5-56

Openi ng the Fi l ter Desi gner

5-57

Basi c Fi l ter Desi gner Functi ons

5-61

Desi gni ng FI R (Fi ni te I mpul se Response) Fi l ters

5-64

Desi gni ng I I R (I nfi ni te I mpul se Response) Fi l ters

5-67

Redesi gni ng a Fi l ter Usi ng the Magni tude Pl ot

5-68

Vi ewi ng Frequency Response Pl ots

5-69 Using the Filter Viewer: Interactive Filter Analysis
5-69

Openi ng the Fi l ter Vi ewer

5-70

Basi c Fi l ter Vi ewer Functi ons

5-74

Vi ewi ng Fi l ter Pl ots

5-82 Using the Spectrum Viewer: Interactive Spectral Density Analysis
5-82

Openi ng the Spectrum Vi ewer

5-84

Basi c Spectrum Vi ewer Functi ons

5-87

Vi ewi ng Spectral Densi ty Pl ots

5-88

Control l i ng and Mani pul ati ng Pl ots

5-93 Example: Generation of Bandlimited Noise

5

Interacti ve Tools

5-2

sptool: An Interactive Signal Processing Environment

The Si gnal Processi ng Tool box i ncl udes an i nteracti ve, GUI (graphi cal user
i nterface) envi ronment for performi ng di gi tal si gnal processi ng tasks. The GUI
tool s are a front end for many of the most i mportant tool box functi ons. Wi th
them, you can use the mouse and on-screen control s to i mport, vi ew, and mea-
sure 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 i nteracti ve tool s. Where appropri ate,
there are poi nters to other areas of the manual that show how to perform si m-
i 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, shows how to use the envi ronment for a compl ete fi l ter desi gn and
anal ysi s task.

Overview

s pt ool

i s a graphi cal envi ronment for anal yzi ng and mani pul ati ng di gi tal si g-
nal 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

s pt ool

, you can i mport si gnal s, fi l ters, and spectra
ei ther from the workspace or as MAT-fi l es. Through

s pt ool

, 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

s pt ool

and enabl es you to i nteracti vel y di spl ay, mea-
sure, and anal yze these si gnal s


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 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, i ts group del ay, i ts zero-pol e pl ot, and i ts i mpul se and step
responses


The

Spectrum Viewer

, whi ch enabl es you to vi ew and modi fy spectra created
i n

s pt ool

and provi des a graphi cal anal ysi s of frequency domai n data usi ng
a vari ety of common methods of spectral esti mati on

Usi ng sptool

5-3

Using sptool

s pt ool

i s the data management tool for the i nteracti ve GUI envi ronment of the
Si gnal Processi ng Tool box. Usi ng

s pt ool

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

Window

menu to change to any open MATLAB Fi gure wi ndow

Loading sptool

Load

s pt ool

from the MATLAB Command Wi ndow by typi ng

s pt ool

and pressi ng

Return

.

Quick Start

Once

s pt ool

i s l oaded, you can i mport data from the workspace or from a fi l e.
You can then vi ew i t i n the Si gnal Browser or generate i ts defaul t 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

s pt ool

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 up to Usi ng the Si gnal Browser: I nteracti ve Si gnal
Expl orati on), and then work through the exampl e.

5

Interacti ve Tools

5-4

Ex a mple: Impor ting Signa l Da ta from a M AT- File

Thi s exampl e uses the sampl e fi l e

mt l b. mat

, whi ch i s i n the

Si gnal

fol der.

1

Sel ect

Import

from the

File

menu.
The I mport wi ndow i s di spl ayed:

2

Make sure that

Signal

i s di spl ayed i n the

Import As

drop-down l i st.

3

Cl i ck on the

From Disk

radi o button.
You can ei ther enter a MAT-fi l e name or cl i ck

Browse

to open the fi l e l i sti ng
and sel ect a MAT-fi l e.

4

To get started, type the fi l e name

mt l b. mat

and press

Tab

or

Return

.
The data from the fi l e you sel ected i s di spl ayed i n the Fi l e Contents l i st. I n
thi s exampl e,

mt l b

i s the si gnal data and

Fs

i s the sampl i ng frequency.
Noti ce that

s i g1

i s di spl ayed i n the

Name

fi el d. Thi s i s the defaul t name of
the i mported si gnal .

5

Cl i ck on

mt l b

to sel ect i t, and then cl i ck on the arrow at the l eft of the

Data


fi el d.

mt l b

i s transferred to the

Data

fi el d.

Usi ng sptool
5-5
6 Cl i ck on Fs to sel ect i t, and then cl i ck on the arrow at the l eft of the
Sampling Frequency fi el d.
Fs i s transferred to the Sampling Frequency fi el d.
7 Cl i ck OK.
The si gnal has been i mported i nto s pt ool wi th the name s i g1.
You can l ook at thi s si gnal i n the Si gnal Browser by cl i cki ng on the View
button under Signals.
You can l ook at the frequency content of the si gnal i n the Spectrum Vi ewer by
cl i cki ng on the Create button under Spectra and then cl i cki ng Apply i n the
Spectrum Vi ewer.
Basic sptool Functions
When you fi rst open s pt ool , i t contai ns no si gnal s, fi l ters, or spectra. You can
i mport si gnal s, fi l ters, and spectra i nto s pt ool , 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 al so save and export data from s pt ool and customi ze many properti es of
5 Interacti ve Tools
5-6
the s pt ool envi ronment. The fol l owi ng fi gure shows the s pt ool wi ndow and i ts
File and Help menus, whi ch are descri bed bel ow:
The onl y button that i s enabl ed i s New Design; you can al ways desi gn a new
fi l ter. The rest of the buttons are enabl ed when an appropri ate vari abl e i s
l i sted and sel ected.
File M enu
Open Session. Use Open Session from the File menu to l oad a saved sessi on
fi l e. An s pt ool sessi on i s saved i n a fi l e wi th an . s pt extensi on.
Impor t. Use Import from the File menu to i mport a si gnal , fi l ter, or spectrum
i nto s pt ool from ei ther the workspace or from a fi l e. You can i mport vari abl es
from any MAT-fi l e i nto s pt ool . See I mporti ng Si gnal s, Fi l ters, and Spectra
on page 5-8 and Exampl e: I mporti ng Si gnal Data from a MAT-Fi l e on
page 5-4 for more i nformati on.
Usi ng sptool
5-7
Expor t. Use Export from the File menu to export si gnal s, fi l ters, and spectra
to the MATLAB workspace as structure vari abl es.
Sa ve Session. Use Save Session and Save Session As from the File menu to
save the current sessi on. Save Session overwri tes the exi sti ng sessi on fi l e.
Save Session Assaves the current sessi on wi th a name you speci fy. An
s pt ool sessi on i s saved i n a fi l e wi th an . s pt extensi on.
Preferences. Use Preferences from the File menu to customi ze preferences
for the behavi or of al l the Si gnal Processi ng GUI tool s. See Customi zi ng Pref-
erences on page 5-21 for a compl ete di scussi on.
Close. Use Close from the File menu to cl ose s pt ool and al l other acti ve Si gnal
Processi ng GUI tool s. s pt ool prompts you i f you have not saved the current
sessi on.
When you cl ose s pt ool , al l si gnal and fi l ter customi zati on and rul er i nforma-
ti on set i n any of the GUI tool s i s l ost. Setti ngs you changed and saved usi ng
the Preferences wi ndow i n s pt ool are saved and used the next ti me you
open s pt ool .
Help M enu
Over view Use Overview from the File menu to get general hel p on s pt ool
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.
Context Sensitive Use Context Sensitive from the File menu for hel p on a
speci fi c part of s pt ool . 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 s pt ool , i ncl udi ng menu i tems, to fi nd out what i t i s and how to use
i t.
5 Interacti ve Tools
5-8
Importing Signals, Filters, and Spectra
You can i mport a si gnal , fi l ter, or spectrum i nto s pt ool from ei ther the work-
space or from a fi l e:
Cl i ck Import from the File menu to open the I mport wi ndow:
Loa ding Va ria bles from the Workspa ce
Fi rst l oad the vari abl es i n the workspace i nto the Workspace Contents l i st and
then sel ect the ones to be i mported i nto s pt ool :
1 Cl i ck the From Workspace radi o button.
The contents of the workspace i s di spl ayed i n the Workspace Contents l i st.
Al l l oaded vari abl e data i s l i sted i n the Workspace Contents l i st, al ong wi th
al l other data i n the workspace.
You can now i mport one or more vari abl es from the Workspace Contents l i st
i nto s pt ool . See I mporti ng Workspace Contents and Fi l e Contents on
page 5-9.
Load t he cont ent s of a f i l e i nt o t he Fi l e
Cont ent s l i st by cl i ck i ng here,
and ei t her t ypi ng a f i l ename here
and pressi ng Tabor Enter or
cl i ck i ng Browseand sel ect i ng a MAT-f i l e.
Load t he cont ent s of t he w ork space i nt o
t he Work space Cont ent s l i st by cl i ck i ng
here.
Work space Cont ent s or Fi l e Cont ent s l i st .
Usi ng sptool
5-9
Loa ding Va ria bles from Disk
Fi rst l oad the vari abl es i n a fi l e i nto the Fi l e Contents l i st and then sel ect the
ones to be i mported i nto s pt ool .
1 Cl i ck the From Disk radi o button.
You can ei ther enter a MAT-fi l e name i n the MAT-file Name fi el d or cl i ck
Browse to open the fi l e l i sti ng and sel ect a MAT-fi l e.
2 Type the exact name of the fi l e you want to i mport i nto the MAT-file Name
fi el d and press Tab or Enter.
or
Cl i ck Browse, fi nd and sel ect the fi l e you want to i mport usi ng the Fi l e
Search wi ndow, and cl i ck OK.
The data from the fi l e you sel ected i s di spl ayed i n the Fi l e Contents l i st.
You can now i mport one or more vari abl es from the Fi l e Contents l i st i nto
s pt ool . See I mporti ng Workspace Contents and Fi l e Contents on page 5-9.
Impor ting Workspa ce Contents a nd File Contents
Once youve l oaded the contents of the workspace or a fi l e i nto the Workspace
Contents or Fi l e Contents l i st, you can sel ect one or more vari abl es from the
l i st to i mport i nto s pt ool . You can i mport a vari abl e as a si gnal parameter, a
fi l ter parameter, or a spectrum parameter. You can al so i mport a vari abl e
whose val ue i s a sampl i ng frequency or other parameter vari abl e.
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 i t i nto s pt ool . I n each
case, however, the general procedure for speci fyi ng a vari abl e or a val ue i s the
same for al l data types. I n the fol l owi ng i l l ustrati on, 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-12, I mporti ng
5 Interacti ve Tools
5-10
a Fi l ter on page 5-12, 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 s pt ool .
1 Cl i ck on a vari abl e name i n the Workspace Contents l i st or the Fi l e Contents
l i st to sel ect i t.
I f the vari abl e i s not a saved data object from s pt ool , sel ect the appropri ate
data type (Si gnal , Fi l ter, or Spectrum) from the Import As drop-down l i st
box and type a name i nto the Label fi el d.
I f the vari abl e i s a saved data object from s pt ool , i ts name i s di spl ayed i n
the Label fi el d, and i ts type (Si gnal , Fi l ter, or Spectrum) i s automati cal l y
sel ected i n the Import As drop-down l i st box.
2 Cl i ck on 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 el d di rectl y.
Work space Cont ent s or Fi l e Cont ent s l i st .
Usi ng sptool
5-11
3 The defaul t sampl i ng frequency i s 1. 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 Workspace Contents l i st or Fi l e Contents l i st
whose val ue i s a sampl i ng frequency, to sel ect i t, and then cl i ck on the
arrow at the l eft of the Sampling Frequency fi el d
The sel ected vari abl e i s transferred to the Sampling Frequency fi el d.
or
b Type a val ue i n the Sampling Frequency fi el d
4 Cl i ck OK.
The si gnal i s i mported i nto s pt ool 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, cl i ck the From Work-
space or From File radi o button, and repeat steps 1 through 4 for each vari -
abl e that you want to l oad i nto s pt ool .
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 el d. When youre i mporti ng from di sk, you
can onl y speci fy vari abl es.
5 Interacti ve Tools
5-12
Impor ting a Signa l. When you i mport a si gnal , you speci fy
A vari abl e name for the si gnal data i n the Signal 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
Impor ting a Filter. When you i mport a fi l ter, fi rst sel ect the appropri ate fi l ter
form from the Form drop-down l i st box:
Each fi l ter form requi res di fferent vari abl es:
For Transfer Function you speci fy
A vari abl e name or a val ue for the numerator i n the Numerator fi el d
A vari abl e name or a val ue for the denomi nator i n the Denominator fi el d
Usi ng sptool
5-13
For State-Space you speci fy
A vari abl e name or a val ue for each matri x i n the A-Matrix, B-Matrix,
C-Matrix, and D-Matrix fi el ds
For Zeros, Poles, Gain you speci fy
A vari abl e name or a val ue for the zeros i n the Zeros fi el d
A vari abl e name or a val ue for the pol es i n the Poles fi el d
A vari abl e name or a val ue for the gai n i n the Gain fi el d
For Second-Order Sections you speci fy
A vari abl e name or a val ue for the SOS matri x i n the SOS Matrix fi el d
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
Sampling Frequency fi el d
Impor ting 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) of the si gnal
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
5 Interacti ve Tools
5-14
Working with Signals, Filters, and Spectra
When a si gnal , fi l ter, or spectrum i s i mported i nto s pt ool or created i n s pt ool ,
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 s pt ool buttons, you can edi t vari ous properti es of the data i n
s pt ool and i nvoke al l of s pt ool s di gi tal si gnal processi ng functi ons.
List Displa ys in sptool
Each si gnal , fi l ter, and spectrum i n s pt ool i s di spl ayed i n the appropri ate
Si gnal s l i st, Fi l ters l i st, or Spectra l i st.
Si gnal s are di spl ayed wi th the signal type [ v ect or ] or [ ar r ay ] :
A vector signal ([ v ect or ] ) has one col umn of data.
An array signal ([ ar r ay ] ) has more than one col umn of data.
Spect rum Vi ew but t on Si gnal Vi ew but t on
Fi l t er Vi ew but t on
Si gnal s l i st
Fi l t ers l i st
Spect ra l i st
Usi ng sptool
5-15
Fi l ters are di spl ayed wi th the filter type [ des i gn] or [ i mpor t ed] :
A designed filter ([ des i gn] ) i s a fi l ter that was created usi ng the New
Design functi on. Thi s type of fi l ter can be edi ted i n the Fi l ter Desi gner.
An imported filter ([ i mpor t ed] ) i s a fi l ter that was i mported from the
MATLAB workspace or a fi l e. I t can be appl i ed to a si gnal i n s pt ool , but i t
cannot be edi ted i n the Fi l ter Desi gner.
Spectra are di spl ayed wi th the spectrum type [ aut o] :
An auto-spectrum ([ aut o] ) 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. s pect r um[ aut o] i s
the onl y spectrum type i n s pt ool .
Selecting Da ta O bjects in sptool
Each si gnal , fi l ter, and spectrum i n s pt ool 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.
You can sel ect one data object i n a l i st, you can sel ect a range of data objects i n
a l i st, and you can sel ect mul ti pl e separate data objects i n a l i st. You may have
data objects sel ected i n each l i st; however, when you are sel ecti ng data objects,
you can onl y work i n one l i st at a ti me.
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, Shi ft-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 the sel ecti on, Control -cl i ck on the object. To
remove a si ngl e data object from a mul ti pl e sel ecti on, Control -cl i ck on the
object. I nstead of Control -cl i ck, you can use the ri ght mouse button.
To add a si ngl e data object to the sel ecti on, Command-cl i ck on the object. To
remove a si ngl e data object from a mul ti pl e sel ecti on, Command-cl i ck on the
object.
The Si gnal s l i st shows al l vector and array si gnal s i n the current s pt ool ses-
si on. One or more si gnal s at a ti me may be sel ected.
The Fi l ters l i st shows al l desi gned and i mported fi l ters i n the current s pt ool
sessi on. Onl y one fi l ter at a ti me may be sel ected.
UN IX &
W indow s
Ma cintosh
5 Interacti ve Tools
5-16
The Spectra l i st shows al l spectra i n the current s pt ool sessi on. One or more
spectra at a ti me may be sel ected.
Editing Da ta O bjects in sptool
The Edit menu entri es are onl y avai l abl e when there i s at l east one sel ected
data object (si gnal , fi l ter, or spectrum) i n s pt ool . Use the Edit menu to dupl i -
cate and cl ear data i n s pt ool and to edi t data names and change the sampl i ng
frequency of data.
A si gnal , fi l ter, or spectrum must be sel ected i n order 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
drop-down l i st.
Editing a Signa l, Filter, or Spectrum.
1 Sel ect a si gnal , fi l ter, or spectrum.
2 Cl i ck the appropri ate Edit menu functi on.
The drop-down l i st 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.
Use Duplicate from the Edit menu to make a copy of the sel ected si gnal , fi l ter,
or spectrum i n s pt ool .
Cl i ck Duplicate and 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.
Use Clear from the Edit menu to remove the sel ected si gnal , fi l ter, or spectrum
from the l i st of data objects and thus from s pt ool .
Cl i ck 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 s pt ool sessi on.
Usi ng sptool
5-17
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 Cl i ck Name and drag to choose the si gnal , fi l ter, or spectrum you want to
rename.
The Name Change di al og box i s di spl ayed.
2 Type i n the new name and cl i ck OK.
Use Sampling Frequency from the Edit menu to suppl y a sampl i ng fre-
quency for a sel ected si gnal or fi l ter. The sampl i ng frequency may be a
numbersuch as 1, 0.001, 1/5000or an expressi on usi ng a MATLAB work-
space vari abl esuch as Fs , 1/Ts , or f unct i on.
1 Cl i ck Sampling Frequency and drag to choose the si gnal or fi l ter you want
to change.
The Sampling Frequency di al og box i s di spl ayed.
2 Type i n the val ue or vari abl e name and cl i ck OK.
View ing a Signa l
Use the Si gnal View button 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 Si gnal s l i st and cl i ck the View button 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 Expl orati on on page 5-43 for a ful l descri pti on
of Si gnal Browser functi ons and operati ons.
View ing a Filter
Use the Fi l ter View button to make the Fi l ter Vi ewer acti ve and vi ew an
i mported fi l ter or a fi l ter desi gned or edi ted i n the Fi l ter Desi gner. The Fi l ter
Vi ewer provi des tool s for anal yzi ng a fi l ter; you can i nvesti gate the magni tude
5 Interacti ve Tools
5-18
response, phase, group del ay, zeros and pol es, and i mpul se and step responses
of the sel ected fi l ter.
Sel ect one fi l ter from the Fi l ters l i st and cl i ck the View button i n the fi l ter
panel .
The Fi l ter Vi ewer di spl ays the sel ected fi l ter. See Usi ng the Fi l ter Vi ewer:
I nteracti ve Fi l ter Anal ysi s on page 5-69 for a ful l descri pti on of Fi l ter
Vi ewer functi ons and operati ons.
Designing a Filter
Use the Fi l ter New Design button to make the Fi l ter Desi gner acti ve and
desi gn a fi l ter. You can 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.
Cl i ck the New Design button i n the fi l ter 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 f i l t n, 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. See
Usi ng the Fi l ter Desi gner: I nteracti ve Fi l ter Desi gn on page 5-55 for a ful l
descri pti on of Fi l ter Desi gner functi ons and operati ons.
Use the Fi l ter Edit Design button to make the Fi l ter Desi gner acti ve and edi t
a fi l ter. You can onl y edi t fi l ters whose fi l ter type i s [ des i gn] , that i s, fi l ters
that were created i n s pt ool ; you cannot edi t fi l ters i mported i nto s pt ool , that
i s, fi l ters whose fi l ter type i s [ i mpor t ed] .
Sel ect one fi l ter from the Fi l ters l i st and cl i ck the Edit Design button i n the
fi l ter panel .
The Fi l ter Desi gner di spl ays the sel ected fi l ter. See Usi ng the Fi l ter
Desi gner: I nteracti ve Fi l ter Desi gn on page 5-55 for a ful l descri pti on of
Fi l ter Desi gner functi ons and operati ons.
Usi ng sptool
5-19
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 Si gnal s l i st and one fi l ter from the Fi l ters l i st and
cl i ck 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 Algorithm drop-down l i st, type the
name for the new si gnal i n the Output Signal fi el d, and cl i ck OK.
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 Si gnal s l i st.
Crea ting a Spectr um
Use the Create Spectrum button to acti vate the Spectrum Vi ewer and gen-
erate a defaul t spectrum of a sel ected si gnal . Once youve generated a spec-
trum, 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 Si gnal s l i st and cl i ck the Create Spectrum button
i n the spectrum panel .
The defaul t spectrum for the sel ected si gnal i s automati cal l y generated and
the Spectrum Vi ewer i s acti vated. No spectrum i s di spl ayed yet. The newl y
created spectrum has a defaul t name of s pecn, where n i s a uni que sequen-
ti al i denti fyi ng di gi t. Once the defaul t spectrum i s created, you can use i t as
Cl i ck here t o di spl ay t he
Algorithmdrop-dow n l i st
and drag t o sel ect t he
al gori t hm you w ant t o
use.
Type t he new si gnal
name here.
5 Interacti ve Tools
5-20
i s or edi t i t i n the Spectrum Vi ewer. You can rename i t usi ng Name from
the Edit menu.
2 Use the defaul t parameters i n the Spectrum Vi ewer, or modi fy the parame-
ters as necessary. See Usi ng the Spectrum Vi ewer: I nteracti ve Spectral
Densi ty Anal ysi s on page 5-82 for a ful l descri pti on of Spectrum Vi ewer
parameters and di spl ays.
3 Press Apply i n the Spectrum Vi ewer to compute the spectrum. 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 new spectrum i s di spl ayed i n the Spectrum Vi ewer. See Usi ng the
Spectrum Vi ewer: I nteracti ve Spectral Densi ty Anal ysi s on page 5-82 for a
ful l descri pti on of Spectrum Vi ewer parameters and di spl ays.
View ing a Spectr um
Use the View button i n the Spectrum panel to acti vate the Spectrum Vi ewer
and di spl ay one or more sel ected spectra.
Sel ect one or more spectra from the Spectra l i st and cl i ck View i n the spec-
trum panel .
The Spectrum Vi ewer di spl ays the sel ected spectrum or spectra.
Upda ting a Spectr um
Use the Update Spectrum button to update the sel ected spectrum so that i ts
parameters are l i nked to the currentl y sel ected si gnal .
1 Sel ect one si gnal from the Si gnal s l i st and one spectrum from the Spectra
l i st and cl i ck Update Spectrum i n the spectrum 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.
2 Press Apply i n the Spectrum Vi ewer to compute the spectrum and compl ete
the update.
The parameters for the current spectrum are automati cal l y appl i ed to the
sel ected si gnal .
Usi ng sptool
5-21
Customizing Preferences
Use Preferences from the File menu to customi ze di spl ays and certai n
parameters for s pt ool 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
Confi gure Pl ug-I ns
When you fi rst sel ect Preferences, the Preferences di al og box i s set to
Rulers. You can change the setti ngs for rul ers, or cl i ck on any of the other set-
ti ngs categori es to customi ze other setti ngs.
Cl i ck once on a setti ngs category to sel ect i t.
The fol l owi ng secti ons descri be al l of the setti ngs you can modi fy. The i l l ustra-
ti 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 each preferences
panel .
5 Interacti ve Tools
5-22
Ruler Settings
The Rulers preferences appl y to the rul ers i n the Si gnal Browser and the Spec-
trum Vi ewer.
Ruler Color. Speci fi es the col or of the rul ers i n the Si gnal Browser and the Spec-
trum Vi ewer. Col or i s speci fi ed as a stri ng (e.g. ' r ' ) or RGB tri pl e
(e.g. [ 1 0 0] ).
Type i n a new val ue to change the rul er col or.
Ruler Ma rker. Speci fi es the marker used i n the track and sl ope rul ers i n the
Si gnal Browser and the Spectrum Vi ewer.
Cl i ck i n the drop-down l i st box and drag to sel ect a di fferent marker.
Ma rker Size. Speci fi es the si ze of the rul er marker i n poi nts. Thi s can be any pos-
i ti ve i nteger val ue.
Type i n a new val ue to change the marker si ze.
Initia l 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 and the Spectrum Vi ewer.
Cl i ck i n the drop-down l i st box and drag to sel ect a di fferent rul er type.
Usi ng sptool
5-23
Color Settings
The Colors preferences appl y to si gnal s di spl ayed i n the Si gnal Browser and
the Spectrum Vi ewer.
Color Order. Speci fi es the col or order to cycl e through for si gnal vari abl es i n the
Si gnal Browser and the Spectrum 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 a cel l array col umn of such objects.
Line Style Order. Speci fi es the l i ne styl es to cycl e through for si gnal vari abl es i n
the Si gnal Browser and the Spectrum Vi ewer. The defaul t i s the axi s l i ne styl e
order.
Type i n a new val ue stri ng or stri ng array to change the l i ne styl e order. Li ne
styl e i s speci fi ed as a stri ng (e.g. ' - - ' ) or a cel l array of stri ngs
(e.g. {' - ' , ' - - ' , ' : ' }).
5 Interacti ve Tools
5-24
Signa l Brow ser 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.
X La bel, Y La bel. 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 Ti me 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-32 for detai l s on usi ng the rul ers i n the Si gnal Browser.
Pa nner. 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.
Sta y in Zoom-mode After Zoom. Cl i ck i n the check box to enabl e (checked) or di s-
abl e (unchecked) zoom persi stence i n the Si gnal Browser. See Zoom Control s
on page 5-30 for detai l s on zoom control s i n the Si gnal Browser.
Usi ng sptool
5-25
Spectr um View er Settings
The Spectrum Viewer preferences l et you set axi s parameters, enabl e and di s-
abl e the di spl ay of the rul ers, and toggl e zoom persi stence.
Ma gnitude Axis Sca ling. 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 linear, log, or decibels.
Cl i ck i n the drop-down l i st box and drag to sel ect a di fferent scal i ng.
Frequency Axis Sca ling. 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.
Cl i ck i n the drop-down l i st box and drag to sel ect a di fferent scal i ng.
Frequency Axis Ra nge. 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].
Cl i ck i n the drop-down l i st box and drag to sel ect a di fferent frequency range.
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-32 for detai l s on usi ng the rul ers i n the Spectrum Vi ewer.
Sta y in Zoom-mode After Zoom. Cl i ck i n the check box to enabl e (checked) or di s-
abl e (unchecked) zoom persi stence i n the Spectrum Vi ewer. See Zoom Con-
trol s on page 5-30 for detai l s on zoom control s i n the Spectrum Vi ewer.
5 Interacti ve Tools
5-26
Filter View er Settings
The Filter Viewer preferences l et you set key fi l ter pl ot confi gurati on param-
eters and toggl e zoom persi stence.
FFT Length. Speci fi es the number of poi nts used for the magni tude, phase, and
group del ay pl ots.
Type i n a new val ue to change the FFT l ength.
Time Response Length. Speci fi es the ti me response l ength for the i mpul se and step
response pl ots. An empty val ue [ ] i ndi cates that a val ue wi l l automati cal l y be
chosen from the i mpz functi on.
Type i n a new val ue to change the ti me response l ength.
Ma gnitude Axis Sca ling. 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.
Cl i ck i n the drop-down l i st box and drag to sel ect a di fferent scal i ng.
Pha se Units. Speci fi es the phase uni ts for the phase response pl ot. Phase uni ts
can be degrees or radians.
Cl i ck i n the drop-down l i st box and drag to sel ect a di fferent phase uni t.
Frequency Axis Sca ling. 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.
Cl i ck i n the drop-down l i st box and drag to sel ect a di fferent scal i ng.
Usi ng sptool
5-27
Frequency Axis Ra nge. 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].
Cl i ck i n the drop-down l i st box and drag to sel ect a di fferent frequency range.
Sta y in Zoom-mode After Zoom. Cl i ck i n the check box to enabl e (checked) or di s-
abl e (unchecked) zoom persi stence i n the Fi l ter Vi ewer. See Zoom Control s on
page 5-30 for detai l s on zoom control s i n the Fi l ter Vi ewer.
Filter View er Tiling Settings
The Filter ViewerTiling preferences 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-3 Grid, 3-by-2 Grid, Vertical (6-by-1 Grid), and
Horizontal (1-by-6 Grid).
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.
5 Interacti ve Tools
5-28
Filter Designer Settings
The Filter Designer preferences l et you set key fi l ter confi gurati 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.
Type i n a new val ue or vari abl e name to change the FFT l ength.
Sta y in Zoom-mode a fter Zoom. Turns persi stent zoomi ng on and off, as descri bed
i n Zoom Control s on page 5-30.
Sna p to Grid w hen dra gging ba nds. Turns the gri d snap opti on on and off. Grid
snap constrai ns the l ocati on of the frequency and magni tude i ndi cators to a
pre-set gri d duri ng mouse draggi ng. See Redesi gni ng a Fi l ter Usi ng the Mag-
ni tude Pl ot on page 5-67 for more detai l s on draggi ng frequency and magni -
tude bands.
Frequency Grid Spa cing, Ma gnitude Grid Spa cing. Speci fi es the x-axi s (frequency)
and y-axi s (magni tude) gri d spaci ng to use when gri d snap i s turned on.
Type i n a new val ue or vari abl e name to change ei ther or both gri d spaci ng
opti ons.
Usi ng sptool
5-29
Plug- Ins Settings
The Plug-Ins preferences l et you search for pl ug-i ns when s pt ool i s started up.
Sea rch for Plug-Ins a t sta r t-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 s pt ool . Pl ug-i ns i ncl ude customi zed add-on panel s
and new buttons i n the panel s i n s pt ool , new spectral methods i n the Spec-
trum Vi ewer, and new s pt ool preferences. You can al so pl ug one or more tool -
boxes i nto s pt ool .
You onl y need to use thi s setti ng when you have i nstal l ed extensi ons or have
other tool boxes pl ugged i nto s pt ool .
To use s pt ool wi th extensi ons, check Search for Plug-ins at start-up, cl ose
s pt ool , and restart i t.
Sa ving a nd Disca rding Cha nges 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:
Fa ctor y Settings. Restores the Preferences i n the current panel to thei r factory
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.
5 Interacti ve Tools
5-30
Rever t Pa nel. Cancel s changes i n the current panel onl y. Setti ngs i n the current
panel revert to the previ ous setti ngs.
Ca ncel. Cancel s changes i n al l Preferences categori es and cl oses the
Preferences wi ndow. Setti ngs i n al l panel s revert to thei r previ ous setti ngs.
OK. Appl i es changes i n al l Preferences panel s and cl oses the Preferences
wi ndow. Setti ngs i n al l panel s are saved wi th the new setti ngs i n a MAT-fi l e
cal l ed s i gpr ef s . mat .
I f s i gpr ef s . 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 setti ngs
are saved and are used the next ti me you open s pt ool .
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 are descri 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:
The Fi l ter Desi gner has one addi ti onal vi ewi ng button, the Pass Band button:
The Fi l ter Vi ewer has a subset of the zoom control buttons:
Usi ng sptool
5-31
Each button works the same way i n every GUI tool where i t occurs.
I n normal use, you cl i ck a button once to zoom i n or out of the si gnal di spl ay.
Zoom In-X, Zoom Out-X, Zoom In-Y, a nd 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 cl i ck 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 Y l 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
X l 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 sampl e si ze 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 axes 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,
- Left-cl i ck on the pl ot
- 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 where 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, cl i ck on the Mouse
Zoom button agai n.
Zoom Persistence. Mouse zoomi ng can ei ther be one-ti me or persi stent:
One-ti me zoomi ng i s acti vated when you cl i ck the Mouse Zoom button. 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
UN IX &
W indow s
Ma cintosh
5 Interacti ve Tools
5-32
operati on occurs. Thi s i s the defaul t for the Si gnal Browser, the Fi l ter
Desi gner, and the Spectrum Vi ewer.
Persi stent zoomi ng i s acti vated when you cl i ck the Mouse Zoom button. 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
Zoom button. Thi s i s the defaul t for the Fi l ter Vi ewer.
You can change whether zoomi ng i s one-ti me or persi stent by sel ecti ng Prefer-
ences from the File menu and toggl i ng Stay In Zoom-Mode After Zoom
from the preferences panel s for the Si gnal Browser, the Spectrum Vi ewer, the
Fi l ter Desi gner, and the Fi l ter Vi ewer.
When Stay In Zoom Mode After Zoom i s sel ected, zoomi ng i s persi stent. To
turn off mouse zoomi ng when Stay In Zoom Mode After Zoom i s sel ected, cl i ck
the Mouse Zoom button.
Pa ssba nd 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.
There i s no stopband zoom button. To zoom the stopband, use standard 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 View to return to the standard vi ew.
Ruler Controls
The Si gnal Browser and Spectrum Vi ewer share a common set of rul er control s.
You 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 mea-
sure 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 poi nt 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 l i ne sel ecti on control s at the top ri ght of the wi ndow and the but-
Usi ng sptool
5-33
tons and edi t boxes i n the Rul ers panel . The Spectrum Vi ewer has the same
rul er control s and they work the same way.
Picking a line to mea sure. 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, Hor-
izontal, 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 l i ne sel ec-
ti on drop-down l i st box.
There are two ways to sel ect a si gnal (l i ne):
Cl i ck on the l i ne sel ecti on drop-down l i st and drag to sel ect the l i ne to
measure.
Al l vari abl es that are currentl y di spl ayed i n the Si gnal Browser (or Spec-
trum Vi ewer) are l i sted. Vector si gnal s i n the Si gnal Browser, and spectra i n
the Spectrum Vi ewer, are l i sted as si ngl e vari abl es; i n the Si gnal Browser,
Fi nd rul er but t ons
Rul er cont rol but t ons
Li ne sel ect i on drop-dow n l i st Li ne sel ect i on di spl ay
Color but t on
Rul ers panel
Di spl ay peak s and val l eys
but t ons
Save Rulers but t on
Edi t boxes i n Rul ers
panel
5 Interacti ve Tools
5-34
each col umn of a two-di mensi onal si gnal matri x i s l i sted as a separate
vari abl e.
or
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.
The l abel of the vari abl e, 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 l i ne sel ecti on drop-down l i st box.
The l i ne sel ecti on di spl ay changes to the col or and pattern of the sel ected si gnal
or spectrum.
Line Selection Drop-dow n List. Use to sel ect a l i ne (vector si gnal , array col umn, or
spectrum) to measure.
Cl i ck the l i ne sel ecti on drop-down l i st and drag to sel ect the l i ne.
Line Selection Displa y. The l i ne col or and styl e of the sel ected si gnal are 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 Line drop-down l i st, whi ch i s shown i n the panel 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 Line Style drop-down l i st 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, as shown on the l eft. 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.
Usi ng sptool
5-35
Find Ruler Button. Use the fi nd rul er buttons to bri ng one or
both rul ers to the center of the mai n axes. When both
rul ers are wi thi n the si gnal di spl ay (mai n axes) area, the
fi nd rul er buttons, at the top ri ght of the mai n axes area,
are not di spl ayed, as shown i n the pi cture on the ri ght:
I f the rul ers are not wi thi n the si gnal di spl ay area, both
fi nd rul er 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 fi nd rul er button to bri ng the speci fi ed rul er to
the center of the mai n axes.
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-38 for
detai l s on mani pul ati ng the rul ers and measuri ng the sel ected si gnal .
Ruler Control Buttons. Use the rul er control buttons to sel ect the type of measure-
ment 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 Rul ers panel changes dependi ng on whi ch rul er control i s sel ected. See
Maki ng Si gnal Measurements on page 5-38 for detai l s on the four ki nds of
measurements you can make and the parameters for each one.
Rulers Pa nel a nd Edit Boxes. The Rul ers panel changes dependi ng on whi ch rul er
control i s sel ected: Vertical, Horizontal, Track, or Slope. I t shows the param-
eters 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: x 1, y 1, x 2, y 2, dx , dy , m. The pi cture
on the l eft shows the Rul ers panel when Slope i s sel ected.
When you cl i ck on 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
5 Interacti ve Tools
5-36
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 Slope i 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 Rul ers 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
Rul ers panel . The parameters are ei ther the x 1 and x 2 val ues or the y 1 and y 2
val ues, dependi ng on whi ch rul er control i s sel ected.
Type the val ue or vari abl e for the rul er parameter i n the x1 and x2 boxes or
the y1 and y2 boxes.
See Maki ng Si gnal Measurements on page 5-38 for detai l s on mani pul ati ng
the rul ers and the parameters you can measure wi th each one.
Displa y Pea ks a nd Va lleys. 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 or spectrum. Onl y peaks,
onl y val l eys, or both peaks and val l eys may be di spl ayed.
Cl i ck Display Peaks to toggl e showi ng (down) or hi di ng (up) the maxi ma of
the si gnal .
Cl i ck Display Valleys to toggl e showi ng (down) or hi di ng (up) the mi ni ma of
the si gnal .
Usi ng sptool
5-37
I n track and sl ope mode (see Maki ng Si gnal Measurements on page 5-38), 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.
Sa ve Rulers Button. Once youve set up and made a certai n set of measure-
ments, you may fi nd i t useful to save them, ei ther to export or to use agai n i n
s pt ool . Use the Save Rulers button to save a structure i n the MATLAB
workspace wi th the fi el ds x 1, y 1, x 2, y 2, dx , dy , m, peaks , and v al l ey s . Unde-
fi ned val ues are set to NaN.
1 Cl i ck Save Rulers to 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 cl i ck OK.
5 Interacti ve Tools
5-38
M a king Signa l M ea surements
You use the rul ers to make measurements on a sel ected l i ne, whi ch i s ei ther a
vector or a col umn of a matri x i n the Si gnal Browser or a spectrum i n the
Spectrum Vi ewer.
1 Sel ect a l i ne as descri bed on page 5-33.
2 Appl y a rul er to the di spl ay as descri bed on page 5-35.
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 drag.
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 Rul ers 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: x 1, y 1, x 2, y 2, dx , dy , m.
You can al so posi ti on a rul er by typi ng i ts x 1 and x 2 or y 1 and y 2 val ues i n the
Rul ers panel , as descri bed on page 5-35.
Usi ng sptool
5-39
Ruler Controls: Ver tica l. There are two verti cal rul ers, cal l ed ruler 1 and ruler 2.
When verti cal rul ers are i n use, the measurements di spl ayed i n the Rul ers
panel are x 1 (the posi ti on of ruler 1 on the x-axi s), x 2 (the posi ti on of ruler 2
on the x-axi s), and dx (the val ue of x2-x1).
Cl i ck Vertical to put the rul ers i n verti cal mode.
I n verti cal mode, you change the x-val ues of the rul ers (that i s, thei r hori zontal
posi ti on). As the x 1 and x 2 val ues change, the val ue of dx changes automati -
cal l y.
You change the x 1 and x 2 val ues by
Draggi ng the rul ers to the l eft and the ri ght wi th the mouse
or
Enteri ng thei r val ues i n the x1 and x2 edi t boxes i n the Rul ers panel
5 Interacti ve Tools
5-40
Ruler Controls: Horizonta l. There are two hori zontal rul ers, cal l ed ruler 1 and
ruler 2. When hori zontal rul ers are i n use, the measurements di spl ayed i n the
Rul ers panel are y 1 (the posi ti on of ruler 1 on the y-axi s), y 2 (the posi ti on of
ruler 2 on the y-axi s), and dy (the val ue of y2-y1).
Cl i ck Horizontal to put the rul ers i n hori zontal mode.
I n hori zontal mode, you change the y-val ues of the rul ers (that i s, thei r verti cal
posi ti on). As the y 1 and y 2 val ues change, the val ue of dy changes automati -
cal l y.
You change the y 1 and y 2 val ues by
Draggi ng the rul ers up and down wi th the mouse
or
Enteri ng thei r val ues i n the y1 and y2 edi t boxes i n the Rul ers panel
Usi ng sptool
5-41
Ruler Controls: Tra ck. There are two verti cal rul ers, cal l ed ruler 1 and ruler 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
Rul ers panel are x 1 (the posi ti on of ruler 1 on the x-axi s), y 1 (the posi ti on of
ruler 1 on the y-axi s), x 2 (the posi ti on of ruler 2 on the x-axi s), y 2 (the posi ti on
of ruler 2 on the y-axi s), dx (the val ue of x2-x1), and dy (the val ue of y2-y1).
Cl i ck Track to put the rul ers i n track mode.
You can change the track marker i n the Rulers preferences panel ; see Rul er
Setti ngs on page 5-22.
I n track mode, you change the x-val ues of the rul ers (that i s, thei r hori zontal
posi ti on). As the x 1 and x 2 val ues change, the val ues of y 1, y 2, dx , and dy
change automati cal l y.
You change the x 1 and x 2 val ues by
Draggi ng the rul ers to the l eft and the ri ght wi th the mouse
or
Enteri ng thei r val ues i n the x1 and x2 edi t boxes i n the Rul ers panel
5 Interacti ve Tools
5-42
Ruler Controls: Slope. There are two verti cal rul ers, cal l ed ruler 1 and ruler 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 (x 1,y 1) and (x 2,y 2) i s i ncl uded i n the mai n pl ot, so you can approx-
i mate deri vati ves and sl opes of the si gnal .
When sl ope rul ers are i n use, the measurements di spl ayed i n the Rul ers panel
are x 1 (the posi ti on of ruler 1 on the x-axi s), y 1 (the posi ti on of ruler 1 on the
y-axi s), x 2 (the posi ti on of ruler 2 on the x-axi s), y 2 (the posi ti on of ruler 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 x1 and x2).
Cl i ck Slope to put the rul ers i n sl ope mode.
I n sl ope mode, you change the x-val ues of the rul ers (that i s, thei r hori zontal
posi ti on). As the x1 and x2 val ues change, the val ues of dy and m change auto-
mati cal l y.
You change the x 1 and x 2 val ues by
Draggi ng the rul ers to the l eft and the ri ght wi th the mouse
or
Enteri ng thei r val ues i n the x1 and x2 edi t boxes i n the Rul ers panel
Usi ng the Si gnal Browser: Interacti ve Si gnal Explorati on
5-43
Using the Signal Browser:
Interactive Signal Exploration
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
Si gnal s col umn of s pt ool .
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
Opening the Signal Browser
Open or acti vate the Si gnal Browser from s pt ool :
1 Cl i ck on one or more si gnal s i n the Si gnal s l i st of s pt ool .
2 Press View i n the Si gnal s panel of s pt ool .
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 Interacti ve 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 s-
pl ay drop-down l i st box
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 com-
pari sons
A panner for seei ng what part of the si gnal i s currentl y bei ng di spl ayed, and
qui ckl y movi ng the vi ew to other features of the si gnal
A menu opti on for pl ayi ng a sel ected spectrum through audi o equi pment
Vi ew i ng ( zoom) cont rol s Measuri ng ( l i ne and rul er) cont rol s
Panner
Mai n axes
( di spl ay) area
Di spl ay management cont rol s
Usi ng the Si gnal Browser: Interacti ve Si gnal Explorati on
5-45
Signa l Brow ser M enus
File Menu. Use Close from the File menu 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. Setti ngs you changed and saved
usi ng the Preferences wi ndow i n s pt ool are saved and used the next ti me
you open a Si gnal Browser.
Options Menu. Use Play from the Options menu to pl ay the sel ected si gnal .
Play onl y works 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.
W indow Menu. Use the wi ndow menu 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 Mouse Zoom, Full
View, Zoom In-Y, Zoom Out-Y, Zoom In-X, and Zoom Out-X. See Zoom Con-
trol s on page 5-30 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 Preferences to toggl e zoom persi stence on and off.
See Si gnal Browser Setti ngs on page 5-24.
Ruler a nd Line Displa y Controls
Usi ng the rul ers and l i ne di spl ay control s, you can measure a vari ety of char-
acteri sti cs of si gnal s i n the Si gnal Browser. See Rul er Control s on page 5-32
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 Si gnal Browser setti ngs panel i n Preferences. See
Si gnal Browser Setti ngs on page 5-24.
Help Button
To use context-sensi ti ve hel p, cl i ck on 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 Interacti ve Tools
5-46
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.
Displa y M a na gement Controls
Arra y Signa lsButton. 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 array si gnal i s
sel ected i n s pt ool .
1 Cl i ck on Array Signals
The Col umn Sel ecti on for Array Si gnal s di al og box i s di spl ayed:
Al l array si gnal s that are sel ected i n s pt ool 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 Signa l Displa y. 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 vari abl es sel ected i n s pt ool 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 just real .
Cl i ck and drag to sel ect the pl otti ng mode.
Usi ng the Si gnal Browser: Interacti ve Si gnal Explorati on
5-47
M a in Ax es Displa y Area
The Si gnal s l i st i n s pt ool shows al l si gnal s i n the current s pt ool 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 s-
pl ayed graphi cal l y i n the mai n axes di spl ay area of the Si gnal Browser.
When there i s onl y one si gnal di spl ayed, i ts properti es are refl ected i n the di s-
pl 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-38), you can choose how to di s-
pl ay the si gnal (see Di spl ay Management Control s on page 5-46), and you can
pl ay the si gnal (see Opti ons Menu on page 5-45). The l abel of the sel ected
si gnal (l i ne) i s di spl ayed i n the l i ne sel ecti on drop-down l i st box.
There are three ways to sel ect a si gnal (l i ne) i n the Si gnal Browser:
Cl i ck on the l i ne sel ecti on drop-down l i st and drag to sel ect the l i ne to
measure.
or
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.
or
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 Pi cki ng a l i ne to measure on page 5-33 for detai l s.
Axes La bels. By defaul t, the x-axi s i n the Si gnal Browser i s l abel ed Ti me. You
can change the x-axi s l abel and add a y-axi s l abel usi ng the Si gnal Browser set-
ti ngs panel i n Preferences. See Si gnal Browser Setti ngs on page 5-24.
Click-a nd-Dra g Pa nning. You can use the mouse to pan around the mai n axes di s-
pl 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.
5 Interacti ve Tools
5-48
The Pa nner
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.
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 Preferences. See Si gnal
Browser Setti ngs on page 5-24.
M a king Signa l M ea surements
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-38 for detai l s.
Viewing and Exploring Signals
You can open or acti vate the Si gnal Browser i n s pt ool by sel ecti ng one or more
si gnal s and pressi ng View i 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 a nd Displa ying a Signa l
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 el ements of the sel ected si gnal s
Usi ng the Si gnal Browser: Interacti ve Si gnal Explorati on
5-49
are pl otted versus an equal l y spaced ti me vector i n both the mai n axes di spl ay
and the panner:
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
l i ne sel ecti on drop-down l i st.
5 Interacti ve Tools
5-50
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 l i ne sel ecti on drop-down l i st, and i ts
col or i s di spl ayed i n the l i ne sel ecti on fi el d.
Usi ng the Si gnal Browser: Interacti ve Si gnal Explorati on
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, use
Array Signals to speci fy the col umn vectors to be di spl ayed (see Array Si g-
nal sButton on page 5-46). 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 i n both
5 Interacti ve Tools
5-52
the mai n axes and the panner, and i ts l abel i s hi ghl i ghted i n the l i ne sel ecti on
drop-down l i st box:
Pa nner Displa y
The panner di spl ays the enti re si gnal sampl e at al l ti mes:
Usi ng the Si gnal Browser: Interacti ve Si gnal Explorati on
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 wi ndow the regi on of data di s-
pl 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.
M a nipula ting Displa ys
Cha nging Signa l Displa ys. 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
Line Style Order fi el ds i n the Colors setti ngs panel (seeCol or Setti ngs on
page 5-23).
Cha nging the Sa mple Inter va l. You can change the sampl e i nterval usi ng
Sampling Frequency from the Edit menu i n s pt ool . See Edi ti ng a Si gnal ,
Fi l ter, or Spectrum on page 5-16.
Displa ying Complex Signa ls. You can change how compl ex numbers are di spl ayed
by sel ecti ng Real, Imaginary, Magnitude, or Angle from the drop-down l i st
box. See Array Si gnal sButton on page 5-46.
Cha nging Signa l Brow ser Displa ys. Usi ng the Signal Browser setti ngs panel i n
Preferences, you can set opti onal x-axi s and y-axi s l abel s, enabl e and di sabl e
5 Interacti ve Tools
5-54
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-24.
Working w ith Signa ls
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-30).
You can mark off a segment of the di spl ay wi th the rul ers (see Rul er Con-
trol s on page 5-32) 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 s-
pl 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-38).
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 Pi cki ng a l i ne to measure on page 5-33).
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-55 and
Usi ng the Fi l ter Vi ewer: I nteracti ve Fi l ter Anal ysi s on page 5-69).
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 Spectral Densi ty Anal ysi s on page 5-82).
You access the Fi l ter Desi gner, Fi l ter Vi ewer, and Spectrum Vi ewer tool s from
s pt ool . You can access s pt ool from the Si gnal Browser by
Cl i cki ng on an acti ve s pt ool wi ndow
or
Acti vati ng s pt ool usi ng the Window menu i n the Si gnal Browser
Usi ng the Fi lter Desi gner: Interacti ve Fi lter Desi gn
5-55
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 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, or bandstop fi l ters).
The Fi l ter Desi gner provi des access to many of the I I R fi l ter desi gn functi ons
di scussed i n Chapter 2, i ncl udi ng the but t er , cheby 1, cheby 2, and el l i p func-
ti ons. I n addi ti on, the Fi l ter Desi gner provi des access to the r emez , f i r l s , and
kai s er functi ons for the desi gn of FI R fi l ters wi th hi ghpass, l owpass, band-
pass, or bandstop confi gurati ons.
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 Butter-
worth, Chebyshev I, Chebyshev II, and Elliptic desi gn opti ons
Desi gn FI R fi l ters wi th standard band confi gurati ons, usi ng the Equir-
ipple, Least Squares, and Kaiser Window desi gn opti ons
Speci fy the fi l ters sampl i ng frequency and the passband and stopband edge
frequenci es
Speci fy the desi red amount of ri ppl e i n the fi l ters passband and attenuati on
i n the stopband
Redesi gn a fi l ter by manual l y adjusti ng i ndi cators i n the magni tude pl ot
Use an automati cal l y appl i ed fi l ter order or set a custom fi l ter order
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 s pt ool (see Appl yi ng a Fi l ter
on page 5-19).
NOTE For i nformati on on usi ng l ter desi gn functi ons from the command l i ne
or from M-l es, see Chapter 2.
5 Interacti ve Tools
5-56
Opening the Filter Designer
You can open or acti vate the Fi l ter Desi gner from s pt ool by pressi ng one of the
fol l owi ng buttons: New Design, Edit Design. See Desi gni ng a Fi l ter on
page 5-18 for compl ete detai l s.
Here i s a bri ef summary of each method of acti vati ng the Fi l ter Desi gner:
To create a fi l ter, press New Design i n s pt ool .
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 one fi l ter i n s pt ool 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.
Usi ng the Fi lter Desi gner: Interacti ve Fi lter Desi gn
5-57
Basic Filter Designer Functions
The Fi l ter Desi gner has the fol l owi ng components:
A magni tude pl ot (di spl ay) area for vi ewi ng fi l ters graphi cal l y
A desi gn panel for vi ewi ng and modi fyi ng the desi gn parameters of the cur-
rentl y sel ected fi l ter
Zoom control s for getti ng a cl oser l ook at fi l ter features
Speci fi cati ons l i nes for manual l y adjusti ng the response parameters of a
fi l ter
A menu opti on for speci fyi ng speci al parameters that are speci fi c to each of
the fi l ter desi gn methods.
Sel ect f i l t er t ype and
conf i gurat i on.
Speci f y band edges.
Speci f y passband ri ppl e
and st opband at t enuat i on.
Di spl ay sampl i ng f requency
f rom sptool
Speci f y f i l t er order ( Set) or l et
Fi l t er Desi gner det ermi ne t he
l ow est order t hat meet s t he
speci f i cat i ons ( Auto) .
Vi ew i ng ( zoom) cont rol s
Desi gn panel
Speci f i cat i ons l i nes.
Cl i ck -and-drag t o
manual l y adj ust t he
response paramet ers of
t he f i l t er.
5 Interacti ve Tools
5-58
Filter Designer M enus
File Menu. Use Close from the File menu to cl ose the Fi l ter Desi gner. Setti ngs
you changed and saved usi ng the Preferences wi ndow i n s pt ool are saved
and used the next ti me you open the Fi l ter Desi gner.
Options Menu. Use Special Design Parameters from the Options menu to
speci fy parameters that are speci fi c to each of the fi l ter desi gn methods.
The di spl ay i s di fferent, dependi ng on whi ch desi gn method i s sel ected, but the
process of setti ng the parameters i s the same:
When the Auto radi o button i s sel ected, the speci al parameters are deter-
mi ned automati cal l y by the Fi l ter Desi gner.
When the Set radi o button i s sel ected, the speci al parameters are gi ven by
the val ues you enter i n the edi tabl e text fi el d.
Cl i ck the Auto-->Set button to transfer the Fi l ter Desi gners automati cal l y
determi ned speci al parameters i nto the edi tabl e text fi el d.
See Fi l ter Desi gn Opti ons on page 5-66 for a l i st of the parameters used i n
each desi gn method.
W indow Menu. Use the wi ndow menu to sel ect a currentl y open MATLAB
wi ndow.
Usi ng the Fi lter Desi gner: Interacti ve Fi lter Desi gn
5-59
Filter Design Pa nel
When you desi gn a new fi l ter, 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,
as shown i n the panel at the l eft.
Use the drop-down menu sel ecti ons at the top of the panel to change the opti -
mi zati on cri teri on used to desi gn the fi l ter and the type of desi red frequency
response. Use the edi t box to change val ues for band edges and amount of
ri ppl e and attenuati on i n the passband and stopband. Use the radi o buttons to
speci fy the l ength of the fi l ter or l et i t be determi ned automati cal l y by the Fi l ter
Desi gner. The fol l owi ng exampl e i l l ustrates these steps:
1 Cl i ck-and-drag to sel ect an appropri ate fi l ter type
from the fi rst drop-down menu:
2 Cl i ck-and-drag to sel ect the
band confi gurati on to use wi th
the fi l ter:
3 Cl i ck on a val ue i n the edi tabl e fi el ds to change the val ue for band edges,
ri ppl e, and attenuati on.
4 To speci fy an order,
a Cl i ck Auto to sel ect automati c fi l ter order sel ecti on
or
b Cl i ck Set and type i n a val ue (see Opti ons Menu on page 5-58 for
detai l s).
Edi t a new fi l ter or an exi sti ng fi l ter i n the same way. You can onl y edi t fi l ters
that were desi gned i n s pt ool .
Fs (Sa mpling Frequency). shows the sampl i ng frequency of the fi l ter. You can
change the fi l ters sampl i ng frequency usi ng Sampling Frequency from the
Edit menu i n s pt ool . See Edi ti ng a Si gnal , Fi l ter, or Spectrum on page 5-16.
The measurements correspondi ng to the edges and wi dths of the passband and
stopband change accordi ngl y when you change Fs .
5 Interacti ve Tools
5-60
Zoom Controls
The avai l abl e zoom control s i n the Fi l ter Desi gner are Mouse Zoom, Full
View, Zoom In-Y, Zoom Out-Y, Zoom In-X, Zoom Out-X, and Pass Band. See
Zoom Control s on page 5-30 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 Preferences to toggl e zoom persi stence on and off.
See Fi l ter Desi gner Setti ngs on page 5-28.
Help Button
To use context-sensi ti ve hel p, cl i ck on 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 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.
M a gnitude Plot (Displa y) Area
The Fi l ters l i st i n s pt ool shows al l fi l ters i n the current s pt ool sessi on. Onl y
one fi l ter may be sel ected at a ti me. The sel ected fi l ter i s di spl ayed graphi cal l y
i n the magni tude pl ot area of the Fi l ter Desi gner and i ts properti es are shown
i n the desi gn panel .
You can zoom i n the di spl ayed fi l ter i n the magni tude pl ot (see Zoom Control s
on page 5-30) and you can drag the speci fi cati ons l i nes to vi sual l y and manu-
al l y redesi gn the di spl ayed fi l ter (see Speci fi cati ons Li nes on page 5-61). The
name of the fi l ter wi th i ts desi gn characteri sti cs i s di spl ayed above the magni -
tude pl ot di spl ay area.
The magni tude pl ot has defaul t frequency (x-axi s) and magni tude (y-axi s) gri d
spaci ng. You can change the gri d spaci ng usi ng the Fi l ter Desi gner setti ngs
panel i n Preferences (see Fi l ter Desi gner Setti ngs on page 5-28).
Usi ng the Fi lter Desi gner: Interacti ve Fi lter Desi gn
5-61
Specica tions Lines
You can redesi gn a fi l ter by mani pul ati ng the speci fi cati ons l i nes i n the mag-
ni tude pl ot. Usi ng the speci fi cati ons l i nes, you can change 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 l i ne and drag-
gi ng i t up or down. The val ues di spl ayed i n Rp or Rs change as you drag.
NOTE Wi th I I R l ters you can onl y drag the l ower passband bar and the stop-
band bar. The upper passband bar i s xed at 0.
Set edge frequenci es by cl i cki ng on the end of a l i ne and draggi ng i t hori zon-
tal l y to resi ze i t. The val ues di spl ayed i n f 1 or f 2 (and f 3 and f 4, when they
are used) change as you drag.
See Redesi gni ng a Fi l ter Usi ng the Magni tude Pl ot on page 5-67 for detai l s.
The speci fi cati ons l i nes snap to a pre-set gri d as they are dragged, when the
grid snap opti on i s on. You can toggl e the state of the gri d snap usi ng the Fi l ter
Desi gner setti ngs panel i n Preferences (see Fi l ter Desi gner Setti ngs on
page 5-28).
Designing FIR (Finite Impulse Response) 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 ow-
pass, hi ghpass, bandpass, or bandstop confi gurati ons onl y). The three opti ons
for FI R fi l ter desi gn are
Equiripple, whi ch accesses the tool box functi on r emez to create an equi r-
i ppl e FI R fi l ter.
Least squares, whi ch accesses the tool box functi on f i r l s to create an FI R
fi l ter usi ng the l east square desi gn method.
Kaiser window, whi ch accesses the f i r 1 functi on to create an FI R fi l ter
usi ng a Kai ser wi ndow.
5 Interacti ve Tools
5-62
Ex a mple: FIR Filter Design, Sta nda rd Ba nd Congura tion
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 Kai ser Wi ndow as the fi l ter type and bandpass as the confi gurati on.
2 Acti vate s pt ool from the Window menu and set the sampl i ng frequency to
2000 (i n Hertz).
Use Sampling Frequency from the Edit menu i n s pt ool .
NOTE Thi s must be done before you change the other setti ngs.
3 Reacti vate the Fi l ter Desi gner from the Window menu.
4 Set f 1 to 200 and f 2 to 290.
These fi el ds defi ne the wi dth for the stopband to passband transi ti on, i n
Hertz.
5 Set f 3 to 525 and f 4 to 625.
These fi el ds defi ne the wi dth for the passband to stopband transi ti on, i n
Hertz.
6 Set Rp (passband ri ppl e) to 4. Set Rs (stopband attenuati on) to 30.
Rp and Rs are speci fi ed i n deci bel s.
7 Sel ect Auto for fi l ter order computati on.
Usi ng the Fi lter Desi gner: Interacti ve Fi lter Desi gn
5-63
The Fi l ter Desi gner cal l s f i r 1 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:
Filter Design O ptions
Duri ng the desi gn process, you can speci fy parameters that defi ne characteri s-
ti cs uni que to certai n fi l ter types by sel ecti ng Special Design Parameters
from the Options menu (see page 5-58 for detai l s).
The exact parameters you can speci fy depend on the fi l ter, as fol l ows:
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 beta parameter of the
Kai ser wi ndow
O rder Selection for FIR Filter Design w ith the Filter Designer
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 r emez , f i r l s , and f i r 1. 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 Equiripple desi gn opti on cal l s the r emez or d 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,
5 Interacti ve Tools
5-64
r emez or d 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 Auto order sel ecti on, sel ect Set and
speci fy a sl i ghtl y l arger order (n+1 or n+2).
The Least squares desi gn opti on cal l s the tool box functi on f i r l s . Because
the tool box does not provi de an order esti mati on functi on for use wi th f i r l s ,
you cannot use the Auto order sel ecti on opti on wi th the Least squares
method.
The Kaiser window desi gn opti on cal l s kai s er or d, 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 Auto order sel ecti on, sel ect
Set and 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. I f you attempt to set the
fi l ter order to an odd val ue for these cases, the Fi l ter Desi gner automati cal l y
i ncrements i t by 1. 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 r emez , r emez or d, kai s er or d,
f i r l s , and f i r 1 i n Chapter 6.
Designing IIR (Innite Impulse Response) 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.
Ex a mple: Cla ssica l 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 a Chebyshev I fi l ter, hi ghpass as the confi gurati on.
2 Acti vate s pt ool from the Window menu and set the sampl i ng frequency to
2000 (i n Hertz).
Use Sampling Frequency from the Edit menu i n s pt ool .
Usi ng the Fi lter Desi gner: Interacti ve Fi lter Desi gn
5-65
NOTE Thi s must be done before you change the other setti ngs.
3 Reacti vate the Fi l ter Desi gner from the Window menu i n s pt ool .
4 Set f 1 (passband edge frequency) to 700. Set f 2 (stopband edge frequency)
to 800.
f 1 and f 2 are speci fi ed i n Hertz.
5 Set Rp (passband ri ppl e) to 2.5. Set Rs (stopband attenuati on) to 35.
Rp and Rs are speci fi ed i n deci bel s.
6 Sel ect Set and speci fy a fi l ter order of 7.
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. The magni tude pl ot di spl ay area i s updated to show the new fi l ters mag-
ni tude response:
5 Interacti ve Tools
5-66
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-30.
Filter Design O ptions
Duri ng the desi gn process, you can speci fy parameters that defi ne characteri s-
ti cs uni que to certai n fi l ter types by sel ecti ng Special Design Parameters
from the Options menu (see page 5-58 for detai l s).
The exact parameters you can speci fy depend on the fi l ter, as fol l ows:
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 pre-
vi ous exampl e as a Butterworth fi l ter, usi ng a 3 dB frequency of 800 Hz:
1 Sel ect Butterworth as the fi l ter type.
The magni tude response pl ot changes to a dotted l i ne to i ndi cate that the
pl ot no l onger refl ects the control setti ngs.
2 Access the speci al fi l ter parameters by sel ecti ng Special Design
Parameters from the Options menu.
The Speci al Parameters di al og box i s di spl ayed.
3 Sel ect the Set radi o button and type a val ue of 800 i n the text fi el d.
4 Enter the val ue by cl i cki ng on the Close button.
After a moment, the magni tude response pl ot changes to a sol i d l i ne to refl ect
the new setti ngs and di spl ay the new fi l ter.
O rder 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 Auto
check box i s sel ected.
Usi ng the Fi lter Desi gner: Interacti ve Fi lter Desi gn
5-67
For detai l s on order sel ecti on wi th the I I R fi l ter desi gn opti ons, see the refer-
ence descri pti ons of but t or d, cheb1or d, cheb2or d, and el l i por d i n Chapter 6.
Sa ving Filter Da ta
After desi gni ng a fi l ter i n the Fi l ter Desi gner, you can export fi l ter i nformati on
to di sk or to the workspace usi ng Export from the File menu i n s pt ool (see
Export on page 5-7 for detai l s).
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 ons l i nes i n the magni tude pl ot. Use the speci fi cati ons l i nes to
change passband ri ppl e, stopband attenuati on, and edge frequenci es (see
Speci fi cati ons Li nes on page 5-61 for detai l s). I n the fol l owi ng exampl e,
modi fy the fi l ter created above usi ng the speci fi cati ons l i nes:
1 I f i t i s not al ready sel ected, sel ect Auto 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.
2 Posi ti on the cursor over the l ower l i ne boundi ng the passband.
The cursor changes to the up/down drag i ndi cator.
3 Drag the l i ne unti l the Rp (passband ri ppl e) fi el d reads 0.75.
Note that the Auto fi el d updates because a hi gher fi l ter order i s needed to
meet the new speci fi cati ons.
The magni tude response pl ot bri efl y changes to a dotted l i ne to i ndi cate that
the pl ot no l onger refl ects the control setti ngs.
After a moment, the magni tude response pl ot changes to a sol i d l i ne to refl ect
the new setti ngs and di spl ay the new fi l ter.
5 Interacti ve Tools
5-68
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 a fi l ter i n the Fi l ter Desi gner:
1 Acti vate s pt ool from the Window menu.
2 Make sure the fi l ter you want to anal yze i s sel ected i n the Fi l ters l i st.
3 Cl i ck View i n the Fi l ter panel .
The Fi l ter Vi ewer i s acti vated wi th the sel ected fi l ter di spl ayed.
4 To edi t the fi l ter youre vi ewi ng, you can reacti vate the Fi l ter Desi gner from
the Window menu i n the Fi l ter Vi ewer.
5 When you want to revi ew the fi l ters characteri sti cs after youve edi ted i t,
reacti vate the Fi l ter Vi ewer from the Window menu 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 forth 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 s pt ool , sel ecti ng the fi l ter i n
the Fi l ters l i st and the si gnal to appl y i t to from the Si gnal s l i st, and pressi ng
Apply. See Appl yi ng a Fi l ter on page 5-19 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-69 for more
i nformati on on the Fi l ter Vi ewer.
Usi ng the Fi lter Vi ewer: Interacti ve Fi lter Analysi s
5-69
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 the 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 one subpl ot or 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 a fi l ters magni tude response pl ot
Vi ew a fi l ters phase response pl ot
Vi ew a fi l ters group del ay pl ot
Vi ew a fi l ters zero-pol e pl ot
Vi ew a fi l ters i mpul se response pl ot
Vi ew a fi l ters step response pl ot
Zoom i n to expl ore fi l ter pl ot detai l s
Modi fy sel ected pl ot parameters and di spl ay characteri sti cs
For i nformati on on frequency anal ysi s usi ng tool box functi ons from the com-
mand 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 Cl i ck on one fi l ter i n the Fi l ters l i st i n s pt ool .
2 Press View i n the Fi l ters panel i n s pt ool .
The Fi l ter Vi ewer i s acti vated and the sel ected fi l ter i s l oaded i nto the Fi l ter
Vi ewer and di spl ayed.
5 Interacti ve Tools
5-70
Basic Filter Viewer Functions
The Fi l ter Vi ewer has the fol l owi ng components:
A pl ots panel for sel ecti ng whi ch subpl ots to di spl ay i n the mai n pl ots
wi ndow
Drop-down menus for modi fyi ng sel ected pl ot di spl ay characteri sti cs
A frequency axi s 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
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
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:
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] .
Pl ot s panel , i ncl udi ng menus f or
modi f yi ng pl ot charact eri st i cs
Frequency axi s panel
Fi l t er I D panel
Vi ew ( zoom) cont rol s
Usi ng the Fi lter Vi ewer: Interacti ve Fi lter Analysi s
5-71
You can choose to di spl ay one or any combi nati on of the si x avai l abl e subpl ots,
usi ng the check boxes i n the pl ots panel , and you can modi fy many of the pl ot
di spl ay characteri sti cs usi ng the drop-down menus i n the pl ots panel and the
frequency axi s panel .
Filter View er M enus
File Menu. Use Close from the Fi l e menu to cl ose the Fi l ter Vi ewer. Setti ngs you
changed and saved usi ng the Preferences wi ndow i n s pt ool are saved and
used the next ti me you open a Fi l ter Vi ewer.
W indow Menu. Use the wi ndow menu to sel ect a currentl y open MATLAB
wi ndow.
Filter Identica tion Pa nel
Thi s panel di spl ays the vari abl e name and the sampl i ng frequency for the cur-
rentl y sel ected fi l ter. To change the name or the sampl i ng frequency, use
Name or Sampling Frequency from the Edit menu i n s pt ool .
Plots Pa nel
Thi s frame sel ects the subpl ots to di spl ay i n the mai n pl ots area. Any combi na-
ti 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 subpl ots:
Magnitude: di spl ays the magni tude of the frequency response of the current
fi l ter.
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 transfer functi on and
thei r proxi mi ty to the uni t ci rcl e.
Impulse Response: di spl ays the response of the current fi l ter to a di s-
crete-ti me uni t-hei ght i mpul se at 0.
Step Response: di spl ays the response of the current fi l ter to a di screte-ti me
uni t-hei ght step functi on.
5 Interacti ve Tools
5-72
You can customi ze the di spl ay characteri sti cs of the magni tude and phase sub-
pl ots usi ng the magni tude and phase drop-down 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 i n
s pt ool .
Frequency Ax is 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 you want to edi t and drag to sel ect a val ue.
The opti ons i ncl ude
Frequency Scale: Scal i ng for the frequency axi s may be linear or log.
Frequency Range: 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 di spl ayed i n
the fi l ter I D panel .
The frequency range cannot be negati ve i f Frequency Scale i 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 Fi l ter setti ngs panel of the Preferences di al og i n s pt ool .
Zoom Controls
The avai l abl e zoom control s i n the Fi l ter Vi ewer are Mouse Zoom and 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 enabl ed i n the Fi l ter Vi ewer. You can turn
persi stent zoomi ng off usi ng the Fi l ter setti ngs panel of the Preferences
di al og i n s pt ool .
See Zoom Control s on page 5-30 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, cl i ck on 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
Usi ng the Fi lter Vi ewer: Interacti ve Fi lter Analysi s
5-73
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.
M a in Plots Area
The Fi l ters l i st i n s pt ool shows al l fi l ters i n the current s pt ool sessi on. Onl y
one fi l ter may be sel ected. The vari abl e name of the fi l ter and i ts sampl i ng fre-
quency are di spl ayed i n the fi l ter i denti fi cati on panel .
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 Fi l ter Vi ewer Ti l i ng setti ngs from the Preferences
di al og i n s pt ool . The opti ons are 2-by-3 Grid, 3-by-2 Grid, Vertical (6-by-1
Grid), and Horizontal (1-by-6 Grid).
The fol l owi ng pi cture 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 experi ment to fi nd the ti l i ng opti on that works best for each speci fi c
combi nati on and number of subpl ots.
You can zoom i n on a subpl ot by cl i cki ng on Mouse Zoom and then cl i cki ng on
or draggi ng over a sel ected area of the subpl ot. Mouse zoomi ng i s persi stent by
5 Interacti ve Tools
5-74
defaul t i n the Fi l ter Vi ewer; you can cl i ck repeatedl y i n the subpl ot to conti nue
to zoom i n on a parti cul ar feature of the di spl ay.
When a subpl ot i s zoomed and mouse zoom mode i s turned i s off, you can
cl i ck-and-drag to pan around a subpl ot:
1 Cl i ck on Mouse Zoom to turn on mouse zoom mode.
2 Cl i ck on a feature of a subpl ot to zoom i t.
3 Cl i ck on Mouse Zoom agai n to turn off mouse zoom mode.
Thi s step i s onl y necessary when persi stent zoomi ng i s turned on; i f persi s-
tent zoomi ng i s turned off, mouse zoom mode turns off automati cal l y.
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 a 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 exam-
pl 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 i s shown for an order 22 equi ri ppl e l owpass
fi l ter wi th a sampl i ng frequency of 1 Hz.
No matter how many or what combi nati on of pl ots i s di spl ayed, you can zoom
i n and pan each subpl ot i ndependentl y.
View ing M a gnitude 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
Usi ng the Fi lter Vi ewer: Interacti ve Fi lter Analysi s
5-75
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:
1 From s pt ool , cl i ck 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 Window menu i n the Fi l ter Desi gner to acti vate s pt ool .
3 Cl i ck View from the Fi l ters panel i n s pt ool 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.
4 Cl i ck the checkbox next to the Phase opti on to turn off the phase pl ot.
5 Interacti ve Tools
5-76
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 Magni tude drop-down menu to choose between l i near, l ogari thmi c,
or deci bel scal i ng of the y-axi s.
Use the Scal e drop-down menu to choose between l i near and l ogari thmi c
scal i ng of the x-axi s.
Use the Range drop-down menu to choose between the fol l owi ng scal es for
the x-axi s: [ 0, Fs /2] , [ 0, Fs ] , or [ - Fs /2, Fs /2] , where Fs i s the sampl i ng
frequency di spl ayed i n the fi l ter I D panel .
View ing Pha se 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 a fi l ters phase response. Phase response i s the angul ar component of
Usi ng the Fi lter Vi ewer: Interacti ve Fi lter Analysi s
5-77
a fi l ters frequency response. To di spl ay onl y a phase response pl ot for the cur-
rent fi l ter
1 Cl i ck the checkbox next to the Magni tude opti on to turn off the magni tude
pl ot.
2 Cl i ck the checkbox next to the Phase opti 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 Phase drop-down menu to choose between di spl ayi ng phase i n
degrees or radi ans.
Use the Scal e drop-down menu to choose between l i near and l ogari thmi c
scal i ng of the x-axi s.
Use the Range drop-down menu to choose between the fol l owi ng scal es for
the x-axi s: [ 0, Fs /2] , [ 0, Fs ] , or [ - Fs /2, Fs /2] , where Fs i s the sampl i ng
frequency di spl ayed i n the fi l ter I D panel .
5 Interacti ve Tools
5-78
View ing Group Dela y
Group delay i s a measure of the average del ay of a fi l ter as a functi on of fre-
quency. To di spl ay onl y a group del ay pl ot for the current fi l ter
1 Cl i ck the checkbox next to the Phase opti on to turn off the phase pl ot.
2 Cl i ck the checkbox next to the Group Del ay 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 Scal e drop-down menu to choose between l i near and l ogari thmi c
scal i ng of the x-axi s.
Use the Range drop-down menu to choose between the fol l owi ng scal es for
the x-axi s: [ 0, Fs /2] , [ 0, Fs ] , or [ - Fs /2, Fs /2] , where Fs i s the sampl i ng
frequency di spl ayed i n the fi l ter I D panel .
Usi ng the Fi lter Vi ewer: Interacti ve Fi lter Analysi s
5-79
View ing a Zero- Pole Plot
The zero-pole plot 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 x represents a pol e of the transfer functi on; a o
represents a zero of the transfer functi on. To di spl ay onl y a zero-pol e pl ot for
the current fi l ter
1 Cl i ck the checkbox next to the Group Del ay opti on to turn off the group del ay
pl ot.
2 Cl i ck the checkbox next to the Zeros and Pol es opti on to turn on the zero-pol e
pl ot and update the di spl ay:
5 Interacti ve Tools
5-80
View ing Impulse Response
The impulse response plot di spl ays the response of the current fi l ter to a di s-
crete-ti me uni t-hei ght i mpul se at 0.
To di spl ay onl y an i mpul se response pl ot for the current fi l ter
1 Cl i ck the checkbox next to the Zeros and Pol es opti on to turn off the zero-pol e
pl ot.
2 Cl i ck the checkbox next to the I mpul se Response opti on to turn on the
i mpul se reponse 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 Time-Response Length fi el d i n the Fi l ter Vi ewer setti ngs i n
Preferences to set the number of sampl es used to di spl ay the i mpul se
response.
Usi ng the Fi lter Vi ewer: Interacti ve Fi lter Analysi s
5-81
View ing Step Response
The step response plot di spl ays the response of the current fi l ter to a di s-
crete-ti me uni t-hei ght step functi on. To di spl ay onl y a step response pl ot for the
current fi l ter
1 Cl i ck the checkbox next to the I mpul se Response opti on to turn off the
i mpul se response pl ot.
2 Cl i ck the checkbox next to the Step Response opti 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 Time-Response Length fi el d i n the Fi l ter Vi ewer setti ngs i n
Preferences to set the number of sampl es used to di spl ay the step
response.
5 Interacti ve Tools
5-82
Using the Spectrum Viewer:
Interactive Spectral Density 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 created i n s pt ool . Thi s wi ndow al ways di spl ays what i s currentl y
sel ected i n the Spectra col umn of s pt ool .
Usi ng the Spectrum Vi ewer, you can control the parameters rel ated to the com-
putati on of these functi ons, i ncl udi ng FFT l ength, wi ndow type, and sampl i ng
frequency. You can al so di spl ay pl ots for any combi nati on of the supported
functi ons. 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 Wel chs method, the mul ti taper
method, maxi mum entropy, and MUSI C
Modi fy spectrum parameters such as FFT l ength and wi ndow type
For i nformati on on spectral anal ysi s usi ng tool box functi ons from the com-
mand 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 s pt ool by pressi ng one of
the fol l owi ng buttons: Create Spectrum, View Spectrum, Update Spectrum.
See Creati ng a Spectrum on page 5-19, Vi ewi ng a Spectrum on page 5-20,
and Updati ng a Spectrum on page 5-20 for compl ete detai l s.
Usi ng the Spectrum Vi ewer: Interacti ve Spectral Densi ty Analysi s
5-83
Here i s a bri ef summary of each method of acti vati ng the Spectrum Vi ewer:
To create a spectrum, sel ect a si gnal i n s pt ool and press Create Spectrum.
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 s pt ool and press View i n
the Spectra panel .
To update a spectrum, sel ect exactl y one si gnal and one spectrum i n s pt ool
and press Update Spectrum. Press Apply i n the Spectrum Vi ewer.
The parameters of the sel ected spectrum are l i nked to the currentl y sel ected
si gnal . The updated spectrum i s generated and di spl ayed.
5 Interacti ve Tools
5-84
Basic Spectrum Viewer Functions
The Spectrum Vi ewer wi ndow has the fol l owi ng components:
A parameters frame for vi ewi ng and modi fyi ng the parameters or method of
the currentl y sel ected 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 currentl y sel ected 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 com-
pari sons
Spectrum management buttons: Inherit From, Revert, and Apply
Menu opti ons for modi fyi ng pl ot di spl ay characteri sti cs
Spectr um View er M enus
File Menu. Use Close from the Fi l e menu to cl ose the Spectrum Vi ewer. Al l spec-
trum sel ecti on and rul er i nformati on wi l l be l ost. Setti ngs you changed and
Mai n axes area
Si gnal I D
Rul er and l i ne
di spl ay cont rol s
Zoom cont rol s
Paramet er dat a
Usi ng the Spectrum Vi ewer: Interacti ve Spectral Densi ty Analysi s
5-85
saved usi ng the Preferences wi ndow i n s pt ool are saved and used the next
ti me you open a Spectrum Vi ewer.
Options Menu. Use these opti ons to temporari l y 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.
The opti ons i ncl ude
Magnitude Scale: Scal i ng for the magni tude pl ot may be linear, log, or
decibels.
Frequency Range: 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, Fs i s chosen as 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>. I n thi s
case, a val ue of twi ce the hi ghest magni tude frequency i n the frequency
vector of the spectrum i s chosen.
The frequency range cannot be negati ve i f Frequency Scale i s set to log.
Frequency Scale: Scal i ng for the frequency axi s may be linear or log.
W indow Menu. Use the wi ndow menu to sel ect a currentl y open MATLAB
wi ndow.
Signa l ID Pa nel
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 fol l owi ng i nformati on about
the si gnal : name, si ze, r eal or compl ex , and sampl i ng frequency. To change
any of these si gnal properti es, use s pt ool .
To assi gn a compl etel y new si gnal to a di spl ayed spectrum, cl i ck on a si gnal i n
s pt ool and cl i ck Update i n the Spectra panel .
5 Interacti ve Tools
5-86
Spectr um M a na gement Buttons
Inherit From Choose a spectrum from thi s menu to i nheri t the parameters (not
i ncl udi ng the si gnal ) from another spectrum i n s pt ool .
Cl i ck on Inherit From and drag to sel ect the spectrum you want to i nheri t
the parameters from.
Rever t. Restores the properti es of the current spectrum to what they were the
l ast ti me Apply was pressed.
Apply. Compute the spectrum of the currentl y sel ected si gnal usi ng the param-
eters set i n the parameter data panel .
Zoom Controls
The avai l abl e zoom control s i n the Spectrum Vi ewer are Mouse Zoom, Full
View, Zoom In-Y, Zoom Out-Y, Zoom In-X, and Zoom Out-X. See Zoom Con-
trol s on page 5-30 for detai l s on usi ng the zoom control s i n the Spectrum
Vi ewer.
Ruler a nd Line Displa y Controls
Usi ng the rul ers and l i ne di spl ay control s, you can measure a vari ety of char-
acteri sti cs of spectra i n the Spectrum Vi ewer. See Rul er Control s on
page 5-32 for detai l s on usi ng rul ers and modi fyi ng l i ne di spl ays i n the Spec-
trum Vi ewer.
Help Button
To use context-sensi ti ve hel p, cl i ck on 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.
M a in Ax es Displa y Area
The Spectra l i st i n s pt ool shows al l spectra i n the current s pt ool 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.
Usi ng the Spectrum Vi ewer: Interacti ve Spectral Densi ty Analysi s
5-87
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 rul er di spl ay
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-38) 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 l i ne sel ecti on drop-down l i st box.
There are two ways to sel ect a spectrum (l i ne):
Cl i ck on the l i ne sel ecti on drop-down l i st and drag to sel ect the l i ne to
measure.
or
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 Pi cki ng a l i ne to measure on page 5-33 for detai l s.
Click-a nd-Dra g Pa nning. You can use the mouse to pan around the mai n axes di s-
pl 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.
M a king Spectr um M ea surements
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-38 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 fre-
quency content of a si gnal . The Spectrum Vi ewer cal cul ates si ngl e channel
5 Interacti ve Tools
5-88
power spectral densi ty (PSD). When you fi rst generate a spectrum, the Spec-
trum 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 computati on,
wi th the fol l owi ng parameters:
An FFT l ength of 1024
A Hanni ng wi ndow of l ength 256
Non-overl appi ng secti ons for peri odograms
No detrendi ng
Unbi ased scal i ng
For i nformati on on changi ng any of these, see Choosi ng Computati on Param-
eters on page 5-88.
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
Cha nging Plot Proper ties
You can control the axes uni ts and scal i ng properti es that affect the Spectrum
Vi ewers pl ots.
Use the Options menu to sel ect:
Li near, l ogari thmi c, or deci bel scal i ng for the magni tude axi s
Li near or l ogari thmi c scal e for the frequency axi s
The frequency range to vi ew
See Opti ons Menu on page 5-85 for detai l s.
You can al so zoom i n on any of the Spectrum Vi ewers pl ots. See Zoom Con-
trol s on page 5-30 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 Computa tion Pa ra meters
The Spectrum Vi ewer l ets you control the PSD computati on parameters of the
sel ected spectrum. Di fferent parameters are avai l abl e, dependi ng on whi ch
Usi ng the Spectrum Vi ewer: Interacti ve Spectral Densi ty Analysi s
5-89
method of PSD computati on you choose. Set these parameters i n the parame-
ters panel , as shown i n the fol l owi ng exampl e:
1 Cl i ck on the Method drop-down l i st box and drag to sel ect one of the fol -
l owi ng methods:
- Wel ch
- MTM
- MEM
- MUSI C
Appropri ate parameter sel ecti ons are di spl ayed, dependi ng on whi ch
method you choose.
2 Modi fy the appropri ate parameters
- When a parameter i s i n a drop-down l i st, cl i ck on the parameter l abel and
drag to sel ect a val ue from the l i st.
- 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 from to copy the
parameters of another spectrum i n s pt ool . See I nheri t From on
page 5-86 for detai l s.
3 I f you change your mi nd, you can di scard changes you make by cl i cki ng
Revert.
4 To save the modi fi ed parameters, cl i ck 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.
5 Interacti ve Tools
5-90
Computa tion M ethods a nd Pa ra meters
You can choose from four 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 page 5-86).
Welch. For Wel chs method, you can speci fy the fol l owi ng parameters:
NFFT
Type i n a val ue.
Nwind
Type i n a val ue.
Window type
Sel ect a wi ndow from the drop-down l i st.
Overlap
Type i n a val ue.
Detrending
Sel ect one of the fol l owi ng from the drop-down l i st:
- none
- linear
- mean
Scaling
Sel ect one of the fol l owi ng from the drop-down l i st:
- Unbiased
- Peaks
- by FS
Conf. Int.
Check to compute a confi dence i nterval and type i n a val ue (see Setti ng Con-
fi dence I nterval s on page 5-92).
Usi ng the Spectrum Vi ewer: Interacti ve Spectral Densi ty Analysi s
5-91
MTM. For the MTM method, you can speci fy the fol l owi ng parameters:
NW
Type i n a val ue.
Nfft
Type i n a val ue.
Weights
Sel ect one of the fol l owi ng from the drop-down l i st:
- 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-92).
MEM. For the MEM method, you can speci fy the fol l owi ng parameters:
Order
Type i n a val ue.
Nfft
Type i n a val ue.
Corr. Matrix
Check to sel ect a correl ati on matri x.
5 Interacti ve Tools
5-92
MUSIC. For the MUSI C method, you can speci fy the fol l owi ng parameters:
Signal Dim.
Type i n a val ue.
Threshold
Type i n a val ue.
Nfft
Type i n a val ue.
Nwind
Type i n a val ue.
Window type.
Sel ect a wi ndow from the drop-down l i st.
Overlap
Type i n a val ue.
Corr. Matrix
Check to sel ect a correl ati on matri x.
Eigenvector Weights
Check to sel ect ei genvector wei ghts.
Setting Condence Inter va ls
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 usi ng
the Wel ch and mul ti taper methods, as shown i n the fol l owi ng exampl e:
1 Cl i ck the Conf. Int. checkbox so that i t i s sel ected.
2 Type a val ue for the confi dence l evel i n the confi dence i nterval edi t box.
Thi s val ue must be a scal ar between 0 and 1.
3 Cl i ck Apply.
NOTE Condence i nterval s are onl y rel i abl e for non-overl appi ng secti ons.
Example: G enerati on of Bandli mi ted N oi se
5-93
Example: Generation of Bandlimited Noise
Thi s secti on provi des a compl ete exampl e that uses 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 s-
pl ay si gnal s and spectra. The steps i ncl ude
Creati ng a si gnal and nami ng i t usi ng s pt ool
Desi gni ng a fi l ter usi ng the Fi l ter Desi gner
I n s pt ool , 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 s pt ool , or you can create a new si gnal
and edi t i t and name i t i n s pt ool . 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 s pt ool .
1 At the command l i ne, create a random si gnal by typi ng:
x = r andn( 5000, 1) ;
2 Acti vate s pt ool by typi ng:
s pt ool
The s pt ool wi ndow i s di spl ayed.
5 Interacti ve Tools
5-94
3 Sel ect Import from the File menu:
The I mport 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 Workspace Contents l i st. (I f i t
i s not, cl i ck the From Workspace radi o button to di spl ay the contents of the
workspace.)
4 I mport the si gnal i nto s pt ool and name i t:
a Make sure that Si gnal i s sel ected i n the Import As: drop-down 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 Workspace Contents l 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 Sampling Frequency fi el d and type 5000.
d Name the si gnal by cl i cki ng i n the Name fi el d and typi ng noi s e.
e Cl i ck OK.
The s pt ool wi ndow i s reacti vated, and the si gnal noi s e[ v ect or ] i s sel ected
i n the Si gnal s l i st.
Example: G enerati on of Bandli mi ted N oi se
5-95
Create a Filter
You can i mport an exi sti ng fi l ter i nto s pt ool , 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 Cl i ck New Design i n s pt ool to generate a defaul t fi l ter and acti vate the
Fi l ter Desi gner.
The Fi l ter Desi gner wi ndow i s di spl ayed wi th the defaul t fi l ter, f i l t 1.
2 Change the sampl i ng frequency to 5000:
a Acti vate s pt ool from the Window menu i n the Fi l ter Desi gner.
b Sel ect Sampling Frequency from the Edit menu i n s pt ool and drag
to sel ect f i l t 1[ des i gn] .
The Sampl i ng Frequency di al og box i s di spl ayed.
c Type i n 5000 and press OK.
d Make sure the fi l ter f i l t 1[ des i gn] i s sel ected i n the Fi l ters l i st.
e Reacti ve the Fi l ter Desi gner by cl i cki ng View i n the Fi l ters panel .
The Fi l ter Desi gner i s reacti vated wi th the new sampl i ng frequency.
3 I n the Fi l ter Desi gner, speci fy the fi l ter parameters, as shown i n the param-
eters panel on the l eft:
a Make sure Equiripple i s sel ected i n the fi l ter type drop-down menu.
b Sel ect Bandpass from the fi l ter characteri sti cs drop-down menu.
c Type 500, 750, 1250, and 1500 i nto the bandpass frequency fi el ds f 1, f 2,
f 3, and f 4, respecti vel y
f 1 and f 2 set the edge frequenci es for the stopband-to-passband transi -
ti on.
f 3 and f 4 set the edge frequenci es for the passband-to-stopband transi -
ti on.
d 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 attenua-
ti on for the fi l ter.
5 Interacti ve Tools
5-96
e Cl i ck anywhere i n the parameters panel outsi de an edi t fi el d to appl y the
new parameters to the fi l ter, or press Control-Return.
The di spl ayed magni tude response i n the mai n axes area bri efl y becomes a
dotted l i ne, to show that the di spl ay does not match the new fi l ter character-
i sti cs.
When the new fi l ter i s computed, the magni tude response of the fi l ter i s di s-
pl 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.
Example: G enerati on of Bandli mi ted N oi se
5-97
Apply the Filter to a Signal
I n thi s step, you appl y the fi l ter to the si gnal i n s pt ool . The new, fi l tered si gnal
i s automati cal l y l oaded i nto s pt ool .
1 Acti vate s pt ool from the Window menu i n the Fi l ter Desi gner.
2 Cl i ck to sel ect the si gnal noi s e[ v ect or ] from the Si gnal s l i st and cl i ck to
sel ect the fi l ter (named f i l t 1[ des i gn] ) from the Fi l ters l i st.
The fol l owi ng i l l ustrati on shows both the si gnal and the fi l ter sel ected:
3 Cl i ck Apply to appl y the fi l ter f i l t 1 to the si gnal noi s e.
The Appl y Fi l ter 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
bl noi s e.
5 Cl i ck OK.
The fi l ter i s appl i ed to the sel ected si gnal . The new, fi l tered si gnal
bl noi s e[ v ect or ] i s di spl ayed i n the Si gnal s l i st.
5 Interacti ve Tools
5-98
View and Play the Signals
You can vi ew 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 capa-
bi l i ti es. I n thi s step, youl l di spl ay both si gnal s i n the Si gnal Browser and sel ect
and pl ay fi rst one si gnal and then the other.
1 Shi ft-cl i ck on the noi s e and bl noi s e si gnal s i n the Si gnal s l i st of s pt ool to
sel ect both si gnal s.
2 Cl i ck View i n the Si gnal s 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 noi s e si gnal covers up the bandl i mi ted
bl noi s e 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 drop-down Li ne sel ecti on menu to sel ect the bl noi s e
si gnal .
The mai n axes di spl ay area i s redi spl ayed. Now you can see the bl noi s e
si gnal superi mposed on top of the noi s e si gnal . The si gnal s are di spl ayed i n
Example: G enerati on of Bandli mi ted N oi se
5-99
di fferent col ors i n both the mai n axes di spl ay area and the panner. Noti ce
that the col or of the l i ne i n the Li ne sel ecti on di spl ay changes to correspond
wi th the col or of the si gnal that youve sel ected:
The si gnal thats di spl ayed i n the Li ne sel ecti on drop-down menu and i n the
Li ne sel ecti on 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 and then sel ect Play
from the Options menu agai n. 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.
5 Interacti ve Tools
5-100
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 shown i n thi s step.
1 Reacti vate s pt ool by sel ecti ng i t from the View menu of the Si gnal Browser.
2 Cl i ck on the noi s e[ v ect or ] si gnal i n the Si gnal s l i st of s pt ool to sel ect i t.
3 Cl i ck Create i n the Si gnal s panel .
The Spectrum Vi ewer i s acti vated, and the defaul t spectrum for noi s e i s cre-
ated, but the spectrum i s not di spl ayed yet.
4 Cl i ck Apply i n the Spectrum Vi ewer to appl y the new spectrum, s pect 1, to
the si gnal , noi s e, sel ected i n the Si gnal s l i st.
The spectrum of the si gnal noi s e 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 oni ncl udi ng i ts
name, i ts type, and i ts sampl i ng frequencyi s di spl ayed above the parame-
Example: G enerati on of Bandli mi ted N oi se
5-101
ters panel , and the spectrums name i s di spl ayed both above the mai n axes
di spl ay area and i n the Li ne sel ecti on drop-down 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 s pt ool by sel ecti ng i t from the Window menu i n the Spectrum
Vi ewer.
6 Cl i ck on the bl noi s e si gnal i n the Si gnal s l i st of s pt ool to sel ect i t.
7 Cl i ck Create i n the Si gnal s panel .
The Spectrum Vi ewer i s agai n acti vated, and the defaul t spectrum for
bl noi s e i s created, but the spectrum i s not di spl ayed yet.
8 Cl i ck Apply i n the Spectrum Vi ewer to appl y the new spectrum, s pect 2, to
the si gnal , bl noi s e, sel ected i n the Si gnal s l i st.
The spectrum of the si gnal bl noi s e i s di spl ayed i n the mai n axes di spl ay
area:
5 Interacti ve Tools
5-102
The new spectrums si gnal i denti fi cati on i nformati oni ncl udi ng i ts name,
i ts type, and i ts sampl i ng frequencyi s di spl ayed above the parameters
panel , and the spectrums name i s di spl ayed both above the mai n axes di s-
pl ay area and i n the Li ne sel ecti on drop-down 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 f i l t 1.
9 Reacti vate s pt ool agai n, as i n step 5, above.
10 Shi ft-cl i ck on s pect 1 and s pect 2 i n the Spectra l i st to sel ect them both.
11 Cl i ck View i n the Spectra panel to reacti vate the Spectrum Vi ewer and di s-
pl ay both spectra together.
Example: G enerati on of Bandli mi ted N oi se
5-103
12 To sel ect one of the spectra for measuri ng or edi ti ng, cl i ck-and-drag i n the
Li ne sel ecti on drop-down 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 Li ne sel ecti on di spl ay changes to correspond wi th
the col or of the spectrum that youve sel ected.
The spectrum thats di spl ayed i n the Li ne sel ecti on drop-down menu and i n
the Li ne sel ecti on di 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 mod-
i fi ed.
5 Interacti ve Tools
5-104



6

Reference

6

Reference

6-2

Thi s secti on 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 con-
ti nues wi th the reference entri es i n al phabeti cal order. For more i nformati on,
see the onl i ne MATLAB Functi on Reference.

Waveform Generation and Plotting

chi r p

Swept-frequency cosi ne generator.

di r i c

Di ri chl et or peri odi c si nc functi on.

gaus pul s

Gaussi an-modul ated si nusoi dal pul se generator.

pul s t r an

Pul se trai n generator.

r ect pul s

Sampl ed aperi odi c rectangl e generator.

s awt oot h

Sawtooth or tri angl e wave generator.

s i nc

Si nc or si n(


t)/


t functi on.

s quar e

Square wave generator.

s t r i ps

Stri p pl ot.

t r i pul s

Sampl ed aperi odi c tri angl e generator.

Filter Analysis and Implementation

abs

Absol ute val ue (magni tude).

angl e

Phase angl e.

conv

Convol uti on and pol ynomi al mul ti pl i cati on.

conv 2

Two-di mensi onal convol uti on.

f f t f i l t

FFT-based FI R l teri ng usi ng the overl ap-add method.

f i l t er

Fi l ter data wi th a recursi ve (I I R) or nonrecursi ve (FI R)
l ter.

6-3

f i l t er 2

Two-di mensi onal di gi tal l teri ng.

f i l t f i l t

Zero-phase di gi tal l teri ng.

f i l t i c

Make i ni ti al condi ti ons for l ter functi on.

f r eqs

Frequency response of anal og l ters.

f r eqs pace

Frequency spaci ng for frequency response.

f r eqz

Frequency response of di gi tal l ters.

gr pdel ay

Average l ter del ay (group del ay).

i mpz

I mpul se response of di gi tal l ters.

l at cf i l t

Latti ce and l atti ce-l adder l ter i mpl ementati on.

unwr ap

Unwrap phase angl es.

z pl ane

Zero-pol e pl ot.

Linear System Transformations

conv mt x

Convol uti on matri x.

l at c2t f

Latti ce l ter to transfer functi on conversi on.

pol y 2r c

Reecti on coefci ents from pol ynomi al coefci ents.

r c2pol y

Pol ynomi al coefci ents from reecti on coefci ents.

r es i duez

z

-transform parti al -fracti on expansi on.

s os 2s s

Second-order secti on to state-space conversi on.

s os 2t f

Second-order secti on to transfer functi on conversi on.

s os 2z p

Second-order secti on to zero-pol e-gai n conversi on.

s s 2s os

State-space to second-order secti on conversi on.

Filter Analysis and Implementation

6

Reference

6-4

s s 2t f

State-space to transfer functi on conversi on.

s s 2z p

State-space to zero-pol e-gai n conversi on.

t f 2l at c

Transfer functi on to l atti ce l ter conversi on.

t f 2s s

Transfer functi on to state-space conversi on.

t f 2z p

Transfer functi on to zero-pol e-gai n conversi on.

z p2s os

Zero-pol e-gai n to second-order secti on conversi on.

z p2s s

Zero-pol e-gai n to state-space conversi on.

z p2t f

Zero-pol e-gai n to transfer functi on conversi on.

IIR Filter DesignClassical and Direct

bes s el f

Bessel anal og l ter desi gn.

but t er

Butterworth anal og and di gi tal l ter desi gn.

cheby 1

Chebyshev type I l ter desi gn (passband ri ppl e).

cheby 2

Chebyshev type I I l ter desi gn (stopband ri ppl e).

el l i p

El l i pti c (Cauer) l ter desi gn.

max f l at

General i zed di gi tal Butterworth fi l ter desi gn.

y ul ewal k

Recursi ve di gi tal l ter desi gn.

Linear System Transformations

6-5

IIR Filter Order Selection

but t or d

Butterworth l ter order sel ecti on.

cheb1or d

Chebyshev type I l ter order sel ecti on.

cheb2or d

Chebyshev type I I l ter order sel ecti on.

el l i por d

El l i pti c l ter order sel ecti on.

FIR Filter Design

cr emez

Compl ex and nonl i near-phase equi ri ppl e FI R l ter desi gn

f i r 1

Wi ndow-based ni te i mpul se response l ter desi gnstan-
dard response.

f i r 2

Wi ndow-based ni te i mpul se response l ter desi gnarbi -
trary response.

f i r cl s

Constrai ned l east square FI R l ter desi gn for mul ti band
l ters.

f i r cl s 1

Constrai ned l east square l ter desi gn for l owpass and hi gh-
pass l i near phase FI R l ters.

f i r l s Least square l i near-phase FI R l ter desi gn.
f i r r cos Rai sed cosi ne FI R l ter desi gn.
i nt f i l t I nterpol ati on FI R l ter desi gn.
kai s er or d Esti mate parameters for f i r 1 wi th Kai ser wi ndow.
r emez Parks-McCl el l an opti mal FI R l ter desi gn.
r emez or d Parks-McCl el l an opti mal FI R l ter order esti mati on.
6 Reference
6-6
Transforms
cz t Chi rp z-transform.
dct Di screte cosi ne transform (DCT).
df t mt x Di screte Fouri er transform matri x.
f f t One-di mensi onal fast Fouri er transform.
f f t 2 Two-di mensi onal fast Fouri er transform.
f f t s hi f t Rearrange the outputs of f f t and f f t 2.
hi l ber t Hi l bert transform.
i dct I nverse di screte cosi ne transform.
i f f t One-di mensi onal i nverse fast Fouri er transform.
i f f t 2 Two-di mensi onal i nverse fast Fouri er transform.
Statistical Signal Processing
coher e Esti mate magni tude squared coherence functi on between
two si gnal s.
cor r coef Correl ati on coefci ent matri x.
cov Covari ance matri x.
cs d Esti mate the cross spectral densi ty (CSD) of two si gnal s.
pmem Power spectrum esti mate usi ng maxi mum entropy method
(MEM).
pmt m Power spectrum esti mate usi ng the mul ti taper method
(MTM).
6-7
pmus i c Power spectrum esti mate usi ng MUSI C ei genvector
method.
ps d Esti mate the power spectral densi ty (PSD) of a si gnal .
t f e Transfer functi on esti mate from i nput and output.
x cor r Cross-correl ati on functi on esti mate.
x cor r 2 Two-di mensi onal cross-correl ati on.
x cov Cross-covari ance functi on esti mate (equal to
mean-removed cross-correl ati on).
Windows
bar t l et t Bartl ett wi ndow.
bl ackman Bl ackman wi ndow.
box car Rectangul ar wi ndow.
chebwi n Chebyshev wi ndow.
hammi ng Hammi ng wi ndow.
hanni ng Hanni ng wi ndow.
kai s er Kai ser wi ndow.
t r i ang Tri angul ar wi ndow.
Statistical Signal Processing
6 Reference
6-8
Parametric Modeling
i nv f r eqs Conti nuous-ti me (anal og) l ter i denti cati on from fre-
quency data.
i nv f r eqz Di screte-ti me l ter i denti cati on from frequency data.
l ev i ns on Levi nson-Durbi n recursi on.
l pc Li near predi cti on coefci ents.
pr ony Pronys method for ti me domai n I I R l ter desi gn.
s t mcb Li near model usi ng Stei gl i tz-McBri de i terati on.
Specialized Operations
cceps Compl ex cepstral anal ysi s.
cpl x pai r Group compl ex numbers i nto compl ex conjugate pai rs.
deci mat e 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.
det r end Remove l i near trends.
dps s Di screte prol ate spheroi dal sequences (Sl epi an sequences).
dps s cl ear Remove di screte prol ate spheroi dal sequences from data-
base.
dps s di r Di screte prol ate spheroi dal sequences database di rectory.
dps s l oad Load di screte prol ate spheroi dal sequences from database.
dps s s av e Save di screte prol ate spheroi dal sequences i n database.
6-9
i cceps I nverse compl ex cepstrum.
i nt er p I ncrease sampl i ng rate by an i nteger factor (i nterpol ati on).
medf i l t 1 One-di mensi onal medi an l teri ng.
modul at e Modul ati on for communi cati ons si mul ati on.
pol y s t ab Stabi l i ze pol ynomi al .
r ceps Real cepstrum and mi ni mum phase reconstructi on.
r es ampl e Change sampl i ng rate by any factor.
s pecgr am Ti me-dependent frequency anal ysi s (spectrogram).
upf i r dn Appl y FI R l ter and perform sampl e rate conversi on.
v co Vol tage control l ed osci l l ator.
Analog Prototype Design
bes s el ap Bessel anal og l owpass l ter prototype.
but t ap Butterworth anal og l owpass l ter prototype.
cheb1ap Chebyshev type I anal og l owpass l ter prototype.
cheb2ap Chebyshev type I I anal og l owpass l ter prototype.
el l i pap El l i pti c anal og l owpass l ter prototype.
Specialized Operations
6 Reference
6-10
Frequency Translation
l p2bp Lowpass to bandpass anal og l ter transformati on.
l p2bs Lowpass to bandstop anal og l ter transformati on.
l p2hp Lowpass to hi ghpass anal og l ter transformati on.
l p2l p Lowpass to l owpass anal og l ter transformati on.
Filter Discretization
bi l i near Map vari abl es usi ng bi l i near transformati on.
i mpi nv ar I mpul se i nvari ance method of anal og-to-di gi tal l ter con-
versi on.
Interactive Tools
s pt ool I nteracti ve si gnal , l ter, and spectrum anal ysi s tool .

abs

6-11

abs

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 ) = s qr t ( r eal ( x ) . ^2 + i mag( x ) . ^2)

I f

x

i s a MATLAB stri ng,

abs

returns the numeri c val ues of the ASCI I charac-
ters i n the stri ng. The di spl ay format of the stri ng changes; the i nternal repre-
sentati on does not.
Thi s functi on i s part of the standard MATLAB envi ronment.

Example

Cal cul ate the magni tude of the FFT of a sequence:

t = ( 0: 99) /100; % t i me v ect or
x = s i n( 2*pi *15*t ) + s i n( 2*pi *40*t ) ; % s i gnal
y = f f t ( x ) ; % comput e DFT of x
m = abs ( y ) ; % magni t ude

Pl ot the magni tude:

f = ( 0: l engt h( y ) 1) ' /l engt h( y ) *100; % f r equency v ect or
pl ot ( f , m)

See Also

angl e

Phase angl e.

angle

6-12

angl e

Purpose

Phase angl e.

Syntax

p = angl e( h)

Description

p = angl e( 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 = angl e( h)

To convert back to the ori gi nal

h

from i ts magni tude and phase:

i = s qr t ( 1)
h = m. *ex p( i *p)

Thi s functi on i s part of the standard MATLAB envi ronment.

Example

Cal cul ate the phase of the FFT of a sequence:

t = ( 0: 99) /100; % t i me v ect or
x = s i n( 2*pi *15*t ) + s i n( 2*pi *40*t ) ; % s i gnal
y = f f t ( x ) ; % comput e DFT of x
p = unwr ap( angl e( y ) ) ; % phas e

Pl ot the phase:

f = ( 0: l engt h( y ) 1) ' /l engt h( y ) *100; % f r equency v ect or
pl ot ( f , p)

Algorithm

angl e

can be expressed as:

angl e( x ) = i mag( l og( x ) ) = at an2( i mag( x ) , r eal ( x ) )

See Also

abs

Absol ute val ue (magni tude).

bartlett

6-13

bartl ett

Purpose

Bartl ett wi ndow.

Syntax

w = bar t l et t ( n)

Description

w = bar t l et t ( 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

t r i ang

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

bar t l et t ( n)

are equi val ent to

t r i ang( n2)

.

See Also

bl ackman

Bl ackman wi ndow.

box car

Rectangul ar wi ndow.

chebwi n

Chebyshev wi ndow.

hammi ng

Hammi ng wi ndow.

hanni ng

Hanni ng wi ndow.

kai s er

Kai ser wi ndow.

t r i ang

Tri angul ar wi ndow.
w k
k
n
k
n
k
n
n
k n
[ ] =
( - ) 2 1
1
1
1
2
2
2 1
1
1
2

'

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

'

,
( )
,

besselap

6-14

bessel ap

Purpose

Bessel anal og l owpass fi l ter prototype.

Syntax

[ z , p, k] = bes s el ap( n)

Description

[ z , p, k] = bes s el ap( 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

bes s el ap

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

s qr t ( 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

bes s el ap

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

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.

bes s el f

Bessel anal og l ter desi gn.
but t ap Butterworth anal og l owpass l ter prototype.
cheb1ap Chebyshev type I anal og l owpass l ter prototype.
cheb2ap Chebyshev type I I anal og l owpass l ter prototype.
el l i pap El l i pti c anal og l owpass l ter prototype.

H s
k
s p s p s p n
( )
( ( ))( ( )) ( ( ))

1 2 L
2
2
1
n
n
n
n
( )

_
,

!
!
/
besself
6-15
bessel f
Purpose Bessel anal og fi l ter desi gn.
Syntax [ b, a] = bes s el f ( n, Wn)
[ b, a] = bes s el f ( n, Wn, ' f t ype' )
[ z , p, k] = bes s el f ( . . . )
[ A, B, C, D] = bes s el f ( . . . )
Description bes s el f 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 bes s el f
therefore does not support the desi gn of di gi tal Bessel fi l ters.
[ b, a] = bes s el f ( 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 frequency i 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 bes s el f , the cutoff frequency Wn must be
greater than 0. The magni tude response of a Bessel fi l ter desi gned by bes s el f
i s al ways l ess than s qr t ( 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, bes s el f ( n, Wn)
returns an order 2*n bandpass anal og fi l ter wi th passband w1 < < w2.
[ b, a] = bes s el f ( n, Wn, ' f t ype' ) desi gns a hi ghpass or bandstop fi l ter,
where f t ype i s
hi gh for a hi ghpass anal og fi l ter wi th cutoff frequency Wn
s t op 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.

H s
B s
A s
b s b s b n
s a s a n
n n
n n
( )
( )
( )
( ) ( ) ( )
( ) ( )

+ + + +
+ + + +

1 2 1
2 1
1
1
L
L
besself
6-16
Wi th di fferent numbers of output arguments, bes s el f 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] = bes s el f ( n, Wn) or
[ z , p, k] = bes s el f ( n, Wn, ' f t ype' )
bes s el f 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] = bes s el f ( n, Wn) or
[ A, B, C, D] = bes s el f ( n, Wn, ' f t ype' ) 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.
x Ax Bu
y Cx Du
+
+
besself
6-17
Example Design a fifth-order analog lowpass Bessel filter that suppresses frequencies greater
than 10,000 rad/sec and plot the frequency response of the filter using f r eqs :
[ b, a] = bes s el f ( 5, 10000) ;
f r eqs ( b, a) % pl ot f r equency r es pons e
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.
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-18
Algorithm bes s el f 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 bes s el ap
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 bes s el ap Bessel anal og l owpass l ter prototype.
but t er Butterworth anal og and di gi tal l ter desi gn.
cheby 1 Chebyshev type I l ter desi gn (passband ri ppl e).
cheby 2 Chebyshev type I I l ter desi gn (stopband ri ppl e).
el l i p El l i pti c (Cauer) l ter desi gn.
bilinear
6-19
bi l i near
Purpose Map vari abl es usi ng bi l i near transformati on.
Syntax [ z d, pd, kd] = bi l i near ( z , p, k, Fs )
[ z d, pd, kd] = bi l i near ( z , p, k, Fs , Fp)
[ numd, dend] = bi l i near ( num, den, Fs )
[ numd, dend] = bi l i near ( num, den, Fs , Fp)
[ Ad, Bd, Cd, Dd] = bi l i near ( A, B, C, D, Fs )
[ Ad, Bd, Cd, Dd] = bi l i near ( 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
bi l i near 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
Wi th the prewarpi ng opti on, bi l i near maps the j axi s (from = - to +)
repeatedl y around the uni t ci rcl e (exp(j), from = to ) by
H z H s
s f
z
z
s
( ) ( )


+
2
1
1

_
,

2
2
1
tan

f
s
H z H s
s
f
z
z
p
f
p
f
s
( ) ( )
tan
( )
( )

_
,

+
2
1
1

_
,

_
,

2
2
1
tan
tan
f
f
p
p
s
f
bilinear
6-20
I n prewarped mode, bi l i near 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 bi l i near functi on works wi th three di fferent l i near system representa-
ti ons: zero-pol e-gai n, transfer functi on, and state-space form.
Zero- Pole- Ga in
[ z d, pd, kd] = bi l i near ( z , p, k, Fs ) and
[ z d, pd, kd] = bi l i near ( z , p, k, Fs , Fp) convert the s-domai n transfer func-
ti 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. bi l i near returns the di screte equi val ent i n col umn vectors
z d and pd and scal ar kd. Fp i s the opti onal match frequency, i n Hertz, for
prewarpi ng.
Tra nsfer Function
[ numd, dend] = bi l i near ( num, den, Fs ) and
[ numd, dend] = bi l i near ( 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
Fs i s the sampl i ng frequency i n Hertz. bi l i near returns the di screte equi va-
l 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.

num s
den s
num s num nn s num nn
den s den nd s den nd
nn
nd
( )
( )
( ) ( ) ( )
( ) ( ) ( )

+ + + +
+ + + +
1 1
1 1
L
L
bilinear
6-21
Sta te- Spa ce
[ Ad, Bd, Cd, Dd] = bi l i near ( A, B, C, D, Fs ) and
[ Ad, Bd, Cd, Dd] = bi l i near ( A, B, C, D, Fs , Fp) convert the conti nuous-ti me
state-space system i n matri ces A, B, C, D,
to the di screte-ti me system
Fs i s the sampl i ng frequency i n Hertz. bi l i near returns the di screte equi va-
l ent i n matri ces Ad, Bd, Cd, Dd. Fp i s the opti onal match frequency, i n Hertz, for
prewarpi ng.
Algorithm bi l i near uses one of two al gor i thms, dependi ng on the for mat of the i nput
l i near system you suppl y. One al gor i thm wor ks on the zer o-pol e-gai n for mat
and the other on the state-space for mat. For tr ansfer functi on r epr esenta-
ti ons, bi l i near conver ts to state-space for m, per for ms the tr ansfor mati on,
and conver ts the r esul ti ng state-space system back to tr ansfer functi on
for m.
Zero- Pole- Ga in Algorithm
For a system i n zero-pol e-gai n form, bi l i near performs four steps:
1 I f Fp i s present, k = 2*pi *Fp/t an( 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 ( f i nd( f i ni t e( z ) ) ) ;
x Ax Bu
y Cx Du
+
+
x n A x n B u n
y n C x n D u n
d d
d d
[ ] [ ] [ ]
[ ] [ ] [ ]
+ +
+ +
1
bilinear
6-22
3 I t transforms the zeros, pol es, and gai n usi ng
pd = ( 1+p/k) . /( 1p/k) ;
z d = ( 1+z /k) . /( 1z /k) ;
kd = r eal ( k*pr od( f s z ) . /pr od( f s p) ) ;
4 I t adds extra zeros at -1 so the resul ti ng system has equi val ent numerator
and denomi nator order.
Sta te- Spa ce Algorithm
For a system i n state-space form, bi l i near performs two steps:
1 I f Fp i s present, k = 2*pi *Fp/t an( 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
bi l i near i mpl ements these rel ati ons usi ng conventi onal MATLAB state-
ments. The scal ar r i s arbi trary; bi l i near uses s qr t ( 2/k) to ensure good
quanti zati on noi se properti es i n the resul ti ng system.
Diagnostics bi l i near requi res that the numerator order be no greater than the denomi -
nator order. I f thi s i s not the case, bi l i near di spl ays:
Numer at or cannot be hi gher or der t han denomi nat or .
For bi l i near to di sti ngui sh between the zero-pol e-gai n and transfer 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, bi l i near di spl ays:
Fi r s t t wo ar gument s mus t hav e t he s ame or i ent at i on.
A I A I A
B I A B
C rC I A
D C I A B D
d
k k
d
k
r k
d
k
d
k k
+
( ) ( )

( ) ( )

( ) ( )

( ) ( )

( )

( ) ( )
+

1 1
1
2 1
1
1
1
1 1
1
bilinear
6-23
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-Time Signal Processing.
Engl ewood Cl i ffs, NJ: Prenti ce Hal l , 1989. Pgs. 415-430.
i mpi nv ar I mpul se i nvari ance method of anal og-to-di gi tal l ter
conversi on.
l p2bp Lowpass to bandpass anal og l ter transformati on.
l p2bs Lowpass to bandstop anal og l ter transformati on.
l p2hp Lowpass to hi ghpass anal og l ter transformati on.
l p2l p Lowpass to l owpass anal og l ter transformati on.
blackman
6-24
bl ackman
Purpose Bl ackman wi ndow.
Syntax w = bl ackman( n)
Description w = bl ackman( n) returns the n-poi nt Bl ackman wi ndow i n the col umn vector
w. 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.
Algorithm w = ( 0. 42 0. 5*cos ( 2*pi *( 0: N1) /( N1) ) + . . .
0. 08*cos ( 4*pi *( 0: N1) /( N1) ) ) ' ;
See Also bar t l et t Bartl ett wi ndow.
box car Rectangul ar wi ndow.
chebwi n Chebyshev wi ndow.
hammi ng Hammi ng wi ndow.
hanni ng Hanni ng wi ndow.
kai s er Kai ser wi ndow.
t r i ang Tri angul ar wi ndow.

w k
k
n
k
n
k n [ ] . . cos . cos , , ,

_
,
+

_
,
0 42 0 5 2
1
1
0 08 4
1
1
1 K
boxcar
6-25
boxcar
Purpose Rectangul ar wi ndow.
Syntax w = box car ( n)
Description w = box car ( 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 va-
l ent to no wi ndow at al l .
Algorithm w = ones ( n, 1) ;
See Also bar t l et t Bartl ett wi ndow.
bl ackman Bl ackman wi ndow.
chebwi n Chebyshev wi ndow.
hammi ng Hammi ng wi ndow.
hanni ng Hanni ng wi ndow.
kai s er Kai ser wi ndow.
t r i ang Tri angul ar wi ndow.
buttap
6-26
buttap
Purpose Butterworth anal og l owpass fi l ter prototype.
Syntax [ z , p, k] = but t ap( n)
Description [ z , p, k] = but t ap( n) returns the zeros, pol es, and gai n of an order n Butter-
worth 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/s qr t ( 2) , regardl ess of the fi l ter order. but t ap sets
0
to 1 for a
normal i zed resul t.
Algorithm z = [ ] ;
p = ex p( s qr t ( 1) *( pi *( 1: 2: 2*n1) /( 2*n) +pi /2) ) . ' ;
k = r eal ( pr od( 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.
bes s el ap Bessel anal og l owpass l ter prototype.
but t er Butterworth anal og and di gi tal l ter desi gn.
cheb1ap Chebyshev type I anal og l owpass l ter prototype.
cheb2ap Chebyshev type I I anal og l owpass l ter prototype.
el l i pap El l i pti c anal og l owpass l ter prototype.

H s
z s
p s
k
s p s p s p n
( )
( )
( ) ( ( )( ( )) ( ( ))

1 2 L
H
n
( )
( )


2
0
2
1
1

+
butter
6-27
butter
Purpose Butterworth anal og and di gi tal fi l ter desi gn.
Syntax [ b, a] = but t er ( n, Wn)
[ b, a] = but t er ( n, Wn, ' f t ype' )
[ b, a] = but t er ( n, Wn, ' s ' )
[ b, a] = but t er ( n, Wn, ' f t ype' , ' s ' )
[ z , p, k] = but t er ( . . . )
[ A, B, C, D] = but t er ( . . . )
Description but t er 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 Butterworth 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.
Digita l Doma in
[ b, a] = but t er ( 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 s qr t ( 1/2) . For but t er , 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] , but t er returns an order 2*n di gi tal
bandpass fi l ter wi th passband w1 < < w2.

H z
B z
A z
b b z b n z
a z a n z
n
n
( )
( )
( )
( ) ( ) ( )
( ) ( )

+ + + +
+ + + +


1 2 1
1 2 1
1
1
L
L

butter
6-28
[ b, a] = but t er ( n, Wn, ' f t ype' ) desi gns a hi ghpass or bandstop fi l ter, where
f t ype i s
hi gh for a hi ghpass di gi tal fi l ter wi th cutoff frequency Wn
s t op 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, but t er 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 argu-
ments:
[ z , p, k] = but t er ( n, Wn) or
[ z , p, k] = but t er ( n, Wn, ' f t ype' )
but t er 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] = but t er ( n, Wn) or
[ A, B, C, D] = but t er ( n, Wn, ' f t ype' ) 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.
Ana log Doma in
[ b, a] = but t er ( 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:
but t er s cutoff frequency Wn must be greater than 0.
x n Ax n Bu n
y n Cx n Du n
[ ] [ ] [ ]
[ ] [ ] [ ]
+ +
+
1

H s
B s
A s
b s b s b n
s a s a n
n n
n n
( )
( )
( )
( ) ( ) ( )
( ) ( )

+ + + +
+ + + +

1 2 1
2 1
1
1
L
L
butter
6-29
I f Wn i s a two-el ement vector wi th w1 < w2, but t er ( n, Wn, ' s ' ) returns an order
2*n bandpass anal og fi l ter wi th passband w1 < < w2.
[ b, a] = but t er ( n, Wn, ' f t ype' , ' s ' ) desi gns a hi ghpass or bandstop fi l ter,
where f t ype i s
hi gh for a hi ghpass anal og fi l ter wi th cutoff frequency Wn
s t op 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, but t er 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] = but t er ( n, Wn, ' s ' ) or
[ z , p, k] = but t er ( n, Wn, ' f t ype' , ' 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] = but t er ( n, Wn, ' s ' ) or
[ A, B, C, D] = but t er ( n, Wn, ' f t ype' , ' 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] = but t er ( 9, 300/500, ' hi gh' )
x Ax Bu
y Cx Du
+
+
butter
6-30
The fi l ters frequency response i s
f r eqz ( 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 sample response:
n = 5; Wn = [ 100 200] /500;
[ b, a] = but t er ( n, Wn) ;
[ y , t ] = i mpz ( b, a, 101) ;
s t em( t , y )
0 50 100 150 200 250 300 350 400 450 500
-1500
-1000
-500
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
-400
-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
)
Frequency Response of 9th Order Butterworth
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-31
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 but t er 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 but t ap
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 For di gi tal fi l ter desi gn, but t er uses bi l i near 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 pre-
warpi 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 bes s el f Bessel anal og l ter desi gn.
but t ap Butterworth anal og l owpass l ter prototype.
but t or d Butterworth l ter order sel ecti on.
cheby 1 Chebyshev type I l ter desi gn (passband ri ppl e).
cheby 2 Chebyshev type I I l ter desi gn (stopband ri ppl e).
el l i p El l i pti c (Cauer) l ter desi gn.
max f l at General i zed di gi tal Butterworth l ter desi gn.
buttord
6-32
buttord
Purpose Butterworth fi l ter order sel ecti on.
Syntax [ n, Wn] = but t or d( Wp, Ws , Rp, Rs )
[ n, Wn] = but t or d( Wp, Ws , Rp, Rs , ' s ' )
Description but t or d 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:
Digita l Doma in
[ n, Wn] = but t or d( 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. but t or d al so
returns Wn, the Butterworth cutoff frequency that al l ows but t er to achi eve the
gi ven speci fi cati ons (the 3 dB frequency).
Use but t or d 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, but t or d returns Wn as a
two-el ement row vector for i nput to but t er .
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-33
Ana log Doma in
[ n, Wn] = but t or d( 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 but t or d for hi ghpass, bandpass, and bandstop fi l ters, as descri bed under
Di gi tal Domai n.
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 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] = but t or d( Wp, Ws , 3, 15)
n =
4
Wn =
0. 2042
[ b, a] = but t er ( n, Wn) ;
f r eqz ( b, a, 512, 1000)
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-34
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] = but t or d( Wp, Ws , Rp, Rs ) ; [ b, a] = but t er ( n, Wn) ;
f r eqz ( b, a, 128, 1000)
Algorithm but t or ds 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.
but t or d i ni ti al l y devel ops a l owpass fi l ter prototype by transformi ng the pass-
band 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-35
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.
but t er Butterworth anal og and di gi tal l ter desi gn.
cheb1or d Chebyshev type I l ter order sel ecti on.
cheb2or d Chebyshev type I I l ter order sel ecti on.
el l i por d El l i pti c l ter order sel ecti on.
cceps
6-36
cceps
Purpose Compl ex cepstral anal ysi s.
Syntax x hat = cceps ( x )
[ x hat , nd] = 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].
x hat = 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 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.
[ x hat , 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.
[ . . . ] = 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 = f f t ( x ) ;
l ogh = l og( abs ( h) ) + s qr t ( 1) *r cunwr ap( angl e( h) ) ;
y = r eal ( i f f t ( l ogh) ) ;
r cunwr ap is a special version of unwr ap that subtracts a straight line from the phase.
See Also
References [1] Oppenhei m, A.V., and R.W. Schafer. Discrete-Time Signal Processing.
Engl ewood Cl i ffs, NJ: Prenti ce Hal l , 1989.
[2] I EEE. Programs for Digital Signal Processing. I EEE Press. New York: John
Wi l ey & Sons, 1979.
i cceps I nverse compl ex cepstrum.
hi l ber t Hi l bert transform.
r ceps Real cepstrum and mi ni mum phase reconstructi on.
unwr ap Unwrap phase angl es.
cheb1ap
6-37
cheb1ap
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.
bes s el ap Bessel anal og l owpass l ter prototype.
but t ap Butterworth anal og and di gi tal l ter desi gn.
cheb2ap Chebyshev type I anal og l owpass l ter prototype.
cheby 1 Chebyshev type I l ter desi gn (passband ri ppl e).
el l i pap El l i pti c anal og l owpass l ter prototype.

H s
z s
p s
k
s p s p s p n
( )
( )
( ) ( ( ))( ( )) ( ( ))

1 2 L

0
cheb1ord
6-38
cheb1ord
Purpose Chebyshev type I fi l ter order sel ecti on.
Syntax [ n, Wn] = cheb1or d( Wp, Ws , Rp, Rs )
[ n, Wn] = cheb1or d( Wp, Ws , Rp, Rs , ' s ' )
Description cheb1or d 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:
Digita l Doma in
[ n, Wn] = cheb1or d( Wp, Ws , Rp, Rs ) returns the order n of the lowest order
Chebyshev filter that loses no more than Rp dB in the passband and has at least
Rs dB of attenuation in the stopband. The passband runs from 0 to Wp and the stop-
band runs from Ws to 1, the Nyquist frequency. cheb1or d also returns Wn, the
Chebyshev type I cutoff frequency that allows cheby 1 to achieve the given specifica-
tions.
Use cheb1or d for l owpass, hi ghpass, bandpass, and bandstop fi l ters. For hi gh-
pass 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, cheb1or d returns Wn as
a two-el ement row vector for i nput to cheby 1.
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-39
Ana log Doma in
[ n, Wn] = cheb1or d( 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 cheb1or d for l owpass, hi ghpass, bandpass, and bandstop fi l ters, as
descri bed under Di gi tal Domai n.
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 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] = cheb1or d( Wp, Ws , Rp, Rs )
n =
3
Wn =
0. 2000
[ b, a] = cheby 1( n, Rp, Wn) ;
f r eqz ( b, a, 512, 1000)
0 50 100 150 200 250 300 350 400 450 500
-300
-200
-100
0
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-40
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] = cheb1or d( Wp, Ws , Rp, Rs )
n =
4
Wn =
0. 2000 0. 4000
[ b, a] = cheby 1( n, Rp, Wn) ;
f r eqz ( b, a, 512, 1000)
Algorithm cheb1or d 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
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-41
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.
cheb1or d 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.
but t or d Butterworth l ter order sel ecti on.
cheby 1 Chebyshev type I l ter desi gn (passband ri ppl e).
cheb2or d Chebyshev type I I l ter order sel ecti on.
el l i por d El l i pti c l ter order sel ecti on.
cheb2ap
6-42
cheb2ap
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 inverse Chebyshev 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.
bes s el ap Bessel anal og l owpass l ter prototype.
but t ap Butterworth anal og l owpass l ter prototype.
cheb1ap Chebyshev type I anal og l owpass l ter prototype.
cheby 2 Chebyshev type I I l ter desi gn (stopband ri ppl e).
el l i pap El l i pti c anal og l owpass l ter prototype.

H s
z s
p s
k
s z s z s z n
s p s p s p n
( )
( )
( )
( ( ))( ( )) ( ( ))
( ( ))( ( )) ( ( ))



1 2
1 2
L
L
cheb2ord
6-43
cheb2ord
Purpose Chebyshev type I I fi l ter order sel ecti on.
Syntax [ n, Wn] = cheb2or d( Wp, Ws , Rp, Rs )
[ n, Wn] = cheb2or d( Wp, Ws , Rp, Rs , ' s ' )
Description cheb2or d 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:
Digita l Doma in
[ n, Wn] = cheb2or d( 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. cheb2or d al so returns
Wn, the Chebyshev type I I cutoff frequency that al l ows cheby 2 to achi eve the
gi ven speci fi cati ons.
Use cheb2or d for l owpass, hi ghpass, bandpass, and bandstop fi l ters. For hi gh-
pass 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, cheb2or d returns Wn as
a two-el ement row vector for i nput to cheby 2.
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-44
Ana log Doma in
[ n, Wn] = cheb2or d( 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 cheb2or d for l owpass, hi ghpass, bandpass, and bandstop fi l ters, as
descri bed under Di gi tal Domai n.
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 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] = cheb2or d( Wp, Ws , Rp, Rs )
n =
3
Wn =
0. 2609
[ b, a] = cheby 2( n, Rs , Wn) ;
f r eqz ( b, a, 512, 1000)
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-45
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] = cheb2or d( Wp, Ws , Rp, Rs )
n =
4
Wn =
0. 1633 0. 4665
[ b, a] = cheby 2( n, Rs , Wn) ;
f r eqz ( b, a, 512, 1000)
Algorithm cheb2or d 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 param-
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-46
eters to the s-domai n before the order and natural frequency esti mati on
process, then converts them back to the z-domai n.
cheb2or d i ni ti al l y devel ops a l owpass fi l ter prototype by transformi ng the stop-
band 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 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.
but t or d Butterworth l ter order sel ecti on.
cheb1or d Chebyshev type I l ter order sel ecti on.
cheby 2 Chebyshev type I I l ter desi gn (stopband ri ppl e).
el l i por d El l i pti c l ter order sel ecti on.
chebwin
6-47
chebwi n
Purpose Chebyshev wi ndow.
Syntax w = chebwi n( n, r )
Description w = chebwi n( 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, where n i s odd. I f n i s even, the wi ndow i s
l ength n+1.
Diagnostics When n i s an even number, chebwi n returns a wi ndow of order n+1 and di spl ays
the warni ng message:
chebwi n: N mus t be odd N i s bei ng i ncr eas ed by 1.
See Also
References [1] I EEE. Programs for Digital Signal Processing. I EEE Press. New York: John
Wi l ey & Sons, 1979. Program 5.2.
bar t l et t Bartl ett wi ndow.
bl ackman Bl ackman wi ndow.
box car Rectangul ar wi ndow.
hammi ng Hammi ng wi ndow.
hanni ng Hanni ng wi ndow.
kai s er Kai ser wi ndow.
t r i ang Tri angul ar wi ndow.
cheby1
6-48
cheby1
Purpose Chebyshev type I fi l ter desi gn (passband ri ppl e).
Syntax [ b, a] = cheby 1( n, Rp, Wn)
[ b, a] = cheby 1( n, Rp, Wn, ' f t ype' )
[ b, a] = cheby 1( n, Rp, Wn, ' s ' )
[ b, a] = cheby 1( n, Rp, Wn, ' f t ype' , ' s ' )
[ z , p, k] = cheby 1( . . . )
[ A, B, C, D] = cheby 1( . . . )
Description cheby 1 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 pass-
band 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.
Digita l Doma in
[ b, a] = cheby 1( 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 frequency i s the frequency at whi ch the magni tude response of the fi l ter
i s equal to Rp dB. For cheby 1, 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] , cheby 1 returns an order 2*n band-
pass fi l ter wi th passband w1 < < w2.

H z
B z
A z
b b z b n z
a z a n z
n
n
( )
( )
( )
( ) ( ) ( )
( ) ( )

+ + + +
+ + + +


1 2 1
1 2 1
1
1
L
L

cheby1
6-49
[ b, a] = cheby 1( n, Rp, Wn, ' f t ype' ) desi gns a hi ghpass or bandstop fi l ter,
where f t ype i s
hi gh for a hi ghpass di gi tal fi l ter wi th cutoff frequency Wn
s t op 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, cheby 1 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 argu-
ments:
[ z , p, k] = cheby 1( n, Rp, Wn) or
[ z , p, k] = cheby 1( n, Rp, Wn, ' f t ype' ) 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] = cheby 1( n, Rp, Wn) or
[ A, B, C, D] = cheby 1( n, Rp, Wn, ' f t ype' ) 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.
Ana log Doma in
[ b, a] = cheby 1( 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 frequency i s the frequency at whi ch the magni tude response of the fi l ter
i s Rp dB. For cheby 1, the cutoff frequency Wn must be greater than 0.
x n Ax n Bu n
y n Cx n Du n
[ ] [ ] [ ]
[ ] [ ] [ ]
+ +
+
1

H s
B s
A s
b s b s b n
s a s a n
n n
n n
( )
( )
( )
( ) ( ) ( )
( ) ( )

+ + + +
+ + + +

1 2 1
2 1
1
1
L
L
cheby1
6-50
I f Wn i s a two-el ement vector, Wn = [ w1 w2] , wi th w1 < w2, then
cheby 1( n, Rp, Wn, ' s ' ) returns an order 2*n bandpass anal og fi l ter wi th pass-
band w1 < < w2.
[ b, a] = cheby 1( n, Rp, Wn, ' f t ype' , ' s ' ) desi gns a hi ghpass or bandstop
fi l ter, where f t ype i s
hi gh for a hi ghpass anal og fi l ter wi th cutoff frequency Wn
s t op 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 cheby 1 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] = cheby 1( n, Rp, Wn, ' s ' ) or
[ z , p, k] = cheby 1( n, Rp, Wn, ' f t ype' , ' 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] = cheby 1( n, Rp, Wn, ' s ' ) or
[ A, B, C, D] = cheby 1( n, Rp, Wn, ' f t ype' , ' 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] = cheby 1( 9, 0. 5, 300/500) ;
x Ax Bu
y Cx Du
+
+
cheby1
6-51
The frequency response of the fi l ter i s
f r eqz ( 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] = cheby 1( n, Rp, Wn) ;
[ y , t ] = i mpz ( b, a, 101) ; s t em( 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-52
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 cheby 1 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 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, cheby 1 uses bi l i near 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 pre-
warpi 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 bes s el f Bessel anal og l ter desi gn.
but t er Butterworth anal og and di gi tal l ter desi gn.
cheb1ap Chebyshev type I anal og l owpass l ter prototype.
cheb1or d Chebyshev type I l ter order sel ecti on.
cheby 2 Chebyshev type I I l ter desi gn (stopband ri ppl e).
el l i p El l i pti c (Cauer) l ter desi gn.
cheby2
6-53
cheby2
Purpose Chebyshev type I I fi l ter desi gn (stopband ri ppl e).
Syntax [ b, a] = cheby 2( n, Rs , Wn)
[ b, a] = cheby 2( n, Rs , Wn, ' f t ype' )
[ b, a] = cheby 2( n, Rs , Wn, ' s ' )
[ b, a] = cheby 2( n, Rs , Wn, ' f t ype' , ' s ' )
[ z , p, k] = cheby 2( . . . )
[ A, B, C, D] = cheby 2( . . . )
Description cheby 2 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 pass-
band 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.
Digita l Doma in
[ b, a] = cheby 2( 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 frequency i 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 cheby 2, 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] , cheby 2 returns an order 2*n band-
pass fi l ter wi th passband w1 < < w2.

H z
B z
A z
b b z b n z
a z a n z
n
n
( )
( )
( )
( ) ( ) ( )
( ) ( )

+ + + +
+ + + +


1 2 1
1 2 1
1
1
L
L
cheby2
6-54
[ b, a] = cheby 2( n, Rs , Wn, ' f t ype' ) desi gns a hi ghpass or bandstop fi l ter,
where f t ype i s
hi gh for a hi ghpass di gi tal fi l ter wi th cutoff frequency Wn
s t op 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, cheby 2 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 argu-
ments:
[ z , p, k] = cheby 2( n, Rs , Wn) or
[ z , p, k] = cheby 2( n, Rs , Wn, ' f t ype' ) 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] = cheby 2( n, Rs , Wn) or
[ A, B, C, D] = cheby 2( n, Rs , Wn, ' f t ype' ) 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.
Ana log Doma in
[ b, a] = cheby 2( 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 frequency i s the frequency at whi ch the magni tude response of the fi l ter
i s equal to Rs dB. For cheby 2, the cutoff frequency Wn must be greater than 0.
x n Ax n Bu n
y n Cx n Du n
[ ] [ ] [ ]
[ ] [ ] [ ]
+ +
+
1

H s
B s
A s
b s b s b n
s a s a n
n n
n n
( )
( )
( )
( ) ( ) ( )
( ) ( )

+ + + +
+ + + +

1 2 1
2 1
1
1
L
L
cheby2
6-55
I f Wn i s a two-el ement vector, Wn = [ w1 w2] , wi th w1 < w2, then
cheby 2( n, Rs , Wn, ' s ' ) returns an order 2*n bandpass anal og fi l ter wi th pass-
band w1 < < w2.
[ b, a] = cheby 2( n, Rs , Wn, ' f t ype' , ' s ' ) desi gns a hi ghpass or bandstop
fi l ter, where f t ype i s
hi gh for a hi ghpass anal og fi l ter wi th cutoff frequency Wn
s t op 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, cheby 2 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] = cheby 2( n, Rs , Wn, ' s ' ) or
[ z , p, k] = cheby 2( n, Rs , Wn, ' f t ype' , ' 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] = cheby 2( n, Rs , Wn, ' s ' ) or
[ A, B, C, D] = cheby 2( n, Rs , Wn, ' f t ype' , ' 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] = cheby 2( 9, 20, 300/500) ;
x Ax Bu
y Cx Du
+
+
cheby2
6-56
The frequency response of the fi l ter i s
f r eqz ( b, a, 512, 1000)
Desi gn a fi fth-order bandpass Chebyshev type I I fi l ter wi th passband from 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] = cheby 2( n, r , Wn) ;
[ y , t ] = i mpz ( b, a, 101) ; s t em( 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-57
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 cheby 2 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, cheby 2 uses bi l i near 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 pre-
warpi 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 bes s el f Bessel anal og l ter desi gn.
but t er Butterworth anal og and di gi tal l ter desi gn.
cheb2ap Chebyshev type I I anal og l owpass l ter prototype.
cheb2or d Chebyshev type I I l ter order sel ecti on.
cheby 1 Chebyshev type I l ter desi gn (passband ri ppl e).
el l i p El l i pti c (Cauer) l ter desi gn.
chirp
6-58
chi rp
Purpose Swept-frequency cosi ne generator.
Syntax y = chi r p( t , f 0, t 1, f 1)
y = chi r p( t , f 0, t 1, f 1, ' met hod' )
y = chi r p( t , f 0, t 1, f 1, ' met hod' , phi )
Description y = chi r p( t , f 0, t 1, f 1) 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 f 0 i s the i nstantaneous
frequency at ti me 0, and f 1 i s the i nstantaneous frequency at ti me t 1. f 0 and
f 1 are both i n Hertz. I f unspeci fi ed, f 0 i s 0, t 1 i s 1, and f 1 i s 100.
y = chi r p( t , f 0, t 1, f 1, ' met hod' ) speci fi es al ternati ve sweep method
opti ons, where met hod can be
l i near , 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.
quadr at i c, whi ch speci fi es an i nstantaneous frequency sweep f
i
(t) gi ven by
where
l ogar i t hmi c speci fi es an i nstantaneous frequency sweep f
i
(t) gi ven by
where
For a l og-sweep, f 1 must be greater than f 0.
y = chi r p( t , f 0, t 1, f 1, ' met hod' , phi ) al l ows an i ni ti al phase phi to be spec-
i fi ed i n degrees. I f unspeci fi ed, phi i s 0.
f t f t
i
( ) +
0

( ) / f f t
1 0 1
f t f t
i
( ) +
0
2

( ) / f f t
1 0 1
f t f
i
t
( ) +
0
10


[ ]
log ( ) /
10 1 0 1
f f t
chirp
6-59
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 l i near chi rp:
t = 0: 0. 001: 2; % 2 s ecs @ 1kHz s ampl e r at e
y = chi r p( t , 0, 1, 150) ; % St ar t @ DC, cr os s 150Hz at t =1 s ec
s pecgr am( y , 256, 1e3, 256, 250) % Di s pl ay t he s pect r ogr am
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-60
Compute the spectrogram of a quadrati c chi rp:
t = 2: 0. 001: 2; % 2 s ecs @ 1kHz s ampl e r at e
y = chi r p( t , 100, 1, 200, ' quadr at i c' ) ; %St ar t @ 100Hz , cr os s 200Hz
% at t =1 s ec
s pecgr am( y , 128, 1e3, 128, 120) % Di s pl ay t he s pect r ogr am
See Also cos Cosi ne of vector/matri x el ements (see MATLAB
Functi on Reference).
di r i c Di ri chl et or peri odi c si nc functi on.
gaus pul s Gaussi an-modul ated si nusoi dal pul se generator.
pul s t r an Pul se trai n generator.
r ect pul s Sampl ed aperi odi c rectangl e generator.
s awt oot h Sawtooth or tri angl e wave generator.
s i n Si ne of vector/matri x el ements (see MATLAB
Functi on Reference).
s i nc Si nc or si n(t)/t functi on.
s quar e Square wave generator.
t r i pul s Sampl ed aperi odi c tri angl e generator.
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
cohere
6-61
cohere
Purpose Esti mate magni tude squared coherence functi on between two si gnal s.
Syntax Cx y = coher e( x , y )
Cx y = coher e( x , y , nf f t )
[ Cx y , f ] = coher e( x , y , nf f t , Fs )
Cx y = coher e( x , y , nf f t , Fs , wi ndow)
Cx y = coher e( x , y , nf f t , Fs , wi ndow, nov er l ap)
Cx y = coher e( x , y , . . . , ' df l ag' )
coher e( x , y )
Description Cx y = coher e( x , y ) fi nds the magni tude squared coherence between l ength n
si gnal vectors 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. Cx y = coher e( x , y ) uses the fol l owi ng defaul t
val ues:
nf f t = mi n( 256, l engt h( x ) )
Fs = 2
wi ndow = hanni ng( nf f t )
nov er l ap = 0
nf f t speci fi es the FFT l ength that coher e 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. wi ndow speci fi es a wi ndowi ng functi on and the number of
sampl es coher e uses i n i ts secti oni ng of the x and y vectors. nov er l ap 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 , coher e esti mates the coherence functi on at posi ti ve frequenci es
onl y; i n thi s case, the output Cx y i s a col umn vector of l ength nf f t /2 + 1 for
nf f t even and ( nf f t + 1) /2 for n odd. I f x or y i s compl ex, coher e esti mates
the coherence functi on at both posi ti ve and negati ve frequenci es, and Cx y has
l ength nf f t .
C f
P f
P f P f
xy
xy
xx yy
( )
( )
( ) ( )

2
cohere
6-62
Cx y = coher e( x , y , nf f t ) uses the FFT l ength nf f t i n esti mati ng the power
spectrum for x . Speci fy nf f t as a power of 2 for fastest executi on.
[ Cx y , f ] = coher e( x , y , nf f t , 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 Cx y , so pl ot ( f , Cx y ) pl ots the coherence functi on versus properl y
scal ed frequency. Fs has no effect on the output Cx y ; i t i s a frequency scal i ng
mul ti pl i er.
Cx y = coher e( x , y , nf f t , Fs , wi ndow) 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
wi ndow, coher e 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 nf f t ; coher e zero pads the secti ons i f the
wi ndow l ength exceeds nf f t .
Cx y = coher e( x , y , nf f t , Fs , wi ndow, nov er l ap) overl aps the secti ons of x by
nov er l ap 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,
Cx y = coher e( x , y , [ ] , [ ] , kai s er ( 128, 5) ) ;
uses 256 as the val ue for nf f t and 2 as the val ue for Fs .
Cx y = coher e( x , y , . . . , ' df l ag' ) speci fi es a detrend opti on, where df l ag i s
l i near , 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 df l ag parameter must appear l ast i n the l i st of i nput arguments. coher e
recogni zes a df l ag stri ng no matter how many i ntermedi ate arguments are
omi tted.
coher e wi th no output arguments pl ots the coherence esti mate versus
frequency i n the current fi gure wi ndow.
cohere
6-63
Example Compute and pl ot the coherence esti mate between two col ored noi se sequences
x and y :
h = f i r 1( 30, 0. 2, box car ( 31) ) ;
h1 = ones ( 1, 10) /s qr t ( 10) ;
r = r andn( 16384, 1) ;
x = f i l t er ( h1, 1, r ) ;
y = f i l t er ( h, 1, x ) ;
coher e( x , y , 1024, [ ] , [ ] , 512)
Diagnostics An appropri ate di agnosti c messages i s di spl ayed when i ncorrect arguments are
used:
Requi r es wi ndow' s l engt h t o be no gr eat er t han t he FFT l engt h.
Requi r es NOVERLAP t o be s t r i ct l y l es s t han t he wi ndow l engt h.
Requi r es pos i t i v e i nt eger v al ues f or NFFT and NOVERLAP.
Requi r es v ect or ( ei t her r ow or col umn) i nput .
Requi r es i nput s X and Y t o hav e t he s ame l engt h.
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-64
Algorithm coher e 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:
1 I t di vi des the si gnal s x and y i nto overl appi ng secti ons, detrends each sec-
ti on, and mul ti pl i es each secti on by wi ndow.
2 I t cal cul ates the l ength nf f t fast Fouri er transform of each secti on.
3 I t averages the squares of the spectra of the x secti ons to form Px x , averages
the squares of the spectra of the y secti ons to form Py y , and averages the
products of the spectra of the x and y secti ons to form Px y . I t cal cul ates Cx y
by
Cx y = abs ( Px y ) . ^2/( Px x . *Py y )
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. Audio Electroacoust. Vol . AU-15 (June 1967).
Pgs. 70-73.
cs d Esti mate the cross spectral densi ty (CSD) of two
si gnal s.
ps d Esti mate the power spectral densi ty (PSD) of a
si gnal .
t f e Transfer functi on esti mate from i nput and output.
conv
6-65
conv
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.
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 Thi s functi on i s part of the MATLAB envi ronment. I t i s an M-fi l e that uses the
f i l t er 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 conv 2 Two-di mensi onal convol uti on.
conv mt x Convol uti on matri x.
conv n N-di mensi onal convol uti on (see MATLAB Functi on
Reference).
deconv Deconvol uti on and pol ynomi al di vi si on.
f i l t er Fi l ter data wi th a recursi ve (I I R) or nonrecursi ve
(FI R) l ter.
r es i duez z-transform parti al fracti on expansi on.
x cor r Cross-correl ati on functi on esti mate.
c n a k b n k
k
N
( ) ( ) ( ) + +

1 1
0
1
conv2
6-66
conv2
Purpose Two-di mensi onal convol uti on.
Syntax C = conv 2( A, B)
C = conv 2( A, B, ' shape' )
Description C = conv 2( 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 corre-
spondi ng di mensi ons of the i nput matri ces mi nus 1. For [ ma, na] = s i z e( A)
and [ mb, nb] = s i z e( B) , then s i z e( C) = [ ma+mb1, na+nb1] .
C = conv 2( A, B, ' shape' ) returns a subsecti on of the two-di mensi onal convo-
l uti on wi th si ze speci fi ed by shape, where:
f ul l returns the ful l two-di mensi onal convol uti on (defaul t)
s ame returns the central part of the convol uti on that i s the same si ze as A
v al i d 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, s i z e( C) = [ mamb+1, nanb+1]
when s i z e( A) > s i z e( B)
conv 2 executes most qui ckl y when s i z e( A) > s i z e( B) .
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 = conv 2( 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 = conv 2( I , s ' ) ;
v 2 = ( s qr t ( h. ^2 + v . ^2) )
conv2
6-67
See Also conv Convol uti on and pol ynomi al mul ti pl i cati on.
conv n N-di mensi onal convol uti on (see MATLAB Functi on
Reference).
deconv Deconvol uti on and pol ynomi al di vi si on.
f i l t er 2 Two-di mensi onal di gi tal l teri ng.
x cor r Cross-correl ati on functi on esti mate.
x cor r 2 Two-di mensi onal cross-correl ati on.
convmtx
6-68
convmtx
Purpose Convol uti on matri x.
Syntax A = conv mt x ( c, n)
A = conv mt x ( 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 = conv mt x ( 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 = conv mt x ( 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] ;
conv mt x ( 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 conv mt x 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 = l engt h( x ) ;
y = conv mt x ( c, n) *x
Algorithm conv mt x uses the functi on t oepl i t z to generate the convol uti on matri x.
convmtx
6-69
See Also conv Convol uti on and pol ynomi al mul ti pl i cati on.
conv n N-di mensi onal convol uti on (see MATLAB Functi on
Reference).
conv 2 Two-di mensi onal convol uti on.
df t mt x Di screte Fouri er transform matri x.
corrcoef
6-70
corrcoef
Purpose Correl ati on coeffi ci ent matri x.
Syntax C = cor r coef ( X)
C = cor r coef ( X, Y)
Description cor r coef 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 cor r coef ( X) i s the matri x whose el ement (i, j) i s
C = cor r coef ( X) i s the zeroth l ag of the covari ance functi on, that i s, the
zeroth l ag of x cov ( x , ' coef f ' ) packed i nto a square array.
C = cor r coef ( X, Y) i s the same as cor r coef ( [ X Y] ) , that i s, i t concatenates
X and Y i n the row di recti on before i ts computati on.
cor r coef removes the mean from each col umn before cal cul ati ng the resul ts.
See the x cor r functi on for cross-correl ati on opti ons.
Thi s functi on i s part of the mai n MATLAB envi ronment.
See Also cov Covari ance matri x.
mean Average val ue (see MATLAB Functi on Reference).
medi an Medi an val ue (see MATLAB Functi on Reference).
s t d Standard devi ati on (see MATLAB Functi on
Reference).
x cor r Cross-correl ati on functi on esti mate.
x cov Cross-covari ance functi on esti mate (equal to
mean-removed cross-correl ati on).
corrcoef( , )
( , )
( , ) ( , )
i j
C i j
C i i C j j

cov
6-71
cov
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. di ag( cov ( X) ) i s a vector of
vari ances for each col umn, and s qr t ( di ag( 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
x cov ( 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 recti on before i ts
computati on.
cov removes the mean from each col umn before cal cul ati ng the resul ts.
Thi s functi on i s part of the mai n MATLAB envi ronment.
Algorithm [ n, p] = s i z e( x ) ;
x = x ones ( n, 1) *( s um( x ) /n) ;
y = x ' *x /( n1) ;
See Also cor r coef Correl ati on coefci ent matri x.
mean Average val ue (see MATLAB Functi on Reference).
medi an Medi an val ue (see MATLAB Functi on Reference).
s t d Standard devi ati on (see MATLAB Functi on
Reference).
x cor r Cross-correl ati on functi on esti mate.
x cov Cross-covari ance functi on esti mate (equal to
mean-removed cross-correl ati on).
cplxpair
6-72
cpl xpai r
Purpose Group compl ex numbers i nto compl ex conjugate pai rs.
Syntax y = cpl x pai r ( x )
y = cpl x pai r ( x , t ol )
Description y = cpl x pai r ( x ) returns x wi th compl ex conjugate pai rs grouped together.
cpl x pai r 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 = cpl x pai r ( x , t ol ) i ncl udes a tol erance, t ol , for determi ni ng whi ch
numbers are real and whi ch are pai red compl ex conjugates. By defaul t,
cpl x pai r uses a tol erance of 100*eps rel ati ve to abs ( x ( i ) ) . cpl x pai r forces
the compl ex conjugate pai rs to be exact compl ex conjugates.
Thi s functi on i s part of the standard MATLAB envi ronment.
Example Order fi ve pol es evenl y spaced around the uni t ci rcl e i nto compl ex pai rs:
cpl x pai r ( ex p( 2*pi *s qr t ( 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, cpl x pai r
generates the error message:
Compl ex number s can' t be pai r ed.
cremez
6-73
cremez
Purpose Compl ex and nonl i near-phase equi ri ppl e FI R fi l ter desi gn
Syntax b = cr emez ( n, f , ' f r esp' )
b = cr emez ( n, f , ' f r esp' , w)
b = cr emez ( n, f , {' f r esp' , p1, p2, . . . }, w)
b = cr emez ( n, f , a, w)
b = cr emez ( . . . , ' sym' )
b = cr emez ( . . . , ' debug' )
b = cr emez ( . . . , ' s ki p_s t age2' )
[ b, del t a, opt ] = cr emez ( . . . )
Description cr emez 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 = cr emez ( n, f , ' f r esp' ) 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
f r es p. f i s a vector of frequency bandedge 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 don't care regi ons duri ng opti mi zati on.
b = cr emez ( n, f , ' f r esp' , 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 = cr emez ( n, f , {' f r esp' , p1, p2, . . . }, . . . ) suppl i es opti onal parameters
p1, p2, ..., to the frequency response functi on f r es p. Predefi ned frequency
response functi ons for ' f r esp' i ncl ude the fol l owi ng desi gn fi l ters wi th the
appropri ate frequency response. For al l of the predefi ned frequency response
functi ons, the symmetry opti on ' sym' defaul ts to ' ev en' 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-74
wi l l have 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.
l owpas s , hi ghpas s , bandpas s , bands t op
These functi ons share a common syntax, exempl i fi ed here by ' l owpas s ' :
b = cr emez ( n, f , ' l owpas s ' , . . . ) and
b = cr emez ( n, f , {' l owpas s ' , d}, . . . ) desi gn a l i near-phase (n/2+d del ay)
fi l ter.
mul t i band desi gns a l i near-phase frequency response fi l ter wi th arbi trary
band ampl i tudes.
b = cr emez ( n, f , {' mul t i band' , a}, . . . ) and
b = cr emez ( n, f , {' mul t i band' , 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) , f ( k+1) ) for k odd i s the l i ne seg-
ment connecti ng the poi nts ( f ( k) , a( k) ) and ( f ( k+1) , a( k+1) ) .
di f f er ent i at or desi gns a l i near-phase di fferenti ator. For these desi gns, ze-
ro-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 = cr emez ( n, f , {' di f f er ent i at or ' , Fs }, . . . ) and
b = cr emez ( n, f , {' di f f er ent i at or ' , 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.
hi l bf i l t 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 = cr emez ( n, f , ' hi l bf i l t ' , . . . ) and
b = cr emez ( N, F, {' hi l bf i l t ' , d}, . . . ) desi gn a l i near-phase (n/2+d del ay)
Hi l bert transform fi l ter.
b = cr emez ( n, f , a, w) i s a synonym for b = cr emez ( n, f , {' mul t i band' , a}, w) .
cremez
6-75
b = cr emez ( . . . , ' sym' ) i mposes a symmetry constrai nt on the i mpul se
response of the desi gn, where ' sym' may be
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
' f r esp' does not suppl y a defaul t.
ev en 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.
r eal 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 wi l l be
fi l l ed i n from symmetry. I f not speci fi ed, the ' f r esp' functi on wi l l be queri ed
for a defaul t setti ng.
b = cr emez ( . . . , ' s ki p_s t age2' ) di sabl es the second-stage opti mi zati on
al gori thm, whi ch executes onl y when cr emez determi nes that an opti mal sol u-
ti 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 reduc-
ti on i n accuracy. By defaul t, the second-stage opti mi zati on i s enabl ed.
b = cr emez ( . . . , ' 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 ' t r ace' , ' pl ot s ' ,
' bot h' , or ' of f ' . By defaul t, i t i s set to ' of f ' .
Note that any combi nati on of the ' sym' , ' debug' , and ' s ki p_s t age2' opti ons
may be speci fi ed.
[ b, del t a] = cr emez ( . . . ) returns the maxi mum ri ppl e hei ght del t a.
cremez
6-76
[ b, del t a, opt ] = cr emez ( . . . ) returns a structure opt of opti onal resul ts
computed by cr emez and contai ns the fol l owi ng fi el ds:
opt . f gr i d, frequency gri d vector used for the fi l ter desi gn opti mi zati on
opt . H, frequency response for each poi nt i n opt . f gr i d
opt . er r or , error at each poi nt i n opt . f gr i d
opt . f ex t r , vector of extremal frequenci es
Example Desi gn a 31-tap, l i near-phase, l owpass fi l ter:
b = cr emez ( 30, [ 1 0. 5 0. 4 0. 7 0. 8 1] , ' l owpas s ' ) ;
f r eqz ( b, 1, 512, ' whol e' ) ;
0 0.5 1 1.5 2
-4000
-3000
-2000
-1000
0
Normalized frequency (Nyquist == 1)
P
h
a
s
e

(
d
e
g
r
e
e
s
)
0 0.5 1 1.5 2
-100
-50
0
50
Normalized frequency (Nyquist == 1)
M
a
g
n
i
t
u
d
e

R
e
s
p
o
n
s
e

(
d
B
)
cremez
6-77
Remarks User-defi nabl e functi ons may be used, i nstead of the predefi ned frequency
response functi ons for ' f r esp' . The functi on i s cal l ed from wi thi n cr emez
usi ng the fol l owi ng syntax:
[ dh, dw] = f r esp( 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 cr emez . gf determi nes the frequency gri d at
whi ch the response functi on must be eval uated.
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 cr emez ; i f not speci fi ed, i t i s set to uni ty wei ghti ng
before bei ng passed to ' f r esp' .
dh and dw are the desi red compl ex frequency response and band wei ght vec-
tors, respecti vel y, eval uated at each frequency i n gri d gf .
p1, p2,..., are opti onal parameters that may be passed to ' f r esp' .
Addi ti onal l y, a prel i mi nary cal l i s made to ' f r esp' to determi ne the defaul t
symmetry property ' sym' . Thi s cal l i s made usi ng the syntax:
s y m = f r esp( ' def aul t s ' , {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 pr i v at e/l owpas s . 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-78
Diagnostics The fol l owi ng di agnosti c messages ari se from i ncorrect usage of cr emez :
Not enough i nput ar gument s .
F mus t cont ai n an ev en number of band edge ent r i es .
Band edges mus t be monot oni cal l y i ncr eas i ng.
Ex pect i ng a s t r i ng ar gument .
I nv al i d ar gument ar g s peci f i ed.
I nv al i d def aul t s y mmet r y opt i on symr et ur ned f r om r es pons e
f unct i on f r esp. Mus t be one of ' none' , ' r eal ' , ' ev en' , or ' odd' .
Fr equency band edges mus t be i n t he r ange [ 1, +1] f or des i gns wi t h
SYM = ' sym' .
Fr equency band edges mus t be i n t he r ange [ 0, +1] f or des i gns wi t h
SYM = ' sym' .
I ncor r ect s i z e of r es ul t s f r om r es pons e f unct i on f r esp. Si z es mus t
be t he s ame s i z e as t he f r equency gr i d GF.
Bot h 1 and 1 hav e been s peci f i ed as f r equenci es i n F, and t he
f r equency s paci ng i s t oo cl os e t o mov e ei t her of t hem t owar d i t s
nei ghbor .
I nt er nal er r or : Gr i d f r equenci es out of r ange.
I nt er nal er r or : domai n mus t be "whol e" or "hal f ".
I nt er nal er r or : obt ai ned a negat i v e bandwi dt h.
I nt er nal er r or : t wo ex t r emal f r equeci es at t he s ame gr i d poi nt .
I nt er nal er r or : dBr ange mus t be > 0.
cremez
6-79
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 Complex Digital FI R Filters in the Chebyshev 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 ntroduction to Minimax. New York:
John Wi l ey & Sons, 1974.
f i r 1 Wi ndow-based fi ni te i mpul se response fi l ter desi gn
standard response.
f i r 2 Wi ndow-based fi ni te i mpul se response fi l ter desi gn
arbi trary response.
f i r l s Least square l i near-phase FI R fi l ter desi gn.
r emez Parks-McCl el l an opti mal FI R fi l ter desi gn.
pr i v at e/bandpas s Bandpass fi l ter desi gn functi on.
pr i v at e/bands t op Bandstop fi l ter desi gn functi on.
pr i v at e/
di f f er ent i at or
Di fferenti ator fi l ter desi gn functi on.
pr i v at e/hi ghpas s Hi ghpass fi l ter desi gn functi on.
pr i v at e/hi l bf i l t Hi l bert fi l ter desi gn functi on.
pr i v at e/l owpas s Lowpass fi l ter desi gn functi on.
pr i v at e/mul t i band Mul ti band fi l ter desi gn functi on.
csd
6-80
csd
Purpose Esti mate the cross spectral densi ty (CSD) of two si gnal s.
Syntax Px y = cs d( x , y )
Px y = cs d( x , y , nf f t )
[ Px y , f ] = cs d( x , y , nf f t , Fs )
Px y = cs d( x , y , nf f t , Fs , wi ndow)
Px y = cs d( x , y , nf f t , Fs , wi ndow, nov er l ap)
Px y = cs d( x , y , . . . , ' df l ag' )
[ Px y , Px y c, f ] = cs d( x , y , nf f t , Fs , wi ndow, nov er l ap, p)
cs d( x , y , . . . )
Description Px y = cs d( 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. Px y = cs d( x , y ) uses
the fol l owi ng defaul t val ues:
nf f t = mi n( 256, l engt h( x ) )
Fs = 2
wi ndow = hanni ng( nf f t )
nov er l ap = 0
nf f t speci fi es the FFT l ength that cs d 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. wi ndow speci fi es a wi ndowi ng functi on and the
number of sampl es cs d uses i n i ts secti oni ng of the x and y vectors. nov er l ap
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 , cs d esti mates the cross spectral densi ty at posi ti ve frequen-
ci es onl y; i n thi s case, the output Px y i s a col umn vector of l ength nf f t /2 + 1
for nf f t even and ( nf f t + 1) /2 for nf f t odd. I f x or y i s compl ex, cs d esti mates
the cross spectral densi ty at both posi ti ve and negati ve frequenci es and Px y has
l ength nf f t .
Px y = cs d( x , y , nf f t ) uses the FFT l ength nf f t i n esti mati ng the cross spec-
tral densi ty of x and y . Speci fy nf f t as a power of 2 for fastest executi on.
[ Px y , f ] = cs d( x , y , nf f t , 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 Px y , so pl ot ( f , Px y ) pl ots the
csd
6-81
spectrum versus properl y scal ed frequency. Fs has no effect on the output Px y ;
i t i s a frequency scal i ng mul ti pl i er.
Px y = cs d( x , y , nf f t , Fs , wi ndow) 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 wi ndow,
cs d 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 nf f t ; cs d zero pads the secti ons i f the l ength of the wi ndow
i s l ess than nf f t . cs d returns an error i f the l ength of the wi ndow i s greater
than nf f t .
Px y = cs d( x , y , nf f t , Fs , wi ndow, nov er l ap) overl aps the secti ons of x and y
by nov er l ap 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,
cs d( x , y , [ ] , 10000)
i s equi val ent to
cs d( x )
but wi th a sampl i ng frequency of 10,000 Hz i nstead of the defaul t of 2 Hz.
Px y = cs d( x , y , . . . , ' df l ag' ) speci fi es a detrend opti on, where df l ag i s
l i near , 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 df l ag parameter must appear l ast i n the l i st of i nput arguments. cs d
recogni zes a df l ag stri ng no matter how many i ntermedi ate arguments are
omi tted.
[ Px y , Px y c, f ] = cs d( x , y , nf f t , Fs , wi ndow, nov er l ap, p) where p i s a posi -
ti ve scal ar between 0 and 1 returns a vector Px y c that contai ns an esti mate of
the p*100 percent confi dence i nterval for Px y . Px y c i s a two-col umn matri x the
same l ength as Px y . The i nterval [ Px y c( : , 1) , Px y c( : , 2) ] covers the true
CSD wi th probabi l i ty p. pl ot ( f , [ Px y Px y c] ) 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-82
cs d( 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 = f i r 1( 30, 0. 2, box car ( 31) ) ;
h1 = ones ( 1, 10) /s qr t ( 10) ;
r = r andn( 16384, 1) ;
x = f i l t er ( h1, 1, r ) ;
y = f i l t er ( h, 1, x ) ;
cs d( x , y , 1024, 10000, t r i ang( 500) , 0, [ ] )
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-83
Algorithm cs d 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 wi ndow vector to each successi ve de-
trended secti on.
2 I t transforms each secti on wi th an nf f t -poi nt FFT.
3 I t forms the peri odogram of each secti on by scal i ng the product of the trans-
form of the x secti on and the conjugate of the transformed y secti on.
4 I t averages the peri odograms of the successi ve overl appi ng secti ons to form
Px y , the cross spectral densi ty of x and y .
The number of secti ons that cs d averages i s k, where k i s
f i x ( ( l engt h( x ) nov er l ap) /( l engt h( wi ndow) nov er l ap) )
Diagnostics An appropri ate di agnosti c message i s di spl ayed when i ncorrect arguments to
cs d are used:
Requi r es wi ndow' s l engt h t o be no gr eat er t han t he FFT l engt h.
Requi r es NOVERLAP t o be s t r i ct l y l es s t han t he wi ndow l engt h.
Requi r es pos i t i v e i nt eger v al ues f or NFFT and NOVERLAP.
Requi r es v ect or ( ei t her r ow or col umn) i nput .
Requi r es i nput s X and Y t o hav e t he s ame l engt h.
Requi r es conf i dence par amet er t o be a s cal ar bet ween 0 and 1.
See Also coher e Esti mate magni tude squared coherence functi on
between two si gnal s.
pmem Power spectrum esti mate usi ng maxi mum entropy
method (MEM).
pmt m Power spectrum esti mate usi ng the mul ti taper
method (MTM).
pmus i c Power spectrum esti mate usi ng MUSI C ei genvector
method.
ps d Esti mate the power spectral densi ty (PSD) of a
si gnal .
t f e Transfer functi on esti mate from i nput and output.
csd
6-84
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. Audio Electroacoust. Vol . AU-15 (June 1967).
Pgs. 70-73.
[3] Oppenhei m, A.V., and R.W. Schafer. Discrete-Time Signal Processing.
Engl ewood Cl i ffs, NJ: Prenti ce Hal l , 1989. Pg. 737.
czt
6-85
czt
Purpose Chi rp z-transform.
Syntax y = cz t ( x , m, w, a)
y = cz t ( x )
Description y = cz t ( x , m, w, a) returns the chi rp z-transform of si gnal x. The chi rp z-trans-
form 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 = cz t ( x ) uses the fol l owi ng defaul t val ues:
m = l engt h( x )
w = ex p( j *2*pi /m)
a = 1
Wi th these defaul ts, cz t 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 f f t ( x ) . The empty matri x [ ] speci fi es the defaul t val ue for a parameter.
I f x i s a matri x, cz t ( 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 cz t . Thi s
i s faster than the f f t functi on on the same sequence.
x = r andn( 1013, 1) ;
y = cz t ( x ) ;
Use cz t 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 = f i r 1( 30, 125/500, box car ( 31) ) ; % f i l t er
Establ i sh frequency and CZT parameters:
Fs = 1000; f 1 = 100; f 2 = 150; % i n Her t z
m = 1024;
w = ex p( j *2*pi *( f 2f 1) /( m*Fs ) ) ;
a = ex p( j *2*pi *f 1/Fs ) ;
czt
6-86
Compute both the DFT and CZT of the fi l ter:
y = f f t ( h, 1000) ;
z = cz t ( h, m, w, a) ;
Create frequency vectors and compare the resul ts:
f y = ( 0: l engt h( y ) 1) ' *1000/l engt h( y ) ;
f z = ( ( 0: l engt h( z ) 1) ' *( f 2f 1) /l engt h( z ) ) + f 1;
pl ot ( f y ( 1: 500) , abs ( y ( 1: 500) ) ) ; ax i s ( [ 1 500 0 1. 2] )
pl ot ( f z , abs ( z ) ) ; ax i s ( [ f 1 f 2 0 1. 2] )
Algorithm cz t uses the next power-of-2 l ength FFT to perform a fast convol uti on when
computi ng the z-transform on a speci fi ed chi rp contour [1]. cz t can be si gni fi -
cantl y faster than f f t for l arge, pri me-l ength sequences.
Diagnostics I f m, w, or a i s not a scal ar, cz t gi ves the fol l owi ng error message:
I nput s M, W, and A mus t be s cal ar s .
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.
f f t One-di mensi onal fast Fouri er transform.
f r eqz Frequency response of di gi tal l ters.
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
dct
6-87
dct
Purpose Di screte cosi ne transform (DCT).
Syntax y = dct ( x )
y = dct ( x , n)
Description y = dct ( x ) returns the 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 and k 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.
I f x i s a matri x, dct transforms i ts col umns.
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.
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, i nd] = s or t ( abs ( X) ) ; i nd = f l i pl r ( i nd) ;
i = 1;
whi l e ( nor m( [ X( i nd( 1: i ) ) z er os ( 1, 100i ) ] ) /nor m( X) <. 99)
i = i + 1;
end
i =
3

y k x n
N
k n k N
n
N
( ) ( ) cos ( )( ) , + + + +

1
]
1

1 2 1
2
1 2 1 1
0
1

0, , K
dct
6-88
See Also f f t One-di mensi onal fast Fouri er transform.
i dct I nverse di screte cosi ne transform.
dct 2 Two-di mensi onal DCT (see I mage Processing Toolbox
Users Manual).
i dct 2 Two-di mensi onal i nverse DCT (see I mage Processing
Toolbox Users Manual).
decimate
6-89
deci mate
Purpose Decrease the sampl i ng rate for a sequence (deci mati on).
Syntax y = deci mat e( x , r )
y = deci mat e( x , r , n)
y = deci mat e( x , r , ' f i r ' )
y = deci mat e( x , r , n, ' f i r ' )
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 = deci mat e( 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,
deci mat e 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 = deci mat e( 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 = deci mat e( x , r , ' f i r ' ) uses a 30-poi nt FI R fi l ter, i nstead of the Cheby-
shev I I R fi l ter. Here deci mat e 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 = deci mat e( x , r , n, ' f i r ' ) 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; % t i me v ect or
x = s i n( 2*pi *30*t ) + s i n( 2*pi *60*t ) ;
y = deci mat e( x , 4) ;
decimate
6-90
Vi ew the ori gi nal and deci mated si gnal s:
s t em( x ( 1: 120) ) , ax i s ( [ 0 120 2 2] ) % or i gi nal s i gnal
s t em( y ( 1: 30) ) % deci mat ed s i gnal
Algorithm deci mat e 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, deci mat e 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 f i r opti on, deci mat e desi gns a l owpass FI R fi l ter wi th cutoff fre-
quency 1/r usi ng f i r 1.
2 For the FI R fi l ter, deci mat e 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, deci mat e appl i es the fi l ter i n forward and reverse
di recti ons wi th f i l t f i l t .
3 deci mat e 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, deci mat e gi ves the fol l owi ng error message:
Res ampl i ng r at e R mus t be an i nt eger .
I f n speci fi es an I I R fi l ter wi th order greater than 13, deci mat e gi ves the
fol l owi ng warni ng:
War ni ng: I I R f i l t er s abov e or der 13 may be unr el i abl e.
0 50 100
-2
-1
0
1
2
Original Signal
0 10 20 30
-2
-1
0
1
2
Decimated Signal
decimate
6-91
See Also
References [1] I EEE. Programs for Digital Signal Processing. I EEE Press. New York: John
Wi l ey & Sons, 1979. Chapter 8.
i nt er p I ncrease sampl i ng rate by an i nteger factor (i nterpol ati on).
r es ampl e Change sampl i ng rate by any factor.
s pl i ne Cubi c spl i ne i nterpol ati on (see MATLAB Functi on
Reference).
upf i r dn Appl y FI R l ter and perform sampl e rate conversi on.
deconv
6-92
deconv
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 .
deconv i s part of the mai n MATLAB envi ronment.
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 i s an M-fi l e i n the MATLAB envi ronment that uses the f i l t er
pri mi ti ve. Deconvol uti on i s 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.
f i l t er Fi l ter data wi th a recursi ve (I I R) or nonrecursi ve
(FI R) l ter.
r es i duez z-transform parti al fracti on expansi on.
demod
6-93
demod
Purpose Demodul ati on for communi cati ons si mul ati on.
Syntax x = demod( y , Fc, Fs , ' met hod' )
x = demod( y , Fc, Fs , ' met hod' , opt )
x = demod( y , Fc, Fs , ' pwm' , ' cent er ed' )
[ x 1, x 2] = 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 modu-
l ated versi on of the si gnal . demod undoes the operati on performed by modul at e.
x = demod( y , Fc, Fs , ' met hod' , opt ) demodul ates 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 met hod. (Note that some methods accept an opti on, opt .)
amds bs c
or
am
Amplitude demodulation, double side-band, suppressed
carrier. Mul ti pl i es y by a si nusoi d of frequency Fc and appl i es a
fth-order Butterworth l owpass l ter usi ng f i l t f i l t :
x = y . *cos ( 2*pi *Fc*t ) ;
[ b, a] = but t er ( 5, Fc*2/Fs ) ;
x = f i l t f i l t ( b, a, x ) ;
amds bt c Amplitude demodulation, double side-band, transmitted
carrier. Mul ti pl i es y by a si nusoi d of frequency Fc, and appl i es a
fth-order Butterworth l owpass l ter usi ng f i l t f i l t :
x = y . *cos ( 2*pi *Fc*t ) ;
[ b, a] = but t er ( 5, Fc*2/Fs ) ;
x = f i l t f i l t ( 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.
ams s b Amplitude demodulation, single side-band. Mul ti pl i es y by a
si nusoi d of frequency Fc and appl i es a fth-order Butterworth
l owpass l ter usi ng f i l t f i l t :
x = y . *cos ( 2*pi *Fc*t ) ;
[ b, a] = but t er ( 5, Fc*2/Fs ) ;
x = f i l t f i l t ( b, a, x ) ;
demod
6-94
The defaul t method i s ' am' . Except for the ' pt m' 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' , ' cent er ed' ) 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
l engt h( y ) *Fc/Fs .
See Also
f m 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 Phase demodulation. 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.
pt m Pulse-time demodulation. 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 l engt h( 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 ed.
qam Quadrature amplitude demodulation.
[ x 1, x 2] = 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 fth-order Butterworth
l owpass l ter usi ng f i l t f i l t :
x 1 = y . *cos ( 2*pi *Fc*t ) ;
x 2 = y . *s i n( 2*pi *Fc*t ) ;
[ b, a] = but t er ( 5, Fc*2/Fs ) ;
x 1 = f i l t f i l t ( b, a, x 1) ;
x 2 = f i l t f i l t ( b, a, x 2) ;
modul at e Modul ati on for communi cati ons si mul ati on.
v co Vol tage control l ed osci l l ator.
detrend
6-95
detrend
Purpose Remove l i near trends.
Syntax y = det r end( x )
y = det r end( x , 0)
Description det r end removes the mean val ue or l i near trend from a vector or matri x,
usual l y for FFT processi ng.
y = det r end( x ) removes the best strai ght-l i ne fi t from vector x and returns i t
i n y . I f x i s an array, det r end removes the trend from each col umn.
y = det r end( x , 0) removes the mean val ue from vector x or, i f x i s an array,
from each col umn of the array.
Algorithm det r end computes the l east-squares fi t of a strai ght l i ne to the data and
subtracts the resul ti ng functi on from the data. The mai n part of the al gori thm
i s
m = l engt h( x ) ;
a = [ ( 1: m) ' /m ones ( m, 1) ] ;
y = x a*( a\x ) ;
To obtai n the equati on of the strai ght-l i ne fi t, use pol y f i t .
See Also pol y f i t Pol ynomi al curve tti ng (see MATLAB Functi on
Reference).
dftmtx
6-96
dftmtx
Purpose Di screte Fouri er transform matri x.
Syntax A = df t mt x ( n)
Description A discrete Fourier transform matrix i 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 = df t mt x ( 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 ( df t mt x ( 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;
y 1 = f f t ( x ) ;
than by usi ng the Fouri er transform matri x
n = l engt h( x ) ;
y 2 = x *df t mt x ( n) ;
nor m( y 1y 2)
ans =
2. 0016e09
Algorithm df t mt x uses an outer product to generate the transform matri x.
See Also conv mt x Convol uti on matri x.
f f t One-di mensi onal fast Fouri er transform.
diric
6-97
di ri c
Purpose Di ri chl et or peri odi c si nc functi on.
Syntax y = di r i c( x , n)
Description y = di r i c( 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, di r i c gi ves the fol l owi ng error message:
Requi r es n t o be a pos i t i v e i nt eger .
See Also cos Cosi ne of vector/matri x el ements (see MATLAB
Functi on Reference).
gaus pul s Gaussi an-modul ated si nusoi dal pul se generator.
pul s t r an Pul se trai n generator.
r ect pul s Sampl ed aperi odi c rectangl e generator.
s awt oot h Sawtooth or tri angl e wave generator.
s i n Si ne of vector/matri x el ements (see MATLAB
Functi on Reference).
s i nc Si nc or si n(t)/t functi on.
s quar e Square wave generator.
t r i pul s Sampl ed aperi odi c tri angl e generator.
diric( )
, , , , ...
sin( / )
sin( / )
( )
x
x k k
nx
n x
k n

t t

'

1 2 0 1 2
2
2
1

else

dpss
6-98
dpss
Purpose Di screte prol ate spheroi dal sequences (Sl epi an sequences).
Syntax [ e, v ] = dps s ( n, nw)
[ e, v ] = dps s ( n, nw, ' cal c' )
[ e, v ] = dps s ( n, nw, ' s pl i ne' )
[ e, v ] = dps s ( n, nw, ' s pl i ne' , Ni )
[ e, v ] = dps s ( n, nw, ' l i near ' )
[ e, v ] = dps s ( n, nw, ' l i near ' , Ni )
[ e, v ] = dps s ( n, nw, ' t r ace' )
[ e, v ] = dps s ( n, nw, ' i nt ' , ' t r ace' )
Description [ e, v ] = dps s ( n, nw) generates the fi rst 2*nw discrete prolate spheroidal
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 generated i n the DPSS MAT-fi l e database
dps s . mat .
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.
I f you speci fy onl y n and nw, DPSS fol l ows these rul es for sel ecti ng an effi ci ent
(al though someti mes approxi mate) al gori thm:
1 I f n < 500, the sequences are cal cul ated di rectl y.
2 I f n 500,
a l ook for sequences i n the DPSS MAT-fi l e database dps s . mat ;
b i f not found, l i nearl y i nterpol ate from sequences wi th the same nw and
next l argest n i n the database;
c i f not found, use spl i ne i nterpol ati on from l ength 64 sequences.
[ e, v ] = dps s ( n, nw, ' cal c' ) forces DPSS to cal cul ate e and v di rectl y. Thi s
can take a l ong ti me for l arge n and nw.
dpss
6-99
[ e, v ] = dps s ( n, nw, ' s pl i ne' ) uses spl i ne i nterpol ati on to compute e and v
from the sequences i n dps s . mat wi th l ength cl osest to n.
[ e, v ] = dps s ( n, nw, ' s pl i ne' , Ni ) i nterpol ates from exi sti ng l ength Ni
sequences.
[ e, v ] = dps s ( n, nw, ' l i near ' ) and
[ e, v ] = dps s ( n, nw, ' l i near ' , 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. ' l i near ' requi res Ni > n.
[ e, v ] = dps s ( n, nw, ' t r ace' ) and
[ e, v ] = dps s ( n, nw, ' i nt ' , ' t r ace' ) use a trai l i ng ' t r ace' argument to fi nd
out whi ch method DPSS uses, where ' i nt ' i s ei ther ' s pl i ne' or ' l i near ' .
See Also
References [1] Perci val , D.B., and A.T. Wal den. Spectral Analysis for Physical Applica-
tions: Multitaper and Conventional Univariate Techniques. Cambri dge:
Cambri dge Uni versi ty Press, 1993.
dps s cl ear Remove di screte prol ate spheroi dal sequences from
database.
dps s di r Di screte prol ate spheroi dal sequences database
di rectory.
dps s l oad Load di screte prol ate spheroi dal sequences from
database.
dps s s av e Save di screte prol ate spheroi dal sequences i n
database.
pmt m Power spectrum esti mate usi ng the mul ti taper
method (MTM).
dpssclear
6-100
dpsscl ear
Purpose Remove di screte prol ate spheroi dal sequences from database.
Syntax dps s cl ear ( n, nw)
Description dps s cl ear ( n, nw) removes sequences wi th l ength n and ti me-bandwi dth
product nw from the DPSS MAT-fi l e database dps s . mat .
See Also dps s Di screte prol ate spheroi dal sequences (Sl epi an
sequences).
dps s di r Di screte prol ate spheroi dal sequences database
di rectory.
dps s l oad Load di screte prol ate spheroi dal sequences from
database.
dps s s av e Save di screte prol ate spheroi dal sequences i n
database.
dpssdir
6-101
dpssdi r
Purpose Di screte prol ate spheroi dal sequences database di rectory.
Syntax dps s di r
dps s di r ( n)
dps s di r ( nw, ' nw' )
dps s di r ( n, nw)
i ndex = dps s di r
Description dps s di r manages the database di rectory that contai ns the generated DPSS
sampl es i n the DPSS MAT-fi l e database dps s . mat .
dps s di r l i sts the di rectory of saved sequences i n dps s . mat .
dps s di r ( n) l i sts the sequences saved wi th l ength n.
dps s di r ( nw, ' nw' ) l i sts the sequences saved wi th ti me-bandwi dth product nw.
dps s di r ( n, nw) l i sts the sequences saved wi th l ength n and ti me-bandwi dth
product nw.
i ndex = dps s di r 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 i ndex .
See Also dps s Di screte prol ate spheroi dal sequences (Sl epi an
sequences).
dps s cl ear Remove di screte prol ate spheroi dal sequences from
database.
dps s l oad Load di screte prol ate spheroi dal sequences from
database.
dps s s av e Save di screte prol ate spheroi dal sequences i n
database.
dpssload
6-102
dpssl oad
Purpose Load di screte prol ate spheroi dal sequences from database.
Syntax [ e, v ] = dps s l oad( n, nw)
Description [ e, v ] = dps s l oad( n, nw) l oads al l sequences wi th l ength n and ti me-band-
wi 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 dps s . mat .
See Also dps s Di screte prol ate spheroi dal sequences (Sl epi an
sequences).
dps s cl ear Remove di screte prol ate spheroi dal sequences from
database.
dps s di r Di screte prol ate spheroi dal sequences database
di rectory.
dps s s av e Save di screte prol ate spheroi dal sequences i n
database.
dpsssave
6-103
dpsssave
Purpose Save di screte prol ate spheroi dal sequences i n database.
Syntax dps s s av e( nw, e, v )
s t at us = dps s s av e( nw, e, v )
Description dps s s av e( nw, e, v ) saves the sequences i n the col umns of e and thei r corre-
spondi ng concentrati ons i n vector v i n the DPSS MAT-fi l e database dps s . mat .
I t i s not necessary to speci fy sequence l ength, because the l ength of the se-
quence 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 dps s .
s t at us = dps s s av e( nw, e, v ) returns 0 i f the save was successful and 1 i f
there was an error.
See Also dps s Di screte prol ate spheroi dal sequences (Sl epi an
sequences).
dps s cl ear Remove di screte prol ate spheroi dal sequences from
database.
dps s di r Di screte prol ate spheroi dal sequences database
di rectory.
dps s l oad Load di screte prol ate spheroi dal sequences from
database.
ellip
6-104
el l i p
Purpose El l i pti c (Cauer) fi l ter desi gn.
Syntax [ b, a] = el l i p( n, Rp, Rs , Wn)
[ b, a] = el l i p( n, Rp, Rs , Wn, ' f t ype' )
[ b, a] = el l i p( n, Rp, Rs , Wn, ' s ' )
[ b, a] = el l i p( n, Rp, Rs , Wn, ' f t ype' , ' s ' )
[ z , p, k] = el l i p( . . . )
[ A, B, C, D] = el l i p( . . . )
Description el l i p 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 Butter-
worth 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 order of any fi l ter type.
Digita l Doma in
[ b, a] = el l i p( 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 el l i p, 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 charac-
teri sti cs).
I f Wn i s a two-el ement vector, Wn = [ w1 w2] , el l i p returns an order 2*n band-
pass fi l ter wi th passband w1 < < w2.

H z
B z
A z
b b z b n z
a z a n z
n
n
( )
( )
( )
( ) ( ) ( )
( ) ( )

+ + + +
+ + + +


1 2 1
1 2 1
1
1
L
L

ellip
6-105
[ b, a] = el l i p( n, Rp, Rs , Wn, ' f t ype' ) desi gns a hi ghpass or bandstop fi l ter,
where f t ype i s
hi gh for a hi ghpass di gi tal fi l ter wi th cutoff frequency Wn
s t op 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, el l i p 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 argu-
ments:
[ z , p, k] = el l i p( n, Rp, Rs , Wn) or
[ z , p, k] = el l i p( n, Rp, Rs , Wn, ' f t ype' ) 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] = el l i p( n, Rp, Rs , Wn) or
[ A, B, C, D] = el l i p( n, Rp, Rs , Wn, ' f t ype' ) 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.
Ana log Doma in
[ b, a] = el l i p( 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 el l i p, the cutoff frequency Wn must be
greater than 0.
x n x n u n
y n x n u n
[ ] [ ] [ ]
[ ] [ ] [ ]
+ +
+
1 A B
C D

H s
B s
A s
b s b s b n
s a s a n
n n
n n
( )
( )
( )
( ) ( ) ( )
( ) ( )

+ + + +
+ + + +

1 2 1
2 1
1
1
L
L
ellip
6-106
I f Wn i s a two-el ement vector wi th w1 < w2, then el l i p( n, Rp, Rs , Wn, ' s ' )
returns an order 2*n bandpass anal og fi l ter wi th passband w1 < < w2.
[ b, a] = el l i p( n, Rp, Rs , Wn, ' f t ype' , ' s ' ) desi gns a hi ghpass or bandstop
fi l ter, where f t ype i s
hi gh for a hi ghpass anal og fi l ter wi th cutoff frequency Wn
s t op 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, el l i p 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] = el l i p( n, Rp, Rs , Wn, ' s ' ) or
[ z , p, k] = el l i p( n, Rp, Rs , Wn, ' f t ype' , ' 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] = el l i p( n, Rp, Rs , Wn, ' s ' ) or
[ A, B, C, D] = el l i p( n, Rp, Rs , Wn, ' f t ype' , ' 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.
x Ax Bu
y Cx Du
+
+
ellip
6-107
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 atten-
uati on i n the stopband:
[ b, a] = el l i p( 6, 3, 50, 300/500) ;
The fi l ters frequency response i s
f r eqz ( b, a, 512, 1000)
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-108
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] = el l i p( n, Rp, Rs , Wn) ;
[ y , t ] = i mpz ( b, a, 101) ; s t em( t , y )
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.
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-109
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. el l i p 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
el l i pap 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.
4 For di gi tal fi l ter desi gn, el l i p uses bi l i near 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 pre-
warpi 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 bes s el f Bessel anal og l ter desi gn.
but t er Butterworth anal og and di gi tal l ter desi gn.
cheby 1 Chebyshev type I l ter desi gn (passband ri ppl e).
cheby 2 Chebyshev type I I l ter desi gn (stopband ri ppl e).
el l i pap El l i pti c anal og l owpass l ter prototype.
el l i por d El l i pti c l ter order sel ecti on.
ellipap
6-110
el l i pap
Purpose El l i pti c anal og l owpass fi l ter prototype.
Syntax [ z , p, k] = el l i pap( n, Rp, Rs )
Description [ z , p, k] = el l i pap( 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.
el l i p 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 el l i pap uses the al gori thm outl i ned i n [1]. I t empl oys the M-fi l e el l i pk 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 el l i pj
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.
bes s el ap Bessel anal og l owpass l ter prototype.
but t ap Butterworth anal og l owpass l ter prototype.
cheb1ap Chebyshev type I anal og l owpass l ter prototype.
cheb2ap Chebyshev type I I anal og l owpass l ter prototype.
el l i p El l i pti c (Cauer) l ter desi gn.

H s
z s
p s
k
s z s z s z n
s p s p s p n
( )
( )
( )
( ( ))( ( )) ( ( ))
( ( ))( ( )) ( ( ))



1 2
1 2
L
L

0
ellipord
6-111
el l i pord
Purpose El l i pti c fi l ter order sel ecti on.
Syntax [ n, Wn] = el l i por d( Wp, Ws , Rp, Rs )
[ n, Wn] = el l i por d( Wp, Ws , Rp, Rs , ' s ' )
Description el l i por d 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:
Digita l Doma in
[ n, Wn] = el l i por d( 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. el l i por d al so returns
Wn, the cutoff frequency that al l ows el l i p to achi eve the gi ven speci fi cati ons.
Use el l i por d for l owpass, hi ghpass, bandpass, and bandstop fi l ters. For hi gh-
pass 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, el l i por d returns Wn as
a two-el ement row vector for i nput to el l i p.
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-112
Ana log Doma in
[ n, Wn] = el l i por d( 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 el l i por d for l owpass, hi ghpass, bandpass, and bandstop fi l ters as
descri bed under Di gi tal Domai n.
Examples For 1000 Hz data, design a lowpass filter with less than 3 dB of attenuation from 0
to 100 Hz and at least 15 dB of attenuation from 150 Hz to the Nyquist frequency:
Wp = 100/500; Ws = 150/500;
Rp = 3; Rs = 15;
[ n, Wn] = el l i por d( Wp, Ws , Rp, Rs )
n =
2
Wn =
0. 2000
[ b, a] = el l i p( n, Rp, Rs , Wn) ;
f r eqz ( b, a, 512, 1000)
0 50 100 150 200 250 300 350 400 450 500
-200
-150
-100
-50
0
50
F (H t )
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-113
Now desi gn a bandpass fi l ter wi th a passband from 100 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 = [ 100 200] /500; Ws = [ 50 250] /500;
Rp = 3; Rs = 30;
[ n, Wn] = el l i por d( Wp, Ws , Rp, Rs )
n =
3
Wn =
0. 2000 0. 4000
[ b, a] = el l i p( n, Rp, Rs , Wn) ;
f r eqz ( b, a, 512, 1000)
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-114
Algorithm el l i por d 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 param-
eters to the s-domai n before the order and natural frequency esti mati on
process, then converts them back to the z-domai n.
el l i por d 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.
but t or d Butterworth l ter order sel ecti on.
cheb1or d Chebyshev type I l ter order sel ecti on.
cheb2or d Chebyshev type I I l ter order sel ecti on.
el l i p El l i pti c (Cauer) l ter desi gn.

fft

6-115

fft

Purpose

One-di mensi onal fast Fouri er transform.

Syntax

y = f f t ( x )
y = f f t ( x , n)

Description

f f t

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

= l engt h( 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 = f f t ( 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 FFT of each col umn
of the matri x. The

f f t

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 = f f t ( x , n)

i s the

n

-poi nt FFT. I f the l ength of

x

i s l ess than

n

,

f f t

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

,

f f t

truncates
the sequence

x

. I f

x

i s an array,

f f t

adjusts the l ength of the col umns i n the
same manner.

f f t

i s part of the standard MATLAB envi ronment.

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 x n W
N
kn
n
N
( ) ( ) + +

1 1
0
1

fft

6-116

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 = s i n( 2*pi *50*t ) + s i n( 2*pi *120*t ) ;
y = x + 2*r andn( 1, l engt h( t ) ) ;
pl ot ( 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 trans-
form of the noi sy si gnal

y

usi ng a 512-poi nt fast Fouri er transform (FFT):

Y = f f t ( y , 512) ;

The power spectral densi ty, a measurement of the energy at vari ous frequen-
ci es, i s

Py y = 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-117

Graph the fi rst 256 poi nts (the other 256 poi nts are symmetri c) on a mean-
i ngful frequency axi s:

f = 1000*( 0: 255) /512;
pl ot ( f , Py y ( 1: 256) )

See the

ps d

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

f f t

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 ( f f t ( x ) ) *2/l engt h( x )

Algorithm

f f t

i s a bui l t-i n MATLAB functi on. When the sequence l ength i s a power of
two,

f f t

uses a hi gh-speed radi x-2 fast Fouri er transform al gori thm. The
radi x-2 FFT routi ne i s opti mi zed to perform a real FFT i 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 50 100 150 200 250 300 350 400 450 500
0
10
20
30
40
50
60
70
80

fft

6-118

The executi on ti me for

f f t

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,

f f t

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 FFT takes 2.1
seconds and a compl ex FFT of 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

x

of

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

dct

Di screte cosi ne transform (DCT).

df t mt x

Di screte Fouri er transform matri x.

f f t 2

Two-di mensi onal fast Fouri er transform.

f f t s hi f t

Rearrange the outputs of

f f t

and

f f t 2

.

f i l t er

Fi l ter data wi th a recursi ve (I I R) or nonrecursi ve
(FI R) l ter.

f r eqz

Frequency response of di gi tal l ters.

i f f t

One-di mensi onal i nverse fast Fouri er transform.

ps d

Esti mate the power spectral densi ty (PSD) of a
si gnal .
f
s
f k f N
s
( ) / 1

fft2

6-119

fft2

Purpose

Two-di mensi onal fast Fouri er transform.

Syntax

Y = f f t 2( X)
Y = f f t 2( X, m, n)

Description

Y = f f t 2( 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 = f f t 2( 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.
f f t 2 i s part of the standard MATLAB envi ronment.
Algorithm f f t 2( x ) i s si mpl y
f f t ( f f t ( x ) . ' ) . '
Thi s computes the one-di mensi onal f f t of each col umn of x , then of each row
of the resul t. The ti me requi red to compute f f t 2( x ) depends on the number of
pri me factors i n [ m, n] = s i z e( x ) . f f t 2 i s fastest when m and n are powers of 2.
See Also f f t One-di mensi onal fast Fouri er transform.
f f t s hi f t Rearrange the outputs of f f t and f f t 2.
i f f t One-di mensi onal i nverse fast Fouri er transform.
i f f t 2 Two-di mensi onal i nverse fast Fouri er transform.
fftfilt
6-120
fftfi l t
Purpose FFT-based FI R fi l teri ng usi ng the overl ap-add method.
Syntax y = f f t f i l t ( b, x )
y = f f t f i l t ( b, x , n)
Description f f t f i l t 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 = f f t f i l t ( b, x ) fi l ters the data i n vector x wi th the fi l ter descri bed by coef-
fi ci ent vector b. I t returns the data vector y . The operati on performed by
f f t f i l t i s descri bed i n the time domain by the di fference equati on
An equi val ent representati on i s the z-transform or frequency domain descri pti on
By defaul t, f f t f i l t chooses an FFT l ength and data bl ock l ength that guar-
antee effi ci ent executi on ti me.
y = f f t f i l t ( b, x , n) uses an FFT l ength of nf f t = 2^nex t pow2( n) and a data
bl ock l ength of nf f t l engt h( b) + 1.
f f t f i l t works for both real and compl ex i nputs.
Example Show that the resul ts from f f t f i l t and f i l t er are i denti cal :
b = [ 1 2 3 4] ;
x = [ 1 z er os ( 1, 99) ] ' ;
nor m( f f t f i l t ( b, x ) f i l t er ( b, 1, x ) )
ans =
9. 5914e15
Algorithm f f t f i l t uses f f t 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.
f f t f i l t breaks an i nput sequence x i nto l ength L data bl ocks:

y n b x n b x n b nb x n nb ( ) ( ) ( ) ( ) ( ) ( ) ( ) + + + + 1 2 1 1 L

Y z b b z b nb z X z
nb
( ) ( ( ) ( ) ( ) ) ( ) + + + +

1 2 1
1
L
x
L 2L 3L ceil(nx/L)*L
. . .
fftfilt
6-121
and convol ves each bl ock wi th the fi l ter b by
y = i f f t ( f f t ( x ( i : i +L1) , nf f t ) . *f f t ( b, nf f t ) ) ;
where nf f t i s the FFT l ength. f f t f i l t 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:
f f t f i l t chooses the key parameters L and nf f t 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),
f f t f i l t chooses these key parameters automati cal l y:
I f l engt h( x ) > l engt h( b) , f f t f i l t chooses val ues that mi ni mi ze the num-
ber of bl ocks ti mes the number of fl ops per FFT.
I f l engt h( b) >= l engt h( x ) , f f t f i l t uses a si ngl e FFT of l ength
2^nex t pow2( l engt h( b) + l engt h( x ) 1)
Thi s essenti al l y computes
y = i f f t ( f f t ( B, nf f t ) . *f f t ( X, nf f t ) )
I f you suppl y a val ue for n, f f t f i l t chooses an FFT l ength, nf f t , of
2^nex t pow2( n) and a data bl ock l ength of nf f t l engt h( b) + 1. I f n i s l ess
than l engt h( b) , f f t f i l t sets n to l engt h( b) .
See Also
References [1] Oppenhei m, A.V., and R.W. Schafer. Discrete-Time Signal Processing.
Engl ewood Cl i ffs, NJ: Prenti ce Hal l , 1989.
f i l t er Fi l ter data wi th a recursi ve (I I R) or nonrecursi ve
(FI R) l ter.
f i l t f i l t Zero-phase di gi tal l teri ng.
nb1
L
nb1 2L
nb1 3L
. . .
fftshift
6-122
fftshi ft
Purpose Rearrange the outputs of f f t and f f t 2.
Syntax y = f f t s hi f t ( x )
Description y = f f t s hi f t ( x ) rearranges the outputs of f f t and f f t 2 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, f f t s hi f t ( x ) returns a vector wi th the l eft and ri ght hal ves
swapped.
For arrays, f f t s hi f t ( x ) swaps quadrants one and three wi th quadrants two
and four.
Thi s functi on i s part of the mai n MATLAB envi ronment.
Example For any array X,
Y = f f t 2( x )
has Y( 1, 1) = s um( s um( 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 = f f t s hi f t ( Y)
the DC component i s near the center of the matri x.
See Also f f t One-di mensi onal fast Fouri er transform.
f f t 2 Two-di mensi onal fast Fouri er transform.
filter
6-123
fi 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 = f i l t er ( b, a, x )
[ y , z f ] = f i l t er ( b, a, x )
[ . . . ] = f i l t er ( b, a, x , z i )
[ . . . ] = f i l t er ( b, a, x , z i , di m)
Description f i l t er i s part of the MATLAB envi ronment. I t fi l ters data usi ng a di gi tal fi l ter.
The fi l ter real i zati on i s the transposed direct form I I structure [1], whi ch can
handl e both FI R and I I R fi l ters.
I f a(1) 1, f i l t er 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 = f i l t er ( 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 , z f ] = f i l t er ( b, a, x ) returns the fi nal val ues of the states i n the vector z f .
[ . . . ] = f i l t er ( b, a, x , z i ) speci fi es i ni ti al state condi ti ons i n the vector z i .
The si ze of the i ni ti al /fi nal condi ti on vector i s max ( l engt h( b) , l engt h( a) ) 1.
z i or z f 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, f i l t er works across the fi rst
nonsi ngl eton di mensi on of x by defaul t.
[ . . . ] = f i l t er ( b, a, x , z i , di m) works across the di mensi on di m of x . Set z i
to empty to get the defaul t i ni ti al condi ti ons.
f i l t er works for both real and compl ex i nputs.
filter
6-124
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 z er os ( 1, 100) ] ;
[ b, a] = but t er ( 12, 400/1000) ;
y = f i l t er ( b, a, x ) ;
s t em( y )
Algorithm f i l t er i s a bui l t-i n MATLAB functi on. f i l t er 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-125
The operati on of f i l t er at sampl e m i s gi ven by the ti me domai n di fference
equati ons for y and the states z
i
:
You can use f i l t i c 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, f i l t er gi ves the fol l owi ng error message:
Fi r s t denomi nat or coef f i ci ent mus t be nonz er o.
I f the l ength of the i ni ti al condi ti on vector i s not the greater of na and nb,
f i l t er gi ves the fol l owi ng error message:
I ni t i al condi t i on v ect or has i ncor r ect di mens i ons .
See Also
References [1] Oppenhei m, A.V., and R.W. Schafer. Discrete-Time Signal Processing.
Engl ewood Cl i ffs, NJ: Prenti ce Hal l , 1989. Pgs. 311-312.
f f t f i l t FFT-based FI R l teri ng usi ng the overl ap-add
method.
f i l t er 2 Two-di mensi onal di gi tal l teri ng.
f i l t f i l t Zero-phase di gi tal l teri ng.
f i l t i c Make i ni ti al condi ti ons for f i l t er functi on.

y m
z m
z m
z m
b x m z m a y m
b x m z m a y m
b n x m z m a n y m
b n x
n
n
n
( )
( )
( )
( )
( ) ( ) ( ) ( ) ( )
( ) ( ) ( ) ( ) ( )
( ) ( ) ( ) ( ) ( )
( )
1
2
1
1
2
1
1 1 1
2 1 2
1 1 1
M M M

+
+
+
(( ) ( ) ( ) m a n y m

Y z
b b z b nb z
a a z a na z
X z
nb
na
( )
( ) ( ) ( )
( ) ( ) ( )
( )
+ + + +
+ + + +


1 2 1
1 2 1
1
1
L
L
filter2
6-126
fi l ter2
Purpose Two-di mensi onal di gi tal fi l teri ng.
Syntax Y = f i l t er 2( B, X)
Y = f i l t er 2( B, X, ' shape' )
Description Y = f i l t er 2( B, X) fi l ters the two-di mensi onal data i n X wi th the two-di men-
si onal FI R fi l ter i n the matri x B. The resul t, Y, i s computed usi ng two-di men-
si onal convol uti on and i s the same si ze as X.
Y = f i l t er 2( B, X, ' shape' ) returns Y computed wi th si ze speci fi ed by shape:
s ame returns the central part of the convol uti on that i s the same si ze as X
(defaul t).
f ul l returns the ful l two-di mensi onal convol uti on, s i z e( Y) > s i z e( X) .
v al i d returns onl y those parts of the convol uti on that are computed wi thout
the zero-padded edges, s i z e( Y) < s i z e( X) .
Algorithm f i l t er 2 i s part of the MATLAB envi ronment. I t uses conv 2 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, f i l t er 2 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 conv 2 Two-di mensi onal convol uti on.
f i l t er Fi l ter data wi th a recursi ve (I I R) or nonrecursi ve
(FI R) l ter.
filtfilt
6-127
fi l tfi l t
Purpose Zero-phase di gi tal fi l teri ng.
Syntax y = f i l t f i l t ( b, a, x )
Description y = f i l t f i l t ( 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. f i l t f i l t mi ni mi zes startup and endi ng
transi ents by matchi ng i ni ti al condi ti ons.
f i l t f i l t works for both real and compl ex i nputs.
Algorithm f i l t f i l t i s an M-fi l e that uses the f i l t er 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-Time Signal Processing.
Engl ewood Cl i ffs, NJ: Prenti ce Hal l , 1989. Pgs. 311-312.
f f t f i l t FFT-based FI R l teri ng usi ng the overl ap-add
method.
f i l t er Fi l ter data wi th a recursi ve (I I R) or nonrecursi ve
(FI R) l ter.
f i l t er 2 Two-di mensi onal di gi tal l teri ng.
filtic
6-128
fi l ti c
Purpose Make i ni ti al condi ti ons for f i l t er functi on.
Syntax z = f i l t i c( b, a, y , x )
z = f i l t i c( b, a, y )
Description z = f i l t i c( b, a, y , x ) fi nds the i ni ti al condi ti ons z for the del ays i n the trans-
posed direct form I 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 l engt h( b) 1 (the numerator order) and na i s l engt h( a) 1 (the
denomi nator order). I f l engt h( x ) i s l ess than nb, f i l t i c pads i t wi th zeros to
l ength nb; i f l engt h( y ) i s l ess than na, f i l t i c 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 unneces-
sary so f i l t i c 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 = f i l t i c( 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.
f i l t i c works for both real and compl ex i nputs.

x x x x x nb
y y y y y na

{ }

{ }
( ), ( ), ( ), , ( ),
( ), ( ), ( ), , ( ),
1 2 3
1 2 3
K K
K K
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-129
Algorithm f i l t i c 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 argu-
ment i s a scal ar or array), f i l t i c gi ves the fol l owi ng error message:
Requi r es v ect or i nput s .
See Also
References [1] Oppenhei m, A.V., and R.W. Schafer. Discrete-Time Signal Processing.
Engl ewood Cl i ffs, NJ: Prenti ce Hal l , 1989. Pgs. 296, 301-302.
f i l t er Fi l ter data wi th a recursi ve (I I R) or nonrecursi ve
(FI R) l ter.
f i l t f i l t Zero-phase di gi tal l teri ng.
fir1
6-130
fi r1
Purpose Wi ndow-based fi ni te i mpul se response fi l ter desi gnstandard response.
Syntax b = f i r 1( n, Wn)
b = f i r 1( n, Wn, ' f t ype' )
b = f i r 1( n, Wn, wi ndow)
b = f i r 1( n, Wn, ' f t ype' , wi ndow)
b = f i r 1( . . . , ' nos cal e' )
Description f i r 1 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 f i r 2.)
b = f i r 1( 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] , f i r 1 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] , f i r 1 returns
an order n mul ti band fi l ter wi th bands 0 < w < w1, w1 < w < w2, ..., wn < w < 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 = f i r 1( n, Wn, ' f t ype' ) speci fi es a fi l ter type, where f t ype i s
hi gh for a hi ghpass fi l ter wi th cutoff frequency Wn
s t op 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 b z b n z
n
( ) ( ) ( ) ( ) + + + +

1 2 1
1
L

fir1
6-131
f i r 1 al ways uses an even fi l ter order for the hi ghpass and bandstop confi gura-
ti 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, f i r 1 i ncrements i t by 1.
b = f i r 1( n, Wn, wi ndow) uses the wi ndow speci fi ed i n col umn vector wi ndow
for the desi gn. The vector wi ndow must be n+1 el ements l ong. I f no wi ndow i s
speci fi ed, f i r 1 empl oys a Hammi ng wi ndow.
b = f i r 1( n, Wn, ' f t ype' , wi ndow) accepts both f t ype and wi ndow parameters.
b = f i r 1( . . . , ' nos cal e' ) turns off the defaul t scal i ng.
The group del ay of the FI R fi l ter desi gned by f i r 1 i s n/2.
Algorithm f i r 1 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
Examples Desi gn a 24th-order FI R bandpass fi l ter wi th passband 0.35 w 0.65:
b = f i r 1( 48, [ 0. 35 0. 65] ) ;
f r eqz ( b, 1, 512)
b n w n h n n N ( ) ( ) ( ), 1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-2500
-2000
-1500
-1000
-500
0
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
-100
-50
0
50
Normalized frequency (Nyquist == 1)
M
a
g
n
i
t
u
d
e

R
e
s
p
o
n
s
e

(
d
B
)
fir1
6-132
Desi gn a 34th order FI R hi ghpass fi l ter wi th a cutoff frequency of 0.48, usi ng a
Chebyshev wi ndow wi th 30 dB of ri ppl e:
b = f i r 1( 34, 0. 48, ' hi gh' , chebwi n( 35, 30) ) ;
x f i l t = f i l t er ( b, 1, x ) ;
Diagnostics I f n i s odd and you speci fy a bandstop or hi ghpass fi l ter, f i r 1 gi ves the
fol l owi ng warni ng message:
For hi ghpas s and bands t op f i l t er s , N mus t be ev en.
Or der i s bei ng i ncr eas ed by 1.
See Also
References [1] I EEE. Programs for Digital Signal Processing. I EEE Press. New York: John
Wi l ey & Sons, 1979. Al gori thm 5.2.
f i l t er Fi l ter data wi th a recursi ve (I I R) or nonrecursi ve
(FI R) l ter.
f i r 2 Wi ndow-based ni te i mpul se response l ter
desi gnarbi trary response.
f i r cl s Constrai ned l east square FI R l ter desi gn for
mul ti band l ters.
f i r cl s 1 Constrai ned l east square l ter desi gn for l owpass
and hi ghpass l i near phase FI R l ters.
f i r l s Least square l i near-phase FI R l ter desi gn.
f r eqz Frequency response of di gi tal l ters.
kai s er or d Esti mate parameters for f i r 1 wi th Kai ser wi ndow.
r emez Parks-McCl el l an opti mal FI R l ter desi gn.
fir2
6-133
fi r2
Purpose Wi ndow-based fi ni te i mpul se response fi l ter desi gnarbi trary response.
Syntax b = f i r 2( n, f , m)
b = f i r 2( n, f , m, wi ndow)
b = f i r 2( n, f , m, npt )
b = f i r 2( n, f , m, npt , wi ndow)
b = f i r 2( n, f , m, npt , l ap)
b = f i r 2( n, f , m, npt , l ap, wi ndow)
Description f i r 2 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 gura-
ti ons, use f i r 1.)
b = f i r 2( 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 pl ot ( 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 = f i r 2( n, f , m, wi ndow) uses the wi ndow speci fi ed i n col umn vector wi ndow
for the fi l ter desi gn. The vector wi ndow must be n+1 el ements l ong. I f no wi ndow
i s speci fi ed, f i r 2 empl oys a Hammi ng wi ndow.

b z b b z b n z
n
( ) ( ) ( ) ( ) + + + +

1 2 1
1
L
fir2
6-134
b = f i r 2( n, f , m, npt ) and
b = f i r 2( n, f , m, npt , wi ndow) speci fy the number of poi nts npt for the gri d
onto whi ch f i r 2 i nterpol ates the frequency response, wi th or wi thout a wi ndow
speci fi cati on.
b = f i r 2( n, f , m, npt , l ap) and
b = f i r 2( n, f , m, npt , l ap, wi ndow) speci fy the si ze of the regi on, l ap, that
f i r 2 i nserts around dupl i cate frequency poi nts, wi th or wi thout a wi ndow
speci fi cati on.
See the Al gori thm secti on for more on npt and l ap.
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 l ap 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, l ap 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-135
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 = f i r 2( 30, f , m) ;
[ h, w] = f r eqz ( b, 1, 128) ;
pl ot ( f , m, w/pi , abs ( h) )
See Also but t er Butterworth anal og and di gi tal l ter desi gn.
cheby 1 Chebyshev type I l ter desi gn (passband ri ppl e).
cheby 2 Chebyshev type I I l ter desi gn (stopband ri ppl e).
el l i p El l i pti c (Cauer) l ter desi gn.
f i r 1 Wi ndow-based ni te i mpul se response l ter desi gn
standard response.
max f l at General i zed di gi tal Butterworth l ter desi gn.
r emez Parks-McCl el l an opti mal FI R l ter desi gn.
y ul ewal k Recursi ve di gi tal 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
0.2
0.4
0.6
0.8
1
1.2
fircls
6-136
fi rcl s
Purpose Constrai ned l east square FI R fi l ter desi gn for mul ti band fi l ters.
Syntax b = f i r cl s ( n, f , amp, up, l o)
f i r cl s ( n, f , amp, up, l o, ' desi gn_f l ag' )
Description b = f i r cl s ( n, f , amp, up, l o) 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 corre-
sponds 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 l engt h( f ) 1.
up and l o 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.
f i r cl s ( n, f , amp, up, l o, ' desi gn_f l ag' ) enabl es you to moni tor the fi l ter
desi gn, where desi gn_f l ag can be
t r ace, for a textual di spl ay of the desi gn tabl e used i n the desi gn
pl ot s , for pl ots of the fi l ters magni tude, group del ay, and zeros and pol es
bot h, for both the textual di spl ay and pl ots
fircls
6-137
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] ;
l o = [ 0. 02 0. 98 0. 01] ;
b = f i r cl s ( n, f , amp, up, l o, ' pl ot s ' ) %pl ot s magni t ude r es pons e
NOTE Normal l y, the l ower val ue i n the stopband wi l l be speci ed as negati ve.
By setti ng l o equal to 0 i n the stopbands, a nonnegati ve frequency response
ampl i tude can be obtai ned. Such l ters can be spectral l y factored to obtai n
mi ni mum phase 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-138
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).
f i r cl s 1 Constrai ned l east square l ter desi gn for l owpass
and hi ghpass l i near phase FI R l ters.
f i r l s Least square l i near-phase FI R l ter desi gn.
r emez Parks-McCl el l an opti mal FI R l ter desi gn.
fircls1
6-139
fi rcl 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 = f i r cl s 1( n, wo, dp, ds )
b = f i r cl s 1( n, wo, dp, ds , ' hi gh' )
b = f i r cl s 1( n, wo, dp, ds , wt )
b = f i r cl s 1( n, wo, dp, ds , wt , ' hi gh' )
b = f i r cl s 1( n, wo, dp, ds , wp, ws , k)
b = f i r cl s 1( n, wo, dp, ds , wp, ws , k, ' hi gh' )
b = f i r cl s 1( n, wo, dp, ds , , ' desi gn_f l ag' )
Description b = f i r cl s 1( 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 = f i r cl s 1( n, wo, dp, ds , ' hi gh' ) generates a hi ghpass FI R fi l ter b.
b = f i r cl s 1( n, wo, dp, ds , wt ) and
b = f i r cl s 1( n, wo, dp, ds , wt , ' hi gh' ) 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 stop-
band 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-140
b = f i r cl s 1( 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 = f i r cl s 1( n, wo, dp, ds , wp, ws , k, ' hi gh' ) generates a hi ghpass FI R fi l ter b
wi th a wei ghted functi on, where ws < wo < wp.
b = f i r cl s 1( n, wo, dp, ds , , ' desi gn_f l ag' ) enabl es you to moni tor the
fi l ter desi gn, where desi gn_f l ag can be
t r ace, for a textual di spl ay of the desi gn tabl e used i n the desi gn
pl ot s , for pl ots of the fi l ters magni tude, group del ay, and zeros and pol es
bot h, for both the textual di spl ay and pl ots
NOTE I n the desi gn of very narrow band l ters wi th smal l dp and ds , there
may not exi st a l ter of the gi ven l ength that meets the speci cati ons.
A ( ) D ( )
2
d
0
w
p

A ( ) D ( )
2
d
w
s

------------------------------------------------------------- k =
fircls1
6-141
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 = f i r cl s 1( n, wo, dp, ds , ' pl ot s ' ) ; %pl ot magni t ude r es pons e
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).
f i r cl s Constrai ned l east square FI R l ter desi gn for
mul ti band l ters.
f i r l s Least square l i near-phase FI R l ter desi gn.
r emez Parks-McCl el l an opti mal FI R l ter desi gn.
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
firls
6-142
fi rl s
Purpose Least square l i near-phase FI R fi l ter desi gn.
Syntax b = f i r l s ( n, f , a)
b = f i r l s ( n, f , a, w)
b = f i r l s ( n, f , a, ' f t ype' )
b = f i r l s ( n, f , a, w, ' f t ype' )
Description f i r l s desi gns a l i near-phase FI R fi l ter that mi ni mi zes the wei ghted, i nte-
grated 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 = f i r l s ( 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 f i r 1 and f i r 2 functi ons wi th a rectangul ar or
box car 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 k k n ( ) ( ), , , + + 2 1 1 K
firls
6-143
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 = f i r l s ( 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 = f i r l s ( n, f , a, ' f t ype' ) and
b = f i r l s ( n, f , a, w, ' f t ype' ) speci fy a fi l ter type, where f t ype i s
hi l ber t 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 am-
pl i tude of 1 across the enti re band.
di f f er ent i at or 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 fre-
quenci 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 de-
si 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-144
Examples Desi gn an order 255 l owpass fi l ter wi th transi ti on band:
b = f i r l s ( 255, [ 0 0. 25 0. 3 1] , [ 1 1 0 0] ) ;
Desi gn a 31 coeffi ci ent di fferenti ator:
b = f i r l s ( 30, [ 0 0. 9] , [ 0 0. 9] , ' di f f er ent i at or ' ) ;
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 = f i r l s ( 24, F, A, ' hi l ber t ' ) ;
f or i =1: 2: 6,
pl ot ( [ F( i ) F( i +1) ] , [ A( i ) A( i +1) ] , ' ' ) , hol d on
end
[ H, f ] = f r eqz ( b, 1, 512, 2) ;
pl ot ( f , abs ( H) ) , gr i d on, hol d of f
Algorithm Reference [1] descri bes the theoreti cal approach that f i r l s 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-145
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 ' hi l ber t ' and
' di f f er ent i at or ' 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 mus t be ev en l engt h.
F and A mus t be equal l engt hs .
Requi r es s y mmet r y t o be ' hi l ber t ' or ' di f f er ent i at or ' .
Requi r es one wei ght per band.
Fr equenci es i n F mus t be nondecr eas i ng.
Fr equenci es i n F mus t be i n r ange [ 0, 1] .
A more seri ous warni ng message i s
War ni ng: Mat r i x i s cl os e t o s i ngul ar or badl y s cal ed.
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 Coefcients
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 k k n ( ) ( ), , , + + 2 1 1 K

b k b n k k n ( ) ( ), , , + + 2 1 1 K
firls
6-146
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-Time Signal Processing.
Engl ewood Cl i ffs, NJ: Prenti ce Hal l , 1989. Pgs. 256-266.
f i r 1 Wi ndow-based ni te i mpul se response l ter desi gn
standard response.
f i r 2 Wi ndow-based ni te i mpul se response l ter desi gn
arbi trary response.
f i r r cos Rai sed cosi ne FI R l ter desi gn.
r emez Parks-McCl el l an opti mal FI R l ter desi gn.
firrcos
6-147
fi rrcos
Purpose Rai sed cosi ne FI R fi l ter desi gn.
b = f i r r cos ( n, F0, df , Fs )
b = f i r r cos ( n, F0, df )
Description f i r r cos ( 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
wi dth df , and sampl i ng frequency Fs , al l i n Hertz. F0 must be between 0 and
Fs/ 2. df must be smal l enough so that F0 df /2 i s between 0 and Fs/2. The
fi l ter order n must be even.
f i r r cos ( n, F0, df ) uses a defaul t sampl i ng frequency of Fs = 2.
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 wi dth of 0.25:
h = f i r r cos ( 20, 0. 25, 0. 25) ;
H = f f t ( h, 1024) ;
pl ot ( ( 0: 1023) /1024*2, abs ( H) ) , ax i s ( [ 0 1 0 1. 2] ) , gr i d
Remarks f i r r cos mi ni mi zes the i ntegral squared error i n the frequency domai n.
See Also f i r l s Least square l i near-phase FI R l ter desi gn.
r emez Parks-McCl el l an opti mal FI R l ter desi gn.
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
Frequency (Normalized)
M
a
g
n
i
t
u
d
e
freqs
6-148
freqs
Purpose Frequency response of anal og fi l ters.
Syntax h = f r eqs ( b, a, w)
[ h, w] = f r eqs ( b, a)
[ h, w] = f r eqs ( b, a, n)
f r eqs ( b, a)
Description f r eqs 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 = f r eqs ( 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. f r eqs 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] = f r eqs ( 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] = f r eqs ( b, a, n) pi cks n frequenci es on whi ch to compute the frequency
response h.
f r eqs wi th no output arguments pl ots the magni tude and phase response
versus frequency i n the current fi gure wi ndow.
f r eqs works onl y for real i nput systems and posi ti ve frequenci es.
Example Fi nd and graph the frequency response of the transfer functi on gi ven by

H s
B s
A s
b s b s b nb
a s a s a na
nb nb
na na
( )
( )
( )
( ) ( ) ( )
( ) ( ) ( )
( )
( )

+ + + +
+ + + +

1 2 1
1 2 1
1
1
L
L
H s
s s
s s
( )
. .
.

+ +
+ +
0 2 0 3 1
0 4 1
2
2
freqs
6-149
a = [ 1 0. 4 1] ;
b = [ 0. 2 0. 3 1] ;
w = l ogs pace( 1, 1) ;
f r eqs ( b, a, w)
You can al so create the pl ot wi th
h = f r eqs ( b, a, w) ;
mag = abs ( h) ;
phas e = angl e( h) ;
s ubpl ot ( 2, 1, 1) , l ogl og( w, mag)
s ubpl ot ( 2, 1, 2) , s emi l ogx ( w, phas e)
To convert to Hertz, degrees, and deci bel s, use
f = w/( 2*pi ) ;
mag = 20*l og10( mag) ;
phas e = phas e*180/pi ;
Algorithm f r eqs 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 = pol y v al ( b, s ) . /pol y v al ( a, s ) ;
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-150
See Also abs Absol ute val ue (magni tude).
angl e Phase angl e.
f r eqz Frequency response of di gi tal l ters.
i nv f r eqs Conti nuous-ti me (anal og) l ter i denti cati on from
frequency data.
l ogs pace Generate l ogari thmi cal l y spaced vectors (see
MATLAB Functi on Reference).
pol y v al Pol ynomi al eval uati on (see MATLAB Functi on
Reference).
freqspace
6-151
freqspace
Purpose Frequency spaci ng for frequency response.
Syntax f = f r eqs pace( n)
f = f r eqs pace( n, ' whol e' )
[ f 1, f 2] = f r eqs pace( n)
[ f 1, f 2] = f r eqs pace( [ m n] )
[ x 1, y 1] = f r eqs pace( n, ' mes hgr i d' )
[ x 1, y 1] = f r eqs pace( [ m n] , ' mes hgr i d' )
Description f r eqs pace 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 f r eqz .
f = f r eqs pace( 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,
f r eqs pace returns ( n + 2) /2 poi nts. For N odd, i t returns ( n + 1) /2 poi nts.
f = f r eqs pace( n, ' whol e' ) 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.
[ f 1, f 2] = f r eqs pace( n) returns the two-di mensi onal frequency vectors f 1 and
f 2 for an n-by-n matri x. For n odd, both f 1 and f 2 are [ 1 + 1/n: 2/n: 11/n] . For
n even, both f 1 and f 2 are [ 1: 2/n: 12/n] .
[ f 1, f 2] = f r eqs pace( [ m n] ) returns the two-di mensi onal frequency vectors
f 1 and f 2 for an m-by-n matri x.
[ x 1, y 1] = f r eqs pace( n, ' mes hgr i d' ) and
[ x 1, y 1] = f r eqs pace( [ m n] , ' mes hgr i d' ) are equi val ent to
[ f 1, f 2] = f r eqs pace( . . . ) ;
[ x 1, y 1] = mes hgr i d( f 1, f 2) ;
See the MATLAB Functi on Reference for detai l s on the mes hgr i d functi on.
See Also f r eqz Frequency response of di gi tal l ters.
i nv f r eqz Di screte-ti me l ter i denti cati on from frequency
data.
freqz
6-152
freqz
Purpose Frequency response of di gi tal fi l ters.
Syntax [ h, w] = f r eqz ( b, a, n)
[ h, f ] = f r eqz ( b, a, n, Fs )
[ h, w] = f r eqz ( b, a, n, ' whol e' )
[ h, f ] = f r eqz ( b, a, n, ' whol e' , Fs )
h = f r eqz ( b, a, w)
h = f r eqz ( b, a, f , Fs )
f r eqz ( b, a)
Description f r eqz returns the compl ex frequency response H(e
jw
) of a di gi tal fi l ter, gi ven
the numerator and denomi nator coeffi ci ents i n vectors b and a.
[ h, w] = f r eqz ( b, a, n) returns the n-poi nt compl ex frequency response of the
di gi tal fi l ter
gi ven the coeffi ci ent vectors b and a. f r eqz returns both h, the compl ex
frequency response, and w, a vector contai ni ng the n frequency poi nts. f r eqz
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 FFT al gori thm. I f you do
not speci fy a val ue for n, i t defaul ts to 512.
[ h, f ] = f r eqz ( b, a, n, Fs ) speci fi es a posi ti ve sampl i ng frequency Fs , i n
Hertz. I t returns a vector f contai ni ng the actual frequency poi nts between 0
and Fs /2 at whi ch i t cal cul ated the frequency response. f i s of l ength n.
[ h, w] = f r eqz ( b, a, n, ' whol e' ) and
[ h, f ] = f r eqz ( b, a, n, ' whol e' , Fs ) use n poi nts around the whol e uni t ci rcl e
(from 0 to 2 , or from 0 to Fs ).
h = f r eqz ( b, a, w) returns the frequency response at the frequenci es i n vector
w. These frequenci es must be between 0 and 2.

H z
B z
A z
b b z b nb z
a a z a na z
nb
na
( )
( )
( )
( ) ( ) ( )
( ) ( ) ( )

+ + + +
+ + + +


1 2 1
1 2 1
1
1
L
L

freqz
6-153
h = f r eqz ( b, a, f , Fs ) returns the frequency response at the frequenci es i n
vector f , where the el ements of f are between 0 and Fs .
f r eqz wi th no output arguments pl ots the magni tude and phase response
versus frequency i n the current fi gure wi ndow.
f r eqz works for both real and compl ex i nput systems.
Example Pl ot the magni tude and phase response of a Butterworth fi l ter:
[ b, a] = but t er ( 5, 0. 2) ;
f r eqz ( b, a, 128)
Algorithm f r eqz 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 = f f t ( b, n) . /f f t ( 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.
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-500
-400
-300
-200
-100
0
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
-250
-200
-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
)
freqz
6-154
When a frequency vector w or f i s present, or i f n i s l ess than
max ( l engt h( b) , l engt h( a) ) , f r eqz 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.
See Also abs Absol ute val ue (magni tude).
angl e Phase angl e.
f f t One-di mensi onal fast Fouri er transform.
f i l t er Fi l ter data wi th a recursi ve (I I R) or nonrecursi ve
(FI R) l ter.
f r eqs Frequency response of anal og l ters.
i mpz I mpul se response of di gi tal l ters.
i nv f r eqz Di screte-ti me l ter i denti cati on from frequency
data.
l ogs pace Generate l ogari thmi cal l y spaced vectors (see
MATLAB Functi on Reference).
gauspuls
6-155
gauspul s
Purpose Gaussi an-modul ated si nusoi dal pul se generator.
Syntax y i = gaus pul s ( t , f c, bw)
y i = gaus pul s ( t , f c, bw, bwr )
[ y i , y q] = gaus pul s ( )
[ y i , y q, y e] = gaus pul s ( )
t c = gaus pul s ( ' cut of f ' , f c, bw, bwr , t pe)
Description gaus pul s generates Gaussi an-modul ated si nusoi dal pul ses.
y i = gaus pul s ( t , f c, 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 f c i n Hertz and a frac-
ti onal bandwi dth bw, whi ch must be greater than 0. The defaul t val ue for f c i s
1000 Hz and for bw i s 0.5.
y i = gaus pul s ( t , f c, bw, bwr ) returns a uni ty-ampl i tude Gaussi an RF pul se
wi th a bandwi dth of 100*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.
[ y i , y q] = gaus pul s ( ) returns both the i n-phase and quadrature pul ses.
[ y i , y q, y e] = gaus pul s ( ) returns the RF si gnal envel ope.
t c = gaus pul s ( ' cut of f ' , f c, bw, bwr , t pe) returns the cutoff ti me t c
(greater than or equal to 0) at whi ch the trai l i ng pul se envel ope fal l s bel ow
t pe dB wi th respect to the peak envel ope ampl i tude. The trai l i ng pul se enve-
l ope l evel t pe 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 t pe 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-156
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:
t c = gaus pul s ( ' cut of f ' , 50e3, 0. 6, [ ] , 40) ;
t = t c : 1e6 : t c;
y i = gaus pul s ( t , 50e3, 0. 6) ;
pl ot ( t , y i )
See Also chi r p Swept-frequency cosi ne generator.
cos Cosi ne of vector/matri x el ements (see MATLAB
Functi on Reference).
di r i c Di ri chl et or peri odi c si nc functi on.
pul s t r an Pul se trai n generator.
r ect pul s Sampl ed aperi odi c rectangl e generator.
s awt oot h Sawtooth or tri angl e wave generator.
s i n Si ne of vector/matri x el ements (see MATLAB
Functi on Reference).
s i nc Si nc or si n(t)/t functi on.
s quar e Square wave generator.
t r i pul s Sampl ed aperi odi c tri angl e generator.
-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
grpdelay
6-157
grpdel ay
Purpose Average fi l ter del ay (group del ay).
Syntax [ gd, w] = gr pdel ay ( b, a, n)
[ gd, f ] = gr pdel ay ( b, a, n, Fs )
[ gd, w] = gr pdel ay ( b, a, n, ' whol e' )
[ gd, f ] = gr pdel ay ( b, a, n, ' whol e' , Fs )
gd = gr pdel ay ( b, a, w)
gd = gr pdel ay ( b, a, f , Fs )
gr pdel ay ( 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
jw
), then the
group del ay i s
where i s frequency and i s the phase angl e of H(e
jw
).
[ gd, w] = gr pdel ay ( 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. gr pdel ay
returns both gd, the group del ay, and w, a vector contai ni ng the n frequency
poi nts i n radi ans. gr pdel ay 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 ] = gr pdel ay ( 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 b z b nb z
a a z a na z
nb
na
( )
( )
( )
( ) ( ) ( )
( ) ( ) ( )

+ + + +
+ + + +


1 2 1
1 2 1
1
1
L
L
grpdelay
6-158
[ gd, w] = gr pdel ay ( b, a, n, ' whol e' ) and
[ gd, f ] = gr pdel ay ( b, a, n, ' whol e' , Fs ) use n poi nts around the whol e uni t
ci rcl e (from 0 to 2, or from 0 to Fs ).
gd = gr pdel ay ( b, a, w) and
gd = gr pdel ay ( 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.
gr pdel ay wi th no output arguments pl ots the group del ay versus frequency i n
the current fi gure wi ndow.
gr pdel ay 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] = but t er ( 6, 0. 2) ;
gr pdel ay ( 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-159
Pl ot both the group and phase del ays of a system on the same graph:
gd = gr pdel ay ( b, a, 512) ;
gd( 1) = [ ] ; % av oi d NaNs
[ h, w] = f r eqz ( b, a, 512) ; h( 1) = [ ] ; w( 1) = [ ] ;
pd = unwr ap( angl e( h) ) . /w;
pl ot ( w, gd, w, pd, ' : ' )
Algorithm gr pdel ay mul ti pl i es the fi l ter coeffi ci ents by a uni t ramp. After Fouri er trans-
formati on, thi s process corresponds to di fferenti ati on.
See Also cceps Compl ex cepstral anal ysi s.
f f t One-di mensi onal fast Fouri er transform.
f r eqz Frequency response of di gi tal l ters.
hi l ber t Hi l bert transform.
i cceps I nverse compl ex cepstrum.
r ceps Real cepstrum and mi ni mum phase reconstructi on.
0 0.5 1 1.5 2 2.5 3 3.5
0
5
10
15
20
25
30
35
40
45
Frequency (rad/sec)
Group Delay
Phase Delay
hamming
6-160
hammi ng
Purpose Hammi ng wi ndow.
Syntax w = hammi ng( n)
Description w = hammi ng( n) returns an n-poi nt Hammi ng wi ndow i n the col umn vector w.
The coeffi ci ents of a Hammi ng wi ndow are
See Also bar t l et t Bartl ett wi ndow.
bl ackman Bl ackman wi ndow.
box car Rectangul ar wi ndow.
chebwi n Chebyshev wi ndow.
hanni ng Hanni ng wi ndow.
kai s er Kai ser wi ndow.
t r i ang Tri angul ar wi ndow.

w k
k
n
k n [ ] . . cos , , , +

_
,

1 0 54 0 46 2
1
0 1 K
hanning
6-161
hanni ng
Purpose Hanni ng wi ndow.
Syntax w = hanni ng( n)
Description w = hanni ng( n) returns an n-poi nt Hanni ng wi ndow i n the col umn vector w.
The coeffi ci ents of a Hanni ng wi ndow are
See Also bar t l et t Bartl ett wi ndow.
bl ackman Bl ackman wi ndow.
box car Rectangul ar wi ndow.
chebwi n Chebyshev wi ndow.
hammi ng Hammi ng wi ndow.
kai s er Kai ser wi ndow.
t r i ang Tri angul ar wi ndow.

w k
k
n
k n [ ] . cos , , ,
+

_
,

_
,

0 5 1 2
1
1 K
hilbert
6-162
hi l bert
Purpose Hi l bert transform.
Syntax y = hi l ber t ( x )
Description y = hi l ber t ( x ) returns a compl ex hel i cal sequence, someti mes cal l ed the
analytic signal, 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
90phase 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 = hi l ber t ( 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 recon-
structi 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 r ceps performs thi s reconstruc-
ti 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 , hi l ber t cal cu-
l ates the FFT of the i nput sequence, repl aces those FFT coeffi ci ents that corre-
spond to negati ve frequenci es wi th zeros, and cal cul ates the i nverse FFT of the
resul t.
hilbert
6-163
I n detai l , hi l ber t uses a four-step al gori thm:
1 I t cal cul ates the FFT of 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 com-
putati 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 FFT of 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, hi l ber t 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.
f f t One-di mensi onal fast Fouri er transform.
i f f t One-di mensi onal i nverse fast Fouri er transform.
r ceps Real cepstrum and mi ni mum phase reconstructi on.
icceps
6-164
i cceps
Purpose I nverse compl ex cepstrum.
Syntax x = i cceps ( x hat , nd)
Description x = i cceps ( x hat , nd) returns the i nverse compl ex cepstrum of the (assumed
real ) sequence x hat , removi ng nd sampl es of del ay. I f x hat was obtai ned wi th
cceps ( x ) , then the amount of del ay that was added to x was the el ement of
r ound( unwr ap( angl e( f f t ( 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.
hi l ber t Hi l bert transform.
r ceps Real cepstrum and mi ni mum phase reconstructi on.
unwr ap Unwrap phase angl es.
idct
6-165
i dct
Purpose I nverse di screte cosi ne transform.
Syntax x = i dct ( y )
x = i dct ( 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 i dct functi on i s the i nverse of the dct
functi on.
x = i dct ( y ) returns the i nverse di screte cosi ne transform of y
where
and N = l engt h( x ) . x i s the same si ze as y . 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.
x = i dct ( y , n) appends zeros or truncates the vector y to l ength n before
transformi ng.
I f y i s a matri x, i dct transforms i ts col umns.
See Also dct Di screte cosi ne transform (DCT).
dct 2 Two-di mensi onal DCT (see I mage Processing Toolbox Users
Manual).
i dct 2 Two-di mensi onal i nverse DCT (see I mage Processing Toolbox
Users Manual).
i f f t One-di mensi onal i nverse fast Fouri er transform.

x n
N
w k y k
N
k n n N
k
N
( ) ( ) ( ) cos ( )( ) , + + + +

1
1
1
2
1 2 1
0
1

= 0, , -1 K
w k
k
k N
( )
,
,

'

1
2
0
1 1 1


ifft
6-166
i fft
Purpose One-di mensi onal i nverse fast Fouri er transform.
Syntax y = i f f t ( x )
y = i f f t ( x , n)
Description i f f t 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 = l engt h( 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 = i f f t ( 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 = i f f t ( x , n) i s the n-poi nt i nverse FFT. I f the l ength of x i s l ess than n, i f f t
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, i f f t
truncates the sequence x . When x i s an array, i f f t adjusts the l ength of the
col umns i n the same manner.
i f f t i s part of the standard MATLAB envi ronment.
Algorithm i f f t i s an M-fi l e. The al gori thm for i f f t i s the same as that for f f t , except for
a si gn change and a scal e factor of n = l engt h( 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 f f t One-di mensi onal fast Fouri er transform.
f f t 2 Two-di mensi onal fast Fouri er transform.
f f t s hi f t Rearrange the outputs of f f t and f f t 2.
i f f t 2 Two-di mensi onal i nverse fast Fouri er transform.
x n N X k W
N
kn
k
N
( ) ( ) ( ) + +

1 1 1
0
1
ifft2
6-167
i fft2
Purpose Two-di mensi onal i nverse fast Fouri er transform.
Syntax Y = i f f t 2( X)
Y = i f f t 2( X, m, n)
Description Y = i f f t 2( 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 = i f f t 2( 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, i f f t 2( f f t 2( X) ) equal s X to wi thi n roundoff error. I f X i s real ,
i f f t 2( f f t 2( X) ) may have smal l i magi nary parts.
i f f t i s part of the standard MATLAB envi ronment.
Algorithm The al gori thm for i f f t 2 i s the same as that for f f t 2, except for a si gn change
and scal e factors of [ m n] = s i z e( 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.
i f f t 2 i s part of the standard MATLAB envi ronment.
See Also f f t One-di mensi onal fast Fouri er transform.
f f t 2 Two-di mensi onal fast Fouri er transform.
f f t n N-di mensi onal fast Fouri er transform (see MATLAB
Functi on Reference).
f f t s hi f t Rearrange the outputs of f f t and f f t 2.
i f f t One-di mensi onal i nverse fast Fouri er transform.
i f f t n N-di mensi onal i nverse fast Fouri er transform (see
MATLAB Functi on Reference).
impinvar
6-168
i 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 ] = i mpi nv ar ( b, a, Fs )
[ bz , az ] = i mpi nv ar ( b, a)
Description [ bz , az ] = i mpi nv ar ( 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 ] = i mpi nv ar ( b, a) uses the defaul t val ue of 1 Hz for Fs .
Example Convert an anal og l owpass fi l ter to a di gi tal fi l ter usi ng i mpi nv ar wi th a
sampl i ng frequency of 10 Hz:
[ b, a] = but t er ( 4, 0. 3, ' s ' ) ;
[ bz , az ] = i mpi nv ar ( b, a, 10) ;
r eal ( bz )
ans =
1. 0e06 *
0 0 0. 1324 0. 5192 0. 1273
r eal ( az )
ans =
1. 0000 3. 9216 5. 7679 3. 7709 0. 9246
Algorithm i mpi nv ar 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 repl aces the pol es p by the pol es ex p( p/Fs ) .
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.
impinvar
6-169
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.
bi l i near Map vari abl es usi ng bi l i near transformati on.
l p2bp Lowpass to bandpass anal og l ter transformati on.
l p2bs Lowpass to bandstop anal og l ter transformati on.
l p2hp Lowpass to hi ghpass anal og l ter transformati on.
l p2l p Lowpass to l owpass anal og l ter transformati on.
impz
6-170
i mpz
Purpose I mpul se response of di gi tal fi l ters.
Syntax [ h, t ] = i mpz ( b, a)
[ h, t ] = i mpz ( b, a, n)
[ h, t ] = i mpz ( b, a, n, Fs )
i mpz ( b, a)
i mpz ( . . . )
Description [ h, t ] = i mpz ( b, a) computes the i mpul se response of the fi l ter wi th numer-
ator coeffi ci ents b and denomi nator coeffi ci ents a. i mpz 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 ] = i mpz ( b, a, n) computes n sampl es of the i mpul se response. I f n i s a
vector of i ntegers, i mpz computes the i mpul se response at those i nteger l oca-
ti ons where 0 i s the starti ng poi nt of the fi l ter.
[ h, t ] = i mpz ( b, a, n, Fs ) computes n sampl es and scal es t so that sampl es
are spaced 1/Fs uni ts apart. Fs i s 1 by defaul t.
[ h, t ] = i mpz ( b, a, [ ] , Fs ) chooses the number of sampl es for you and scal es
t so that sampl es are spaced 1/Fs uni ts apart.
i mpz wi th no output arguments pl ots the i mpul se response i n the current
fi gure wi ndow usi ng s t em( t , h) .
i mpz works for both real and compl ex i nput systems.
impz
6-171
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] = el l i p( 4, 0. 5, 20, 0. 4) ;
i mpz ( b, a, 50)
Algorithm i mpz fi l ters a l ength n i mpul se sequence usi ng
f i l t er ( b, a, [ 1 z er os ( 1, n1) ] )
To compute n i n the auto-l ength case, i mpz ei ther uses n = l engt h( b) for the
FI R case or fi rst fi nds the pol es usi ng p = r oot s ( a) , i f l engt h( 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), i mpz 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-172
l argest (nonuni ty) ampl i tude pol e i s 5*10^5 of i ts ori gi nal ampl i tude, whi ch-
ever i s greater.
i mpz 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 i mpul s e Uni t i mpul se response (see Control Toolbox Users
Guide).
s t em Pl ot di screte sequence data (see MATLAB Functi on
Reference).
interp
6-173
i nterp
Purpose I ncrease sampl i ng rate by an i nteger factor (i nterpol ati on).
Syntax y = i nt er p( x , r )
y = i nt er p( x , r , l , al pha)
[ y , b] = i nt er p( x , r , l , al pha)
Description I nterpol ati on i ncreases the ori gi nal sampl i ng rate for a sequence to a hi gher
rate. i nt er p 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 = i nt er p( x , r ) i ncreases the sampl i ng rate of x by a factor of r . The i nter-
pol ated vector y i s r ti mes l onger than the ori gi nal i nput x .
y = i nt er p( x , r , l , al pha) speci fi es l (fi l ter l ength) and al pha (cut-off
frequency). The defaul t val ue for l i s 4 and the defaul t val ue for al pha i s 0.5.
[ y , b] = i nt er p( x , r , l , al pha) 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; % t i me v ect or
x = s i n( 2*pi *30*t ) + s i n( 2*pi *60*t ) ;
y = i nt er p( x , 4) ;
s t em( x ( 1: 30) )
s t em( y ( 1: 120) ) , ax i s ( [ 0 120 2 2] )
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-174
Algorithm i nt er p 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 al pha 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 al pha i s 0.5.
Diagnostics I f r i s not an i nteger, i nt er p gi ves the fol l owi ng error message:
Res ampl i ng r at e R mus t be an i nt eger .
See Also
References [1] I EEE. Programs for Digital Signal Processing. I EEE Press. New York: John
Wi l ey & Sons, 1979. Al gori thm 8.1.
deci mat e Decrease the sampl i ng rate for a sequence
(deci mati on).
i nt er p1 1-D data i nterpol ati on (tabl e l ookup) (see MATLAB
Functi on Reference).
r es ampl e Change sampl i ng rate by any factor.
s pl i ne Cubi c spl i ne i nterpol ati on (see MATLAB Functi on
Reference).
upf i r dn Appl y FI R l ter and perform sampl e rate conversi on.
intfilt
6-175
i ntfi l t
Purpose I nterpol ati on FI R fi l ter desi gn.
Syntax b = i nt f i l t ( r , l , al pha)
b = i nt f i l t ( r , n, ' Lagr ange' )
Description b = i nt f i l t ( r , l , al pha) 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 r 1 consecuti ve zeros every r sampl es. I t
assumes an ori gi nal bandl i mi tedness of al pha ti mes the Nyqui st frequency.
The returned fi l ter i s i denti cal to that used by i nt er p.
b = i nt f i l t ( r , n, ' Lagr ange' ) or b = i nt f i l t ( 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 r 1 consecuti ve zeros every r sampl es. b has l ength ( n + 1) *r
for n even, and l ength ( n + 1) *r 1 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:
al pha = 0. 5; % "bandl i mi t ednes s " f act or
h1 = i nt f i l t ( 4, 2, al pha) ; % bandl i mi t ed i nt er pol at i on
The fi l ter h1 works best when the ori gi nal si gnal i s bandl i mi ted to al pha ti mes
the Nyqui st frequency. Create a bandl i mi ted noi se si gnal :
r andn( ' s eed' , 0)
x = f i l t er ( f i r 1( 40, 0. 5) , 1, r andn( 200, 1) ) ; % bandl i mi t
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 :
x r = r es hape( [ x z er os ( l engt h( x ) , 3) ] ' , 4*l engt h( x ) , 1) ;
I nterpol ate usi ng the f i l t er command:
y = f i l t er ( h1, 1, x r ) ;
intfilt
6-176
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:
pl ot ( 100: 200, y ( 100: 200) , 7+( 101: 4: 196) , x ( 26: 49) , ' o' )
i nt f i l t s 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 = i nt f i l t ( 4, 1, ' l ' ) % Lagr ange i nt er pol at i on
h2 =
0. 2500 0. 5000 0. 7500 1. 0000 0. 7500 0. 5000 0. 2500
Algorithm The bandl i mi ted method uses f i r l s 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 nter-
pol ators. I EEE Trans. Acoust., Speech, Signal Processing. Vol . ASSP-23 (June
1975). Pgs. 301-309.
deci mat e Decrease the sampl i ng rate for a sequence
(deci mati on).
i nt er p I ncrease sampl i ng rate by an i nteger factor
(i nterpol ati on).
r es ampl e Change sampl i ng rate by any factor.
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
invfreqs
6-177
i nvfreqs
Purpose Conti nuous-ti me (anal og) fi l ter i denti fi cati on from frequency data.
Syntax [ b, a] = i nv f r eqs ( h, w, nb, na)
[ b, a] = i nv f r eqs ( h, w, nb, na, wt )
[ b, a] = i nv f r eqs ( h, w, nb, na, wt , i t er )
[ b, a] = i nv f r eqs ( h, w, nb, na, wt , i t er , t ol )
[ b, a] = i nv f r eqs ( h, w, nb, na, wt , i t er , t ol , ' t r ace' )
Description i nv f r eqs i s the i nverse operati on of f r eqs ; 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, i nv f r eqs i s useful i n converti ng magni tude
and phase data i nto transfer functi ons.
[ b, a] = i nv f r eqs ( 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 numer-
ator and denomi nator pol ynomi al s.
Frequency i s speci fi ed i n radi ans and the l ength of h must be the same as the
l ength of w.
[ b, a] = i nv f r eqs ( 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.
i nv f r eqs ( h, w, nb, na, wt , i t er ) and
i nv f r eqs ( h, w, nb, na, wt , i t er , t ol ) provi de a superi or al gori thm that guar-
antees 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 i t er parameter tel l s i nv f r eqs to end
the i terati on when the sol uti on has converged, or after i t er i terati ons, whi ch-
ever comes fi rst. i nv f r eqs defi nes convergence as occurri ng when the norm of
H s
B s
A s
b s b s b nb
a s a s a na
nb
nb
na
na
( )
( )
( )

( ) + ( ) + + + ( )
( ) + ( ) + + + ( )
( )
( )
1 2 1
1 2 1
1
1
...
...
invfreqs
6-178
the (modi fi ed) gradi ent vector i s l ess than t ol . t ol i s an opti onal parameter
that defaul ts to 0.01. To obtai n a wei ght vector of al l ones, use
i nv f r eqs ( h, w, nb, na, [ ] , i t er , t ol )
i nv f r eqs ( h, w, nb, na, wt , i t er , t ol , ' t r ace' ) di spl ays a textual progress
report of the i terati on.
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] = f r eqs ( b, a, 64) ;
[ bb, aa] = i nv f r eqs ( 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 i n the l eft hal f-pl ane and thus the system i s unstabl e. Use i nv f r eqs s
i terati ve al gori thm to fi nd a stabl e approxi mati on to the system:
[ bbb, aaa] = i nv f r eqs ( h, w, 4, 5, [ ] , 30)
bbb =
0. 6602 2. 0058 2. 3589 1. 0837 0. 1337
aaa =
1. 0000 3. 2986 7. 0223 5. 7543 2. 9219 0. 0002
invfreqs
6-179
Suppose you have two vectors, mag and phas e, 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 i nv f r eqs :
[ b, a] = i nv f r eqs ( mag. *ex p( j *phas e) , w, 2, 3) ;
Algorithm By defaul t, i nv f r eqs 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 yno-
mi 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 frequenci 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:
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 Methods for Unconstrained
Optimization and Nonlinear Equations. Engl ewood Cl i ffs, NJ: Prenti ce Hal l ,
1983.
f r eqs Frequency response of anal og l ters.
f r eqz Frequency response of di gi tal l ters.
i nv f r eqz Di screte-ti me l ter i denti cati on from frequency data.
pr ony Pronys method for ti me domai n I I R l ter desi gn.
min ( ) ( ) ( ( )) ( ( ))
, b a
k
n
wt k h k A w k B w k

2
1
min ( ) ( )
( ( ))
( ( ))
, b a
k
n
wt k h k
B w k
A w k

2
1
invfreqz
6-180
i nvfreqz
Purpose Di screte-ti me fi l ter i denti fi cati on from frequency data.
Syntax [ b, a] = i nv f r eqz ( h, w, nb, na)
[ b, a] = i nv f r eqz ( h, w, nb, na, wt )
[ b, a] = i nv f r eqz ( h, w, nb, na, wt , i t er )
[ b, a] = i nv f r eqz ( h, w, nb, na, wt , i t er , t ol )
[ b, a] = i nv f r eqz ( h, w, nb, na, wt , i t er , t ol , ' t r ace' )
Description i nv f r eqz i s the i nverse operati on of f r eqz ; 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, i nv f r eqz can be used to convert magni tude
and phase data i nto transfer functi ons.
[ b, a] = i nv f r eqz ( 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 numer-
ator 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.
[ b, a] = i nv f r eqz ( 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.
i nv f r eqz ( h, w, nb, na, wt , i t er ) and
i nv f r eqz ( h, w, nb, na, wt , i t er , t ol ) provi de a superi or al gori thm that guar-
antees 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 i t er parameter tel l s i nv f r eqz to end
the i terati on when the sol uti on has converged, or after i t er i terati ons, whi ch-
ever comes fi rst. i nv f r eqz defi nes convergence as occuri ng when the norm of
H z
B z
A z
b b z b nb z
a a z a na z
nb
na
( )
( )
( )

( ) + ( ) + + + ( )
( ) + ( ) + + + ( )


1 2 1
1 2 1
1
1
...
...
invfreqz
6-181
the (modi fi ed) gradi ent vector i s l ess than t ol . t ol i s an opti onal parameter
that defaul ts to 0.01. To obtai n a wei ght vector of al l ones, use
i nv f r eqz ( h, w, nb, na, [ ] , i t er , t ol )
i nv f r eqz ( h, w, nb, na, wt , i t er , t ol , ' t r ace' ) di spl ays a textual progress
report of the i terati on.
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] = f r eqz ( b, a, 64) ;
[ bb, aa] = i nv f r eqz ( 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 i nv f r eqz s
i terati ve al gori thm to fi nd a stabl e approxi mati on to the system:
[ bbb, aaa] = i nv f r eqz ( 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, i nv f r eqz 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
min ( ) ( ) ( ( )) ( ( ))
, b a
k
n
wt k h k A w k B w k

2
1
invfreqz
6-182
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 Methods for Unconstrained
Optimization and Nonlinear Equations. Engl ewood Cl i ffs, NJ: Prenti ce Hal l ,
1983.
f r eqs Frequency response of anal og l ters.
f r eqz Frequency response of di gi tal l ters.
i nv f r eqs Conti nuous-ti me (anal og) l ter i denti cati on from
frequency data.
pr ony Pronys method for ti me domai n I I R l ter desi gn.
min ( ) ( )
( ( ))
( ( ))
, b a
k
n
wt k h k
B w k
A w k

2
1
kaiser
6-183
kai ser
Purpose Kai ser wi ndow.
Syntax w = kai s er ( n, bet a)
Description w = kai s er ( n, bet a) returns an n-poi nt Kai ser ( - si nh) wi ndow i n the
col umn vector w. bet a 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 bet a 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 Processing I I . I EEE Press. New York: John Wi l ey &
Sons, 1975.
bar t l et t Bartl ett wi ndow.
bl ackman Bl ackman wi ndow.
box car Rectangul ar wi ndow.
chebwi n Chebyshev wi ndow.
hammi ng Hammi ng wi ndow.
hanni ng Hanni ng wi ndow.
kai s er or d Esti mate parameters for f i r 1 wi th Kai ser wi ndow.
t r i ang Tri angul ar wi ndow.
I
0

>
+
<

'

0 1102 8 7 50
0 5842 21 0 07886 21 50 21
0 21
0 4
. ( . ),
. ( ) . ( ),
,
.
I
0
kaiserord
6-184
kai serord
Purpose Esti mate parameters for f i r 1 wi th Kai ser wi ndow.
Syntax [ n, Wn, bet a, f t y pe] = kai s er or d( f , a, dev )
[ n, Wn, bet a, f t y pe] = kai s er or d( f , a, dev , Fs )
c = kai s er or d( f , a, dev , Fs , ' cel l ' )
Description kai s er or d returns a fi l ter order n and bet a parameter to speci fy a Kai ser
wi ndow for use wi th the f i r 1 functi on. Gi ven a set of speci fi cati ons i n the
frequency domai n, kai s er or d 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. kai s er or d converts the gi ven fi l ter
speci fi cati ons i nto passband and stopband ri ppl es and converts cutoff frequen-
ci 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 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 l ters wi th equal ri ppl e
hei ghts i n al l the passbands and stopbands.
[ n, Wn, bet a, f t y pe] = kai s er or d( 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 ca-
ti 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 ow-
abl 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.
f i r 1 can use the resul ti ng order n, frequency vector Wn, mul ti band magni tude
type f t y pe, and the Kai ser wi ndow parameter bet a. The f t y pe stri ng i s
i ntended for use wi th f i r 1; i t i s equal to 'hi gh' for a hi ghpass fi l ter and 's t op'
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 kai s er
parameters f , a, and dev :
b = f i r 1( n, Wn, kai s er ( n+1, bet a) , f t y pe, ' nos cal e' )
kaiserord
6-185
[ n, Wn, bet a, f t y pe] = kai s er or d( 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 ca-
ti ons sampl i ng frequency.
c = kai s er or d( f , a, dev , Fs , ' cel l ' ) i s a cel l -array whose el ements are the
parameters to f i r 1.
NOTE I n some cases, kai s er or d underesti mates or overesti mates the order n.
I f the l ter does not meet the speci cati ons, try a hi gher order such as n+1,
n+2, and so on, or a l ower order.
NOTE 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 kai s er or d 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.

>
+
<

'

0 1102 8 7 50
0 5842 21 0 07886 21 50 21
0 21
0 4
. ( . ),
. ( ) . ( ),
,
.
n

8
2 285 .
kaiserord
6-186
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:
f s amp = 8000;
f cut s = [ 1000 1500] ;
mags = [ 1 0] ;
dev s = [ 0. 05 0. 01] ;
[ n, Wn, bet a, f t y pe] = kai s er or d( f cut s , mags , dev s , f s amp) ;
hh = f i r 1( n, Wn, f t y pe, kai s er ( n+1, bet a) , ' nos cal e' ) ;
f r eqz ( hh)
0 0.2 0.4 0.6 0.8 1
-1500
-1000
-500
0
Normalized frequency (Nyquist == 1)
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 frequency (Nyquist == 1)
M
a
g
n
i
t
u
d
e

R
e
s
p
o
n
s
e

(
d
B
)
kaiserord
6-187
Desi gn an odd-l ength bandpass fi l ter (note that odd l ength means even order,
so the i nput to f i r 1 must be an even i nteger):
f s amp = 8000;
f cut s = [ 1000 1300 2410] ;
mags = [ 0 1 0] ;
dev s = [ 0. 01 0. 05 0. 01] ;
[ n, Wn, bet a, f t y pe] = kai s er or d( f cut s , mags , dev s , f s amp) ;
n = n + r em( n, 2) ;
hh = f i r 1( n, Wn, f t y pe, kai s er ( n+1, bet a) , ' nos cal e' ) ;
[ H, f ] = f r eqz ( hh, 1, 1024, f s amp) ;
pl ot ( f , abs ( H) ) , gr i d 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, bet a, f t y pe] = kai s er or d( [ 1500 2000] , [ 1 0] , [ 0. 01 0. 1] , 8000) ;
b = f i r 1( n, Wn, f t y pe, kai s er ( n+1, bet a) , ' nos cal e' ) ;
Thi s i s equi val ent to
c = kai s er or d( [ 1500 2000] , [ 1 0] , [ 0. 01 0. 1] , 8000, ' cel l ' ) ;
b = f i r 1( 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-188
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 representa-
ti 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;
otherwi se, kai s er or d gi ves the fol l owi ng error message:
Requi r es M and DEV t o be t he s ame l engt h.
Lengt h of F mus t be 2*l engt h( M) 2.
When magni tudes are not speci fi ed correctl y, kai s er or d gi ves the fol l owi ng
error messages:
St opbands mus t be z er o.
Al l pas s bands mus t hav e t he s ame hei ght .
I f the band edges are not stri ctl y i ncreasi ng, kai s er or d gi ves the fol l owi ng
error message:
Bandedges mus t be s t r i ct l y i ncr eas i ng.
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 Processing I I . I EEE Press. New York: John Wi l ey &
Sons, 1975. Pgs. 123-126.
f i r 1 Wi ndow-based fi ni te i mpul se response fi l ter desi gn
standard response.
kai s er Kai ser wi ndow.
r emez or d Parks-McCl el l an opti mal FI R l ter order esti mati on.
I
0
latc2tf
6-189
l atc2tf
Purpose Latti ce fi l ter to transfer functi on conversi on.
Syntax [ num, den] = l at c2t f ( k, v )
[ num, den] = l at c2t f ( k, ' i i r ' )
num = l at c2t f ( k, ' f i r ' )
num = l at c2t f ( k)
Description [ num, den] = l at c2t f ( 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] = l at c2t f ( k, ' i i r ' ) assumes that k i s associ ated wi th an al l -pol e
I I R l atti ce fi l ter.
num = l at c2t f ( k, ' f i r ' ) and
num = l at c2t f ( 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 l at cf i l t Latti ce and l atti ce-l adder l ter i mpl ementati on.
t f 2l at c Transfer functi on to l atti ce l ter conversi on.
latcfilt
6-190
l atcfi l t
Purpose Latti ce and l atti ce-l adder fi l ter i mpl ementati on.
Syntax [ f , g] = l at cf i l t ( k, x )
[ f , g] = l at cf i l t ( k, v , x )
[ f , g] = l at cf i l t ( k, 1, x )
Description [ f , g] = l at cf i l t ( 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] = l at cf i l t ( 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] = l at cf i l t ( 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.
See Also f i l t er Fi l ter data wi th a recursi ve (I I R) or nonrecursi ve
(FI R) l ter.
l at c2t f Latti ce l ter to transfer functi on conversi on.
t f 2l at c Transfer functi on to l atti ce l ter conversi on.
levinson
6-191
l evi nson
Purpose Levi nson-Durbi n recursi on.
Syntax a = l ev i ns on( r , n)
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 l ev i ns on
produces i s mi ni mum phase.
a = l ev i ns on( r , n) fi nds the coeffi ci ents of an nth-order autoregressi ve l i near
process whi ch has r as i ts autocorrel ati on sequence. r i s a real determi ni sti c
autocorrel ati on sequence (a vector), and n i s the order of denomi nator pol yno-
mi al a(z), that i s, a = [ 1 a( 2) . . . a( n+1) ] . The fi l ter coeffi ci ents are ordered
i n descendi ng powers of z:
Algorithm l ev i ns on sol ves the symmetri c Toepl i tz system of l i near equati ons:
where r = [ R(1) ... R(n+1)] i s the i nput autocorrel ati on vector. The al gori thm
requi res O(n
2
) fl ops and i s thus much more effi ci ent than the MATLAB \
command for l arge n. However, the l ev i ns on functi on uses \ for l ow orders to
gi ve the fastest possi bl e executi on.
See Also
References [1] Ljung, L. System I dentification: Theory for the User. Engl ewood Cl i ffs, NJ:
Prenti ce Hal l , 1987. Pgs. 278-280.
l pc Li near predi cti on coefci ents.
pr ony Pronys method for ti me domai n I I R l ter desi gn.
s t mcb Li near model usi ng Stei gl i tz-McBri de i terati on.

H z
A z
a a z a n z
n
( )
( )
( ) ( ) ( )

+ + + +

1 1
1 2 1
1
L

R R R n
R R R n
R n R n R
a
a
a n
R
R
R n
( ) ( ) ( )
( ) ( ) ( )
( ) ( ) ( )
( )
( )
( )
( )
( )
( )
1 2
2 1 1
1 1
2
3
1
2
3
1
L
L
M M O M
L
M M

1
]
1
1
1
1
1
+

1
]
1
1
1
1
1

1
]]
1
1
1
1
1
lp2bp
6-192
l p2bp
Purpose Lowpass to bandpass anal og fi l ter transformati on.
Syntax [ bt , at ] = l p2bp( b, a, Wo, Bw)
[ At , Bt , Ct , Dt ] = l p2bp( A, B, C, D, Wo, Bw)
Description l p2bp 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
but t er , cheby 1, cheby 2, and el l i p functi ons.
l p2bp can perform the transformati on on two di fferent l i near system represen-
tati 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.
Tra nsfer Function For m (Polynomia l)
[ bt , at ] = l p2bp( 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 = s qr t ( w1*w2) and Bw = w2w1.
l p2bp returns the frequency transformed fi l ter i n row vectors bt and at .
Sta te- Spa ce For m
[ At , Bt , Ct , Dt ] = l p2bp( 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 s b nn s b nn
a s a nd s a nd
nn
nd
( )
( )
( ) ( ) ( )
( ) ( ) ( )

+ + + +
+ + + +
1 1
1 1
L
L
x Ax Bu
y Cx Du
+
+
lp2bp
6-193
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 = s qr t ( w1*w2) and
Bw = w2w1.
The bandpass fi l ter i s returned i n matri ces At , Bt , Ct , Dt .
Algorithm l p2bp 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 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 trans-
formed 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 Ax Bu +
s Q p p + ( )
2
1
Qx Qx Ax Bu + +
Qx Ax Bu Qx
Q Qx


Qx Ax Q Bu + +
lp2bp
6-194
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] = s i z e( A) ;
At = Wo*[ A/Q ey e( ma, na) ; ey e( ma, na) z er os ( ma, na) ] ;
Bt = Wo*[ B/Q; z er os ( ma, nb) ] ;
Ct = [ C z er os ( mc, ma) ] ;
Dt = d;
I f the i nput to l p2bp 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 bi l i near Map vari abl es usi ng bi l i near transformati on.
i mpi nv ar I mpul se i nvari ance method of anal og-to-di gi tal l ter
conversi on.
l p2bs Lowpass to bandstop anal og l ter transformati on.
l p2hp Lowpass to hi ghpass anal og l ter transformati on.
l p2l p Lowpass to l owpass anal og l ter transformati on.
lp2bs
6-195
l p2bs
Purpose Lowpass to bandstop anal og fi l ter transformati on.
Syntax [ bt , at ] = l p2bs ( b, a, Wo, Bw)
[ At , Bt , Ct , Dt ] = l p2bs ( A, B, C, D, Wo, Bw)
Description l p2bs 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
but t er , cheby 1, cheby 2, and el l i p functi ons.
l p2bs can perform the transformati on on two di fferent l i near system represen-
tati 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.
Tra nsfer Function For m (Polynomia l)
[ bt , at ] = l p2bs ( 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 = s qr t ( w1*w2) and Bw = w2w1.
l p2bs returns the frequency transformed fi l ter i n row vectors bt and at .
Sta te- Spa ce For m
[ At , Bt , Ct , Dt ] = l p2bs ( 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 s b nn s b nn
a s a nd s a nd
nn
nd
( )
( )
( ) ( ) ( )
( ) ( ) ( )

+ + + +
+ + + +
1 1
1 1
L
L
x Ax Bu
y Cx Du
+
+
lp2bs
6-196
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 = s qr t ( w1*w2) and
Bw = w2w1.
The bandstop fi l ter i s returned i n matri ces At , Bt , Ct , Dt .
Algorithm l p2bs 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 versi on of thi s transformati on i s
Q = Wo/Bw;
At = [ Wo/Q*i nv ( A) Wo*ey e( ma) ; Wo*ey e( ma) z er os ( ma) ] ;
Bt = [ Wo/Q*( A B) ; z er os ( ma, nb) ] ;
Ct = [ C/A z er os ( mc, ma) ] ;
Dt = D C/A*B;
See l p2bp for a deri vati on of the bandpass versi on of thi s transformati on.
See Also bi l i near Map vari abl es usi ng bi l i near transformati on.
i mpi nv ar I mpul se i nvari ance method of anal og-to-di gi tal l ter
conversi on.
l p2bp Lowpass to bandpass anal og l ter transformati on.
l p2hp Lowpass to hi ghpass anal og l ter transformati on.
l p2l p Lowpass to l owpass anal og l ter transformati on.
s
p
Q p

+ ( )
2
1
lp2hp
6-197
l p2hp
Purpose Lowpass to hi ghpass anal og fi l ter transformati on.
Syntax [ bt , at ] = l p2hp( b, a, Wo)
[ At , Bt , Ct , Dt ] = l p2hp( A, B, C, D, Wo)
Description l p2hp transforms anal og l owpass fi l ter prototypes wi th a cutoff frequency of
1 rad/sec i nto hi ghpass fi l ters wi th desi red cutoff frequency. The transforma-
ti on i s one step i n the di gi tal fi l ter desi gn process for the but t er , cheby 1,
cheby 2, and el l i p functi ons.
The l p2hp 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.
Tra nsfer Function For m (Polynomia l)
[ bt , at ] = l p2hp( 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 .
Sta te- Spa ce For m
[ At , Bt , Ct , Dt ] = l p2hp( 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 s b nn s b nn
a s a nd s a nd
nn
nd
( )
( )
( ) ( ) ( )
( ) ( ) ( )

+ + + +
+ + + +
1 1
1 1
L
L
x Ax Bu
y Cx Du
+
+
lp2hp
6-198
Algorithm l p2hp 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*i nv ( A) ;
Bt = Wo*( A\B) ;
Ct = C/A;
Dt = D C/A*B;
See l p2bp for a deri vati on of the bandpass versi on of thi s transformati on.
See Also bi l i near Map vari abl es usi ng bi l i near transformati on.
i mpi nv ar I mpul se i nvari ance method of anal og-to-di gi tal l ter
conversi on.
l p2bp Lowpass to bandpass anal og l ter transformati on.
l p2bs Lowpass to bandstop anal og l ter transformati on.
l p2l p Lowpass to l owpass anal og l ter transformati on.
s
p
o


lp2lp
6-199
l p2l p
Purpose Lowpass to l owpass anal og fi l ter transformati on.
Syntax [ bt , at ] = l p2l p( b, a, Wo)
[ At , Bt , Ct , Dt ] = l p2l p( A, B, C, D, Wo)
Description l p2l p 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 transfor-
mati on i s one step i n the di gi tal fi l ter desi gn process for the but t er , cheby 1,
cheby 2, and el l i p functi ons.
The l p2l p 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.
Tra nsfer Function For m (Polynomia l)
[ bt , at ] = l p2l p( 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. l p2l p
returns the frequency transformed fi l ter i n row vectors bt and at .
Sta te- Spa ce For m
[ At , Bt , Ct , Dt ] = l p2l p( 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. l p2l p returns the l owpass fi l ter
i n matri ces At , Bt , Ct , Dt .

b s
a s
b s b nn s b nn
a s a nd s a nd
nn
nd
( )
( )
( ) ( ) ( )
( ) ( ) ( )

+ + + +
+ + + +
1 1
1 1
L
L
x Ax Bu
y Cx Du
+
+
lp2lp
6-200
Algorithm l p2l p 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 l p2bp for a deri vati on of the bandpass versi on of thi s transformati on.
See Also bi l i near Map vari abl es usi ng bi l i near transformati on.
i mpi nv ar I mpul se i nvari ance method of anal og-to-di gi tal l ter
conversi on.
l p2bp Lowpass to bandpass anal og l ter transformati on.
l p2bs Lowpass to bandstop anal og l ter transformati on.
l p2hp Lowpass to hi ghpass anal og l ter transformati on.
s p
o
/
lpc
6-201
l pc
Purpose Li near predi cti on coeffi ci ents.
Syntax [ a, g] = l pc( x , n)
Description Li near predi cti on model s each sampl e of a si gnal as a l i near combi nati on of
previ ous sampl es, that i s, as the output of an al l -pol e I I R fi l ter. I t has appl i ca-
ti ons i n fi l ter desi gn, speech codi ng, spectral anal ysi s, and system
i denti fi cati on.
[ a, g] = l pc( x , n) fi nds the coeffi ci ents and gai n of an nth-order auto-regres-
si ve l i near process that model s the ti me seri es x as
x i s the real i nput ti me seri es (a vector), and n i s the order of the denomi nator
pol ynomi al a(z), that i s, a = [ 1 a( 2) . . . a( n+1) ] . The fi l ter coeffi ci ents are
ordered i n descendi ng powers of z.
I f n i s unspeci fi ed, l pc uses as a defaul t n = l engt h( x ) 1.
I f x i s a matri x contai ni ng a separate si gnal i n each col umn, l pc returns a
model esti mate for each col umn i n the rows of a and a row vector of gai ns g.

x k a x k a x k a n x k n ( ) ( ) ( ) ( ) ( ) ( ) ( ) + 2 1 3 2 1 1 L
lpc
6-202
Example Model a nonrecursi ve (FI R) fi l ter wi th an al l -pol e I I R fi l ter usi ng l pc:
x = [ 1: 4 4: 1: 1] ;
[ a, g] = l pc( x , 15) ;
[ H, w] = f r eqz ( x , 1, 512) ; [ H1, w] = f r eqz ( g, a, 512) ;
Pl ot the FI R response wi th a sol i d l i ne and the I I R response wi th a dashed l i ne:
pl ot ( w/pi , abs ( H) , w/pi , abs ( H1) , ' ' )
Algorithm l pc uses the autocorrel ati on method of autoregressi ve (AR) model i ng to fi nd
the fi l ter coeffi ci ents. Thi s techni que i s al so cal l ed the maxi mum entropy
method (MEM) of spectral esti mati on. The fi l ter generated i s stabl e. However,
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 auto-
correl 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.
0 0.2 0.4 0.6 0.8 1
0
2
4
6
8
10
12
14
16
18
20
Comparison of MA and AR Frequency Responses
Normalized Frequency
lpc
6-203
l pc sol ves the fol l owi ng system of equati ons usi ng the equi val ent of
MATLABs \ operator:
I t fi rst forms the determi ni sti c autocorrel ati on of x wi th x cor r ( x ) and then
cal l s l ev i ns on wi th the resul ti ng autocorrel ati on as i nput.
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.
ar Compute autoregressi ve model s of si gnal s (see
System I dentification Toolbox Users Guide).
l ev i ns on Levi nson-Durbi n recursi on.
pmem Power spectrum esti mate usi ng maxi mum entropy
method (MEM).
pr ony Pronys method for ti me domai n I I R l ter desi gn.
s t mcb Li near model usi ng Stei gl i tz-McBri de i terati on.

0 0 0
1 0 0
2 1
0
1 1
0
0 0 1
0 0
2
3
1
L
L
O M
M M O
O
O M
L
L
M
x
x x
x l x l x
x l
x l
x l
a
a
a n
( )
( ) ( )
( ) ( ) ( )
( )
( )
( )
( )
( )
( )

1
]
1
1
1
1
1
1
1
1
1
1
1
+

1
]
1
1
1
1
11

1
]
1
1
1
1
1
1
1
1
1
x
x
x l
( )
( )
( )
1
2
0
0
M
M
maxflat
6-204
maxfl at
Purpose General i zed di gi tal Butterworth fi l ter desi gn.
Syntax [ b, a, ] = max f l at ( nb, na, Wn)
b = max f l at ( nb, ' s y m' , Wn)
[ b, a, b1, b2] = max f l at ( nb, na, Wn)
[ . . . ] = max f l at ( nb, na, Wn, ' desi gn_f l ag' )
Description [ b, a, ] = max f l at ( 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 = max f l at ( nb, ' s y m' , 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] = max f l at ( 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.
[ . . . ] = max f l at ( nb, na, Wn, ' desi gn_f l ag' ) enabl es you to moni tor the
fi l ter desi gn, where desi gn_f l ag i s
t r ace, for a textual di spl ay of the desi gn tabl e used i n the desi gn
pl ot s , for pl ots of the fi l ters magni tude, group del ay, and zeros and pol es
bot h, for both the textual di spl ay and pl ots
1 2 /
maxflat
6-205
Examples nb = 10; na = 2; Wn = 0. 2*pi ;
[ b, a, b1, b2] = max f l at ( nb, na, Wn, ' pl ot s ' )
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. Proceedings of the I EEE I nt. Conf. Acoust., Speech, Signal Processing.
Vol . 3 (May 1996).
but t er Butterworth anal og and di gi tal l ter desi gn.
f i l t er Fi l ter data wi th a recursi ve (I I R) or nonrecursi ve
(FI R) l ter.
f r eqz Frequency response of di gi tal l ters.
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
medfilt1
6-206
medfi l t1
Purpose One-di mensi onal medi an fi l teri ng.
Syntax y = medf i l t 1( x , n)
y = medf i l t 1( x , n, bl ks z )
Description y = medf i l t 1( 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, medf i l t 1 sorts the numbers, then takes the average of the ( n1) /2
and ( ( n1) /2) +1 el ements.
The defaul t for n i s 3.
y = medf i l t 1( x , n, bl ks z ) uses a f or -l oop to compute bl ks z (bl ock si ze)
output sampl es at a ti me. Use bl ks z << l engt h( x ) i f you are l ow on memory,
si nce medf i l t 1 uses a worki ng matri x of si ze n-by-bl ks z . By defaul t,
bl ks z = l engt h( 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, medf i l t 1 medi an fi l ters i ts col umns usi ng
y ( : , i ) = medf i l t 1( x ( : , i ) , n, bl ks z )
i n a l oop over the col umns of x .
See Also
References [1] Pratt,W.K. Digital I mage Processing. New York: John Wi l ey & Sons, 1978.
Pgs. 330-333.
f i l t er Fi l ter data wi th a recursi ve (I I R) or nonrecursi ve
(FI R) l ter.
medf i l t 2 Two-di mensi onal medi an l teri ng (see I mage
Processing Toolbox Users Guide).
medi an Medi an val ue (see MATLAB Functi on Reference).
modulate
6-207
modul ate
Purpose Modul ati on for communi cati ons si mul ati on.
Syntax y = modul at e( x , Fc, Fs , ' met hod' )
y = modul at e( x , Fc, Fs , ' met hod' , opt )
[ y , t ] = modul at e( x , Fc, Fs )
Description y = modul at e( x , Fc, Fs , ' met hod' ) and
y = modul at e( x , Fc, Fs , ' met hod' , 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 met hod. Note that some methods accept an opti on, opt .
amds bs c
or
am
Amplitude modulation, double side-band, suppressed carrier.
Mul ti pl i es x by a si nusoi d of frequency Fc:
y = x . *cos ( 2*pi *Fc*t )
amds bt c Amplitude modulation, double side-band, 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 = ( x opt ) . *cos ( 2*pi *Fc*t )
I f the opt parameter i s not present, modul at e uses a defaul t of
mi n( mi n( x ) ) so that the message si gnal ( x opt ) i s enti rel y
non-negati ve and has a mi ni mum val ue of 0.
ams s b Amplitude modulation, single side-band. 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 ) +i mag( hi l ber t ( x) ) . *s i n( 2*pi *Fc*t )
Thi s effecti vel y removes the upper si deband.
modulate
6-208
f m 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 *cums um( x ) )
cums um i s a rectangul ar approxi mati on to the i ntegral of x .
modul at e uses opt as the constant of frequency modul ati on. I f opt
i s not present, modul at e 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 Phase modulation. 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 )
modul at e uses opt as the constant of phase modul ati on. I f opt i s
not present, modul at e 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 from 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 ed.
modul at e( x , Fc, Fs , ' pwm' , ' cent er ed' )
yi el ds pul ses centered at the begi nni ng of each peri od. y i s l ength
l engt h( x ) *Fs /Fc.
pt m Pulse time modulation. 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
l engt h( x ) *Fs /Fc.
qam Quadrature amplitude modulation. 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 . *s i n( 2*pi *Fc*t )
opt must be the same si ze as x .
modulate
6-209
I f you do not speci fy met hod, then modul at e assumes am. Except for the pwm and
pt m cases, y i s the same si ze as x .
I f x i s an array, modul at e modul ates i ts col umns.
[ y , t ] = modul at e( x , Fc, Fs ) returns the i nternal ti me vector t that modul at e
uses i n i ts computati ons.
See Also demod Demodul ati on for communi cati ons si mul ati on.
v co Vol tage control l ed osci l l ator.
pmem
6-210
pmem
Purpose Power spectrum esti mate usi ng maxi mum entropy method (MEM).
Syntax [ Px x , f r eq] = pmem( x , p)
[ Px x , f r eq] = pmem( x , p, nf f t , Fs , ' cor r ' )
[ Px x , f r eq, a] = pmem( x , p, nf f t , Fs , ' cor r ' )
Description pmem esti mates the power spectral densi ty (PSD) of the si gnal vector x[n] or
correl ati on matri x R usi ng the maxi mum entropy method (MEM) descri bed
i n [1]. I t deri ves an al l -pol e model to represent the spectrum, so the correct
choi ce of the model order p i s cruci al .
[ Px x , f r eq] = pmem( x , p) returns Px x , the power spectrum esti mate, and
f r eq, a vector of frequenci es at whi ch the PSD was esti mated. x i s the i nput
si gnal , or the i nput correl ati on matri x, where
A row or col umn vector represents one si gnal
A square, Hermi ti an symmetri c matri x represents a correl ati on matri x
(when 'cor r ' i s used)
A rectangul ar array assumes that each col umn of x i s a separate l ook at the
si gnal (as i n array processi ng)
p i s the model order for the al l -pol e fi l ter.
[ Px x , f r eq] = pmem( x , p, nf f t , Fs , ' cor r ' ) speci fi es the FFT l ength nf f t
(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 r eq i s scal ed by thi s val ue. I f the
i nput si gnal i s real -val ued, f r eq ranges from 0 to Fs /2. I f the i nput si gnal i s
compl ex, f r eq ranges from 0 to Fs . ' cor r ' i s a text stri ng to speci fy a correl a-
ti on opti on. Speci fyi ng ' cor r ' forces x to be taken as a correl ati on matri x.
' cor r ' must appear at the end of the argument l i st.
[ Px x , f r eq, a] = pmem( x , p, nf f t , Fs , ' cor r ' ) returns vector a of fi l ter coeffi -
ci ents for the al l -pol e fi l ter model .
pmem
6-211
Examples Thi s exampl e anal yzes a sequence x[n], assumi ng that two real si gnal s are
present i n the si gnal subspace. I n thi s case, the model order must be four or
l arger, because each real si nusoi d i s the sum of two compl ex exponenti al s.
Experi ence shows that taki ng a l arger model order than the mi ni mum seems
to work better.
% Cr eat e x x as a s i gnal v ect or .
nn = 0: 199;
r andn( ' s eed' , 0)
x x = cos ( 0. 257*pi *nn) + s i n( 0. 2*pi *nn) + 0. 01*r andn( s i z e( nn) ) ;
[ PP, f f , aa] = pmem( x x , 7) ; % 7t h or der model
pl ot ( f f *pi , 10*l og10( PP) ) % Pl ot t he pol e l ocat i ons .
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6
-30
-25
-20
-15
-10
-5
0
5
10
15
pmem
6-212
The fol l owi ng exampl es use x as a correl ati on matri x and a data matri x:
% As s ume t hat RR i s a s quar e cor r . mat r i x ( f or ex ampl e, 7 by 7) .
RR = t oepl i t z ( cos ( 0. 1*pi *[ 0: 6] ) ) + 0. 1*ey e( 7) ;
[ PP, f f ] = pmem( RR, 4, ' cor r ' ) ;
% Make a Look Mat r i x : x x i s r ect angul ar ( 100 by 7) .
%
r andn( ' s eed' , 0)
x x = r es hape( cos ( 0. 257*pi *( 0: 699) ) , 7, 100) + 0. 1*r andn( 7, 100) ;
[ PP, f f ] = pmem( x x , 4) ;
% Same ( 100 by 7) dat a mat r i x as bef or e, but wi t h a l onger FFT.
[ PP, f f ] = pmem( x x , 4, 512) ;
Algorithm The MEM esti mate i s gi ven by the formul a:
where the vector of al l -pol e fi l ter coeffi ci ents a i s the sol uti on of the autocorre-
l ati on normal equati on:
The matri x R i s the autocorrel ati on matri x, whi ch shoul d be Toepl i tz [1]. The
el ements of the vector r are al so correl ati ons.
Diagnostics There must be at l east one output argument and at l east two i nputs; otherwi se,
pmem stops and gi ves one of the fol l owi ng error messages:
Mus t hav e at l eas t 1 out put ar gument .
Mus t hav e at l eas t 2 i nput ar gument s .
The fi rst argument must be a ful l matri x, otherwi se pmem gi ves the fol l owi ng
error message:
I nput s i gnal or cor r el at i on cannot be s par s e.
P
mem
f ( )
1
a
H
e f ( )
2
-------------------------- =
Ra r =
pmem
6-213
I f you speci fy an empty matri x for the second argument, pmem gi ves the
fol l owi ng error message:
Model or der mus t be gi v en, empt y not al l owed.
I f the fi nal argument i s the stri ng ' cor r ' , then the fi rst i nput must be a square
correl ati on matri x that i s al so Hermi ti an symmetri c, otherwi se pmem gi ves the
fol l owi ng error messages:
Cor r el at i on mat r i x ( R) i s not s quar e.
Cor r el at i on mat r i x ( R) i s not Her mi t i an s y mmet r i c.
See Also
References [1] Marpl e, S.L. Digital Spectral Analysis. Engl ewood Cl i ffs, NJ: Prenti ce Hal l ,
1987. Chapter 7.
l pc Li near predi cti on coefci ents.
pmt m Power spectrum esti mate usi ng the mul ti taper
method (MTM).
pmus i c Power spectrum esti mate usi ng MUSI C ei genvector
method.
pr ony Pronys method for ti me domai n I I R l ter desi gn.
ps d Esti mate the power spectral densi ty (PSD) of a
si gnal .
pmtm
6-214
pmtm
Purpose Power spectrum esti mate usi ng the mul ti taper method (MTM).
Syntax Px x = pmt m( x )
Px x = pmt m( x , nw)
Px x = pmt m( x , nw, nf f t )
[ Px x , f ] = pmt m( x , nw, nf f t , Fs )
[ Px x , f ] = pmt m( x , nw, nf f t , Fs , ' met hod' )
[ Px x , Px x c, f ] = pmt m( x , nw, nf f t , Fs , ' met hod' )
[ Px x , Px x c, f ] = pmt m( x , nw, nf f t , Fs , ' met hod' , p)
[ Px x , Px x c, f ] = pmt m( x , e, v , nf f t , Fs , ' met hod' , p)
[ Px x , Px x c, f ] = pmt m( x , dps s _par ams , nf f t , Fs , ' met hod' , p)
Description pmt m esti mates the power spectral densi ty (PSD) of the real ti me seri es x usi ng
the mul ti taper method (MTM), descri bed i n [1].
Px x = pmt m( 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 Px x i s 2*nw1.
Px x = pmt m( x , nw, nf f t ) defi nes the frequency gri d as l ength nf f t . When x i s
real , Px x i s l ength ( nf f t /2+1) for nf f t even and ( nf f t +1) /2 for nf f t odd;
when x i s compl ex, Px x i s l ength nf f t . The defaul t for nf f t i s 256 or the next
power of 2 greater than the l ength of x , whi chever i s l arger.
[ Px x , f ] = pmt m( x , nw, nf f t , 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 2 Hz.
[ Px x , f ] = pmt m( x , nw, nf f t , Fs , ' met hod' ) 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)
uni t y , to speci fy a l i near combi nati on wi th uni ty wei ghts
ei gen, to speci fy a l i near combi nati on wi th ei genval ue wei ghts
pmtm
6-215
[ Px x , Px x c, f ] = pmt m( x , nw, nf f t , Fs , ' met hod' ) returns Px x c, the 95%
confi dence i nterval for Px x , and
[ Px x , Px x c, f ] = pmt m( x , nw, nf f t , Fs , ' met hod' , p) returns Px x c, the p*100%
confi dence i nterval for Px x , where p i s a scal ar between 0 and 1. Confi dence
i nterval s are computed usi ng a chi -squared approach, where Px x c( : , 1) i s the
l ower bound and Px x c( : , 2) i s the upper bound of the confi dence i nterval .
[ Px x , Px x c, f ] = pmt m( x , e, v , nf f t , Fs , ' met hod' , p) returns the PSD esti -
mate Px x , the confi dence i nterval Px x c, and the frequency vector f from the
data tapers i n e and thei r concentrati ons v .
[ Px x , Px x c, f ] = pmt m( x , dps s _par ams , nf f t , Fs , ' met hod' , p) returns the
PSD esti mate Px x , the confi dence i nterval Px x c, and the frequency vector f
from the data tapers computed usi ng dps s wi th parameters from the cel l array
dps s _par ams , starti ng wi th the second el ement of the array. The fi rst param-
eter i s set by the l ength of x . For exampl e,
pmt m( x , {3. 5, ' cal c' , ' t r ace' }, 512, Fs ) forces di rect cal cul ati on of the
Sl epi an sequences. See dps s for opti ons.
Remarks pmt m 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, pmt m( x , [ ] , [ ] , 1000) uses defaul ts for the second and
thi rd el ements, i n thi s case, nw and nf f t .
pmtm
6-216
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) + r andn( s i z e( t ) ) ;
[ Px x , Px x c, f ] = pmt m( x , 3. 5, 512, Fs , [ ] , 0. 99) ;
pl ot ( f , 10*l og10( [ Px x Px x c] ) )
See Also
References [1] Perci val , D.B., and A.T. Wal den. Spectral Analysis for Physical Applica-
tions: Multitaper and Conventional Univariate Techniques. 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 Proceed-
ings of the I EEE. Vol . 70 (1982). Pgs. 1055-1096.
dps s Di screte prol ate spheroi dal sequences (Sl epi an
sequences).
pmem Power spectrum esti mate usi ng maxi mum entropy
method (MEM).
pmus i c Power spectrum esti mate usi ng MUSI C ei genvector
method.
ps d Esti mate the power spectral densi ty (PSD) of a
si gnal .
0 100 200 300 400 500
-10
-5
0
5
10
15
20
pmusic
6-217
pmusi c
Purpose Power spectrum esti mate usi ng MUSI C ei genvector method.
Syntax [ Px x , f ] = pmus i c( x , p)
[ Px x , f ] = pmus i c( x , [ p t hr es h] )
[ Px x , f ] = pmus i c( x , [ p t hr es h] , nf f t , Fs , wi ndow, nov er l ap)
[ Px x , f ] = pmus i c( x , . . . , ' cor r ' )
[ Px x , f ] = pmus i c( x , . . . , ' ev ' )
[ Px x , f , ev ect s , s v al s ] = pmus i c( x , . . . )
Description pmus i c 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 ps d, whi ch al so performs spectrum esti mati on. ps d uses the cl assi cal
FFT-based approach whi l e pmus i c performs ei gen-anal ysi s of the si gnal s
correl ati on matri x.
[ Px x , f ] = pmus i c( x , p) and
[ Px x , f ] = pmus i c( x , [ p t hr es h] ) return Px x , 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 , where
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 sep-
arate observati on of the process output (for exampl e, each col umn i s one out-
put of an array of sensors, as i n array processi ng)
A square matri x, gi ven the trai l i ng argument ' cor r ' , represents a correl a-
ti on matri x
The second argument i s a one- or two-el ement vector, ei ther p or [ p t hr es h] .
I f onl y p i s speci fi ed, the si gnal subspace di mensi on i s p. I f [ p t hr es h] i s spec-
i fi ed, t hr es h 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
*t hr es h 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-218
WARNING pmus i c must assi gn ei genvectors to the noi se and si gnal
subspaces, but thi s i s very di fcul t to do i n practi ce. The two parameters p
and t hr es h are provi ded for exi bi l i ty and control .
[ Px x , f ] = pmus i c( x , [ p t hr es h] , nf f t , Fs , wi ndow, nov er l ap) speci fi es the
FFT l ength nf f t (defaul t i s 256) and the sampl i ng frequency for the si gnal Fs
(defaul t i s 2). 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 . wi ndow 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. nov er l ap,
used i n conjuncti on wi th wi ndow, i s a scal ar that gi ves the number of poi nts by
whi ch to overl ap successi ve wi ndows.
[ Px x , f ] = pmus i c( x , . . . , ' cor r ' ) forces x to be taken as a correl ati on
matri x. I n thi s case, the arguments wi ndow and nov er l ap are i gnored.
[ Px x , f ] = pmus i c( 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 , evect s , s val s ] = pmus i c( x, . . . ) returns two addi ti onal arguments.
evect s i s a matri x of ei genvectors spanni ng the noi se subspace (one per col umn).
s val s i s ei ther a vector of si ngul ar val ues (squared) from s vd or a vector of ei gen-
val ues of the correl ati on matri x when the ' cor r ' opti on i s present.
Remarks The i nput x can be a vector or a matri x. x can be i nterpreted 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 wi ndow.
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-219
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 ' cor r ' i s present. x i s treated as a cor-
rel 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 t hr es h can determi ne the number of noi se ei genvectors i n one
of three ways:
I f t hr es h < 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 vectors. The val ue of t hr es h i s
unused.
I f p n, t hr es h must be at l east 1. t hr es h i s used as the mul ti pl i er to deter-
mi 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 t hr es h < 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 error message:
Noi s e s ubs pace di mens i on cannot be z er o.
When p < n and t hr es h 1, p speci fi es the maxi mum number of si gnal
ei genvectors. However, the threshol d test speci fi ed by t hr es h 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 x x , 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 exponen-
ti al s:
nn = 0: 199;
x x = cos ( 0. 257*pi *nn) + s i n( 0. 2*pi *nn) + 0. 01*r andn( s i z e( nn) ) ;
[ PP, f f ] = pmus i c( x x , 4) ;
Thi s exampl e anal yzes the same si gnal vector x x wi th an ei genval ue cutoff of
10% above the mi ni mum. Setti ng p = I nf forces the si gnal /noi se subspace deci -

k
t h r e s h ( ) mi n
k
{ }
k
'v
k
, { } bel ong to noi se subspace
pmusic
6-220
si on to be based on t hr es h. Use ei genvectors of di mensi on 7 and a sampl i ng
frequency Fs of 8 kHz:
[ PP, f f ] = pmus i c( x x , [ I nf , 1. 1] , [ ] , 8000, 7) ; % wi ndow l engt h = 7
Wi th the thi rd and fourth outputs, by pl otti ng the zeros of the noi se-ei gen-
vector 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 z pl ane pl ot i l l ustrates:
[ PP, f f , v _noi s e] = pmus i c( x x , 4) ;
f or kk = 1: s i z e( v _noi s e, 2)
r r ( : , kk) = r oot s ( v _noi s e( : , kk) ) ;
end
z pl ane( r r )
Assume that RR i s a square correl ati on matri x (for exampl e, 7-by-7):
RR = t oepl i t z ( cos ( 0. 1*pi *[ 0: 6] ) ) + 0. 1*ey e( 7) ;
[ PP, f f ] = pmus i c( RR, 4, ' cor r ' ) ;
Make an observati on matri x x x that i s rectangul ar (100-by-7):
x x = r es hape( cos ( 0. 257*pi *( 0: 699) ) , 7, 100) + 0. 1*r andn( 7, 100) ;
[ PP, f f ] = pmus i c( x x , 4) ;
Use the same si gnal , but l et pmus i c 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:
y y = x x ( : ) ;
[ PP, f f ] = pmus i c( y y , 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, f f ] = pmus i c( RR, 0, ' ev ' , ' cor r ' ) ;
Algorithm The MUSI C esti mate i s gi ven by the formul a
1
v
k
H
e f ( )
2
k p 1 + =
N

--------------------------------------------- = P
music
f ( )
1
e
H
f ( ) v
k
v
k
H
k p = 1 +
N




e f ( )
--------------------------------------------------------------------- =
pmusic
6-221
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 p i 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 FFT i 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 s v d matri x decomposi ti on i n the si gnal case, and i t
uses the ei g 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,
pmus i c stops and gi ves one of the fol l owi ng error messages:
Mus t hav e at l eas t 1 out put ar gument .
Mus t hav e at l eas t 2 i nput ar gument s .
The fi rst argument must be a ful l matri x, otherwi se pmus i c gi ves the fol l owi ng
error message:
I nput s i gnal or cor r el at i on cannot be s par s e.
v
k
H
e f ( )

k
P
ev
f ( )
1
v
k
H
e f
2
k p 1 + =
N

------------------------------------------- =
pmusic
6-222
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, pmus i c gi ves one of
the fol l owi ng error messages:
P cannot be empt y .
Second i nput mus t hav e onl y 1 or 2 el ement s .
P mus t be an i nt eger .
Second i nput mus t cont ai n non- negat i v e ent r i es .
I f the val ue of p i s too l arge wi th respect to the ei genvector di mensi on, and
t hr es h 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, pmus i c gi ves the fol l owi ng error message:
Noi s e s ubs pace di mens i on cannot be z er o.
I f the ' cor r ' parameter i s used, then the fi rst i nput must be a square correl a-
ti on matri x. I f i t i s not, pmus i c gi ves the fol l owi ng error message:
Cor r el at i on mat r i x ( R) i s not s quar e.
The correl ati on matri x i s then checked for val i di ty; i f i t fai l s, pmus i c gi ves the
fol l owi ng error message:
Cor r el at i on mat r i x ( R) has negat i v e or compl ex ei genv al ue.
See Also
References [1] Schmi dt, R.O. Mul ti pl e Emi tter Locati on and Si gnal Parameter Esti ma-
ti 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.
l pc Li near predi cti on coefci ents.
pmem Power spectrum esti mate usi ng maxi mum entropy method
(MEM).
pmt m Power spectrum esti mate usi ng the mul ti taper method
(MTM).
pr ony Pronys method for ti me domai n I I R l ter desi gn.
ps d Esti mate the power spectral densi ty (PSD) of a si gnal .
poly2rc
6-223
pol y2rc
Purpose Refl ecti on coeffi ci ents from pol ynomi al coeffi ci ents.
Syntax k = pol y 2r c( a)
Description k = pol y 2r c( a) fi nds the refl ecti on coeffi ci ents of the l atti ce structure of the
di screte fi l ter a. a must be real , and a( 1) cannot be 0. k i s a row vector of si ze
l engt h( a) 1.
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 have magni tude l ess than 1:
s t abl e = al l ( abs ( pol y 2r c( 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 = pol y 2r c( a)
k =
0. 3090 0. 9800 0. 0031 0. 0082 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. pol y 2r c wi l l return some NaNs and provi de a warni ng message
i n thi s case.
Algorithm pol y 2r c i mpl ements the recursi ve rel ati onshi p:
k n a n
a m
a m k n a n m
k n
m n
n
n
n n
( ) ( )

( ) ( ) ( )
( )
1
2
1
1 2 1 ( ) , = , , ... -
poly2rc
6-224
Thi s rel ati onshi p i s based on Levi nsons recursi on [1]. To i mpl ement i t,
pol y 2r c 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 ) *f l i pl r ( a) ) /( 1k( i ) ^2) ;
See Also
References [1] McCl el l an, J. Parametri c Si gnal Model i ng. Advanced Topics in Signal
Processing. Oppenhei m, A.V., and J.S. Li m, ed. Engl ewood Cl i ffs, NJ: Prenti ce
Hal l , 1988. Pgs. 20-21.
l at c2t f Latti ce l ter to transfer functi on conversi on.
l at cf i l t Latti ce and l atti ce-l adder l ter i mpl ementati on.
r c2pol y Pol ynomi al coefci ents from reecti on coefci ents.
t f 2l at c Transfer functi on to l atti ce l ter conversi on.
polystab
6-225
pol ystab
Purpose Stabi l i ze pol ynomi al .
Syntax b = pol y s t ab( a)
Description pol y s t ab 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 = pol y s t ab( 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 pol y s t ab 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 = f i r 1( 25, 0. 4) ;
hmi n = pol y s t ab( h) *nor m( h) /nor m( pol y s t ab( h) ) ;
Algorithm pol y s t ab 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 = r oot s ( a) ;
v s = 0. 5*( s i gn( abs ( v ) 1) +1) ;
v = ( 1v s ) . *v + v s . /conj ( v ) ;
b = a( 1) *pol y ( v ) ;
See Also r oot s Pol ynomi al roots (see MATLAB Functi on Reference).

a z a a z a na z
na
( ) ( ) ( ) ( ) + + + +

1 2 1
1
L
prony
6-226
prony
Purpose Pronys method for ti me domai n I I R fi l ter desi gn.
Syntax [ b, a] = pr ony ( 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] = pr ony ( 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. pr ony 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] = but t er ( 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 = f i l t er ( b, a, [ 1 z er os ( 1, 25) ] ) ;
[ bb, aa] = pr ony ( 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 pr ony 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

H z
B z
A z
b b z b nb z
a a z a na z
nb
na
( )
( )
( )
( ) ( ) ( )
( ) ( ) ( )

+ + + +
+ + + +


1 2 1
1 2 1
1
1
L
L
prony
6-227
fi l ter i s not necessari l y stabl e, but potenti al l y can 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.
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.
but t er Butterworth anal og and di gi tal l ter desi gn.
cheby 1 Chebyshev type I l ter desi gn (passband ri ppl e).
cheby 2 Chebyshev type I I l ter desi gn (stopband ri ppl e).
el l i p El l i pti c (Cauer) l ter desi gn.
i nv f r eqz Di screte-ti me l ter i denti cati on from frequency
data.
l ev i ns on Levi nson-Durbi n recursi on.
l pc Li near predi cti on coefci ents.
s t mcb Li near model usi ng Stei gl i tz-McBri de i terati on.
psd
6-228
psd
Purpose Esti mate the power spectral densi ty (PSD) of a si gnal .
Syntax Px x = ps d( x )
Px x = ps d( x , nf f t )
[ Px x , f ] = ps d( x , nf f t , Fs )
Px x = ps d( x , nf f t , Fs , wi ndow)
Px x = ps d( x , nf f t , Fs , wi ndow, nov er l ap)
Px x = ps d( x , . . . , ' df l ag' )
[ Px x , Px x c, f ] = ps d( x , nf f t , Fs , wi ndow, nov er l ap, p)
ps d( x , . . . )
Description Px x = ps d( x ) esti mates the power spectrum of the sequence x usi ng the
Wel ch method of spectral esti mati on. Px x = ps d( x ) uses the fol l owi ng defaul t
val ues:
nf f t = mi n( 256, l engt h( x ) )
Fs = 2
wi ndow = hanni ng( nf f t )
nov er l ap = 0
nf f t speci fi es the FFT l ength that ps d 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 spec-
i fi es the sampl i ng frequency. wi ndow speci fi es a wi ndowi ng functi on and the
number of sampl es ps d uses i n i ts secti oni ng of the x vector. nov er l ap 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 x i s real , ps d esti mates the spectrum at posi ti ve frequenci es onl y; i n thi s case,
the output Px x i s a col umn vector of l ength nf f t /2+1 for nf f t even and
( nf f t +1) /2 for nf f t odd. I f x i s compl ex, ps d esti mates the spectrum at both
posi ti ve and negati ve frequenci es and Px x has l ength nf f t .
Px x = ps d( x , nf f t ) uses the speci fi ed FFT l ength nf f t i n esti mati ng the
power spectrum for x . Speci fy nf f t as a power of 2 for fastest executi on.
[ Px x , f ] = ps d( x , nf f t , Fs ) returns a vector f of frequenci es at whi ch the
functi on eval uates the PSD. f i s the same si ze as Px x , so pl ot ( f , Px x ) pl ots the
power spectrum versus properl y scal ed frequency. Fs has no effect on the
output Px x ; i t i s a frequency scal i ng mul ti pl i er.
psd
6-229
Px x = ps d( x , nf f t , Fs , wi ndow) 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 wi ndow,
ps d 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 nf f t ; ps d zero pads the secti ons i f the l ength of the wi ndow
i s l ess than nf f t . ps d returns an error i f the l ength of the wi ndow i s greater
than nf f t .
Px x = ps d( x , nf f t , Fs , wi ndow, nov er l ap) overl aps the secti ons of x by
nov er l ap sampl es.
You can use the empty matri x [ ] to speci fy the defaul t val ue for any i nput
argument except x . For exampl e,
ps d( x , [ ] , 10000)
i s equi val ent to
ps d( x )
but wi th a sampl i ng frequency of 10,000 Hz i nstead of the defaul t of 2 Hz.
Px x = ps d( x , . . . , ' df l ag' ) speci fi es a detrend opti on, where df l ag i s
l i near , to remove the best strai ght-l i ne fi t from the prewi ndowed secti ons
of x
mean, to remove the mean from the prewi ndowed secti ons of x
none, for no detrendi ng (defaul t)
The df l ag parameter must appear l ast i n the l i st of i nput arguments. ps d
recogni zes a df l ag stri ng no matter how many i ntermedi ate arguments are
omi tted.
[ Px x , Px x c, f ] = ps d( x , nf f t , Fs , wi ndow, nov er l ap, p) where p i s a posi ti ve
scal ar between 0 and 1 returns a vector Px x c that contai ns an esti mate of the
p*100 percent confi dence i nterval for Px x . Px x c i s a two-col umn matri x that i s
the same l ength as Px x . The i nterval [Px x c( : , 1) , Px x c( : , 2) ] covers the true
PSD wi th probabi l i ty p. pl ot ( f , [ Px x Px x c Px x c] ) pl ots the power spectrum
i nsi de the p*100 percent confi dence i nterval . I f unspeci fi ed, p defaul ts to 0.95.
psd
6-230
ps d( x , . . . ) wi th no output arguments pl ots the PSD 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 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 = f i r 1( 30, 0. 2, box car ( 31) ) ; % des i gn a l owpas s f i l t er
r = r andn( 16384, 1) ; % whi t e noi s e
x = f i l t er ( h, 1, r ) ; % col or t he noi s e
ps d( x , 1024, 10000, kai s er ( 512, 5) , 0, 0. 95)
0 1000 2000 3000 4000 5000
-70
-60
-50
-40
-30
-20
-10
0
10
Frequency
P
o
w
e
r

S
p
e
c
t
r
u
m

M
a
g
n
i
t
u
d
e

(
d
B
)
Power Spectral Density Estimate
psd
6-231
Algorithm ps d 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 wi ndow vector to each successi ve de-
trended secti on of x .
2 I t transforms each secti on wi th an nf f t -poi nt FFT.
3 I t forms the peri odogram of each secti on by scal i ng the magni tude squared
of each transform.
4 I t averages the peri odograms of the overl appi ng secti ons to form Px x , the
power spectrum of x .
The number of secti ons that ps d averages i s
k = f i x ( ( l engt h( x ) nov er l ap) /( l engt h( wi ndow) nov er l ap) )
Diagnostics An appropri ate di agnosti c message i s di spl ayed when i ncorrect arguments to
ps d are used:
Requi r es wi ndow s l engt h t o be no gr eat er t han FFT l engt h.
Requi r es NOVERLAP t o be s t r i ct l y l es s t han t he wi ndow l engt h.
Requi r es pos i t i v e i nt eger v al ues f or NFFT and NOVERLAP.
Requi r es conf i dence par amet er t o be a s cal ar bet ween 0 and 1.
Requi r es v ect or i nput .
See Also coher e Esti mate magni tude squared coherence functi on
between two si gnal s.
cs d Esti mate the cross spectral densi ty (CSD) of two
si gnal s.
pmem Power spectrum esti mate usi ng maxi mum entropy
method (MEM).
pmt m Power spectrum esti mate usi ng the mul ti taper
method (MTM).
pmus i c Power spectrum esti mate usi ng MUSI C ei genvector
method.
s pecgr am Ti me-dependent frequency anal ysi s (spectrogram).
t f e Transfer functi on esti mate from i nput and output.
psd
6-232
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. Audio Electroacoust. Vol . AU-15 (June 1967).
Pgs. 70-73.
[3] Oppenhei m, A.V., and R.W. Schafer. Discrete-Time Signal Processing.
Engl ewood Cl i ffs, NJ: Prenti ce Hal l , 1989. Pgs. 311-312.
pulstran
6-233
pul stran
Purpose Pul se trai n generator.
Syntax y = pul s t r an( t , d, ' f unc' )
y = pul s t r an( t , d, ' f unc' , p1, p2, )
y = pul s t r an( t , d, p, Fs )
y = pul s t r an( t , d, p)
Description pul s t r an generates pul se trai ns from conti nuous functi ons or sampl ed proto-
type pul ses.
y = pul s t r an( t , d, ' f unc' ) generates a pul se trai n based on sampl es of a
conti nuous functi on, ' f unc' , where f unc i s
gaus pul s , for Gaussi an-modul ated si nusoi dal pul se generator
r ect pul s , for sampl ed aperi odi c rectangl e generator
t r i pul s , for sampl ed aperi odi c tri angl e generator
pul s t r an i s eval uated l engt h( d) ti mes and returns the sum of the eval uati ons
y = f unc( t d( 1) ) + f unc( t d( 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
f unc 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.
pul s t r an( t , d, ' f unc' , p1, p2, . . . ) al l ows addi ti onal parameters to be passed
to 'f unc' as necessary. For exampl e,
f unc( t d( 1) , p1, p2, . . . ) + f unc( t d( 2) , p1, p2, . . . ) + . . .
pul s t r an( 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, ( l engt h( 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-234
pul s t r an( t , d, p) assumes that the sampl i ng rate Fs i s equal to 1 Hz.
pul s t r an( . . . , ' f unc' ) speci fi es al ternati ve i nterpol ati on methods. See
i nt er p1 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 s ampl e f r eq f or 1 s ec
d = 0 : 1/3 : 1; % 3 Hz r epet i t i on f r eq
y = pul s t r an( t , d, ' t r i pul s ' , 0. 1, 1) ;
pl ot ( t , y )
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-235
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
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 = pul s t r an( t , d, ' gaus pul s ' , 10e3, 0. 5) ;
pl ot ( 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-236
Thi s exampl e generates a trai n of 10 Hammi ng wi ndows:
p = hammi ng( 32) ;
t = 0: 320; d = ( 0: 9) ' *32;
y = pul s t r an( t , d, p) ;
pl ot ( t , y )
See Also chi r p Swept-frequency cosi ne generator.
cos Cosi ne of vector/matri x el ements (see MATLAB
Functi on Reference).
di r i c Di ri chl et or peri odi c si nc functi on.
gaus pul s Gaussi an-modul ated si nusoi dal pul se generator.
r ect pul s Sampl ed aperi odi c rectangl e generator.
s awt oot h Sawtooth or tri angl e wave generator.
s i n Si ne of vector/matri x el ements (see MATLAB
Functi on Reference).
s i nc Si nc or si n(t)/t functi on.
s quar e Square wave generator.
t r i pul s Sampl ed aperi odi c tri angl e generator.
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

rc2poly

6-237

rc2pol y

Purpose

Pol ynomi al coeffi ci ents from refl ecti on coeffi ci ents.

Syntax

a = r c2pol y ( k)

Description

a = r c2pol y ( k)

fi nds the fi l ter coeffi ci ents

a

, wi th

a( 1)



=



1

, from the real
refl ecti on coeffi ci ents

k

of the l atti ce structure of a di screte fi l ter.

a

i s row vector
of l ength

k + 1

.

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 = r c2pol y ( k)
a =
1. 0000 0. 6149 0. 9899 0. 0000 0. 0031 0. 0082

Algorithm

r c2pol y

computes

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

l oops through the remai ni ng el ements of

k

For each l oop i terati on

i

,

a = [ a + a( i 1: 1: 1) *k( i ) k( i ) ]

.

3

i mpl ements

a = [ 1 a]

See Also
References

[1] McCl el l an, J. Parametri c Si gnal Model i ng.

Advanced Topics in Signal
Processing

. Oppenhei m, A.V., and J.S. Li m, ed. Engl ewood Cl i ffs, NJ: Prenti ce
Hal l , 1988. Pgs. 20-21.

l at c2t f

Latti ce l ter to transfer functi on conversi on.

l at cf i l t

Latti ce and l atti ce-l adder l ter i mpl ementati on.

pol y 2r c

Reecti on coefci ents from pol ynomi al coefci ents.

t f 2l at c

Transfer functi on to l atti ce l ter conversi on.

rceps

6-238

rceps

Purpose

Real cepstrum and mi ni mum phase reconstructi on.

Syntax

y = r ceps ( x )
[ y , y m] = r ceps ( x )

Description

The

real cepstrum

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

r ceps ( x )

returns the real cepstrum of the real sequence

x

. The real cepstrum
i s a real -val ued functi on.

[ y , y m] = r ceps ( x )

returns both the real cepstrum

y

and a mi ni mum phase
reconstructed versi on

y m

of the i nput sequence.

Algorithm

r ceps

i s an M-fi l e i mpl ementati on of al gori thm 7.2 i n [2], that i s:

y = r eal ( i f f t ( l og( abs ( f f t ( 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 r em( n, 2) , 1) ; z er os ( n/21, 1) ] ;
y m = r eal ( i f f t ( ex p( f f t ( 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.

Programs for Digital Signal Processing

. I EEE Press. New York: John
Wi l ey & Sons, 1979.

cceps

Compl ex cepstral anal ysi s.

f f t

One-di mensi onal fast Fouri er transform.

hi l ber t

Hi l bert transform.

i cceps

I nverse compl ex cepstrum.

unwr ap

Unwrap phase angl es.

rectpuls

6-239

rectpul s

Purpose

Sampl ed aperi odi c rectangl e generator.

Syntax

y = r ect pul s ( t )
y = r ect pul s ( t , w)

Description

y = r ect pul s ( 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,

r ect pul s ( 0. 5) = 1

whi l e

r ect pul s ( 0. 5) = 0

.

y = r ect pul s ( t , w)

generates a rectangl e of wi dth

w

.

r ect pul s

i s typi cal l y used i n conjuncti on wi th the pul se trai n generati ng func-
ti on,

pul s t r an

.

See Also

chi r p

Swept-frequency cosi ne generator.

cos

Cosi ne of vector/matri x el ements (see MATLAB
Functi on Reference).

di r i c

Di ri chl et or peri odi c si nc functi on.

gaus pul s

Gaussi an-modul ated si nusoi dal pul se generator.

pul s t r an

Pul se trai n generator.

s awt oot h

Sawtooth or tri angl e wave generator.

s i n

Si ne of vector/matri x el ements (see MATLAB
Functi on Reference).

s i nc

Si nc or si n(


t)/t functi on.
s quar e Square wave generator.
t r i pul s Sampl ed aperi odi c tri angl e generator.
remez
6-240
remez
Purpose Parks-McCl el l an opti mal FI R fi l ter desi gn.
Syntax b = r emez ( n, f , a)
b = r emez ( n, f , a, w)
b = r emez ( n, f , a, ' f t ype' )
b = r emez ( n, f , a, w, ' f t ype' )
Description r emez desi gns a l i near-phase FI R fi l ter usi ng the Parks-McCl el l an
al gori thm [1]. The Parks-McCl el l an al gori thm uses the Remez exchange al go-
ri 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 equiripple fi l ters.
b = r emez ( 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:
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 frequen-
cy). 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.

b k b n k k n ( ) ( ), , , + + 2 1 1 K
remez
6-241
The rel ati onshi p between the f and a vectors i n defi ni ng a desi red frequency
response i s
r emez ( 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 = r emez ( n, f , a, ' f t ype' ) and
b = r emez ( n, f , a, w, ' f t ype' ) speci fy a fi l ter type, where f t ype i s
hi l ber t , 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 = r emez ( 30, [ 0. 1 0. 9] , [ 1 1] , ' Hi l ber t ' ) ;
desi gns an approxi mate FI R Hi l bert transformer of l ength 31.
di f f er ent i at or , for type I I I and I V fi l ters, usi ng a speci al wei ghti ng tech-
ni 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
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-242
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).
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 = r emez ( 17, f , a) ;
[ h, w] = f r eqz ( b, 1, 512) ;
pl ot ( f , a, w/pi , abs ( h) )
Algorithm r emez 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.
r emez 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 ' hi l ber t ' and ' di f f er ent i at or ' fl ags.
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-243
The di fferent types of fi l ters have di fferent symmetri es and certai n constrai nts
on thei r frequency responses (see reference [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:
Fi l t er or der mus t be 3 or mor e.
Ther e s houl d be one wei ght per band.
Fr equency and ampl i t ude v ect or s mus t be t he s ame l engt h.
The number of f r equency poi nt s mus t be ev en.
Fr equenci es mus t l i e bet ween 0 and 1.
Fr equenci es mus t be s peci f i ed i n bands .
Fr equenci es mus t be nondecr eas i ng.
Adj acent bands not al l owed.
A more seri ous warni ng message i s
Fai l ur e t o Conv er ge
Pr obabl e caus e i s machi ne r oundi ng er r or .
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 Coefcients
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 k k n ( ) ( ), , , + + 2 1 1 K

b k b n k k n ( ) ( ), , , + + 2 1 1 K
remez
6-244
See Also
References [1] I EEE. Programs for 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-Time Signal Processing.
Engl ewood Cl i ffs, NJ: Prenti ce Hal l , 1989. Pgs. 256-266.
but t er Butterworth anal og and di gi tal l ter desi gn.
cheby 1 Chebyshev type I l ter desi gn (passband ri ppl e).
cheby 2 Chebyshev type I I l ter desi gn (stopband ri ppl e).
cr emez Compl ex and nonl i near-phase equi ri ppl e FI R l ter
desi gn
el l i p El l i pti c (Cauer) l ter desi gn.
f i r 1 Wi ndow-based ni te i mpul se response l ter desi gn
standard response.
f i r 2 Wi ndow-based ni te i mpul se response l ter desi gn
arbi trary response.
f i r cl s Constrai ned l east square FI R l ter desi gn for
mul ti band l ters.
f i r cl s 1 Constrai ned l east square l ter desi gn for l owpass
and hi ghpass l i near phase FI R l ters.
f i r l s Least square l i near-phase FI R l ter desi gn.
f i r r cos Rai sed cosi ne FI R l ter desi gn.
r emez or d Parks-McCl el l an opti mal FI R l ter order esti mati on.
y ul ewal k Recursi ve di gi tal l ter desi gn.
remezord
6-245
remezord
Purpose Parks-McCl el l an opti mal FI R fi l ter order esti mati on.
Syntax [ n, f o, ao, w] = r emez or d( f , a, dev )
[ n, f o, ao, w] = r emez or d( f , a, dev , Fs )
c = r emez or d( f , a, dev , Fs , ' cel l ' )
Description [ n, f o, ao, w] = r emez or d( 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 r emez command.
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.
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 de-
vi 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 r emez wi th the resul ti ng order n, frequency vector f o, 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 r emez or d i nput parameters f , a, and dev :
b = r emez ( n, f o, ao, w)
[ n, f o, ao, w] = r emez or d( 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 r emez or d 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 = r emez or d( f , a, dev , Fs , ' cel l ' ) speci fi es a cel l -array whose el ements are
the parameters to r emez .
remezord
6-246
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
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:
r p = 3; % pas s band r i ppl e
r s = 40; % s t opband r i ppl e
Fs = 2000; % s ampl i ng f r equency
f = [ 500 600] ; % cut of f f r equenci es
a = [ 1 0] ; % des i r ed ampl i t udes
% comput e dev i at i ons
dev = [ ( 10^( r p/20) 1) /( 10^( r p/20) +1) 10^( r s /20) ] ;
[ n, f o, ao, w] = r emez or d( f , a, dev , Fs ) ;
b = r emez ( n, f o, ao, w) ;
[ h, f ] = f r eqz ( b, 1, 1024, Fs ) ;
pl ot ( f , 20*l og10( abs ( h) ) )
Note that the fi l ter fal l s sl i ghtl y short of meeti ng the speci fi cati ons. Usi ng n+1
i n the cal l to r emez 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-247
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, f o, ao, w] = r emez or d( [ 1500 2000] , [ 1 0] , [ 0. 01 0. 1] , 8000 ) ;
b = r emez ( n, f o, ao, w) ;
Thi s i s equi val ent to
c = r emez or d( [ 1500 2000] , [ 1 0] , [ 0. 01 0. 1] , 8000, ' cel l ' ) ;
b = r emez ( c{: }) ;
NOTE I n some cases, r emez or d underesti mates or overesti mates the order n.
I f the l ter does not meet the speci cati ons, try a hi gher order such as n+1
or n+2.
NOTE Resul ts are i naccurate i f the cutoff frequenci es are near 0 or the
Nyqui st frequency.
Algorithm r emez or d 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, r emez or d gi ves the fol l owi ng
error messages:
Requi r es M and DEV t o be t he s ame l engt h.
Lengt h of F mus t be l engt h( M) 2.
See Also but t or d Butterworth l ter order sel ecti on.
cheb1or d Chebyshev type I l ter order sel ecti on.
cheb2or d Chebyshev type I I l ter order sel ecti on.
el l i por d El l i pti c l ter order sel ecti on.
kai s er or d Esti mate parameters for r1 wi th Kai ser wi ndow.
r emez Parks-McCl el l an opti mal FI R l ter desi gn.
remezord
6-248
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-249
resampl e
Purpose Change sampl i ng rate by any factor.
Syntax y = r es ampl e( x , p, q)
y = r es ampl e( x , p, q, n)
y = r es ampl e( x , p, q, n, bet a)
y = r es ampl e( x , p, q, b)
[ y , b] = r es ampl e( x , p, q)
Description y = r es ampl e( 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. y i s p/q ti mes
the l ength of x . p and q must be posi ti ve i ntegers. I f x i s a matri x, r es ampl e
works down the col umns of x .
r es ampl e appl i es an anti -al i asi ng (l owpass) FI R fi l ter to x duri ng the resam-
pl i ng process. I t desi gns the fi l ter usi ng f i r 1 wi th a Kai ser wi ndow.
y = r es ampl e( x , p, q, n) uses n terms on ei ther si de of x [ n] to perform the
resampl i ng. The l ength of the FI R fi l ter r es ampl e 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, r es ampl e uses a zero-order hol d.
y = r es ampl e( x , p, q, n, bet a) uses bet a as the desi gn parameter for the
Kai ser wi ndow that r es ampl e uses i n desi gni ng the l owpass fi l ter. The defaul t
for bet a i s 5.
y = r es ampl e( x , p, q, b) fi l ters x wi th b, a vector of fi l ter coeffi ci ents.
[ y , b] = r es ampl e( 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-250
Examples Resampl e a si mpl e l i near sequence at 3/2 the ori gi nal rate:
Fs 1 = 10; % or i gi nal s ampl i ng f r eq. i n Hz
t 1 = 0: 1/Fs 1: 1; % t i me v ect or
x = t 1; % def i ne a l i near s equence
y = r es ampl e( x , 3, 2) ; % now r es ampl e i t
t 2 = ( 0: ( l engt h( y ) 1) ) *2/( 3*Fs 1) ; % new t i me v ect or
pl ot ( t 1, x , ' *' , t 2, y , ' o' , 0. 5: 0. 01: 1. 5, 0. 5: 0. 01: 1. 5, ' : ' )
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, r es ampl e 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-251
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 r es ampl e:
x = [ 1: 10 9: 1: 1] ; y = r es ampl e( x , 3, 2) ;
pl ot ( 1: 19, x , ' *' , ( 0: 28) *2/3 + 1, y , ' o' )
x = [ 10: 1: 1 2: 10] ; y = r es ampl e( x , 3, 2) ;
pl ot ( 1: 19, x , ' *' , ( 0: 28) *2/3 + 1, y , ' o' )
Diagnostics I f p or q are not posi ti ve i ntegers, r es ampl e gi ves the appropri ate error
message:
P mus t be a pos i t i v e i nt eger .
Q mus t be a pos i t i v e i nt eger .
I f x i s not a vector, r es ampl e gi ves the fol l owi ng error message:
I nput X mus t be a v ect or .
0 5 10 15 20
0
2
4
6
8
10
12
Edge effects very noticeable
original
resampled
0 5 10 15 20
0
2
4
6
8
10
Edge effects not so noticeable
resample
6-252
See Also deci mat e Decrease the sampl i ng rate for a sequence
(deci mati on).
f i r 1 Wi ndow-based ni te i mpul se response l ter desi gn
standard response.
i nt er p I ncrease sampl i ng rate by an i nteger factor
(i nterpol ati on).
i nt er p1 1-D data i nterpol ati on (tabl e l ookup) (see MATLAB
Functi on Reference).
i nt f i l t I nterpol ati on FI R l ter desi gn.
kai s er Kai ser wi ndow.
s pl i ne Cubi c spl i ne i nterpol ati on (see MATLAB Functi on
Reference).
upf i r dn Appl y FI R l ter and perform rate changi ng.
residuez
6-253
resi duez
Purpose z-transform parti al -fracti on expansi on.
Syntax [ r , p, k] = r es i duez ( b, a)
[ b, a] = r es i duez ( r , p, k)
Description r es i duez converts a di screte ti me system, expressed as the rati o of two pol yno-
mi 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] = r es i duez ( 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 row vector k contai ns the di rect terms. The number of
pol es i s
n = l engt h( a) 1 = l engt h( r ) = l engt h( p)
The di rect term coeffi ci ent vector k i s empty i f l engt h( b) < l engt h( a) ; other-
wi se
l engt h( k) = l engt h( b) l engt h( a) + 1
I f p( j ) = . . . = p( j +s 1) 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 b z b z b z
a z a a z a z a z
m
m
n
n
( )
( )
+ + + +
+ + + +


0 1
1
2
2
0 1
1
2
2
L
L

b z
a z
r
p z
r n
p n z
k k z k m n z
m n
( )
( )
( )
( )
( )
( )
( ) ( ) ( )
( )

+ +

+ + + + +


1
1 1 1
1 2 1
1 1
1
L L

r j
p j z
r j
p j z
r j s
p j z
s
( )
( )
( )
( ( ) )
( )
( ( ) ) 1
1
1
1
1
1 1 2 1

+
+

+ +
+


L
residuez
6-254
[ b, a] = r es i duez ( r , p, k) wi th three i nput arguments and two output argu-
ments, 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 r es i due functi on i n the MATLAB envi ronment i s very si mi l ar to r es i duez .
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 r es i duez .
Algorithm r es i duez 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:
1 I t fi nds the di rect terms a usi ng deconv (pol ynomi al l ong di vi si on) when
l engt h( b) >l engt h( a) 1.
2 I t fi nds the pol es usi ng p = r oot s ( a) . mpol es fi nds repeated pol es and
reorders the pol es accordi ng to thei r mul ti pl i ci ti es.
3 I t fi nds 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 I t fi nds the resi dues for the repeated pol es by sol vi ng
S2*r 2 = h S1*r 1
for r 2 usi ng \. h i s the i mpul se response of the reduced b(z)/ a(z), S1 i s a ma-
tri x whose col umns are i mpul se responses of the fi rst-order systems made
up of the nonrepeati ng roots, and r 1 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 m-
pul se responses of each of the fol l owi ng systems:
The vector h and matri ces S1 and S2 have n + x t r a rows, where n i s the total
number of roots and the i nternal parameter x t r a, set to 1 by defaul t, deter-
mi nes the degree of overdetermi 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] = r es i duez ( b, a) , r es i duez gi ves the fol l owi ng error message:
Fi r s t coef f i ci ent i n A v ect or mus t be nonz er o.

1
1
1
1
1
1
1 1 2
1




p z p z
p z j j
j
s
j
,
( )
, ,
( )
L
residuez
6-255
I f the number of resi dues r and pol es p i s not the same, r es i duez gi ves the
fol l owi ng error message:
R and P v ect or s mus t be t he s ame s i z e.
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.
conv mt x Convol uti on matri x.
deconv Deconvol uti on and pol ynomi al di vi si on (see MATLAB
Functi on Reference).
pol y Pol ynomi al wi th speci ed roots (see MATLAB
Functi on Reference).
pr ony Pronys method for ti me domai n I I R l ter desi gn.
r es i due Parti al fracti on expansi on (see MATLAB Functi on
Reference).
r oot s Pol ynomi al roots (see MATLAB Functi on Reference).
s s 2t f State-space to zero-pol e-gai n conversi on.
t f 2s s Transfer functi on to state-space conversi on.
t f 2z p Transfer functi on to zero-pol e-gai n conversi on.
z p2s s Zero-pol e-gai n to state-space conversi on.
sawtooth
6-256
sawtooth
Purpose Sawtooth or tri angl e wave generator.
Syntax x = s awt oot h( t )
x = s awt oot h( t , wi dt h)
Description s awt oot h( t ) generates a sawtooth wave wi th peri od 2 for the el ements of
ti me vector t . s awt oot h( t ) i s si mi l ar to s i n( 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.
s awt oot h( t , wi dt h) generates a modi fi ed tri angl e wave where wi dt h, 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*wi dt h, then decreases l i nearl y from 1 to -1 on the i nterval 2*wi dt h 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. s awt oot h( t , 1) i s equi val ent
to s awt oot h( t ) .
Diagnostics I f the wi dt h parameter i s not a scal ar, s awt oot h gi ves the fol l owi ng error
message:
Requi r es WI DTH par amet er t o be a s cal ar .
See Also chi r p Swept-frequency cosi ne generator.
cos Cosi ne of vector/matri x el ements (see MATLAB
Functi on Reference).
di r i c Di ri chl et or peri odi c si nc functi on.
gaus pul s Gaussi an-modul ated si nusoi dal pul se generator.
pul s t r an Pul se trai n generator.
r ect pul s Sampl ed aperi odi c rectangl e generator.
s i n Si ne of vector/matri x el ements (see MATLAB
Functi on Reference).
s i nc Si nc or si n(t)/t functi on.
s quar e Square wave generator.
t r i pul s Sampl ed aperi odi c tri angl e generator.
sinc
6-257
si nc
Purpose Si nc or si n(t)/t functi on.
Syntax y = s i nc( x )
Description s i nc 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 = s i nc( x ) returns an array y the same si ze as x , whose el ements are the
s i nc 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:
sinc( )
,
sin
,
t
t
t
t
t

( )

'

1 0
0

sinc( ) t e d
j t

1
2

[ , ]
g t g n t n
n
( ) ( )sinc( )

sinc
6-258
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 col umn v ect or of t i me s ampl es
x = r andn( s i z e( t ) ) ; % a col umn v ect or of dat a
% t s i s t i mes at whi ch t o i nt er pol at e dat a
t s = l i ns pace( 5, 15, 600) ' ;
y = s i nc( t s ( : , ones ( s i z e( t ) ) ) t ( : , ones ( s i z e( t s ) ) ) ' ) *x ;
pl ot ( t , x , ' o' , t s , y )
-5 0 5 10 15
-1
-0.5
0
0.5
1
1.5
2
sinc
6-259
See Also chi r p Swept-frequency cosi ne generator.
cos Cosi ne of vector/matri x el ements (see MATLAB
Functi on Reference).
di r i c Di ri chl et or peri odi c si nc functi on.
gaus pul s Gaussi an-modul ated si nusoi dal pul se generator.
pul s t r an Pul se trai n generator.
r ect pul s Sampl ed aperi odi c rectangl e generator.
s awt oot h Sawtooth or tri angl e wave generator.
s i n Si ne of vector/matri x el ements (see MATLAB
Functi on Reference).
s quar e Square wave generator.
t r i pul s Sampl ed aperi odi c tri angl e generator.
sos2ss
6-260
sos2ss
Purpose Second-order secti on to state-space conversi on.
Syntax [ A, B, C, D] = s os 2s s ( s os )
Description s os 2s s 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] = s os 2s s ( s os ) converts the system s os , 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
where L i s the number of rows i n s os . s os i s a L-by-6 matri x organi zed as
The entri es of s os 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.
x n x n u n
y n x n u n
[ ] [ ] [ ]
[ ] [ ] [ ]
+ +
+
1 A B
C D
H z H z
b b z b z
a a z a z
k
k
L
k k k
k k k
k
L
( ) ( )
+ +
+ +


1
0 1
1
2
2
0 1
1
2
2
1

sos
b b b a a a
b b b a a a
b b b a a a
L L L L L L

1
]
1
1
1
1
01 11 21 01 11 21
02 12 22 02 12 22
0 1 2 0 1 2
M M M M M M
sos2ss
6-261
Example Compute the state-space representati on of a si mpl e second-order secti on form
system:
s os = [ 1 1 1 1 0 1; 2 3 1 1 10 1] ;
[ A, B, C, D] = s os 2s s ( s os )
A =
10. 8990 3. 1463 0 0
3. 1463 0 0 0
9. 8990 2. 8284 0. 8990 0. 3178
0 0 0. 3178 0
B =
1
0
1
0
C =
19. 7980 5. 6569 1. 2020 2. 5106
D =
2
Algorithm s os 2s s fi rst fi nds the zeros and pol es of the second-order secti ons usi ng r oot s ,
then uses z p2s s to fi nd a state-space representati on of the system.
See Also s os 2t f Second-order secti on to transfer functi on conversi on.
s os 2z p Second-order secti on to zero-pol e-gai n conversi on.
s s 2s os State-space to second-order secti on conversi on.
z p2s os Zero-pol e-gai n to second-order secti on conversi on.
sos2tf
6-262
sos2tf
Purpose Second-order secti on to transfer functi on conversi on.
Syntax [ b, a] = s os 2t f ( s os )
Description s os 2t f 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] = s os 2t f ( s os ) 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 s os i n second-order secti on form. The second-order secti on format of
H(z) i s gi ven by
where L i s the number of rows of s os . s os i s an L-by-6 matri x whi ch 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:
Algorithm s os 2t f 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.
H z H z
b b z b z
a a z a z
k
k
L
k k k
k k k
k
L
( ) ( )
+ +
+ +


1
0 1
1
2
2
0 1
1
2
2
1

sos
b b b a a a
b b b a a a
b b b a a a
L L L L L L

1
]
1
1
1
1
01 11 21 01 11 21
02 12 22 02 12 22
0 1 2 0 1 2
M M M M M M

H z
B z
A z
b b z b n z
a a z a m z
n
m
( )
( )
( )
( ) ( ) ( )
( ) ( ) ( )

+ + + +
+ + + +


1 2 1
1 2 1
1
1
L
L
sos2tf
6-263
Example Compute the transfer functi on representati on of a si mpl e second-order secti on
form system:
s os = [ 1 1 1 1 0 1; 2 3 1 1 10 1] ;
[ b, a] = s os 2t f ( s os )
b =
2 1 2 4 1
a =
1 10 0 10 1
See Also s os 2s s Second-order secti on to state-space conversi on.
s os 2z p Second-order secti on to zero-pol e-gai n conversi on.
s s 2s os State-space to second-order secti on conversi on.
z p2s os Zero-pol e-gai n to second-order secti on conversi on.
sos2zp
6-264
sos2zp
Purpose Second-order secti on to zero-pol e-gai n conversi on.
Syntax [ z , p, k] = s os 2z p( s os )
Description s os 2z p 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] = s os 2z p( s os ) returns the zeros z , pol es p, and gai n k of the system
gi ven by s os i n second-order secti on form. The second-order secti on format of
H(z) i s gi ven by
where L i s the number of rows of s os . s os i s an L-by-6 matri x whi ch 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 M are determi ned by the matri x s os .
H z H z
b b z b z
a a z a z
k
k
L
k k k
k k k
k
L
( ) ( )
+ +
+ +


1
0 1
1
2
2
0 1
1
2
2
1

sos
b b b a a a
b b b a a a
b b b a a a
L L L L L L

1
]
1
1
1
1
01 11 21 01 11 21
02 12 22 02 12 22
0 1 2 0 1 2
M M M M M M

H z k
z z z z z z N
p p p p p p M
( )
( ( ))( ( )) ( ( ))
( ( ))( ( )) ( ( ))



1 2
1 2
L
L
sos2zp
6-265
Example Compute the pol es, zeros, and gai n of a si mpl e system i n second-order secti on
form:
s os = [ 1 1 1 1 0 1; 2 3 1 1 10 1] ;
[ z , p, k] = s os 2z p( s os )
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 s os 2z p fi nds the roots and pol es of each second-order secti on usi ng the r oot s
command. s os 2z p returns the roots and pol es wi th conjugate pai rs i n consecu-
ti ve l ocati ons, wi th the order of the pai rs determi ned by thei r row i n the s os
matri x. The gai n k i s the product of the gai ns of the secti ons:
See Also s os 2s s Second-order secti on to state-space conversi on.
s os 2t f Second-order secti on to transfer functi on conversi on.
s s 2s os State-space to second-order secti on conversi on.
z p2s os Zero-pol e-gai n to second-order secti on conversi on.
k
b
a
k
k
k
L

0
0
1
specgram
6-266
specgram
Purpose Ti me-dependent frequency anal ysi s (spectrogram).
Syntax B = s pecgr am( a)
B = s pecgr am( a, nf f t )
[ B, f ] = s pecgr am( a, nf f t , Fs )
[ B, f , t ] = s pecgr am( a, nf f t , Fs )
B = s pecgr am( a, nf f t , Fs , wi ndow)
B = s pecgr am( a, nf f t , Fs , wi ndow, nov er l ap)
s pecgr am( a)
B = s pecgr am( a, f , Fs , wi ndow, nov er l ap)
Description s pecgr am 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 = s pecgr am( a) cal cul ates the spectrogram for the si gnal i n vector a. Thi s
syntax uses the defaul t val ues:
nf f t = mi n( 256, l engt h( a) )
Fs = 2
wi ndow = hanni ng( nf f t )
nov er l ap = l engt h( wi ndow) /2
nf f t speci fi es the FFT l ength that s pecgr am 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. wi ndow speci fi es a wi ndowi ng
functi on and the number of sampl es s pecgr am uses i n i ts secti oni ng of vector a.
nov er l ap i s the number of sampl es by whi ch the secti ons overl ap. Any argu-
ments 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 , s pecgr am computes the di screte-ti me Fouri er transform at posi ti ve
frequenci es onl y. I f n i s even, s pecgr am returns nf f t /2+1 rows (i ncl udi ng the
zero and Nyqui st frequency terms). I f n i s odd, s pecgr am returns nf f t /2 rows.
The number of col umns i n B i s
k = f i x ( ( nnov er l ap) /( l engt h( wi ndow) nov er l ap) )
I f a i s compl ex, s pecgr am 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 nf f t
specgram
6-267
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 = s pecgr am( a, nf f t ) uses the speci fi ed FFT l ength nf f t i n i ts cal cul ati ons.
Speci fy nf f t as a power of 2 for fastest executi on.
[ B, f ] = s pecgr am( a, nf f t , 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 ] = s pecgr am( a, nf f t , 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 = s pecgr am( a, nf f t , Fs , wi ndow) 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 wi ndow,
s pecgr am 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 nf f t ; s pecgr am zero pads the secti ons i f the l ength
of the wi ndow exceeds nf f t .
B = s pecgr am( a, nf f t , Fs , wi ndow, nov er l ap) overl aps the secti ons of x by
nov er l ap 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 = s pecgr am( x , [ ] , [ ] , [ ] , 10000)
i s equi val ent to
B = s pecgr am( x )
but wi th a sampl i ng frequency of 10,000 Hz i nstead of the defaul t 2 Hz.
s pecgr am wi th no output arguments di spl ays the scal ed l ogari thm of the spec-
trogram i n the current fi gure wi ndow usi ng
i mages c( t , f , 20*l og10( abs ( b) ) ) , ax i s x y , col or map( j et )
specgram
6-268
The ax i s x y 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. s pecgr am uses Fs to l abel the axes
accordi ng to true ti me and frequency.
B = s pecgr am( a, f , Fs , wi ndow, nov er l ap) 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 terbank. f i s a vector
of frequenci es i n Hertz; i t must have at l east two el ements.
Algorithm s pecgr am 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 wi ndow 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 nf f t FFT to produce an esti mate of the short-term frequency content
of the si gnal ; these transforms make up the col umns of B. s pecgr am zero
pads the wi ndowed secti ons i f nf f t > l engt h( wi ndow) , so the quanti ty
( l engt h( wi ndow) nov er l ap) speci fi es by how many sampl es s pecgr am
shi fts the wi ndow.
3 For real i nput, s pecgr am truncates the spectrogram to the fi rst nf f t /2 + 1
poi nts for nf f t even and ( nf f t + 1) /2 for nf f t odd.
specgram
6-269
Example Pl ot the spectrogram of a di gi ti zed speech si gnal :
l oad mt l b
s pecgr am( mt l b, 512, Fs , kai s er ( 500, 5) , 475)
Diagnostics An appropri ate di agnosti c message i s di spl ayed when i ncorrect arguments are
used:
Requi r es wi ndow' s l engt h t o be no gr eat er t han t he FFT l engt h.
Requi r es NOVERLAP t o be s t r i ct l y l es s t han t he wi ndow l engt h.
Requi r es pos i t i v e i nt eger v al ues f or NFFT and NOVERLAP.
Requi r es v ect or i nput .
See Also coher e Esti mate magni tude squared coherence functi on
between two si gnal s.
cs d Esti mate the cross spectral densi ty (CSD) of two
si gnal s.
ps d Esti mate the power spectral densi ty (PSD) of a
si gnal .
t f e Transfer functi on esti mate from i nput and output.
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
specgram
6-270
References [1] Oppenhei m, A.V., and R.W. Schafer. Discrete-Time Signal 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 Processing of Speech Signals.
Engl ewood Cl i ffs, NJ: Prenti ce Hal l , 1978.
sptool
6-271
sptool
Purpose I nteracti ve di gi tal si gnal processi ng tool .
Syntax s pt ool
Description The s pt ool 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 func-
ti 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 s pt ool , you can i mport, export, and manage si gnal s, fi l ters, and spectra.
From s pt ool , 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 ti me-domai n i n-
formati on of i mported si gnal s:
sptool
6-272
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, and band-
stop) confi gurati ons:
sptool
6-273
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-274
The Spectrum Viewer, 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 Wel chs meth-
od (PSD and CSD), the maxi mum entropy method (MEM), the mul ti taper
method (MTM), and the MUSI C ei genvector method:
s pt ool opens an empty si gnal , fi l ter, and spectrum management wi ndow. See
Chapter 5, I nteracti ve Tool s, for a ful l di scussi on of how to use s pt ool .
square
6-275
square
Purpose Square wave generator.
Syntax x = s quar e( t )
x = s quar e( t , dut y )
Description s quar e( t ) generates a square wave wi th peri od for the el ements of ti me
vector t . s quar e( t ) i s si mi l ar to s i n( t ) , but i t creates a square wave wi th
peaks of i nstead of a si ne wave.
s quar e( t , dut y ) generates a square wave wi th speci fi ed duty cycl e, dut y . The
duty cycle i s the percent of the peri od i n whi ch the si gnal i s posi ti ve.
See Also chi r p Swept-frequency cosi ne generator.
cos Cosi ne of vector/matri x el ements (see MATLAB
Functi on Reference).
di r i c Di ri chl et or peri odi c si nc functi on.
gaus pul s Gaussi an-modul ated si nusoi dal pul se generator.
pul s t r an Pul se trai n generator.
r ect pul s Sampl ed aperi odi c rectangl e generator.
s awt oot h Sawtooth or tri angl e wave generator.
s i n Si ne of vector/matri x el ements (see MATLAB
Functi on Reference).
s i nc Si nc or si n(t)/t functi on.
t r i pul s Sampl ed aperi odi c tri angl e generator.
2
1
ss2sos
6-276
ss2sos
Purpose State-space to second-order secti on conversi on.
Syntax s os = s s 2s os ( A, B, C, D)
s os = s s 2s os ( A, B, C, D, i u)
s os = s s 2s os ( A, B, C, D, ' or der ' )
s os = s s 2s os ( A, B, C, D, i u, ' or der ' )
Description s s 2s os converts a state-space representati on of a gi ven system to an equi va-
l ent second-order secti on representati on.
s os = s s 2s os ( A, B, C, D) fi nds a matri x s os i n second-order secti on form 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 i nput and real . s os 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):
s os = s s 2s os ( A, B, C, D, i u) speci fi es a scal ar i u that determi nes whi ch
output of the state-space system A, B, C, D i s used i n the conversi on. The defaul t
for i u i s 1.
s os = s s 2s os ( A, B, C, D, ' or der ' ) and
s os = s s 2s os ( A, B, C, D, i u, ' or der ' ) speci fy the order of the rows i n s os ,
where or der i s
down, to order the secti ons so the fi rst row of s os 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 s os contai ns the pol es farthest
from the uni t ci rcl e (defaul t)

sos
b b b a a a
b b b a a a
b b b a a a
L L L L L L

1
]
1
1
1
1
01 11 21 01 11 21
02 12 22 02 12 22
0 1 2 0 1 2
M M M M M M
H z H z
b b z b z
a a z a z
k
k
L
k k k
k k k
k
L
( ) ( )
+ +
+ +


1
0 1
1
2
2
0 1
1
2
2
1
ss2sos
6-277
Example Fi nd a second-order secti on form of a Butterworth l owpass fi l ter:
[ A, B, C, D] = but t er ( 5, 0. 2) ;
s os = s s 2s os ( A, B, C, D)
s os =
0. 2330 0. 2329 0 1. 0000 0. 5095 0
0. 0647 0. 1294 0. 0647 1. 0000 1. 0966 0. 3554
0. 0851 0. 1701 0. 0851 1. 0000 1. 3693 0. 6926
Algorithm s s 2s os uses a four-step al gori thm to determi ne the second-order secti on repre-
sentati on for an i nput state-space system:
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 z p2s os , whi ch fi rst groups the zeros and pol es i nto com-
pl ex conjugate pai rs usi ng the cpl x pai r functi on. z p2s os 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 rcl e wi th the zeros 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.
s s 2s os 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. s s 2s os normal l y orders the secti ons wi th pol es cl osest to the uni t ci r-
cl e l ast i n the cascade. You can tel l s s 2s os to order the secti ons i n the re-
verse order by speci fyi ng the ' down' fl ag.
Putti ng hi gh Q secti ons at the begi nni ng of the cascade, by speci fyi ng the
' down' fl ag, reduces the sensi ti vi ty of the fi l ter response to quanti zati on
noi se near those pol es. Putti ng hi gh Q secti ons at the end of the cascade
(the defaul t) prevents reducti on i n si gnal power l evel earl y i n the cascade.
s s 2s os orders al l -zero secti ons accordi ng to the mi ni mum of | z
i
| and | z
i
-1
| ,
ss2sos
6-278
where z
i
, i = 1, 2, are the zeros i n the secti on.References [1] and [2] provi de
a detai l ed di scussi on of secti on orderi ng.
4 s s 2s os scal es the secti ons so the maxi mum of the magni tude of the transfer
functi on of the fi rst N secti ons i n cascade i s l ess than 1:
subject to the constrai nt that the overal l gai n, k, stays the same:
Thi s scal i ng i s an attempt to mi ni mi ze overfl ow i n some standard fi xed poi nt
i mpl ementati ons of fi l teri ng.
Diagnostics I f there i s more than one i nput to the system, s s 2s os gi ves the fol l owi ng error
message:
St at es pace s y s t em mus t hav e onl y one i nput .
See Also
References [1] Oppenhei m, A.V., and R.W. Schafer. Discrete-Time Signal Processing.
Engl ewood Cl i ffs, NJ: Prenti ce Hal l , 1989. Pgs. 363-370.
[2] Jackson, L.B. Digital Filters and Signal Processing. Second Ed. Boston:
Kl uwer Academi c Publ i shers, 1989. Pgs. 319-324.
s os 2s s Second-order secti on to state-space conversi on.
s os 2t f Second-order secti on to transfer functi on conversi on.
s os 2z p Second-order secti on to zero-pol e-gai n conversi on.
z p2s os Zero-pol e-gai n to second-order secti on conversi on.
max
( ) , , ...,

<

H e N L
i
j
i
N
1
1 1 1
k
b
a
k
k
k
L

0
0
1
ss2tf
6-279
ss2tf
Purpose State-space to transfer functi on conversi on.
Syntax [ num, den] = s s 2t f ( a, b, c, d, i u)
Description s s 2t f converts a state-space representati on of a gi ven system to an equi val ent
transfer functi on representati on.
[ num, den] = s s 2t f ( a, b, c, d, i u) returns the transfer functi on
of the system
from the i u-th i nput. Vector den 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 num
wi th as many rows as there are outputs y. The functi on t f 2s s i s the i nverse of
s s 2t f . s s 2t f 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.
Algorithm s s 2t f uses pol y to fi nd the characteri sti c pol ynomi al det(sI -A) and the equal i ty
See Also s s 2z p State-space to zero-pol e-gai n conversi on.
t f 2s s Transfer functi on to state-space conversi on.
t f 2z p Transfer functi on to zero-pol e-gai n conversi on.
z p2s s Zero-pol e-gai n to state-space conversi on.
z p2t f Zero-pol e-gai n to transfer functi on conversi on.
H s
num s
den s
C sI A B D ( )
( )
( )
( ) +
1
x Ax Bu
y Cx Du
+
+
H s c sI A b
sI A bc sI A
sI A
( ) ( )
det( ) det( )
det( )

+

1
ss2zp
6-280
ss2zp
Purpose State-space to zero-pol e-gai n conversi on.
Syntax [ Z, p, k] = s s 2z p( A, B, C, D, i u)
Description s s 2z p 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] = s s 2z p( A, B, C, D, i u) cal cul ates the transfer functi on i n factored
form
of the system
from the i u-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. Array 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.
The functi on z p2s s i s the i nverse of s s 2z p. s s 2z p 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 .
Example Here are two ways of fi ndi ng the zeros, pol es, and gai ns of a system:
num = [ 2 3] ;
den = [ 1 0. 4 1] ;
[ z , p, k] = t f 2z p( num, den)
z =
1. 5000

H s
z s
p s
k
s z s z s z n
s p s p s p n
( )
( )
( )
( ( ))( ( )) ( ( ))
( ( ))( ( )) ( ( ))



1 2
1 2
L
L
x Ax Bu
y Cx Du
+
+
ss2zp
6-281
p =
0. 2000 + 0. 9798i
0. 2000 0. 9798i
k =
2
[ A, B, C, D] = t f 2s s ( num, den) ;
[ z , p, k] = s s 2z p( A, B, C, D, 1)
z =
1. 5000
p =
0. 2000 + 0. 9798i
0. 2000 0. 9798i
k =
2
Algorithm s s 2z p 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 = ei g( [ A B; C D] , di ag( [ 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.
s s 2z p i nterprets these l arge zeros as i nfi ni te.
s s 2z p fi nds the gai ns by sol vi ng for the fi rst nonzero Markov parameters.
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.
s s 2t f State-space to transfer functi on conversi on.
t f 2s s Transfer functi on to state-space conversi on.
z p2s s Zero-pol e-gai n to state-space conversi on.
stmcb
6-282
stmcb
Purpose Li near model usi ng Stei gl i tz-McBri de i terati on.
Syntax [ b, a] = s t mcb( x , nb, na)
[ b, a] = s t mcb( x , u, nb, na)
[ b, a] = s t mcb( x , nb, na, ni t er )
[ b, a] = s t mcb( x , u, nb, na, ni t er )
[ b, a] = s t mcb( x , nb, na, ni t er , ai )
[ b, a] = s t mcb( x , u, nb, na, ni t er , 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] = s t mcb( 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] = s t mcb( 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] = s t mcb( x , nb, na, ni t er ) and
[ b, a] = s t mcb( x , u, nb, na, ni t er ) use ni t er i terati ons. The defaul t for
ni t er i s 5.
[ b, a] = s t mcb( x , nb, na, ni t er , ai ) and
[ b, a] = s t mcb( x , u, nb, na, ni t er , 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, s t mcb uses the
output argument from [ b, ai ] = pr ony ( x , 0, na) as the vector ai .
s t mcb 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 b z b nb z
a a z a na z
nb
na
( )
( )
( )
( ) ( ) ( )
( ) ( ) ( )

+ + + +
+ + + +


1 2 1
1 2 1
1
1
L
L
stmcb
6-283
Example Approxi mate the i mpul se response of a Butterworth fi l ter wi th a system of
l ower order:
[ b, a] = but t er ( 6, 0. 2) ;
h = f i l t er ( b, a, [ 1 z er os ( 1, 100) ] ) ;
f r eqz ( b, a, 128)
[ bb, aa] = s t mcb( h, 4, 4) ;
f r eqz ( bb, aa, 128)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-600
-400
-200
0
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
100
Normalized frequency (Nyquist == 1)
M
a
g
n
i
t
u
d
e

R
e
s
p
o
n
s
e

(
d
B
)
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
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
-60
-40
-20
0
20
Normalized frequency (Nyquist == 1)
M
a
g
n
i
t
u
d
e

R
e
s
p
o
n
s
e

(
d
B
)
stmcb
6-284
Algorithm s t mcb 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 :
s t mcb 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 \.
s t mcb repeats thi s process ni t er 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 ni t er i terati ons.
Diagnostics I f x and u have di fferent l engths, s t mcb gi ves the fol l owi ng error message:
X and U mus t hav e s ame l engt h.
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. System I dentification: Theory for the User. Engl ewood Cl i ffs, NJ:
Prenti ce Hal l , 1987. Pg. 297.
l pc Li near predi cti on coefci ents.
oe Compute the predi cti on error esti mate of an
output-error model (see System I dentification
Toolbox Users Manual).
pr ony Pronys method for ti me domai n I I R l ter desi gn.
min | ( ) ( ) |
, a b
i
x i x i

2
0
strips
6-285
stri ps
Purpose Stri p pl ot.
Syntax s t r i ps ( x )
s t r i ps ( x , n)
s t r i ps ( x , s d, Fs )
s t r i ps ( x , s d, Fs , s cal e)
Description s t r i ps ( x ) pl ots vector x i n hori zontal stri ps of l ength 250. I f x i s a matri x,
s t r i ps ( 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.
s t r i ps ( x , n) pl ots vector x i n stri ps that are each n sampl es l ong.
s t r i ps ( x , s d, Fs ) pl ots vector x i n stri ps of durati on s d seconds, gi ven a
sampl i ng frequency of Fs sampl es per second.
s t r i ps ( x , s d, Fs , s cal e) scal es the verti cal axes.
I f x i s a matri x, s t r i ps ( x , n) , s t r i ps ( x , s d, Fs ) , and s t r i ps ( x , s d, Fs , s cal e)
pl ot the di fferent col umns of x on the same stri p pl ot.
s t r i ps i gnores the i magi nary part of x i f i t i s compl ex.
strips
6-286
Example Pl ot two seconds of a frequency modul ated si nusoi d i n 0.25 second stri ps:
Fs = 1000; % s ampl i ng f r equency
t = 0: 1/Fs : 2; % t i me v ect or
x = v co( s i n( 2*pi *t ) , [ 10 490] , Fs ) ; % FM wav ef or m
s t r i ps ( x , 0. 25, Fs )
See Also pl ot Li near 2-D pl ot (see MATLAB Functi on Reference).
s t em Pl ot di screte sequence data (see MATLAB Functi on
Reference).
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
tf2latc
6-287
tf2l atc
Purpose Transfer functi on to l atti ce fi l ter conversi on.
Syntax [ k, v ] = t f 2l at c( num, den)
k = t f 2l at c( 1, den)
[ k, v ] = t f 2l at c( 1, den)
k = t f 2l at c( num)
Description [ k, v ] = t f 2l at c( num, den) 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 den( 1) .
Note that an error wi l l be generated i f any pol es of the transfer functi on l i e on
the uni t ci rcl e.
k = t f 2l at c( 1, den) 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 ] = t f 2l at c( 1, den) returns a scal ar l adder coeffi ci ent v .
k = t f 2l at c( num) fi nds the l atti ce parameters k for an FI R (MA) l atti ce fi l ter,
normal i zed by num( 1) .
The functi on l at c2t f i s the i nverse of t f 2l at c.
See Also l at c2t f Latti ce l ter to transfer functi on conversi on.
l at cf i l t Latti ce and l atti ce-l adder l ter i mpl ementati on.
pol y 2r c Reecti on coefci ents from pol ynomi al coefci ents.
r c2pol y Pol ynomi al coefci ents from reecti on coefci ents.
tf2ss
6-288
tf2ss
Purpose Transfer functi on to state-space conversi on.
Syntax [ A, B, C, D] = t f 2s s ( num, den)
Description t f 2s s 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] = t f 2s s ( num, den) 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 den contai ns the denomi nator coeffi ci ents i n
descendi ng powers of s. Array num contai ns the numerator coeffi ci ents wi th as
many rows as there are outputs y. t f 2s s returns the A, B, C, and D matri ces i n
control l er canoni cal form.
t f 2s s 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 functi on s s 2t f i s the i nverse of t f 2s s .
Example Consi der the system
To convert thi s system to state-space:
num = [ 0 2 3; 1 2 1] ;
den = [ 1 0. 4 1] ;
[ A, B, C, D] = t f 2s s ( num, den)
x Ax Bu
y Cx Du
+
+
H s
num s
den s
C sI A B D ( )
( )
( )
( ) +
1
H s
s
s s
s s
( )
.

+
+ +

1
]
1
+ +
2 3
2 1
0 4 1
2
2
tf2ss
6-289
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 canon-
i 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 = f l i pl r ( ey e( n) ) ;
A = T\A*T;
Algorithm t f 2s s wri tes the output i n control l er canoni cal form by i nspecti on.
See Also s s 2t f State-space to transfer functi on conversi on.
s s 2z p State-space to zero-pol e-gai n conversi on.
t f 2z p Transfer functi on to zero-pol e-gai n conversi on.
z p2s s Zero-pol e-gai n to state-space conversi on.
z p2t f Zero-pol e-gai n to transfer functi on conversi on.
tf2zp
6-290
tf2zp
Purpose Transfer functi on to zero-pol e-gai n conversi on.
Syntax [ z , p, k] = t f 2z p( num, den)
Description t f 2z p fi nds the zeros, pol es, and gai ns of a system i n pol ynomi al transfer func-
ti on form.
[ z , p, k] = t f 2z p( num, den) 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 den speci fi es the coeffi ci ents of the denomi nator i n descendi ng powers
of s. Matri x num 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 num. 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.
t f 2z p al so works for di screte systems. The functi on z p2t f i s the i nverse of
t f 2z p.

H s
Z s
p s
k
s Z s Z s Z m
s p s p s p n
( )
( )
( )
( ( ))( ( )) ( ( ))
( ( ))( ( )) ( ( ))



1 2
1 2
K
K

num s
den s
num s num nn s num nn
den s den nd s den nd
nn
nd
( )
( )
( ) ( ) ( )
( ) ( ) ( )

+ + +
+ + +

1 1
1 1
1
1
L
L
tf2zp
6-291
Example Fi nd the zeros, pol es, and gai ns of the system
num = [ 2 3] ;
den = [ 1 0. 4 1] ;
[ z , p, k] = t f 2z p( num, den)
z =
1. 5000
p =
0. 2000 + 0. 9798i
0. 2000 0. 9798i
k =
2
Algorithm The system i s converted to state-space usi ng t f 2s s and then to zeros, pol es,
and gai ns usi ng s s 2z p.
See Also s s 2t f State-space to transfer functi on conversi on.
s s 2z p State-space to zero-pol e-gai n conversi on.
t f 2s s Transfer functi on to state-space conversi on.
z p2s s Zero-pol e-gai n to state-space conversi on.
z p2t f Zero-pol e-gai n to transfer functi on conversi on.
H s
s
s s
( )
.

+
+ +
2 3
0 4 1
2
tfe
6-292
tfe
Purpose Transfer functi on esti mate from i nput and output.
Syntax Tx y = t f e( x , y )
Tx y = t f e( x , y , nf f t )
[ Tx y , f ] = t f e( x , y , nf f t , Fs )
Tx y = t f e( x , y , nf f t , Fs , wi ndow)
Tx y = t f e( x , y , nf f t , Fs , wi ndow, nov er l ap)
Tx y = t f e( x , y , . . . , ' df l ag' )
t f e( x , y )
Description Tx y = t f e( x , y ) fi nds a transfer functi on esti mate Tx y 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 Tx y .
Vectors x and y must be the same l ength. Tx y = t f e( x , y ) uses the fol l owi ng
defaul t val ues:
nf f t = mi n( 256, ( l engt h( x ) )
Fs = 2
wi ndow = hanni ng( nf f t )
nov er l ap = 0
nf f t speci fi es the FFT l ength that t f e 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 spec-
i fi es the sampl i ng frequency. wi ndow speci fi es a wi ndowi ng functi on and the
number of sampl es t f e uses i n i ts secti oni ng of the x and y vectors. nov er l ap
i s the number of sampl es by whi ch the secti ons overl ap. Any arguments that
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 , t f e esti mates the transfer functi on at posi ti ve frequenci es onl y; i n
thi s case, the output Tx y i s a col umn vector of l ength nf f t /2+1 for nf f t even
and ( nf f t +1) /2 for n odd. I f x or y i s compl ex, t f e esti mates the transfer func-
ti on for both posi ti ve and negati ve frequenci es and Tx y has l ength nf f t .
T f
P f
P f
xy
xy
xx
( )
( )
( )

tfe
6-293
Tx y = t f e( x , y , nf f t ) uses the speci fi ed FFT l ength nf f t i n esti mati ng the
transfer functi on. Speci fy nf f t as a power of 2 for fastest executi on.
[ Tx y , f ] = t f e( x , y , nf f t , Fs ) returns a vector f of frequenci es at whi ch t f e
esti mates the transfer functi on. Fs i s the sampl i ng frequency. f i s the same si ze
as Tx y , so pl ot ( f , Tx y ) pl ots the transfer functi on esti mate versus properl y
scal ed frequency. Fs has no effect on the output Tx y ; i t i s a frequency scal i ng
mul ti pl i er.
Tx y = t f e( x , y , nf f t , Fs , wi ndow) 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 wi ndow,
Tx y 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 nf f t ; t f e zero pads the secti ons i f the l ength of the wi ndow
exceeds nf f t .
Tx y = t f e( x , y , nf f t , Fs , wi ndow, nov er l ap) overl aps the secti ons of x by
nov er l ap 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,
Tx y = t f e( x , y , [ ] , [ ] , kai s er ( 128, 5) )
uses 256 as the val ue for nf f t and 2 as the val ue for Fs .
Tx y = t f e( x , y , . . . , ' df l ag' ) speci fi es a detrend opti on, where df l ag i s
l i near , 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 df l ag parameter must appear l ast i n the l i st of i nput arguments. t f e
recogni zes a df l ag stri ng no matter how many i ntermedi ate arguments are
omi tted.
t f e 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-294
Example Compute and pl ot the transfer functi on esti mate between two col ored noi se
sequences x and y :
h = f i r 1( 30, 0. 2, box car ( 31) ) ;
x = r andn( 16384, 1) ;
y = f i l t er ( h, 1, x ) ;
t f e( x , y , 1024, [ ] , [ ] , 512)
Algorithm t f e uses a four-step al gori thm:
1 I t mul ti pl i es the detrended secti ons by wi ndow.
2 I t takes the l ength nf f t FFT of each secti on.
3 I t averages the squares of the spectra of the x secti ons to form Px x and av-
erages the products of the spectra of the x and y secti ons to form Px y .
4 I t cal cul ates Tx y :
Tx y = Px y . /Px x
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Frequency
Transfer Function Estimate
tfe
6-295
Diagnostics An appropri ate di agnosti c message i s di spl ayed when i ncorrect arguments are
used:
Requi r es wi ndow' s l engt h t o be no gr eat er t han t he FFT l engt h.
Requi r es NOVERLAP t o be s t r i ct l y l es s t han t he wi ndow l engt h.
Requi r es pos i t i v e i nt eger v al ues f or NFFT and NOVERLAP.
Requi r es v ect or ( ei t her r ow or col umn) i nput .
Requi r es i nput s X and Y t o hav e t he s ame l engt h.
See Also et f e Compute empi ri cal transfer functi on esti mate and
peri odogram (see System I dentification Toolbox
Users Guide).
coher e Esti mate magni tude squared coherence functi on
between two si gnal s.
cs d Esti mate the cross spectral densi ty (CSD) of two
si gnal s.
ps d Esti mate the power spectral densi ty (PSD) of a
si gnal .
s pa Perform spectral anal ysi s for i nput-output data (see
System I dentification Toolbox Users Guide).
triang
6-296
tri ang
Purpose Tri angul ar wi ndow.
Syntax w = t r i ang( n)
Description t r i ang( 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
t r i ang( n2) are equi val ent to bar t l et t ( n) .
See Also bar t l et t Bartl ett wi ndow.
bl ackman Bl ackman wi ndow.
box car Rectangul ar wi ndow.
chebwi n Chebyshev wi ndow.
hammi ng Hammi ng wi ndow.
hanni ng Hanni ng wi ndow.
kai s er Kai ser wi ndow.
w k
k
n
k
n
n k
n
n
k n
[ ]
,
( )
,

+

+
+
+
+

'

2
1
1
1
2
2 1
1
1
2
w k
k
n
k
n
n k
n
n
k n
[ ]
,
( )
,


+
+

'

2 1
1
2
2 1
2
1
tripuls
6-297
tri pul s
Purpose Sampl ed aperi odi c tri angl e generator.
Syntax y = t r i pul s ( T)
y = t r i pul s ( T, w)
y = t r i pul s ( T, w, s )
Description y = t r i pul s ( 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 = t r i pul s ( T, w) generates a tri angl e of wi dth w.
y = t r i pul s ( T, w, s ) generates a tri angl e wi th skew s , where
1 < s < 1. When s i s 0, a symmetri c tri angl e i s generated.
See Also chi r p Swept-frequency cosi ne generator.
cos Cosi ne of vector/matri x el ements (see MATLAB
Functi on Reference).
di r i c Di ri chl et or peri odi c si nc functi on.
gaus pul s Gaussi an-modul ated si nusoi dal pul se generator.
pul s t r an Pul se trai n generator.
r ect pul s Sampl ed aperi odi c rectangl e generator.
s awt oot h Sawtooth or tri angl e wave generator.
s i n Si ne of vector/matri x el ements (see MATLAB
Functi on Reference).
s i nc Si nc or si n(t)/t functi on.
s quar e Square wave generator.
unwrap
6-298
unwrap
Purpose Unwrap phase angl es.
Syntax p = unwr ap( p)
Description p = unwr ap( 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, unwr ap corrects the phase angl es down each col umn. The phase must
be i n radi ans.
Thi s functi on i s part of the standard MATLAB envi ronment.
Limitations unwr ap 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 angl e Phase angl e.
2
upfirdn
6-299
upfi rdn
Purpose Appl y FI R fi l ter and perform sampl e rate conversi on.
Syntax y out = upf i r dn( x i n, h)
y out = upf i r dn( x i n, h, p)
y out = upf i r dn( x i n, h, p, q)
Description upf i r dn 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)
upf i r dn 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 r emez or f i r 1.
NOTE The functi on r es ampl e performs an FI R desi gn usi ng f i r 1, fol l owed by
rate changi ng i mpl emented wi th upf i r dn.
y out = upf i r dn( x i n, h) returns the output si gnal y out . I f y out i s a row or
col umn vector, then i t represents one si gnal ; i f y out i s an array, then each
col umn i s a separate output. x i n i s the i nput si gnal . I f x i n i s a row or col umn
vector, then i t represents one si gnal ; i f x i n 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 sepa-
rate i mpul se response.
y out = upf i r dn( x i n, h, p) speci fi es the upsampl i ng factor p. p i s an i nteger
wi th a defaul t of 1.
y out = upf i r dn( x i n, 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-300
NOTE Si nce upf i r dn performs convol uti on and rate changi ng, the y out
si gnal s have a di fferent l ength than x i n. 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 x i n 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 x i n 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 x i n wi th h. The
output si gnal y out i s a row vector i f x i n i s a row; otherwi se, i t i s a col umn
vector.
2 x i n 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 x i n. The resul ti ng y out wi l l be an array wi th the same number of
col umns as x i n.
3 x i n 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 x i n. The resul ti ng y out wi l l be an array wi th the same number of
col umns as h.
4 x i n 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 corre-
spondi ng col umns of x i n and h. The resul ti ng y out i s an array wi th the same
number of col umns as x i n 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 ):
y y = upf i r dn( x x , 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:
% As s ume t hat hh i s an L- by - 7 ar r ay of f i l t er s .
y y = upf i r dn( x x , hh, 1, 5) ;
upfirdn
6-301
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:
% Des i gn l owpas s f i l t er wi t h cut of f at 1/160t h of Fs .
hh = f i r 1( 300, 2/160) ; % need a v er y l ong l owpas s f i l t er
y y = upf i r dn( x x , hh, 160, 147) ;
I n thi s exampl e, the fi l ter desi gn and resampl i ng are separate steps. Note that
r es ampl e woul d do both steps as one.
Algorithm upf i r dn 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 are vi ol ated, upf i r dn gi ves the appropri ate error message:
UPFI RDN needs at l eas t t wo i nput ar gument s .
UPFI RDN s houl d hav e ex act l y one out put ar gument .
I f the arrays are sparse, upf i r dn gi ves the error message
H mus t be f ul l numer i c mat r i x .
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, upf i r dn gi ves the error message
X and H mus t hav e t he s ame number of col umns , i f mor e t han one.
The arguments p and q must be i ntegers. I f they are not, upf i r dn gi ves the
error message
P and/or Q mus t be gr eat er t han z er o
I f the arguments p and q are not rel ati vel y pri me, upf i r dn gi ves the warni ng
message
WARNI NG ( upf i r dn) p & q hav e common f act or
upfirdn
6-302
See Also
References [1] Crochi ere, R.E., and L.R. Rabi ner. Multi-Rate Signal Processing. Engl e-
wood 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.
deci mat e Decrease the sampl i ng rate for a sequence
(deci mati on).
f i l t er Fi l ter data wi th a recursi ve (I I R) or nonrecursi ve
(FI R) l ter.
i nt er p I nterpol ati on FI R l ter desi gn.
r es ampl e Change sampl i ng rate by any factor.
vco
6-303
vco
Purpose Vol tage control l ed osci l l ator.
Syntax y = v co( x , Fc, Fs )
y = v co( x , [ Fmi n Fmax ] , Fs )
Description y = v co( 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 ranges from -1 to 1, where -1 corresponds to a 0 frequency
output, 0 to Fc, and 1 to 2*Fc. y i s the same si ze as x .
y = v co( x , [ Fmi n 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 Fmi n Hz and Fmax Hz respecti vel y. For
best resul ts, Fmi n 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, v co 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 = v co( s awt oot h( 2*pi *t , 0. 75) , [ . 1 0. 4] *Fs , Fs ) ;
vco
6-304
Pl ot the spectrogram of the generated si gnal .
s pecgr am( x , 512, Fs , kai s er ( 256, 5) , 220)
Algorithm v co performs FM modul ati on usi ng the modul at e functi on.
Diagnostics I f any val ues of x l i e outsi de [-1,1], v co gi ves the fol l owi ng error message:
X out s i de of r ange [ 1, 1] .
See Also demod Demodul ati on for communi cati ons si mul ati on.
modul at e Modul ati on for communi cati ons si mul ati on.
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
xcorr
6-305
xcorr
Purpose Cross-correl ati on functi on esti mate.
Syntax c = x cor r ( x , y )
c = x cor r ( x )
c = x cor r ( x , y , ' opt i on' )
c = x cor r ( x , y , max l ags )
c = x cor r ( x , y , max l ags , ' opt i on' )
[ c, l ags ] = x cor r ( x , y )
[ c, l ags ] = x cor r ( x , y , max l ags )
[ c, l ags ] = x cor r ( x , y , max l ags , ' opt i on' )
Description x cor r esti mates the cross-correl ati on sequence of random processes. Autocor-
rel 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. x cor r must esti mate the sequence because, i n prac-
ti 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.
c = x cor r ( 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.
c = x cor r ( x ) i s the autocorrel ati on sequence for the vector x . Where x i s an
N-by-P matri x, c = x cor r ( X) returns 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.
By defaul t, x cor r computes raw correl ati ons wi th no normal i zati on. For a
l ength N vector:

xy n n m
m E x y ( )
*

{ } +
n < <
c m
x y m
c m m
xy
n n m
n
N m
yx
( )
( )
*
| |
*

<

'

+ + +

1 1
0
1
0
0
xcorr
6-306
The output vector c has el ements gi ven by c(m) = c
xy
(m-N), m=1,...,2N-1.
The correl ati on functi on requi res normal i zati on to esti mate the functi on prop-
erl y.
c = x cor r ( x , y , ' opt i on' ) speci fi es a scal i ng opti on, where ' opt i on' i s
bi as ed, for bi ased esti mates of the cross-correl ati on functi on:
unbi as ed, for unbi ased esti mates of the cross-correl ati on functi on:
coef f , to normal i ze the sequence so the autocorrel ati ons at zero l ag are i den-
ti 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, l ags ] = x cor r ( x , y ) where x and y are l ength N vectors, returns the
cross-correl ati on sequence i n a l ength 2N1 vector and the output l ags i n the
vector [ N+1: N1] . That i s, the maxi mum l ag i s N1.
[ c, l ags ] = x cor r ( x , y , max l ags ) where x and y are l ength N vectors, returns
the cross-correl ati on sequence i n a l ength 2*max l ags +1 vector c. l ags i s a
vector of the l ag i ndi ces where c was esti mated, that i s, [ max l ags : max l ags ] .
[ c, l ags ] = x cor r ( x , max l ags ) returns the autocorrel ati on sequence over the
l ag range [ max l ags : max l ags ] .
[ c, l ags ] = x cor r ( X, max l ags ) where x i s an M-by-P matri x, i s a matri x wi th
2*max l ags +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, l ags ] = x cor r ( x , max l ags , ' opt i on' ) and
c m
N
c m
xy biased xy ,
( ) ( )
1
c m
N m
c m
xy unbiased xy ,
( ) ( )

1
xcorr
6-307
[ c, l ags ] = x cor r ( x , y , max l ags , ' opt i on' ) speci fi es both a maxi mum
number of l ags and a scal i ng opti on.
I n al l cases, x cor r gi ves an output such that the zeroth l ag of the correl ati on
vector i s i n the mi ddl e of the sequence, at el ement or row max l ags +1 or at N.
Examples The second output l ags i s useful when pl otti ng. 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 = r andn( 1000, 1) ;
[ c_ww, l ags ] = x cor r ( ww, 10, ' coef f ' ) ;
s t em( l ags , 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 property (mat 2s t r i s used for a compact di spl ay of compl ex numbers):
x = [ 1, 2i , 3] ; y = [ 4, 5, 6] ;
[ c1, l ags ] = x cor r ( x , y ) ;
c1 = mat 2s t r ( c1, 2) , l ags
c1 =
[ 12+i *4. 2e16 15i *8 22i *10 5i *12 6i *1. 4e15]
l ags =
2 1 0 1 2
c2 = conj ( f l i pl r ( x cor r ( y , x ) ) ) ;
c2 = mat 2s t r ( c2, 2)
c2 =
[ 12+i *4. 2e16 15i *8 22i *10 5i *12 6i *1. 4e15]
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-308
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
r andn( ' s eed' , 0)
X = r andn( 2, 2) ;
[ M, P] = s i z e( X) ;
c = x cor r ( X) ;
c0 = z er os ( P) ; c0( : ) = c( M, : ) % Ex t r act z er o- l ag r ow
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 func-
ti on cor r coef generates by substi tuti ng
c = x cov ( X, ' coef ' )
i n the l ast exampl e. The functi on x cov subtracts the mean and then cal l s
x cor r .
Use f f t s hi f t to move the second hal f of the sequence starti ng at the zeroth l ag
to the front of the sequence. f f t s hi f t 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, x cor r gi ves the
fol l owi ng error message:
1s t ar g mus t be a v ect or or mat r i x .
The stri ng ' opt i on' must be the l ast argument; otherwi se, x cor r gi ves the
fol l owi ng error message:
Ar gument l i s t not i n cor r ect or der .
I f the second argument was entered as a scal ar, i t i s taken to be max l ag 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-309
a scal ar or a stri ng. I f they are not, x cor r gi ves the appropri ate error
message(s):
3r d ar g i s max l ag, 2nd ar g cannot be s cal ar .
When b i s a v ect or , a mus t be a v ect or .
Max l ag mus t be a s cal ar .
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, x cor r gi ves the
fol l owi ng error message:
OPTI ON mus t be ' none' f or di f f er ent l engt h v ect or s A and B.
See Also
References [1] Bendat, J.S., and A.G. Pi ersol . Random Data: 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.
cor r coef Correl ati on coefci ent matri x.
cov Covari ance matri x.
x cor r 2 Two-di mensi onal cross-correl ati on.
x cov Cross-covari ance functi on esti mate (equal to
mean-removed cross-correl ati on).
xcorr2
6-310
xcorr2
Purpose Two-di mensi onal cross-correl ati on.
Syntax C = x cor r 2( A)
C = x cor r 2( A, B)
Description C = x cor r 2( A, B) returns the cross-correl ati on of matri ces A and B wi th no
scal i ng. x cor r 2 i s the two-di mensi onal versi on of x cor r . 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.
x cor r 2( A) i s the autocorrel ati on matri x of i nput matri x A. I t i s i denti cal to
x cor r 2( A, A) .
See Also conv 2 Two-di mensi onal convol uti on.
f i l t er 2 Two-di mensi onal di gi tal l teri ng.
x cor r Cross-correl ati on functi on esti mate.
xcov
6-311
xcov
Purpose Cross-covari ance functi on esti mate (equal to mean-removed cross-correl ati on).
Syntax v = x cov ( x , y )
v = x cov ( x )
v = x cov ( x , ' opt i on' )
[ c, l ags ] = x cov ( x , y , max l ags )
[ c, l ags ] = x cov ( x , max l ags )
[ c, l ags ] = x cov ( x , y , max l ags , ' opt i on' )
Description x cov esti mates the cross-covari ance sequence of random processes. Autocova-
ri 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. x cov 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 = x cov ( 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 = x cov ( x ) i s the autocovari ance sequence for the vector x . Where x i s an
N-by-P array, v = x cov ( 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, x cov computes raw covari ances wi th no normal i zati on. For a l ength
N vector:

xy n x n m y
m E x m y m ( ) ( )( )
*

{ } +
c m
x n
N
x y
N
y m
c m m
xy
i
i
N
n m i
i
N
n
N m
yx
( )
( )
( )
* *
| |
*

_
,

_
,


<

'



1 1
0
0
0
1
0
1
0
1
xcov
6-312
The output vector c has el ements gi ven by c(m) = c
xy
(m-N), m=1,...,2N-1.
The covari ance functi on requi res normal i zati on to esti mate the functi on prop-
erl y.
v = x cov ( x , ' opt i on' ) speci fi es a scal i ng opti on, where opt i on i s
bi as ed, for bi ased esti mates of the cross-covari ance functi on
unbi as ed, for unbi ased esti mates of the cross-covari ance functi on
coef f , 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 a-
ti on and covari ance esti mates.
[ c, l ags ] = x cov ( x , y , max l ags ) where x and y are l ength m vectors, returns
the cross-covari ance sequence i n a l ength 2*max l ags +1 vector c. l ags i s a
vector of the l ag i ndi ces where c was esti mated, that i s, [ max l ags : max l ags ] .
[ c, l ags ] = x cov ( x , max l ags ) i s the autocovari ance sequence over the range
of l ags [ max l ags : max l ags ] .
[ c, l ags ] = x cov ( x , max l ags ) where x i s an m-by-p array, returns array c
wi th 2*max l ags +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, l ags ] = x cov ( x , y , max l ags , ' opt i on' ) speci fi es a scal i ng opti on, where
opt i on i s the l ast i nput argument.
I n al l cases, x cov 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 max l ag+1 or at m.
Examples The second output l ags 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 = r andn( 1000, 1) % gener at e uni f or m noi s e wi t h mean = 1/2
[ cov _ww, l ags ] = x cov ( ww, 10, ' coef f ' ) ;
s t em( l ags , cov _ww)
xcov
6-313
Algorithm x cov computes the mean of i ts i nputs, subtracts the mean, and then cal l s
x cor r . For more i nformati on on esti mati ng covari ance and correl ati on func-
ti ons, see [1] and [2].
Diagnostics x cov does not check for any errors other than the correct number of i nput argu-
ments. I nstead, i t rel i es on the error checki ng i n x cor r , whi ch i t cal l s.
See Also
References [1] Bendat, J.S., and A.G. Pi ersol . Random Data: 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.
cor r coef Correl ati on coefci ent matri x.
cov Covari ance matri x.
x cor r Cross-correl ati on functi on esti mate.
x cor r 2 Two-di mensi onal cross-correl ati on.
yulewalk
6-314
yul ewal k
Purpose Recursi ve di gi tal fi l ter desi gn.
Syntax [ b, a] = y ul ewal k( n, f , m)
Description y ul ewal k desi gns recursi ve I I R di gi tal fi l ters usi ng a l east-squares fi t to a spec-
i fi ed frequency response.
[ b, a] = y ul ewal k( 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
approxi 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 frequen-
cy).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, corre-
spondi 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.
pl ot ( 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.

B z
A z
b b z b n z
a a z a n z
n
n
( )
( )
( ) ( ) ( )
( ) ( ) ( )

+ + + +
+ + + +


1 2 1
1 2 1
1
1
L
L
yulewalk
6-315
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, a] = y ul ewal k( 8, f , m) ;
[ h, w] = f r eqz ( b, a, 128) ;
pl ot ( f , m, w/pi , abs ( h) , ' ' )
Algorithm y ul ewal k 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 a-
ti on coeffi ci ents computed by i nverse Fouri er transformati on of the speci fi ed
frequency response. To compute the numerator, y ul ewal k 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 re-
sponse.
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-316
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 Aerospace Electronic Systems.
AES-20, No. 2 (March 1984). Pgs. 158-173.
but t er Butterworth anal og and di gi tal l ter desi gn.
cheby 1 Chebyshev type I l ter desi gn (passband ri ppl e).
cheby 2 Chebyshev type I I l ter desi gn (stopband ri ppl e).
el l i p El l i pti c (Cauer) l ter desi gn.
f i r 2 Wi ndow-based ni te i mpul se response l ter desi gn
arbi trary response.
f i r l s Least square l i near-phase FI R l ter desi gn.
max f l at General i zed di gi tal Butterworth l ter desi gn.
r emez Parks-McCl el l an opti mal FI R l ter desi gn.
zp2sos
6-317
zp2sos
Purpose Zero-pol e-gai n to second-order secti on conversi on.
Syntax s os = z p2s os ( z , p, k)
s os = z p2s os ( z , p, k, ' or der ' )
Description z p2s os converts a zero-pol e-gai n representati on of a gi ven system to an equi v-
al ent second-order secti on representati on.
s os = z p2s os ( z , p, k) fi nds a matri x s os i n second-order secti on form equi va-
l 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:
k i s a scal ar gai n. The zeros and pol es must be real or come i n compl ex conju-
gate pai rs. s os 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 s os i s the maxi mum of the cei l i ng of N/2 and
the cei l i ng of M/2, where N and M are the l engths of z and p, respecti vel y.

H z k
z z z z z z N
p p p p p p M
( )
( ( ))( ( )) ( ( ))
( ( ))( ( )) ( ( ))



1 2
1 2
K
K

sos
b b b a a a
b b b a a a
b b b a a a
L L L L L L

1
]
1
1
1
1
1
1
01 11 21 01 11 21
02 12 22 02 12 22
0 1 2 0 1 2
M M M M M M
H z H z
b b z b z
a a z a z
k
k
L
k k k
k k k
k
L
( ) ( )
+ +
+ +


1
0 1
1
2
2
0 1
1
2
2
1
zp2sos
6-318
s os = z p2s os ( z , p, k, ' or der ' ) speci fi es the order of the rows i n s os , where
or der i s
down, to order the secti ons so the fi rst row of s os 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 s os contai ns the pol es farthest
from the uni t ci rcl e (defaul t)
Example Fi nd a second-order secti on form of a Butterworth l owpass fi l ter:
[ z , p, k] = but t er ( 5, 0. 2) ;
s os = z p2s os ( z , p, k) ;
Algorithm z p2s os uses a four-step al gori thm to determi ne the second-order secti on repre-
sentati 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
cpl x pai r functi on.
2 I t forms the second-order secti on by matchi ng the pol e and zero pai rs accord-
i ng to the fol l owi ng rul es:
a Match the pol es cl osest to the uni t ci rcl e wi th the zeros 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.
z p2s os 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. z p2s os normal l y orders the secti ons wi th pol es cl osest to the uni t ci r-
cl e l ast i n the cascade. You can tel l z p2s os to order the secti ons i n the re-
verse order by speci fyi ng the down fl ag.
Putti ng hi gh Q secti ons at the begi nni ng of the cascade, by speci fyi ng the
down fl ag, reduces the response sensi ti vi ty of the fi l ter to quanti zati on noi se
near those pol es. Putti ng hi gh Q secti ons at the end of the cascade (the de-
faul t) prevents reducti on i n si gnal power l evel earl y i n the cascade. z p2s os
orders al l zero secti ons accordi ng to the mi ni mum of | z
i
| and | z
i
-1
| where
zp2sos
6-319
z
i
(for i = 1, 2) are the zeros i n the secti on. References [1] and [2] provi de de-
tai l ed di scussi ons of secti on orderi ng.
4 z p2s os scal es the secti ons so the maxi mum of the magni tude of the transfer
functi on of the fi rst N secti ons i n cascade i s l ess than 1:
subject to the constrai nt that the overal l gai n, k, stays the same:
Thi s scal i ng i s an attempt to mi ni mi ze overfl ow i n some standard fi xed poi nt
i mpl ementati ons of fi l teri ng.
See Also
References [1] Oppenhei m, A.V., and R.W. Schafer. Discrete-Time Signal Processing.
Engl ewood Cl i ffs, NJ: Prenti ce Hal l , 1989. Pgs. 363-370.
[2] Jackson, L.B. Digital Filters and Signal Processing. Thi rd Ed. Boston:
Kl uwer Academi c Publ i shers, 1989. Pgs. 319-324.
s os 2s s Second-order secti on to state-space conversi on.
s os 2t f Second-order secti on to transfer functi on conversi on.
s os 2z p Second-order secti on to zero-pol e-gai n conversi on.
s s 2s os State-space to second-order secti on conversi on.
max
( ) , , ...,

<

H e N L
i
j
i
N
1
1 1 1
b
a
k
k
k k
L
0
0 1


zp2ss
6-320
zp2ss
Purpose Zero-pol e-gai n to state-space conversi on.
Syntax [ A, B, C, D] = z p2s s ( Z, p, k)
Description z p2s s converts a zero-pol e-gai n representati on of a gi ven system to an equi va-
l ent state-space representati on. I t forms state-space model s from the zeros,
pol es, and gai ns of systems i n transfer functi on form.
[ A, B, C, D] = z p2s s ( 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 array 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.
I nf val ues may be used as pl ace hol ders i n Z i f some col umns have fewer zeros
than others.
Algorithm z p2s s , 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 come i n compl ex conjugate pai rs.
See Also s s 2t f State-space to transfer functi on conversi on.
s s 2z p State-space to zero-pol e-gai n conversi on.
t f 2s s Transfer functi on to state-space conversi on.
t f 2z p Transfer functi on to zero-pol e-gai n conversi on.
z p2t f Zero-pol e-gai n to transfer functi on conversi on.
x Ax Bu
y Cx Du
+
+

H s
z s
p s
k
s z s z s z n
s p s p s p n
( )
( )
( )
( ( ))( ( )) ( ( ))
( ( ))( ( )) ( ( ))



1 2
1 2
K
K
zp2tf
6-321
zp2tf
Purpose Zero-pol e-gai n to transfer functi on conversi on.
Syntax [ num, den] = z p2t f ( Z, p, k)
Description z p2t f forms transfer functi on pol ynomi al s from the zeros, pol es, and gai ns of a
system i n factored form.
[ num, den] = z p2t f ( z , p, k) fi nds a rati onal transfer functi 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 array 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 den and the numerator coeffi ci ents
i n matri x num, wi th as many rows as there are col umns of z .
I nf 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 pol y wi th p and the
col umns of Z.
See Also s s 2t f State-space to transfer functi on conversi on.
s s 2z p State-space to zero-pol e-gai n conversi on.
t f 2s s Transfer functi on to state-space conversi on.
t f 2z p Transfer functi on to zero-pol e-gai n conversi on.
z p2s s Zero-pol e-gai n to state-space conversi on.
num s
den s
num s num nn s num nn
den s den nd s den nd
nn
nd
( )
( )
( ) ... ( ) ( )
( ) ... ( ) ( )

+ + +
+ + +

1 1
1 1
1
1
H s
Z s
p s
k
s Z s Z s Z m
s p s p s p n
( )
( )
( )
( ( ))( ( ))...( ( ))
( ( ))( ( ))...( ( ))



1 2
1 2
zplane
6-322
zpl ane
Purpose Zero-pol e pl ot.
Syntax z pl ane( z , p)
z pl ane( b, a)
[ hz , hp, ht ] = z pl ane( z , p)
Description Thi s functi on di spl ays the pol es and zeros of di screte-ti me systems.
z pl ane( 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' repre-
sents 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, z pl ane 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 z pl ane usi ng
ax i s ( [ x mi n x max y mi n y max ] )
or
s et ( gca, ' y l i m' , [ y mi n y max ] )
or
s et ( gca, ' x l i m' , [ x mi n x max ] )
after cal l i ng z pl ane. 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 around the
ori gi n and are thus hard to di sti ngui sh.
z pl ane( b, a) where b and a are row vectors, fi rst uses r oot s 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 ] = z pl ane( 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-323
Examples Pl ot the pol es and zeros of a 5th-order Butterworth l owpass di gi tal fi l ter wi th
cutoff frequency of 0.2:
[ z , p, k] = but t er ( 5, 0. 2) ;
z pl ane( z , p)
To generate the same pl ot wi th a transfer functi on representati on of the fi l ter:
[ b, a] = but t er ( 5, 0. 2) ; % t r ans f er f unct i on
z pl ane( b, a)
See Also f r eqz Frequency response of di gi tal l ters.
-1 -0.5 0 0.5 1
-1
-0.5
0
0.5
1
Real part
I
m
a
g
i
n
a
r
y

p
a
r
t
Poles and Zeros of 5th-Order Butterworth Lowpass Digital Filter
5
zplane
6-324

I-1

I ndex

Symbols

. s pt

extensi on 5-6, 5-7

A

abs

6-2,

6-11

, 6-12, 6-150, 6-154
al gori thm
fi l teri ng i n

s pt ool

5-19
al i ased si nc functi on.

See

Di ri chl et functi on
al i asi ng
and i mpul se i nvari ance 2-42
i n i mpul se i nvari ance 2-42
preventi ng duri ng resampl i ng 4-22
reduci ng wi th anal yti c si gnal 4-37
al l -pol e fi l ter.

See

I I R fi l ter
al l -zero fi l ter.

See

FI R fi l ter

am

4-29
AM.

See

ampl i tude modul ati on
amdsbsc 6-207

amds bs c

4-29
amdsbtc 6-207

amds bt c

4-29
ampl i tude demodul ati on
doubl e si de-band, suppressed carri er 6-93
doubl e si de-band, transmi tted carri er 6-93
si ngl e si de-band 6-93
ampl i tude modul ati on 4-29
doubl e si de-band, suppressed carri er 6-207
doubl e si de-band, transmi tted carri er 6-207
si ngl e si de-band 6-207
amssb 6-207

ams s b

4-29
anal og fi l ter
Bessel 6-15
Butterworth 6-28
Chebyshev type I 6-49
Chebyshev type I I 6-54
converti ng to di gi tal 2-41, 6-168
desi gn 2-7
Bessel 6-15
Butterworth 6-27
Chebyshev type I 6-48
Chebyshev type I I 6-54
el l i pti c 6-104
i nverse 6-177
el l i pti c 6-105
frequency response 1-26, 6-148
order esti mati on
Butterworth 6-33
Chebyshev type I 6-39
Chebyshev type I I 6-44
el l i pti c 6-112
representati onal model s 1-39
anal og fi l ter desi gn
Bessel 2-13
anal og frequency

xx

anal og prototype 2-38
Bessel fi l ter 2-13, 6-14
Butterworth fi l ter 2-9, 6-26
Chebyshev type I fi l ter 2-10, 6-37
Chebyshev type I I fi l ter 2-11, 6-42
conversi on to bandpass 6-192
conversi on to bandstop 6-195
conversi on to hi ghpass 6-197
conversi on to l owpass 6-199
el l i pti c fi l ter 6-110
frequency response 2-14
pl otti ng 2-14
anal og prototype desi gn
Bessel 2-38
bi l i near transformati on 2-42
Butterworth 2-38
Chebyshev 2-38

Index

I-2

el l i pti c 2-38
fi l ter di screti zati on 2-41
frequency transformati on 2-39
i npul se i nvari ance 2-42

See also

I I R fi l ter desi gn
anal og si gnal .

See

si gnal
anal yti c si gnal 2-26, 6-162
appl i cati ons 4-37
properti es 4-37

angl e

6-2, 6-11,

6-12

, 6-150, 6-154, 6-298
anti -symmetri c fi l ter 2-25

Apply

5-83

Apply Filter

5-19
appl yi ng parameters wi th

Apply

5-86

ar

6-203
AR model 4-11
ARMA fi l ter 1-15

See also

I I R fi l ter
ARMA model 4-12, 4-14
Pronys method 4-12
Stei gl i tz-McBri de method 4-14
array
di spl ay
i n Si gnal Browser 5-46, 5-51
i n

s pt ool

5-14

Array Signals

5-46, 5-51
ARX model 4-13
ASCI I fi l e
i mporti ng 1-13
attenuati on
stopband 5-61
attri butes
i nstananeous 6-162

Auto

5-58

Auto-->Set

5-58
autocorrel ati on 4-11, 6-305
mul ti pl e channel s 3-4
two-di mensi onal 6-310
autocovari ance 6-311
mul ti pl e channel s 3-4
autoregressi ve (AR) fi l ter 1-15

See also

I I R fi l ter
autoregressi ve movi ng average (ARMA) fi l ter 1-15

See also

I I R fi l ter
autoregressi ve sequences
i n MEM techni que 3-19
auto-spectrum
i n

s pt ool

5-15
averagi ng fi l ter 1-14
axi s l abel s
i n Si gnal Browser 5-21, 5-24
axi s parameters
i n Fi l ter Vi ewer 5-21
i n Spectrum Vi ewer 5-21
axi s scal i ng range
i n Fi l ter Vi ewer 5-27, 5-72
i n Spectrum Vi ewer 5-25, 5-85, 5-88
axi s scal i ng uni ts
i n Fi l ter Vi ewer 5-26, 5-72
i n Spectrum Vi ewer 5-25, 5-85, 5-88

B

band edges
prewarpi ng 2-44
bandl i mi ted i nterpol ati on 6-258
bandpass fi l ter
anal og prototype desi gn 2-6
and i mpul se i nvari ance 2-42
Bessel 6-15
Butterworth 6-27, 6-29
Chebyshev type I 6-48, 6-50
Chebyshev type I I 6-53, 6-55
el l i pti c 6-104, 6-106

Index

I-3

exampl e, Chebyshev type I 2-40
FI R desi gn
wi th wi ndow method 2-21, 6-131
transformati on from l owpass to 6-192
bandstop fi l ter
anal og prototype desi gn 2-6
Bessel 6-15
Butterworth 6-28, 6-29
Chebyshev type I 6-49, 6-50
Chebyshev type I I 6-54, 6-55
el l i pti c 6-105, 6-106
FI R desi gn
wi th wi ndow method 2-21, 6-131
transformati on from l owpass to 6-195
bandwi dth 2-40

bar t l et t

4-2, 6-7,

6-13

, 6-24, 6-25, 6-47, 6-160,
6-161, 6-183, 6-296
compared to

t r i ang

6-13
exampl e 4-2
Bartl ett wi ndow 4-2
coeffi ci ents 6-13
Bessel 2-38
Bessel fi l ter
anal og 6-15
anal og prototype 2-13, 6-14
bandpass confi gurati on
anal og 6-15
bandstop confi gurati on
anal og 6-15
characteri sti cs 2-13
hi ghpass confi gurati on
anal og 6-15
l i mi tati ons 6-17
l owpass confi gurati on
anal og 6-15

bes s el ap

2-5, 6-9,

6-14

, 6-18, 6-26, 6-37, 6-42,
6-110
exampl e 2-13

bes s el f

2-5, 2-6, 6-4, 6-14,

6-15

, 6-31, 6-52, 6-57,
6-109
beta parameter
of Kai ser wi ndow 5-63
bi as
correl ati on 3-3, 4-12
power spectral densi ty 3-11
spectral densi ty 3-11
vari ance tradeoff 3-4

bi l i near

2-5, 2-41, 2-43, 6-10,

6-19

, 6-169, 6-194,
6-196, 6-198, 6-200
bi l i near transformati on 2-42, 6-19
defi ned 2-42
output representati on 6-20
prewarpi ng 2-44, 6-19

bl ackman

4-2, 6-7, 6-13,

6-24

, 6-25, 6-47, 6-160,
6-161, 6-183, 6-296
Bl ackman wi ndow 4-4, 6-24
defi ned 4-4

box car

4-2, 6-7, 6-13, 6-24,

6-25

, 6-47, 6-160,
6-161, 6-183, 6-296
exampl e 4-2
boxcar wi ndow.

See

rectangul ar wi ndow

but t ap

2-5, 6-9, 6-14,

6-26

, 6-31, 6-37, 6-42,
6-110
exampl e 2-9

but t er

2-5, 2-6, 6-4, 6-18, 6-26,

6-27

, 6-35, 6-52,
6-57, 6-109, 6-135, 6-205, 6-227, 6-244,
6-316
accessi ng from Fi l ter Desi gner 5-55
Butterworth 2-38, 5-55
Butterworth fi l ter
anal og 6-28
anal og prototype 2-9, 6-26

Index

I-4

bandpass confi gurati on
anal og 6-29
di gi tal 6-27
bandstop confi gurati on
anal og 6-29
di gi tal 6-28
characteri sti cs 2-9
desi gn 6-27
di gi tal 6-27
general i zed 2-15
hi ghpass confi gurati on
anal og 6-29
di gi tal 6-28
l i mi tati ons 6-31
l owpass confi gurati on
anal og 6-28
di gi tal 6-27
order esti mati on 2-7, 6-32

but t or d

2-5, 6-5, 6-31,

6-32

, 6-41, 6-46, 6-114,
6-247

C

canoni cal forms 1-17, 6-289
carri er frequency 4-28, 6-207, 6-303
carri er si gnal 4-28, 6-93
cascade, di gi tal fi l ter 1-36
Cauer fi l ter.

See

el l i pti c fi l ter

cceps

4-23, 6-8,

6-36

, 6-159, 6-238
exampl e 4-23
center frequency 2-40
central features 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

See also

real cepstrum, compl ex cepstrum
cepstrum anal ysi s 4-23

cheb1ap

2-5, 6-9, 6-14, 6-26,

6-37

, 6-42, 6-52,
6-110
exampl e 2-10, 2-40

cheb1or d

2-5, 6-5, 6-35,

6-38

, 6-46, 6-52, 6-114,
6-247

cheb2ap

2-5, 6-9, 6-14, 6-26, 6-37,

6-42

, 6-57,
6-110
exampl e 2-11

cheb2or d

2-5, 6-5, 6-35, 6-41,

6-43

, 6-57, 6-114,
6-247

chebwi n

4-2, 6-7, 6-13, 6-24, 6-25,

6-47

, 6-160,
6-161, 6-183, 6-296

cheby 1

2-5, 2-6, 6-4, 6-18, 6-31, 6-37, 6-41, 6-46,

6-48

, 6-57, 6-109, 6-135, 6-227, 6-244,
6-316
accessi ng from Fi l ter Desi gner 5-55
exampl e 2-44

cheby 2

2-5, 2-6, 6-4, 6-18, 6-31, 6-42, 6-52,

6-53

,
6-109, 6-135, 6-227, 6-244, 6-316
accessi ng from Fi l ter Desi gner 5-55
Chebyshev 2-38
Chebyshev error mi ni mi zati on 2-22, 6-240
Chebyshev type I fi l ter
anal og 6-49
anal og prototype 2-10, 6-37
bandpass confi gurati on
anal og 6-50
di gi tal 6-48
bandstop confi gurati on
anal og 6-50
di gi tal 6-49
characteri sti cs 2-10
desi gn 6-48
di gi tal 6-48

Index

I-5

hi ghpass confi gurati on
anal og 6-50
di gi tal 6-49
l owpass confi gurati on
anal og 6-49
di gi tal 6-48
order esti mati on 2-7, 6-38
Chebyshev type I I fi l ter
anal og 6-54
anal og prototype 6-42
bandpass confi gurati on
anal og 6-55
di gi tal 6-53
bandstop confi gurati on
anal og 6-55
di gi tal 6-54
characteri sti cs 2-11
desi gn
Chebyshev type I I 6-53
di gi tal 6-53
hi ghpass confi gurati on
anal og 6-55
di gi tal 6-54
l i mi tati ons 6-52
l owpass confi gurati on
anal og 6-54
di gi tal 6-53
order esti mati on 2-7, 6-43
Chebyshev wi ndow 4-8, 6-47
frequency response 4-9

chi r p

1-9, 6-2,

6-58

, 6-156, 6-236, 6-239, 6-256,
6-259, 6-275, 6-297
chi rp si gnal
chi rp

z

-transform 6-85
for narrowband frequency anal ysi s 6-85
chi rp

z

-transform (CZT) 4-33
compared to di screte Fouri er transform 4-33
executi on ti me 4-34
cl assi cal I I R fi l ter desi gn 2-9
cl i ck-and-drag panni ng
i n Si gnal Browser 5-47
coeffi ci ents
correl ati on 6-70
fi l ter 1-15
l i near predi cti on
refl ecti on 1-37, 6-223, 6-237

coher e

3-6, 3-16, 6-6,

6-61

, 6-83, 6-231, 6-269,
6-295
coherence 3-15, 6-61
defi ned 3-15
coherence functi on 3-15

Color

5-34
col or
customi zi ng i n

s pt ool

5-21

Color Order

5-23
col or order
i n Si gnal Browser 5-23
i n Spectrum Vi ewer 5-23
col umn
array 5-46
col umn i ndex vector
enteri ng i n Si gnal Browser 5-46
communi cati ons 4-10
communi cati ons si mul ati on 4-28, 6-93, 6-207

See also

modul 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-72

Complex Display

5-46
compl ex envel ope 4-37
compl ex numbers
groupi ng by conjugate 6-72

Index
I-6
compl ex si gnal s
i n Si gnal Browser 5-46
computati on parameters
i n Spectrum Vi ewer 5-88, 5-90
Conf. Int. 5-92
confi dence i nterval
for cross spectral densi ty 3-14
for power spectral densi ty 3-14, 5-92
setti ng i n Spectrum Vi ewer 5-92
conservati on of total power
usi ng pmt m 3-19
context sensi ti ve hel p i n s pt ool 5-7
conti nuous si gnal . See si gnal
conti nuous-ti me fi l ter. See anal og fi l ter
Control System Tool box 1-34
control systems 1-34, 6-172
conv 1-14, 1-19, 6-2, 6-65, 6-67, 6-69, 6-92, 6-302,
6-309, 6-313
conv 2 1-14, 6-2, 6-65, 6-66, 6-69, 6-126, 6-310
conv mt x 1-38, 1-41, 6-3, 6-65, 6-68, 6-96, 6-255
conv n 6-65, 6-67, 6-69
convol uti on
and cross-correl ati on 3-3
and fi l teri ng 1-14, 6-126
convol uti on matri x 1-38, 6-68
defi ned 6-65
exampl e 1-14
two-di mensi onal 6-66
obtai ni ng subsecti on 6-66
convol uti on matri x 1-41, 6-68
defi ned 1-38
exampl e 6-68
cor r coef 6-6, 6-70, 6-71, 6-309, 6-313
correl ati on 3-2
coeffi ci ent matri x 6-70
See also autocorrel ati on, cross-correl ati on
cos 6-156, 6-236, 6-239, 6-256, 6-259, 6-275, 6-297
cosi ne wi ndow 4-4
cov 6-6, 6-70, 6-71, 6-309, 6-313
covari ance 3-2
matri x 6-71
See also autocovari ance, cross-covari ance
cpl x pai r 6-8, 6-72
Create Spectrum 5-19, 5-83
cr emez 2-17, 6-5, 6-73, 6-244
cross spectral densi ty 3-14, 6-80
confi dence i nterval 3-14
defi ned 3-5
cross-correl ati on 6-305
bi ased 3-3
mul ti pl e channel s 3-4
normal i zati on 3-4
two-di mensi onal 6-310
unbi ased 3-3
cross-covari ance 6-311
mul ti pl e channel s 3-4
cs d 3-6, 3-14, 6-6, 6-64, 6-80, 6-231, 6-269, 6-295
CSD. See cross spectral densi ty
cutoff frequency 2-39
defi ned 6-15
for Kai ser wi ndow fi l ter 5-63
cz t 4-34, 6-6, 6-85
CZT. See chi rp z-transform 4-33
D
data
dupl i cati ng i n s pt ool 5-16
edi ti ng i n s pt ool 5-14, 5-16
enteri ng 1-13
exporti ng from s pt ool 5-7
i mporti ng 1-13
i mporti ng i nto s pt ool 5-4, 5-6, 5-8
Index
I-7
measuri ng i n s pt ool 5-30
mul ti channel 1-4, 1-7
vi ewi ng i n s pt ool 5-30
data compressi on 4-10
data matri x 1-4, 1-7
data vector 1-4
dct 4-35, 6-6, 6-87, 6-118, 6-165
exampl e 4-36
dct 2 6-88, 6-165
deci mat e 6-8, 6-89, 6-174, 6-176, 6-252, 6-302
deci mati on 6-89
FI R fi l ter for 6-175
deconv 4-32, 6-8, 6-65, 6-67, 6-92, 6-255
exampl e 4-32
deconvol uti on 4-32, 6-92
defaul t pl ot
i n Spectrum Vi ewer 5-88
del ay
addi ng to si gnal 2-26
group 1-28
noni nteger 2-26
phase 1-28
demod 4-28, 4-29, 6-8, 6-93, 6-209, 6-304
exampl e 4-30
demodul ati on 4-29, 6-93
exampl e 4-30
methods 4-29, 6-93
desi gn
fi l ter
general i zed 2-5
desi gned fi l ter
i n s pt ool 5-15
det r end 6-8, 6-95
DFT. See di screte Fouri er transform 2-26
DFT. Seedi screte Fouri er transform
df t mt x 6-6, 6-69, 6-96, 6-118
di fference equati on
rel ati on to transfer functi on 1-31
di fferenti ator 2-26, 6-143, 6-241
Di gi tal Audi o Tape standard 4-20
di gi tal fi l ter
anti -causal 1-19
as convol uti on matri x 1-39
Butterworth 6-27
cascade 1-36
Chebyshev type I 6-48
Chebyshev type I I 6-53
coeffi ci ents 1-15
desi gn 2-2
el l i pti c 6-104
FI R 2-17
compared to I I R 2-17
fi xed-poi nt i mpl ementati on 1-36
frequency response 1-24
group del ay 1-28, 6-157
i denti fi cati on from frequency data 6-180
I I R 2-4
compared to FI R 2-4
i mpl ementati on 1-14, 6-120, 6-123
FFT-based (FI R) 6-120
overl ap-add method 1-22
usi ng convol uti on 1-14
usi ng f i l t er functi on 1-16
i mpul se response 1-14, 1-23, 6-170
i ni ti al condi ti ons 1-17
l i near system model s 1-31
names 1-15
order 1-15
i n state-space representati on 1-33
Index
I-8
order esti mati on
Butterworth 6-32
Chebyshev type I 6-38
Chebyshev type I I 6-43
el l i pti c 6-111
equi ri ppl e FI R 6-245
phase del ay 1-28, 6-157
pol es 1-30, 1-32
representati onal model s 1-31
representi ng i n MATLAB 1-31
second-order secti ons 1-36
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 representati on 1-15
two-di mensi onal 6-126
zero-phase 1-19, 6-127
zeros 1-30, 1-32
zeros and pol es 1-32
See also FI R fi l ter, I I R fi l ter
di gi tal fi l ter desi gn
FI R 2-17
I I R 2-4
di gi tal frequency xx
di rect desi gn 2-14
descri bed 2-14
summary 2-5
di r i c 6-2, 6-60, 6-97, 6-156, 6-236, 6-239, 6-256,
6-259, 6-275, 6-297
Di ri chl et functi on 1-11, 6-97
defi ned 1-11
exampl e 1-12
di screte cosi ne transform 6-87
i nverse 6-165
di screte cosi ne transform (DCT)
appl i cati ons 4-35
energy compacti on property 4-36
exampl e 4-36
i nverse 4-35
reconstructi ng si gnal from few coeffi ci ents 4-36
di screte Fouri er transform 6-115
and spectral anal ysi s 3-6
appl i cati ons 6-115
i nverse 6-166
matri x 6-96
two-di mensi onal 6-167
matri x 6-96
two-di mensi onal 6-119
di screte Fouri er transform (DFT) 1-2, 1-42, 2-26
al gori thms 1-43
and I I R fi l ter i mpl ementati on 1-22
dependence on si gnal l ength 1-43
exampl e 1-43
executi on ti me
usi ng chi rp z-transform 4-34
i nverse 1-42
two-di mensi onal 1-44
two-di mensi onal 1-44
See also fast Fouri er transform (FFT), f f t
di screte prol ate spheroi dal sequences 3-19
di screte-ti me Fouri er transform 3-5
di screti zati on 2-41, 6-168
bi l i near transformati on 2-42
prewarpi ng 2-44
i mpul se i nvari ance 2-42
Display Peaks 5-36
Display Valleys 5-36
dps s 6-8, 6-98, 6-100, 6-101, 6-102, 6-103, 6-216
dps s . mat 3-19
dps s cl ear 3-19, 6-8, 6-99, 6-100, 6-101, 6-102,
6-103
Index
I-9
dps s di r 3-19, 6-8, 6-99, 6-100, 6-101, 6-102,
6-103
dps s l oad 3-19, 6-8, 6-99, 6-100, 6-101, 6-102,
6-103
DPSSs. See di screte prol ate spheroi dal
sequences
dps s s av e 3-19, 6-8, 6-99, 6-100, 6-101, 6-102,
6-103
duty cycl e
speci fyi ng 1-8
E
echo detecti on 4-23
edge effects 1-22
edge frequenci es
setti ng i n Fi l ter Desi gner 5-61
Edit Design 5-18, 5-56
ei g
i n pmus i c functi on 3-22
ei genanal ysi s
defi ned 3-21
frequency esti mator functi ons 3-21
ei genvector method 3-5, 3-21
See also mul ti pl e si gnal cl assi fi cati on method
el l i p 2-5, 2-6, 6-4, 6-18, 6-31, 6-52, 6-57, 6-104,
6-110, 6-114, 6-135, 6-227, 6-244, 6-316
accessi ng from Fi l ter Desi gner 5-55
el l i pap 2-5, 6-9, 6-14, 6-26, 6-37, 6-42, 6-109,
6-110
exampl e 2-12
el l i por d 2-5, 6-5, 6-35, 6-41, 6-46, 6-109, 6-111,
6-247
el l i pti c 2-38
el l i pti c fi l ter
anal og 6-105
anal og prototype 6-110
bandpass confi gurati on
anal og 6-106
di gi tal 6-104
bandstop confi gurati on
anal og 6-106
di gi tal 6-105
characteri sti cs 2-12
desi gn 6-104
di gi tal 6-104
hi ghpass confi gurati on
anal og 6-106
di gi tal 6-105
l i mi tati ons 6-108
l owpass confi gurati on
anal og 6-105
di gi tal 6-104
order esti mati on 2-7, 6-111
energy compacti on 4-36
equi ri ppl e characteri sti cs
Chebyshev type I fi l ter (passband) 2-10
Chebyshev type I I fi l ter (stopband) 2-11
Chebyshev wi ndow 4-8
el l i pti c fi l ter 2-12, 6-104, 6-110
from Parks-McCl el l an desi gn 6-240
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-63
for l east squares fi l ter 5-63
i ntegral of square 2-22
mi ni max 2-22
wei ghti ng i n frequency bands 2-25
esti mati on
cross spectrum 3-14
power spectrum 3-6
transfer functi on 3-14
See Also parametri c model i ng
Index
I-10
esti mati on methods
i n Spectrum Vi ewer 5-88, 5-90
nonparametri c
mul ti pl e si gnal cl assi fi cati on method (MU-
SI C) 3-5, 5-92
mul ti taper method (MTM) 3-5, 5-91
Wel chs method 3-5, 5-90
parametri c
maxi mum entropy method (MEM) 3-5,
5-91
et f e 6-295
Export 5-7
exporti ng data
from MATLAB 1-13
extensi ons to s pt ool 5-29
F
Factory Settings 5-29
fast Fouri er transform (FFT) 1-22, 1-42
and frequency response 1-24
f f t functi on 1-22
pri me factor al gori thm 1-43
radi x-2 al gori thm 1-43
rol e i n si gnal processi ng 1-42
FFT 6-115
pri me factor al gori thm 6-117
radi x-2 al gori thm 6-117
two-di mensi onal 6-119
f f t 1-2, 1-22, 1-42, 6-6, 6-36, 6-86, 6-88, 6-96,
6-115, 6-119, 6-122, 6-154, 6-159, 6-163,
6-164, 6-166, 6-167, 6-238
compl ex i nputs 1-44
exampl e 1-43
executi on ti me 1-43, 6-118
pri me factor al gori thm 1-43, 6-117
radi x-2 al gori thm 1-43, 6-117
real i nputs 1-44
rearrangi ng output 1-44, 6-122
speci fyi ng number of poi nts 1-43
FFT Length 5-26, 5-28
FFT l ength
i n Fi l ter Desi gner 5-21, 5-28
i n Fi l ter Vi ewer 5-26
FFT. See fast Fouri er transform
f f t 2 1-44, 6-6, 6-118, 6-119, 6-122, 6-166, 6-167
rearrangi ng output 1-44
FFT-based fi l teri ng 1-22
f f t f i l t 1-19, 6-2, 6-120, 6-125, 6-127
compared to f i l t er 6-120
f f t n 6-167
f f t s hi f t 1-44, 6-6, 6-118, 6-119, 6-122, 6-166,
6-167
Fi l e Contents l i st 5-9
fi l ter
anal og prototype 2-9, 2-13, 6-14, 6-26, 6-37, 6-42,
6-110
anal yzi ng i n Fi l ter Vi ewer 5-17
appl yi ng to a si gnal 5-19
Butterworth 2-7, 6-27
general i zed 2-15
Chebyshev 2-7
Chebyshev type I 6-48
Chebyshev type I I 6-53
coeffi ci ents 1-15, 2-18
desi gn
FI R 6-240
general i zed 2-5
I I R 2-5
i nverse 6-177, 6-180
di screti zati on 2-41
edi ti ng i n s pt ool 5-18
el l i pti c 2-7, 6-104
equi ri ppl e 2-22
Index
I-11
group del ay 5-18
i denti fi cati on from frequency data 6-177
i mpl ementati on 1-21, 6-120, 6-123
i mporti ng i nto s pt ool 5-8, 5-9, 5-12
i mpul se response 5-18
l i near ti me-i nvari ant di gi tal 1-2
magni tude response 5-17
medi an 4-27, 6-206
mi ni max 2-22
mi ni mum phase 6-225
mul ti band FI R 2-22
names 1-15
nami ng i n s pt ool 5-17
order 1-15, 2-7, 6-32, 6-38, 6-43, 6-111
order sel ecti on 2-7
phase response 5-18
pri nci pal supported 1-2
si ngl e band FI R 2-20
speci fi cati ons 2-7
step response 5-18
transposed di rect form I I structure 1-17
two-di mensi onal 6-126
types 2-18
vi ewi ng i n Fi l ter Vi ewer 5-17
zeros and pol es 5-18
See also FI R fi l ter, I I R fi l ter, di gi tal fi l ter, ana-
l og fi l ter
f i l t er 1-2, 1-16, 1-19, 6-2, 6-65, 6-92, 6-118,
6-121, 6-123, 6-127, 6-129, 6-132, 6-154,
6-190, 6-205, 6-206, 6-302
compared to f f t f i l t 6-120
compared to f i l t f i l t 1-21
fi nal condi ti on parameters 1-17
i mpl ementati on 1-17
i ni ti al condi ti on parameters 1-17
i ni ti al condi ti ons 6-128
fi l ter desi gn
i n Fi l ter Desi gner 5-55, 5-61, 5-64
parameters i n Fi l ter Desi gner 5-58
standard band confi gurati ons 5-55
usi ng speci fi cati ons l i nes 5-61
Fi l ter Desi gner 5-2, 5-18, 5-55, 5-56, 6-272
acti vati ng 5-18, 5-56
changi ng pl ot properti es 5-28
cl assi cal I I R fi l ter desi gn 5-64
cl osi ng 5-58
customi zi ng 5-21
magni tude pl ot 5-60
magni tude pl ot as desi gn tool 5-67
magni tude response pl ot 5-59
savi ng data to workspace 5-67
setti ng edge frequenci es 5-61
setti ng passband ri ppl e 5-61
setti ng stopband attenuati on 5-61
si ngl e band FI R fi l ter desi gn 5-62
wi ndow 5-57
fi l ter parameters
i n Fi l ter Vi ewer 5-21
fi l ter type
desi gn 5-15, 5-18
i mported 5-15, 5-18
Fi l ter Vi ewer 5-2, 5-17, 5-69, 6-273
acti vati ng 5-17, 5-69
customi zi ng 5-21
defaul t pl ot 5-70
pl ots 5-71
preferences 5-71
setti ngs 5-71
subpl ots 5-71
vi ewi ng frequency response 5-68
vi ewi ng group del ay 5-78
vi ewi ng i mpul se response 5-80
vi ewi ng magni tude response 5-74
vi ewi ng phase response 5-76
Index
I-12
vi ewi ng step response 5-81
vi ewi ng zero-pol e pl ot 5-79
wi ndow 5-70
f i l t er 2 6-3, 6-67, 6-125, 6-126, 6-127, 6-310
fi l teri ng
and convol uti on 1-14
anti -causal 1-19
frequency domai n 1-21
i ni ti al condi ti ons 1-17
generati ng 1-18
zero-phase 1-19
fi l teri ng al gori thm 5-19
f i l t f i l t 1-19, 1-20, 2-4, 6-3, 6-121, 6-125, 6-127,
6-129
compared to f i l t er 1-21
exampl e 1-20
i ni ti al condi ti ons 1-21
f i l t i c 1-18, 6-3, 6-125, 6-128
FI R fi l ter
arbi trary frequency response 6-133
compared to I I R 2-17
desi gn 2-17
deci mati on 6-175
i nterpol ati on 6-175
l east squares method 6-142
l i near phase 6-142
mul ti band frequency response 6-133
Parks-McCl el l an method 6-240
wi ndow method 6-130
di fferenti ator 2-26, 6-143, 6-241
Hi l bert transformer 2-25, 6-143, 6-241
i mpl ementati on 1-17, 6-123
FFT-based 1-22, 6-120
overl ap-add method 1-22, 6-120
l i near phase 2-18, 6-240
order esti mati on, r emez functi on 6-245
types 6-145, 6-243
FI R fi l ter desi gn 2-17
anti -symmetri c 2-25
arbi trary response 2-31
reduced del ay 2-34
arbi trary responses
compl ex fi l ters 2-17, 6-73
nonl i near phase 2-17, 6-73
compare l east squares to equi ri ppl e 2-23
constrai ned l east squares 2-17, 2-27
l i near phase 2-28
mul ti band 2-28, 2-29
wei ghted 2-30
equi ri ppl e 2-17, 2-22, 2-23, 5-61, 5-63
exampl e 5-62, 5-93
i n Fi l ter Desi gner 5-55, 5-61
Kai ser wi ndow 5-61, 5-64
l east squares 2-17, 2-22, 2-23, 5-61, 5-64
l i near phase fi l ters 2-18, 2-22
mul ti band 2-17, 2-21, 2-22
order sel ecti on 5-63
parameters i n Fi l ter Desi gner 5-63
Parks-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-17, 2-19
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-37
f i r 1 2-17, 2-20, 6-5, 6-130, 6-135, 6-146, 6-188,
6-244, 6-252
accessi ng from Fi l ter Desi gner 5-61, 5-63
fi r2 6-244
f i r 2 2-17, 2-20, 6-5, 6-132, 6-133, 6-146, 6-244,
6-316
exampl e 2-21
Index
I-13
f i r cl s 2-17, 6-5, 6-132, 6-136, 6-141, 6-244
f i r cl s 1 2-17, 6-5, 6-132, 6-138, 6-139, 6-244
f i r l s 2-17, 2-22, 6-5, 6-132, 6-138, 6-141, 6-142,
6-147, 6-244, 6-316
accessi ng from Fi l ter Desi gner 5-55, 5-61, 5-63
compared to r emez 2-23
fi l ter characteri sti cs 6-145
for di fferenti ator desi gn 2-26
wei ght vector 2-25
f i r r cos 2-17, 6-5, 6-146, 6-147, 6-244
fi xed-poi nt i mpl ementati on
di gi tal fi l ter 1-36
f m 4-29
FM. See frequency modul ati on
f open 1-13
Fouri er transform
ei genvector equi val ent 3-22
Fouri er transform, ti me dependent. See ti me-de-
pendent Fouri er transform
Fouri er transform. See DFT, FFT
Fouri er transform. See di screte Fouri er trans-
form, FFT
f r ead 1-13
f r eq2 6-154
f r eqs 1-26, 6-3, 6-148, 6-179, 6-182
f r eqs pace 6-151
frequency 6-240
anal og xx
angul ar 2-2
carri er 4-28, 6-207, 6-303
center 2-40
cutoff 2-39
di gi tal xx
normal i zati on 2-2
Nyqui st xx, 2-2
prewarpi ng 6-19
transformati on 6-192, 6-195, 6-197, 6-199
vector 2-24, 6-133, 6-136, 6-314
frequency anal ysi s
i n Fi l ter Vi ewer 5-69
ti me-dependent 6-266
usi ng Fi l ter Vi ewer 5-69
Frequency Axis Range 5-25, 5-27
Frequency Axis Scaling 5-25, 5-26
frequency axi s scal i ng
i n Spectrum Vi ewer 5-85
frequency demodul ati on 6-94
frequency domai n
dual i ty wi th ti me domai n 1-21
FI R fi l teri ng 1-19
for fi l ter i mpl ementati on 1-21
frequency domai n based model i ng. See parametri c
model i ng
frequency esti mator functi ons
i n ei genanal ysi s 3-21
frequency esti mator techni ques
ei genvector (EV) method 3-21
mul ti pl e si gnal cl assi fi cati on (MUSI C) method
3-21
Frequency Grid Spacing 5-28
frequency modul ati on 6-208
frequency poi nts
f r eqz 1-24, 1-26
range 1-26
spaci ng 1-26
Frequency Range 5-72, 5-85
frequency response 1-24
arbi trary 2-14, 6-133
exampl e 1-25
i n Fi l ter Vi ewer 5-69
i nverse 6-177
Kai ser wi ndow 4-6
l i near phase 2-18
magni tude 1-26
Index
I-14
mi ni mi zed error between desi red and actual
2-22
monotoni c 2-9
mul ti band 2-14
of Bessel prototype 2-13
of Butterworth prototype 2-9
of Chebyshev type I prototype 2-10
of Chebyshev type I I prototype 2-11
of Chebyshev wi ndow 4-9
of el l i pti c prototype 2-12
phase 1-26
unwrappi ng 1-27
pl otti ng 1-25
poi nts at whi ch eval uated 1-24
spaci ng 6-151
speci fyi ng sampl i ng frequency 1-24
vi ewi ng i n Fi l ter Vi ewer 5-68, 5-74
Frequency Scale 5-72, 5-85
frequency transformati on 2-39
exampl e 2-40
l owpass to bandpass 6-192
l owpass to bandstop 6-195
l owpass to hi ghpass 6-197
l owpass to l owpass 6-199
frequency vector 6-240
f r eqz 1-24, 6-3, 6-86, 6-118, 6-132, 6-150, 6-151,
6-152, 6-159, 6-179, 6-182, 6-205, 6-323
frequency poi nts 1-24
sampl i ng frequency 1-24
spaci ng 6-151
From Disk 5-9
From Workspace 5-8
f s canf 1-13
Full View 5-31
G
gaus pul s 1-8, 1-10, 6-2, 6-60, 6-97, 6-155, 6-236,
6-239, 6-256, 6-259, 6-275, 6-297
Gauss-Newton method 6-179, 6-182
general i zed Butterworth fi l ter 2-15
general i zed cosi ne wi ndow 4-4
Gi bbs effect 2-20
reduced by wi ndow 4-2
graphi cal user i nterface 1-3
graphi cal user i nterface (GUI ) xvi
gri d
i n Fi l ter Desi gner 5-21
gri d snap
i n Fi l ter Desi gner 5-28, 5-61
gri d spaci ng
i n Fi l ter Desi gner 5-28
Group Delay 5-71
group del ay 1-28, 5-18, 6-157
defi ned 1-28
exampl e 1-29
of l i near response fi l ter 2-18
passband 2-13
vi ewi ng i n Fi l ter Vi ewer 5-78
group del ay pl ot 5-71, 5-78
gr pdel ay 1-28, 6-3, 6-157
GUI . See graphi cal user i nterface
GUI . See graphi cal user i nterface
GUI -based tool s. See i nteracti ve tool s
H
hammi ng 4-2, 6-7, 6-13, 6-24, 6-25, 6-47, 6-160,
6-161, 6-183, 6-296
Hammi ng wi ndow 2-20, 4-4, 6-160
hanni ng 4-2, 6-7, 6-13, 6-24, 6-25, 6-47, 6-160,
6-161, 6-183, 6-296
Hanni ng wi ndow 4-4, 6-161
Index
I-15
hi ghpass fi l ter
anal og prototype desi gn 2-6
Bessel 6-15
Butterworth 6-28, 6-29
Chebyshev type I 6-49, 6-50
Chebyshev type I I 6-54, 6-55
el l i pti c 6-105, 6-106
FI R desi gn
wi th wi ndow method 2-21, 6-132
transformati on from l owpass to 6-197
hi l ber t 2-26, 4-37, 6-6, 6-36, 6-159, 6-162, 6-164,
6-238
exampl e 4-37
Hi l bert transform 4-33, 4-37, 6-162
and anal yti c si gnal 2-26
and i nstantaneous attri butes 4-38
exampl e 4-37
Hi l bert transformer 6-143, 6-241
homomorphi c systems 4-23
Horizontal 5-35, 5-38, 5-40
I
i cceps 4-23, 4-25, 6-9, 6-159, 6-164, 6-238
exampl e 4-25
i dct 4-35, 6-6, 6-88, 6-165
i dct 2 6-88, 6-165
i deal l owpass fi l ter 2-19
i f f t 1-42, 6-6, 6-118, 6-119, 6-163, 6-165, 6-166,
6-167
speci fyi ng number of poi nts 1-44
i f f t 2 1-44, 6-6, 6-119, 6-166, 6-167
i f f t n 6-167
I I R fi l ter
arbi trary frequency response 2-14
Bessel 2-13
Butterworth 2-9
Chebyshev type I 2-10
Chebyshev type I I 2-11
compared to FI R 2-4
desi gn 2-4
di rect 2-14
Levi nson-Durbi n recursi on 6-191, 6-201
mul ti band 2-14
Prony's method 6-226
Stei gl i tz-McBri de i terati on 6-282
Yul e-Wal ker 6-314
el l i pti c 2-12
i mpl ementati on 6-123
frequency domai n 1-21
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-9, 5-64, 5-66
Chebyshev 2-7, 2-10, 2-11, 5-64, 5-66
cl assi cal
i n Fi l ter Desi gner 5-64
cl assi cal (anal og prototype) 2-5, 2-9
compari son of fi l ter types 2-9
general steps 2-37
i l l ustrati on 2-37
order esti mati on 2-7
pl otti ng prototypes 2-14
si ngl e step 2-6
si ngl e step order esti mati on 2-7
system model 2-7
di rect
Yul e-Wal ker 2-14
di rect methods 2-14
el l i pti c 2-7, 2-12, 5-64, 5-66
exampl e 5-64, 5-66
general i zed Butterworth 2-15
i n Fi l ter Desi gner 5-55, 5-64
maxi mal l y fl at 2-15
Index
I-16
parameters i n Fi l ter Desi gner 5-66
to speci fi cati ons 2-7
See also di rect desi gn, parametri c model i ng
I I R fi l ter desi gn, cl assi cal (anal og prototype)
si ngl e step 2-6
speci fyi ng fi l ter confi gurati on 2-6
I I R l atti ce fi l ter
i mpl ementati on 1-37
i mage processi ng 6-66
wi th f f t 2 and i f f t 2 1-44
i mpi nv ar 2-5, 2-41, 6-10, 6-23, 6-168, 6-194,
6-196, 6-198, 6-200
Import 5-4, 5-6
Import As 5-10
i mported fi l ter
i n s pt ool 5-15
i mpul s e 6-172
i mpul se i nvari ance 2-42, 6-168
l i mi tati ons 2-42
Impulse Response 5-71
i mpul se response 1-23, 5-18, 6-170
and i mpul se i nvari ance 2-42
computi ng wi th f i l t er 1-23
computi ng wi th i mpz 1-23
defi ned 1-23
exampl e 1-23
of i deal l owpass fi l ter 2-19
vi ewi ng i n Fi l ter Vi ewer 5-80
i mpul se response pl ot 5-71, 5-80
i mpz 6-3, 6-154, 6-170
exampl e 1-23
i ndexi ng
of vectors 1-15
Inherit From 5-86
i nheri ti ng parameters 5-86
i ni ti al condi ti ons 1-17, 1-21, 6-128
generati ng 1-18
Initial Type 5-22
i nstantaneous attri butes 4-38, 6-162
i nteracti ve tool s 5-2
extended exampl e 5-93
Fi l ter Desi gner 5-2, 5-55, 6-272
Fi l ter Vi ewer 5-2, 5-69, 6-273
Si gnal Browser 5-2, 5-43, 6-271
Spectrum Vi ewer 5-2, 5-82, 6-274
s pt ool 5-2, 6-271
i nt er p 6-9, 6-91, 6-173, 6-176, 6-252, 6-302
i nt er p1 6-174, 6-252
i nterpol ati on 6-173
FI R fi l ter desi gn 6-175
i nt f i l t 6-5, 6-175, 6-252
i nverse compl ex cepstrum 4-25
i nverse di screte cosi ne transform 6-165
accuracy of si gnal reconstructi on 4-36
i nverse di screte Fouri er transform 1-42, 6-166
i f f t 1-42
matri x 6-96
two-di mensi onal 1-44, 6-167
i nverse fi l ter desi gn 6-180, 6-226
anal og 6-177
di gi tal 6-180
i nverse Fouri er transform
conti nuous. See s i nc functi on
i nv f r eqs 2-5, 4-10, 4-16, 6-8, 6-150, 6-177, 6-182
i nv f r eqz 2-5, 4-10, 4-16, 6-8, 6-151, 6-154, 6-179,
6-180, 6-227
K
kai s er 4-2, 6-7, 6-13, 6-24, 6-25, 6-47, 6-160, 6-161,
6-183, 6-188, 6-252, 6-296
accessi ng from Fi l ter Desi gner 5-55, 5-61
exampl e 4-5
Kai ser wi ndow 4-4, 6-183
Index
I-17
and FI R fi l ter desi gn 4-7, 5-61
beta parameter 4-5, 6-183
exampl e 4-5
frequency response 4-6
kai s er or d 2-17, 6-5, 6-132, 6-183, 6-184, 6-247
accessi ng from Fi l ter Desi gner 5-64
L
l adder coeffi ci ents 1-37
Lagrange i nterpol ati on fi l ter 6-175
Lapl ace transform 1-40
equi val ent to state-space representati on 1-40
l at c2t f 1-38, 1-41, 6-3, 6-189, 6-190, 6-224, 6-237,
6-287
l at cf i l t 1-38, 6-3, 6-189, 6-190, 6-224, 6-237,
6-287
l atti ce coeffi ci ents 1-37
l atti ce fi l ter 1-41
i mpl ementati on 1-37
i mpl ementati on wi th l at cf i l t 1-38
l atti ce structure 1-37
l atti ce/l adder fi l ter
i mpl ementati on 1-37
i mpl ementati on wi th l at cf i l t 1-38
l east squares method, FI R fi l ter desi gn 6-142
fi l ter characteri sti cs 6-145
l ev i ns on 4-10, 6-8, 6-191, 6-203, 6-227
and parametri c model i ng 4-12
Levi nson-Durbi n recursi on 4-12, 6-191
l i ne col or
i n Si gnal Browser 5-34
i n Spectrum Vi ewer 5-34
l i ne sel ecti on
i n Si gnal Browser 5-33, 5-34
i n Spectrum Vi ewer 5-33, 5-34
l i ne styl e
customi zi ng i n s pt ool 5-21
i n Si gnal Browser 5-23, 5-34
i n Spectrum Vi ewer 5-23, 5-34
Line Style Order 5-23
l i near phase 2-17, 2-18, 6-142
fi l ter desi gn 6-240
rel ated characteri sti cs 2-18
l i near predi cti on coeffi ci ents 6-201
l i near predi cti on model i ng 4-11
l i near predi cti ve codi ng
l i near swept-frequency cosi ne. See chi rp
l i near system model s 1-31
l i near system transformati ons 1-40
conversi on chart 1-41
l i near ti me-i nvari ant di fferenti al equati ons
represented i n state-space form 1-39
l i near trend
removi ng from sequence 6-95
l oad 1-13
l ogs pace 6-150, 6-154
l owpass fi l ter
anal og prototype desi gn 2-6
and i mpul se i nvari ance 2-42
Bessel 6-15
Butterworth 6-27, 6-28
Chebyshev type I 6-48, 6-49
Chebyshev type I I 6-53, 6-54
el l i pti c 6-104, 6-105
FI R desi gn
wi th wi ndow method 2-21
for deci mati on 6-89
for i nterpol ati on 6-173
i deal i mpul se response 2-19
transl ati on of cutoff frequency 6-199
l p2bp 2-5, 2-39, 6-10, 6-23, 6-169, 6-192, 6-196,
6-198, 6-200
exampl e 2-40
Index
I-18
l p2bs 2-5, 2-39, 6-10, 6-23, 6-169, 6-194, 6-195,
6-198, 6-200
l p2hp 2-5, 2-39, 6-10, 6-23, 6-169, 6-194, 6-196,
6-197, 6-200
l p2l p 2-5, 2-39, 6-10, 6-23, 6-169, 6-194, 6-196,
6-198, 6-199
l pc 2-5, 4-10, 6-8, 6-191, 6-201, 6-213, 6-222,
6-227, 6-284
See also l i near predi cti ve codi ng
See also Pronys method 4-12
LPC. See l i near predi cti on coeffi ci ents
M
Magnitude 5-71
magni tude
of Fouri er transform of sequence 1-43
of frequency response 1-26
vi ewi ng i n Fi l ter Vi ewer 5-74
of transfer functi on esti mate 3-15
vector 2-24, 6-133, 6-136, 6-314
Magnitude Axis Scaling 5-25, 5-26
magni tude pl ot
i n Fi l ter Desi gner 5-60, 5-67
magni tude response 5-17
magni tude response pl ot 5-67, 5-71, 5-74
i n Fi l ter Desi gner 5-59
Magnitude Scale 5-85
magni tude scal e
i n Spectrum Vi ewer 5-85
manufacturi ng 4-10
Marker Size 5-22
match frequency (for prewarpi ng) 6-19
MAT-fi l e
dps s . mat 3-19
i mporti ng 1-13
i mporti ng i nto s pt ool 5-4, 5-6
l oadi ng i nto s pt ool 5-9
MAT-fi l e format
converti ng to 1-13
matri ces
convol uti on 1-38, 6-68
correl ati on coeffi ci ent 6-70
covari ance 6-71
data 1-4, 1-7
di screte Fouri er transform 6-96
for second-order secti ons form 1-36
i nverse di screte Fouri er transform 6-96
matri x form. See state-space form
maxfl at 6-4
max f l at 2-5, 2-15, 6-4, 6-31, 6-135, 6-204, 6-316
maxi ma
l ocal 5-36
maxi mal l y fl at 2-15
maxi mum entropy method 4-11
maxi mum entropy method (MEM) 3-5, 3-6, 3-19
compared to Wel chs method 3-20
defi ned 3-19
exampl e 3-20
i n Spectrum Vi ewer 5-91
mean 6-70, 6-71
measurements
i n Si gnal Browser 5-38
i n Spectrum Vi ewer 5-38, 5-87
savi ng i n Si gnal Browser 5-37
savi ng i n Spectrum Vi ewer 5-37
medf i l t 1 4-27, 6-9, 6-206
medf i l t 2 6-206
medi an 6-70, 6-71, 6-206
medi an fi l ter 4-27, 6-206
MEM. See maxi mum entropy method
message si gnal 4-28, 6-207
Method 5-89
MEX-fi l e 1-13
Index
I-19
M-fi l es 1-3
creati ng xvi, 1-3
modi fyi ng xvi
vi ewi ng xvi
mi ni ma
l ocal 5-36
mi ni max method, FI R fi l ter desi gn 2-22
See also Parks-McCl el l an method
mi ni mum phase fi l ter 6-225
model s
system representati on 1-31
modi fi ed peri odogram 3-9
modul at e 4-28, 6-9, 6-94, 6-207, 6-304
exampl e 4-30
method fl ags 4-29
modul ati on 6-207
ampl i tude
defi ned 4-28
exampl e 4-30
frequency
methods 4-29, 6-207
phase 4-29
pul se ti me 4-29
pul se wi dth 4-29
quadrature ampl i tude 4-29
Mouse Zoom 5-31
mouse zoom 5-31
i n Fi l ter Desi gner 5-21
i n Fi l ter Vi ewer 5-21, 5-73
i n Si gnal Browser 5-21
i n Spectrum Vi ewer 5-21
turni ng off 5-32
movi ng average (MA) fi l ter 1-15
See also FI R fi l ter
MTM. See mul ti taper method
mul ti band fi l ter
FI R 2-21
wi th transi ti on bands 2-22
I I R 2-14
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-21
defi ned 3-21
i n Spectrum Vi ewer 5-92
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
compared to Wel chs method 3-19
defi ned 3-16
exampl e 3-17
i n Spectrum Vi ewer 5-91
MUSI C. See mul ti pl e si gnal cl assi fi cati on
method
N
New Design 5-6, 5-15, 5-18, 5-56
noni nteger del ay 2-26
nonrecursi ve fi l ter. See FI R fi l ter
normal i zati on 3-3
correl ati on 3-4, 6-306
power spectral densi ty 3-11
Nyqui st frequency xx, 2-2
O
oe 6-284
Open Session 5-6
order
of fi l ter 1-15, 2-7
order esti mati on 2-7, 6-245
Index
I-20
Butterworth 6-32
Chebyshev type I 6-38
Chebyshev type I I 6-43
el l i pti c 6-111
i n Fi l ter Desi gner 5-63, 5-66
order sel ecti on 2-7
i n Fi l ter Desi gner 5-63, 5-67
orthogonal wi ndows
i n psd esti mates 3-16
osci l l ator
vol tage control l ed 6-303
overl ap-add method
FI R fi l ter i mpl ementati on 1-22
overl ap-add method, fi l ter i mpl ementati on
6-120
overl ap-add method, FI R fi l ter i mpl ementati on
6-120
P
Panner 5-24
panner 5-52
i n Si gnal Browser 5-21, 5-24, 5-48
parameters
appl yi ng i n Spectrum Vi ewer 5-86
i n Spectrum Vi ewer 5-85, 5-88
i nheri ti ng i n Spectrum Vi ewer 5-86
parametri c model i ng 4-10, 6-180
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-11, 4-12
Stei gl i tz-McBri de method 4-14
ti me-domai n based 4-11
Parks-McCl el l an method, FI R fi l ter desi gn 2-22,
6-240
Parseval s rel ati on 3-13
parti al fracti on 1-41
parti al fracti on expansi on 1-39
defi ned 1-34
determi ni ng wi th r es i due 1-40
exampl e 1-35
parti al fracti on form 1-34
parti al fracti ons form 6-253
passband
equi ri ppl e 2-10, 2-12
group del ay 2-13
passband ri ppl e
setti ng i n Fi l ter Desi gner 5-61
Passband Zoom 5-32
passband zoom 5-32
peri odi c si nc functi on 6-97
peri odi c si nc functi on. See Di ri chl et functi on
peri odogram 3-6
modi fi ed 3-9
Phase 5-71
phase
computi ng wi th angl e 6-12
of Fouri er transform of sequence 1-43
of frequency response 1-26
vi ewi ng i n Fi l ter Vi ewer 5-76
of transfer functi on esti mate 3-14
unwrappi ng 1-27, 6-298
phase del ay 1-28, 6-157
defi ned 1-28
exampl e 1-29
of l i near response fi l ter 2-18
phase demodul ati on 6-94
phase di storti on
el i mi nati ng
exampl e 1-20
Index
I-21
el i mi nati ng duri ng fi l teri ng 1-19
el i mi nati ng usi ng f i l t f i l t 1-20
i n FI R fi l ters 1-19
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-29, 6-208
phase response 5-18
phase response pl ot 5-71, 5-76
Phase Units 5-26
phase uni ts
i n Fi l ter Vi ewer 5-26
Play 5-45
pl ayi ng a si gnal 5-45
pl ot
anal og prototypes 2-14
coherence functi on 3-16
compl ex cepstrum 4-24
DFT 1-43
frequency response 1-25
magni tude 1-26
phase 1-26
group del ay 1-29, 5-71, 5-78
i mpul se response 5-71, 5-80
i n Fi l ter Vi ewer 5-69, 5-71, 5-73
magni tude response 5-67, 5-71, 5-74
MEM vs. peri odogram 3-20
modi fi ed peri odogram 3-9
mul ti taper esti mate 3-17, 3-18
peri odogram 3-7
phase del ay 1-29
phase response 5-71, 5-76
power spectral densi ty 3-10
spectral densi ty 5-87
step response 5-71, 5-81
stri p pl ot 6-285
ti l i ng i n Fi l ter Vi ewer 5-73
transfer functi on 3-15
vi ewi ng i n Fi l ter Vi ewer 5-74
zero-pol e 1-30, 5-71, 5-79, 6-322
pl ot 6-286
pl ug-i ns 5-21, 5-29
pm 4-29
pmem 3-6, 3-20, 6-6, 6-83, 6-203, 6-210, 6-216,
6-222, 6-231
exampl e 3-20
p-model . See parametri c model i ng
pmt m 3-6, 6-6, 6-83, 6-99, 6-213, 6-214, 6-222,
6-231
exampl e 3-17
pmus i c 3-6, 3-21, 6-7, 6-83, 6-213, 6-216, 6-217,
6-231
pol e-zero fi l ter. See I I R fi l ter
pol y 1-32, 1-41, 6-255
pol y 2r c 6-3, 6-223, 6-237, 6-287
pol y f i t 6-95
pol ynomi al
stabi l i zati on 6-225
pol ynomi al di vi si on 4-32, 6-92
pol ynomi al mul ti pl i cati on 6-65
pol ynomi al roots 1-32
pol yphase fi l teri ng techni ques 1-19
pol y s t ab 6-9, 6-225
pol y v al 6-150
power spectral densi ty 6-228
approxi mati ng energy i n frequency band 3-13
bi as 3-11
computati on parameters 5-88, 5-90
confi dence i nterval 3-14
defaul t pl ot 5-88
defi ned 3-5
Index
I-22
esti mati on by maxi mum entropy method 3-6,
3-19, 5-91
esti mati on by mul ti taper method 3-6, 3-16,
5-91
esti mati on by MUSI C method 3-6, 3-21, 5-92
esti mati on by Wel chs method 3-6, 3-10, 5-90
esti mati on methods 5-88, 5-90
i n s pt ool 5-13
normal i zati on 3-11
vi ewi ng i n Spectrum Vi ewer 5-82, 5-88, 5-89
Preferences 5-7, 5-21, 5-29
preferences
rul ers 5-22
savi ng i n Si gnal Browser 5-45
preferences fi l e
i n s pt ool 5-30
s i gpr ef s . mat 5-30
prewarpi ng 6-19
defi ned 6-19
prol ate-spheroi dal wi ndow 4-4
pr ony 2-5, 4-10, 4-12, 6-8, 6-179, 6-182, 6-191,
6-203, 6-213, 6-222, 6-226, 6-255, 6-284
Prony's method 6-226
Pronys method 4-12
model i ng 4-12
prototype
Bessel fi l ter 2-13, 6-14
Butterworth fi l ter 2-9, 6-26
Chebyshev type I fi l ter 6-37
Chebyshev type I I fi l ter 6-42
el l i pti c fi l ter 6-110
ps d 3-6, 3-10, 6-7, 6-64, 6-83, 6-118, 6-213, 6-216,
6-222, 6-228, 6-269, 6-295
exampl e 3-11
PSD. See power spectral densi ty
pt m 4-29
pul se ti me demodul ati on 6-94
pul se ti me modul ati on 4-29, 6-208
pul se trai n generator 6-233
pul se trai ns
generati ng 1-9
pul s t r an 1-9
pul se wi dth demodul ati on 6-94
pul se wi dth modul ati on 4-29, 6-208
pul s t r an 1-9, 6-2, 6-58, 6-60, 6-97, 6-98, 6-100,
6-101, 6-102, 6-103, 6-156, 6-233, 6-239,
6-256, 6-259, 6-275, 6-287, 6-297
pwm 4-29
Q
qam 4-29
quadrature ampl i tude demodul ati on 6-94
quadrature ampl i tude modul ati on 4-29, 6-208
quanti zati on noi se 6-318
R
radar appl i cati ons 4-26
radi x-2 al gori thm 1-43
r andn xviii
random number
generati on xviii
r c2pol y 6-3, 6-224, 6-237, 6-287
r ceps 4-23, 4-24, 6-9, 6-36, 6-159, 6-163, 6-164,
6-238
real cepstrum 6-238
defi ned 4-24
reconstructi ng si gnal (mi ni mum-phase) 4-24
rectangul ar wi ndow 2-19, 4-2, 6-25
r ect pul s 6-2, 6-60, 6-97, 6-156, 6-236, 6-239,
6-256, 6-259, 6-275, 6-297
recursi ve fi l ter. See I I R fi l ter
references 1-45, 3-24, 4-39
Index
I-23
refl ecti on coeffi ci ents 1-37, 1-38, 6-223, 6-237
r emez 2-17, 2-22, 6-5, 6-132, 6-135, 6-138, 6-141,
6-146, 6-147, 6-240, 6-247, 6-316
accessi ng from Fi l ter Desi gner 5-55, 5-61, 5-63
compared to f i r l s 2-23
fi l ter characteri sti cs 6-243
for di fferenti ator desi gn 2-26
for Hi l bert transformer desi gn 2-25
order esti mati on 6-245
wei ght vector 2-25
Remez exchange al gori thm 2-22, 6-240
r emez or d 2-17, 6-5, 6-188, 6-244, 6-245
accessi ng from Fi l ter Desi gner 5-63
r es ampl e 6-9, 6-91, 6-174, 6-176, 6-249, 6-302
resampl i ng 4-20, 6-249
i n FI R fi l teri ng 1-19
See also deci mati on, i nterpol ati on 4-20
r es i due 1-40, 1-41, 6-255
resi due form. See parti al fracti on form
r es i duez 1-41, 6-3, 6-65, 6-92, 6-253
Revert Panel 5-30
ri ppl e
passband 5-61
roots
of Bessel fi l ter 6-14
pol ynomi al 1-32
r oot s 1-32, 1-41, 6-225, 6-255
Ruler Color 5-22
rul er col or 5-22
Ruler Marker 5-22
rul er markers 5-22, 5-35
rul er type
i n Si gnal Browser 5-22
i n Spectrum Vi ewer 5-22
Rulers 5-24, 5-25
rul ers
bri ngi ng to center 5-35
customi zi ng i n s pt ool 5-21
draggi ng 5-36
fi nd rul er buttons 5-35
hori zontal 5-35
hori zontal mode 5-40
i n Si gnal Browser 5-21, 5-22, 5-24, 5-32
i n Spectrum Vi ewer 5-21, 5-22, 5-25, 5-32
parameters 5-36
posi ti oni ng 5-38
preferences 5-22
savi ng measurements 5-37
sl ope 5-35
sl ope mode 5-42
track 5-35
track mode 5-41
verti cal 5-35
verti cal mode 5-39
S
Sampling Frequency 5-5, 5-11, 5-17
sampl i ng frequency
changi ng i n s pt ool 5-11
i n Fi l ter Desi gner 5-59
i n s pt ool 5-17
sampl i ng rate
changi ng by non-i nteger factor 4-20, 6-249
changi ng for i rregul arl y spaced data 4-22
changi ng wi th upf i r dn 1-19
decreasi ng by i nteger factor 6-89
i ncreasi ng by i nteger factor 6-173
Save Rulers 5-37
Save Session 5-7
savi ng changes i n s pt ool 5-29
savi ng data
from Fi l ter Desi gner 5-67
savi ng setti ngs
Index
I-24
i n Fi l ter Vi ewer 5-71
s awt oot h 1-8, 6-2, 6-60, 6-97, 6-156, 6-236, 6-239,
6-256, 6-259, 6-275, 6-297
sawtooth wave 1-8
scal ar
for state-space form 1-33
representi ng gai n 1-32
Search for Plug-Ins at start-up 5-29
second-order secti ons 1-41
second-order secti ons form 1-36
converti ng to state-space 6-260
converti ng to transfer functi on 6-262
converti ng to zero-pol e-gai n 6-264
defi ned 1-36
i n s pt ool 5-13
sel ecti ng data objects i n s pt ool 5-15
Set 5-58
setti ngs
restori ng i n s pt ool 5-29
rul ers 5-22
savi ng i n Si gnal Browser 5-45
savi ng i n s pt ool 5-30
si gnal
addi ng noi se 1-6
anal yti c 4-37, 6-162
carri er 4-28, 6-93
compl ex 5-46
conti nuous (anal og) 1-2
di fferenti ati on 2-26
di screte (di gi tal ) 1-2
generati ng 1-7
i mporti ng i nto s pt ool 5-4, 5-8, 5-9, 5-12
l i nki ng to spectrum 5-85
measurements 5-38
measurements i n Si gnal Browser 5-35
message 4-28, 6-207
mul ti channel 3-4
nami ng i n s pt ool 5-17
peaks 5-36
pl ayi ng 5-45
pl otti ng 1-6
reconstructi on
from DCT coeffi ci ents 4-36
mi ni mum phase 4-24, 6-238
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-47
val l eys 5-36
vi ewi ng i n Si gnal Browser 5-17, 5-47
See also waveform
Si gnal Browser 5-2, 5-17, 5-43, 6-271
acti vati ng 5-17, 5-43
customi zi ng 5-21
wi ndow 5-44
Si gnal Processi ng Tool box 1-2
si gnal type
array 5-14
vector 5-14
s i gpr ef s . mat 5-30
s i n 6-60, 6-97, 6-156, 6-236, 6-239, 6-256, 6-259,
6-275, 6-297
s i nc 1-10, 6-2, 6-60, 6-97, 6-156, 6-236, 6-239,
6-256, 6-257, 6-275, 6-297
bandl i mi ted i nterpol ati on exampl e 6-258
si nc functi on 1-10, 6-257
and bandl i mi ted i nterpol ati on 6-258
basi c exampl e 1-10
defi ned 1-10
si nusoi dal wave 1-8
Sl epi an sequences. See di screte prol ate spheroi dal
sequences
Slope 5-35, 5-38, 5-42
Index
I-25
Snap to Grid when dragging bands 5-28
sonar appl i cati ons 4-26
s os 2s s 1-41, 6-3, 6-260, 6-263, 6-265, 6-278,
6-319
s os 2t f 1-41, 6-3, 6-261, 6-262, 6-265, 6-278,
6-319
s os 2z p 1-41, 6-3, 6-261, 6-263, 6-264, 6-278,
6-319
s pa 6-295
s pecgr am 4-26, 6-9, 6-231, 6-266
exampl e 4-26, 6-303
Special Design Parameters 5-58, 5-63, 5-66
speci fi cati ons for fi l ter desi gn 2-7
speci fi cati ons l i nes 5-67
draggi ng to edi t fi l ter 5-61
spectral anal ysi s 3-5
cross spectral densi ty 3-14
defi ned 3-5
maxi mum entropy method 4-11
power spectral densi ty 3-5
usi ng Spectrum Vi ewer 5-82
spectral densi ty 3-5
See also power spectral densi ty, cross spectral
densi ty
spectral densi ty pl ot
i n Spectrum Vi ewer 5-86
vi ewi ng i n Spectrum Vi ewer 5-87
spectrogram 4-26, 6-266
exampl e 4-26, 6-303
spectrum
computi ng i n s pt ool 5-20
generati ng i n s pt ool 5-19
i mporti ng i nto s pt ool 5-8, 5-9, 5-13
l i nki ng to si gnal 5-85
measurements 5-38
measurements i n Spectrum Vi ewer 5-35, 5-87
nami ng i n s pt ool 5-17
peaks 5-36
updati ng i n s pt ool 5-20
val l eys 5-36
vi ewi ng i n Spectrum Vi ewer 5-82
vi ewi ng i n s pt ool 5-20
spectrum type
auto 5-15
Spectrum Vi ewer 5-2, 5-19, 5-82, 6-274
acti vati ng 5-19, 5-82
changi ng pl ot properti es 5-88
customi zi ng 5-21
defaul t pl ot 5-88
setti ng confi dence i nterval s 5-92
vi ewi ng power spectral densi ty pl ots 5-88
wi ndow 5-84
speech processi ng 4-10, 4-21
s pl i ne 4-22, 6-91, 6-174, 6-252
s pt ool 5-2, 6-10, 6-271
acti vati ng from Si gnal Browser 5-54
cl osi ng 5-7
customi zi ng 5-7, 5-21
l oadi ng 5-3
preferences 5-7
wi ndow 5-6
s quar e 1-8, 6-2, 6-60, 6-97, 6-156, 6-236, 6-239,
6-256, 6-259, 6-275, 6-297
square wave 1-8
s s 2s os 1-41, 6-3, 6-261, 6-263, 6-265, 6-276,
6-319
s s 2t f 1-41, 6-255, 6-279, 6-281, 6-289, 6-291,
6-320, 6-321
s s 2z p 1-41, 6-4, 6-279, 6-280, 6-289, 6-291, 6-320,
6-321
stabi l i zati on, pol ynomi al 6-225
standards
Compact Di sc 4-20
Di gi tal Audi o Tape 4-20
Index
I-26
startup transi ents 1-22
reduci ng 1-21, 6-127
state-space form 1-39, 1-41
converti ng to second-order secti on 6-276
converti ng to zero-pol e-gai n 6-280
defi ned 1-33
i n s pt ool 5-13
representi ng i n MATLAB 1-33
stati sti cal operati ons 3-2
Stay in Zoom-mode After Zoom 5-24, 5-25,
5-27, 5-28
s t d 6-70, 6-71
Stei gl i tz-McBri de i terati on 6-282
Stei gl i tz-McBri de Method 4-14
s t em 6-172, 6-286
Step Response 5-71
step response 5-18
vi ewi ng i n Fi l ter Vi ewer 5-81
step response pl ot 5-71, 5-81
s t mcb 2-5, 4-10, 4-14, 6-8, 6-191, 6-203, 6-227,
6-282
stopband
equi ri ppl e 2-11, 2-12
stopband attenuati on
setti ng i n Fi l ter Desi gner 5-61
stri p pl ot 6-285
defi ned 6-285
s t r i ps 6-2, 6-285
structure
di gi tal fi l ter
l atti ce 1-37
transposed di rect form I I 1-17
subpl ots 5-69
i n Fi l ter Vi ewer 5-71
subspace threshol ds
control l i ng i n pmus i c functi on 3-23
s v d
i n pmus i c functi on 3-22
swept-frequency cosi ne generator. See chi rp
system i denti fi cati on 4-13
system model s 1-31
and bi l i near transformati on 2-43
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-18
texts, rel ated 1-45
t f 2l at c 1-38, 1-41, 6-4, 6-189, 6-190, 6-224, 6-237,
6-287
t f 2s s 1-41, 6-4, 6-255, 6-279, 6-281, 6-288, 6-291,
6-320, 6-321
t f 2z p 1-41, 6-255, 6-279, 6-280, 6-289, 6-290,
6-320, 6-321
t f e 3-6, 3-14, 6-7, 6-64, 6-83, 6-231, 6-269, 6-292
t hr es h 3-23
ti l i ng 5-73
ti l i ng di spl ay
i n Fi l ter Vi ewer 5-27
ti l i ng preferences
i n Fi l ter Vi ewer 5-21
Ti me 4-26
Time Response Length 5-26
ti me response l ength
i n Fi l ter Vi ewer 5-26
ti me vector 1-6
returned by modul at e 4-29
ti me-dependent Fouri er transform 4-26
ti me-domai n anal ysi s
i n Fi l ter Vi ewer 5-69
Index
I-27
ti me-domai n based model i ng. See parametri c
model i ng
tool box
Control System Tool box 1-34
control s 6-172
i mage processi ng 6-88, 6-165, 6-206
Si gnal Processi ng Tool box 1-2
symbol i c math 6-14
system i denti fi cati on 6-203, 6-284, 6-295
Track 5-35, 5-38, 5-41
transfer functi on 1-31, 1-34, 1-39, 1-41
coeffi ci ents 1-15
converti ng to state-space 6-288
defi ned 1-15
deri vati on 1-15
esti mate from i nput and output 6-292
esti mati ng usi ng Wel chs method 3-14
factored form 1-32
for anal og fi l ter 1-40
representi ng i n MATLAB 1-31
speci fyi ng i n s pt ool 5-12
zero-pol e-gai n form 1-32
transform 4-33
chi rp z-transform 6-85
chi rp z-transform (CZT) 4-33
di screte cosi ne 6-87
di screte Fouri er 1-42, 6-115
Hi l bert 4-37, 6-162
i nverse di screte cosi ne 4-35, 6-165
i nverse di screte Fouri er 6-166
transformati ons
between system model s 1-40
bi l i near 2-42, 6-19
frequency 2-39, 6-192, 6-195, 6-197, 6-199
transi ti on band 2-23
transposed di rect form I I 6-123
i ni ti al condi ti ons 6-128
trend
removi ng 6-95
t r i ang 4-2, 6-7, 6-13, 6-24, 6-25, 6-47, 6-160,
6-161, 6-183, 6-296
compared to bar t l et t 6-13
exampl e 4-2
tri angul ar wi ndow 6-296
t r i pul s 6-2, 6-60, 6-97, 6-156, 6-236, 6-239, 6-256,
6-259, 6-275, 6-297
two-di mensi onal operati ons
autocorrel ati on 6-310
convol uti on 6-66
obtai ni ng subsecti on 6-66
cross-correl ati on 6-310
di screte Fouri er transform 1-44, 6-119
fi l teri ng 6-126
i nverse di screte Fouri er transform 1-44, 6-167
two-di mensi onal si gnal processi ng
wi th f f t 2 and i f f t 2 1-44
U
uni t ci rcl e 6-225
uni t i mpul se functi on 1-7
uni t ramp functi on 1-7
uni t sampl e
mul ti channel representati on 1-7
uni t step functi on 1-7
unwr ap 1-27, 6-3, 6-36, 6-164, 6-238, 6-298
Update Spectrum 5-20, 5-83
upf i r dn 1-19, 6-9, 6-91, 6-174, 6-252, 6-299
V
vari ance
of correl ati on sequence esti mate 3-4
of power spectrum esti mate 3-8
Index
I-28
v co 4-28, 4-30, 6-9, 6-94, 6-209, 6-303
vector
data 1-4
di spl ay
i n Si gnal Browser 5-49
for fi l ter coeffi ci ents 1-16, 1-31
frequency 2-24, 6-133, 6-136, 6-240, 6-314
i n s pt ool 5-14
i ndexi ng xx, 1-15
magni tude 2-24, 6-133, 6-136, 6-314
ti me 1-6
wei ghti ng 2-25, 6-143, 6-241
Verti cal 5-35
Vertical 5-35, 5-38, 5-39
View 5-17, 5-20
vol tage control l ed osci l l ator 4-30, 6-303
W
waveform
aperi odi c 1-8
chi rp
exampl e 1-9
from si nusoi ds 1-6
generati ng wi th di r i c functi on 1-11
generati ng wi th pul s t r an 1-9
generati ng wi th s i nc functi on 1-10
l i near swept-frequency cosi ne. See chi rp
peri odi c 1-8
sawtooth 1-8, 6-256
exampl e 1-8
si nusoi dal pul se
Gaussi an-modul ated 1-8
square 1-8, 6-275
tri angl e 6-256
Wel chs method 3-6
bi as 3-11
compared to MEM 3-20
compared to MTM 3-19
for cross spectral densi ty esti mati on 3-14, 6-83
for nonparametri c system i denti fi cati on 3-14
for power spectral densi ty esti mati on 3-5, 3-10,
6-64, 6-231
i n Spectrum Vi ewer 5-90
normal i zati on 3-11
whi te noi se 1-6
wi ndow
appl i ed to peri odogram 3-9
Bartl ett 4-2, 6-13
Bl ackman 4-4, 6-24
boxcar 2-19
Chebyshev 4-8, 6-47
for fi l ter desi gn 2-19
general i zed cosi ne 4-4
Hammi ng 2-20, 4-4, 6-160
Hanni ng 4-4, 6-161
Kai ser 4-4, 6-183
rectangul ar 2-19, 6-25
shapes, overvi ew 4-2
speci fyi ng for f i r 1 2-21
tri angul ar 6-296
wi ndow method
FI R fi l ter desi gn 2-19
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-130
bandstop confi gurati on 6-130
hi ghpass confi gurati on 6-130
l owpass confi gurati on 6-130
workspace
l oadi ng vari abl es from 5-8
Workspace Contents l i st 5-8
Index
I-29
X
X Label 5-24
x cor r 3-2, 6-7, 6-65, 6-67, 6-70, 6-71, 6-305, 6-310,
6-313
and parametri c model i ng 4-12
x cor r 2 6-7, 6-67, 6-309, 6-310, 6-313
x cov 3-2, 6-7, 6-70, 6-71, 6-309, 6-311
Y
Y Label 5-24
y ul ewal k 2-5, 2-14, 4-10, 6-4, 6-135, 6-244, 6-314
exampl e 2-15
Yul e-Wal ker equati ons 2-14
Yul e-Wal ker fi l ter desi gn 6-314
Z
zero frequency component
centeri ng wi th f f t s hi f t 1-44
zero-order hol d 6-249
See also averagi ng fi l ter
zero-phase fi l teri ng 6-127
zero-pol e anal ysi s
exampl e 1-30
zero-pol e pl ots 6-322
zero-pol e gai n 1-41
zero-pol e pl ot 5-71, 5-79
vi ewi ng i n Fi l ter Vi ewer 5-79
zero-pol e-gai n form 1-39
converti ng to second-order secti on 6-317
converti ng to state-space 6-320
defi ned 1-32
i n s pt ool 5-13
representi ng i n MATLAB 1-32
Zeros and Poles 5-71
zeros and pol es 5-18
i n transfer functi on 1-32
zoom control s
i n Fi l ter Desi gner 5-30
i n Fi l ter Vi ewer 5-30
i n Si gnal Browser 5-30
i n Spectrum Vi ewer 5-30
i n s pt ool 5-30
Zoom In-X 5-31
Zoom In-Y 5-31
Zoom Out-X 5-31
Zoom Out-Y 5-31
zoom persi stence 5-31
changi ng 5-32
i n Fi l ter Desi gner 5-28
i n Fi l ter Vi ewer 5-27, 5-32, 5-72
i n Si gnal Browser 5-24
i n Spectrum Vi ewer 5-25
zoomi ng
i n Fi l ter Desi gner 5-66
i n Fi l ter Vi ewer 5-72
i n Spectrum Vi ewer 5-88
z p2s os 1-41, 6-4, 6-261, 6-263, 6-265, 6-278,
6-317
z p2s s 1-41, 6-4, 6-255, 6-279, 6-281, 6-289, 6-291,
6-320, 6-321
z p2t f 1-41, 6-279, 6-289, 6-290, 6-291, 6-320,
6-321
z pl ane 1-30, 6-3, 6-322
z-transform 1-15, 1-31
chi rp z-transform (CZT) 4-33
di screte Fouri er transform 1-42
z-transform
chi rp z-transform 6-85
di screte Fouri er transform 6-115
Index
I-30

You might also like