Tải bản đầy đủ (.pdf) (478 trang)

XỬ LÝ TÍN HIỆU SỐ Digital signal processing using matlab and wavelets

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (2.81 MB, 478 trang )

DIGITAL SIGNAL PROCESSING
®

Using MATLAB and Wavelets
Michael Weeks

Designed for upper division engineering and computer science students as well as practicing engineers,
Digital Signal Processing Using MATLAB and Wavelets emphasizes the practical applications of signal
processing. Over 100 MATLAB examples and wavelet techniques provide the latest applications of DSP,
including image processing, games, filters, transforms, networking, parallel processing, and sound.
The book also provides the mathematical processes and techniques needed to ensure an understanding of DSP theory. Designed to be incremental in difficulty, the book will benefit readers who are
unfamiliar with complex mathematical topics or those limited in programming experience. Beginning
with an introduction to MATLAB programming, it moves through filters, sinusoids, sampling, the Fourier transform, the z-transform and other key topics. An entire chapter is dedicated to the discussion
of wavelets and their applications. A CD-ROM (platform independent) accompanies the book and
contains source code, projects for each chapter, and the figures contained in the book.
FEATURES:
■ Contains over 100 short examples in MATLAB used
throughout the book
■ Includes an entire chapter on the wavelet transform
■ Designed for the reader who does not have extensive
math and programming experience
■ Accompanied by a CD-ROM containing MATLAB
examples, source code, projects, and figures from
the book
■ Contains modern applications of DSP and MATLAB
project ideas

BRIEF TABLE OF CONTENTS:
1. Introduction. 2. MATLAB.
3. Filters. 4. Sinusoids. 5. Sampling.
6. The Fourier Transform. 7. The


Number e. 8. The z-Transform.
9. The Wavelet Transform
10. Applications. Appendix A.
Constants and Variables.
B. Equations. C. DSP Project Ideas.
D. About the CD. Answers.
Glossary. Index.

ABOUT THE AUTHOR:

Shelving: Engineering / Computer Science
Level: Intermediate to Advanced

ISBN: 0-9778582-0-0
U.S. $69.95 / Canada $85.50

INFINITY SCIENCE PRESS

WEEKS
All trademarks and service marks are the property of their respective owners.
Cover design: Tyler Creative

weeks_DSP.indd 1

Using MATLAB
and Wavelets

®

Michael Weeks


®

11 Leavitt Street
Hingham, MA 02043
(781) 740-4487
(781) 740-1677 FAX

www.infinitysciencepress.com

DIGITAL SIGNAL
PROCESSING

Using MATLAB
and Wavelets

Michael Weeks is an associate professor at Georgia State University where he teaches courses in Digital Signal Processing.
He holds a PhD in computer engineering from the University of Louisiana at Lafayette and has authored or co-authored
numerous journal and conference papers.

DIGITAL SIGNAL PROCESSING

Although DSP has long been considered an EE topic, recent developments have also generated significant interest from the computer science community. DSP applications in the consumer market,
such as bioinformatics, the MP3 audio format, and MPEG-based cable/satellite television have fueled
a desire to understand this technology outside of hardware circles.

E L E C T R I C A L EN G I N E E R I N G SE R I E S

8/11/06 1:15:29 PM



Digital Signal Processing
Using MATLAB
r and Wavelets


License, Disclaimer of Liability, and Limited Warranty
The CD-ROM that accompanies this book may only be used on a single PC. This
license does not permit its use on the Internet or on a network (of any kind). By
purchasing or using this book/CD-ROM package (the “Work”), you agree that this
license grants permission to use the products contained herein, but does not give
you the right of ownership to any of the textual content in the book or ownership to
any of the information or products contained on the CD-ROM. Use of third party
software contained herein is limited to and subject to licensing terms for the respective products, and permission must be obtained from the publisher or the owner of
the software in order to reproduce or network any portion of the textual material
or software (in any media) that is contained in the Work.
Infinity Science Press LLC (“ISP” or “the Publisher”) and anyone involved
in the creation, writing or production of the accompanying algorithms, code, or
computer programs (“the software”) or any of the third party software contained on
the CD-ROM or any of the textual material in the book, cannot and do not warrant
the performance or results that might be obtained by using the software or contents
of the book. The authors, developers, and the publisher have used their best efforts to insure the accuracy and functionality of the textual material and programs
contained in this package; we, however, make no warranty of any kind, express or
implied, regarding the performance of these contents or programs. The Work is sold
“as is” without warranty (except for defective materials used in manufacturing the
disc or due to faulty workmanship);
The authors, developers, and the publisher of any third party software, and anyone
involved in the composition, production, and manufacturing of this work will not be
liable for damages of any kind arising out of the use of (or the inability to use) the
algorithms, source code, computer programs, or textual material contained in this

publication. This includes, but is not limited to, loss of revenue or profit, or other
incidental, physical, or consequential damages arising out of the use of this Work.
The sole remedy in the event of a claim of any kind is expressly limited to replacement of the book and/or the CD-ROM, and only at the discretion of the Publisher.
The use of “implied warranty” and certain “exclusions” vary from state to state,
and might not apply to the purchaser of this product.


Digital Signal Processing
Using MATLAB
r and Wavelets

Michael Weeks
Georgia State University

Infinity Science Press LLC
Hingham, Massachusetts


Copyright 2007 by Infinity Science Press LLC
All rights reserved.
This publication, portions of it, or any accompanying software may not be reproduced in any way, stored in
a retrieval system of any type, or transmitted by any means or media, electronic or mechanical, including,
but not limited to, photocopy, recording, Internet postings or scanning, without prior permission in writing
from the publisher.
Publisher: David F. Pallai
Infinity Science Press LLC
11 Leavitt Street
Hingham, MA 02043
Tel. 877-266-5796 (toll free)
Fax 781-740-1677


www.infinitysciencepress.com
This book is printed on acid-free paper.
Michael Weeks. Digital Signal Processing Using MATLAB and Wavelets.
ISBN: 0-9778582-0-0

The publisher recognizes and respects all marks used by companies, manufacturers, and developers as a
means to distinguish their products. All brand names and product names mentioned in this book are trademarks or service marks of their respective companies. Any omission or misuse (of any kind) of service marks
or trademarks, etc. is not an attempt to infringe on the property of others.
Library of Congress Cataloging-in-Publication Data
Weeks, Michael.
Digital signal processing using MATLAB and Wavelets / Michael Weeks.
p. cm.
Includes index.
ISBN 0-9778582-0-0 (hardcover with cd-rom : alk. paper)
1. Signal processing–Digital techniques–Mathematics. 2. MATLAB. 3.
Title.
TK5102.9.W433 2006
621.382’2–dc22
2006021318

Wavelets (Mathematics)

I.

678954321

Our titles are available for adoption, license or bulk purchase by institutions, corporations, etc. For additional information, please contact the Customer Service Dept. at 877-266-5796 (toll free).
Requests for replacement of a defective CD-ROM must be accompanied by the original disc, your mailing address, telephone number, date of purchase and purchase price. Please state the nature of the problem,
and send the information to Infinity Science Press, 11 Leavitt Street, Hingham, MA 02043.

The sole obligation of Infinity Science Press to the purchaser is to replace the disc, based on defective materials or faulty workmanship, but not based on the operation or functionality of the product.


I dedicate this book to my wife Sophie. Je t’aimerai pour toujours.



Contents
Preface

xxi

1 Introduction
1.1 Numbers . . . . . . . . . . . . . . . . . . . . . . . . . .
1.1.1 Why Do We Use a Base 10 Number System? .
1.1.2 Why Do Computers Use Binary? . . . . . . .
1.1.3 Why Do Programmers Sometimes Use Base 16
(Hexadecimal)? . . . . . . . . . . . . . . . . . .
1.1.4 Other Number Concepts . . . . . . . . . . . . .
1.1.5 Complex Numbers . . . . . . . . . . . . . . . .
1.2 What Is a Signal? . . . . . . . . . . . . . . . . . . . .
1.3 Analog Versus Digital . . . . . . . . . . . . . . . . . .
1.4 What Is a System? . . . . . . . . . . . . . . . . . . . .
1.5 What Is a Transform? . . . . . . . . . . . . . . . . . .
1.6 Why Do We Study Sinusoids? . . . . . . . . . . . . . .
1.7 Sinusoids and Frequency Plots . . . . . . . . . . . . .
1.8 Summations . . . . . . . . . . . . . . . . . . . . . . . .
1.9 Summary . . . . . . . . . . . . . . . . . . . . . . . . .
1.10 Review Questions . . . . . . . . . . . . . . . . . . . . .
2 MATLAB

2.1 Working with Variables . . . . . . . .
2.2 Getting Help and Writing Comments
2.3 MATLAB Programming Basics . . . .
2.3.1 Scalars, Vectors, and Matrices
2.3.2 Number Ranges . . . . . . . . .
2.3.3 Output . . . . . . . . . . . . .
2.3.4 Conditional Statements (if) . .
2.3.5 Loops . . . . . . . . . . . . . .
vii

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.

.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.

.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.


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

.
.
.
.
.
.
.
.

.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

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


.
.
.
.
.
.
.
.

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

.
.
.
.
.
.
.

.

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

.
.
.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.
.
.

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

.

.
.
.
.
.
.
.

1
1
2
2

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

3
4
5
10

14
19
20
22
24
26
27
27

.
.
.
.
.
.
.
.

29
30
31
32
33
35
35
36
39


viii


DSP Using MATLAB and Wavelets

2.4
2.5
2.6
2.7
2.8
2.9
2.10

2.11
2.12
2.13
2.14
2.15

2.3.6 Continuing a Line . . . . . . . . . . .
Arithmetic Examples . . . . . . . . . . . . . .
Functions . . . . . . . . . . . . . . . . . . . .
How NOT to Plot a Sinusoid . . . . . . . . .
Plotting a Sinusoid . . . . . . . . . . . . . . .
Plotting Sinusoids a Little at a Time . . . .
Calculating Error . . . . . . . . . . . . . . . .
Sometimes 0 Is Not Exactly 0 . . . . . . . . .
2.10.1 Comparing Numbers with a Tolerance
2.10.2 Rounding and Truncating . . . . . . .
MATLAB Programming Tips . . . . . . . . .
MATLAB Programming Exercises . . . . . .
Other Useful MATLAB Commands . . . . . .

Summary . . . . . . . . . . . . . . . . . . . .
Review Questions . . . . . . . . . . . . . . . .

3 Filters
3.1 Parts of a Filter . . . . . . . . . . . . . . .
3.2 FIR Filter Structures . . . . . . . . . . . .
3.3 Causality, Linearity, and Time-Invariance
3.4 Multiply Accumulate Cells . . . . . . . . .
3.5 Frequency Response of Filters . . . . . . .
3.6 IIR Filters . . . . . . . . . . . . . . . . . .
3.7 Trends of a Simple IIR Filter . . . . . . .
3.8 Correlation . . . . . . . . . . . . . . . . .
3.9 Summary . . . . . . . . . . . . . . . . . .
3.10 Review Questions . . . . . . . . . . . . . .
4 Sinusoids
4.1 Review of Geometry and Trigonometry . .
4.2 The Number π . . . . . . . . . . . . . . .
4.3 Unit Circles . . . . . . . . . . . . . . . . .
4.4 Principal Value of the Phase Shift . . . .
4.5 Amplitudes . . . . . . . . . . . . . . . . .
4.6 Harmonic Signals . . . . . . . . . . . . . .
4.7 Representing a Digital Signal as a Sum of
Sinusoids . . . . . . . . . . . . . . . . . .
4.8 Spectrum . . . . . . . . . . . . . . . . . .
4.9 Summary . . . . . . . . . . . . . . . . . .

.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.

.

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

.
.
.
.
.
.
.
.
.
.

.

.
.
.
.
.

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

.
.
.
.
.
.
.
.

.
.

.
.
.
.
.
.

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

.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

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


.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.

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

.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.


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

.
.
.
.
.
.
.
.
.
.

.
.
.

.
.
.

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

.
.
.
.
.
.
.
.
.
.


.
.
.
.
.
.

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

.
.
.
.
.
.

.
.
.
.

.
.
.
.
.
.

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

.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.

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

.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.

39
39
52
53
56
60
63
64
65
69
70
71
81
83
83

.
.
.
.
.
.
.
.

.
.

85
89
91
98
103
104
111
113
115
128
130

.
.
.
.
.
.

133
133
134
136
138
139
140


. . . . . . . . . . . . . . . 145
. . . . . . . . . . . . . . . 152
. . . . . . . . . . . . . . . 156


ix

Contents

4.10 Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
5 Sampling
5.1 Sampling . . . . . . . . . . . . . . . . . . . . . .
5.2 Reconstruction . . . . . . . . . . . . . . . . . . .
5.3 Sampling and High-Frequency Noise . . . . . . .
5.4 Aliasing . . . . . . . . . . . . . . . . . . . . . . .
5.4.1 Aliasing Example . . . . . . . . . . . . . .
5.4.2 Folding . . . . . . . . . . . . . . . . . . .
5.4.3 Locations of Replications After Sampling
5.5 Nyquist Rate . . . . . . . . . . . . . . . . . . . .
5.6 Bandpass Sampling . . . . . . . . . . . . . . . . .
5.7 Summary . . . . . . . . . . . . . . . . . . . . . .
5.8 Review Questions . . . . . . . . . . . . . . . . . .
6 The
6.1
6.2
6.3
6.4
6.5
6.6
6.7

6.8
6.9
6.10
6.11
6.12

.
.
.
.
.
.
.
.
.
.
.

Fourier Transform
Fast Fourier Transform Versus the Discrete Fourier
The Discrete Fourier Transform . . . . . . . . . . .
Plotting the Spectrum . . . . . . . . . . . . . . . .
Zero Padding . . . . . . . . . . . . . . . . . . . . .
DFT Shifting Theory . . . . . . . . . . . . . . . . .
The Inverse Discrete Fourier Transform . . . . . .
Forward and Inverse DFT . . . . . . . . . . . . . .
Leakage . . . . . . . . . . . . . . . . . . . . . . . .
Harmonics and Fourier Transform . . . . . . . . .
Sampling Frequency and the Spectrum . . . . . . .
Summary . . . . . . . . . . . . . . . . . . . . . . .

Review Questions . . . . . . . . . . . . . . . . . . .

7 The Number e
7.1 Reviewing Complex Numbers . . .
7.2 Some Interesting Properties of j .
7.2.1 Rotating Counterclockwise
7.2.2 Rotating Clockwise
√. . . . .
7.2.3 Removing j from −a . . .
7.3 Where Does e Come from? . . . .
7.4 Euler’s Formula . . . . . . . . . . .
7.5 Alternate Form of Euler’s Equation
7.6 Euler’s Inverse Formula . . . . . .
7.7 Manipulating Vectors . . . . . . .

.
.
.
.
.
.
.
.
.
.

.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.


.
.
.
.
.
.
.
.
.
.
.

159
160
162
162
164
165
168
171
175
176
182
183

Transform .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .

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

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

.
.
.
.
.
.
.
.
.

.
.
.

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

187
190
191
196
202
203
204
207
212
214
219
221
221


.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.

.
.
.
.
.
.
.
.
.
.

225
225
228
228
229
230
230
233
235
236
238

.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.


.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.

.
.
.
.
.
.
.
.
.
.


x

DSP Using MATLAB and Wavelets

7.7.1 Adding Two Vectors . . . . . . . . . . . .
7.7.2 Adding Vectors in General . . . . . . . . .
7.7.3 Adding Rotating Phasors . . . . . . . . .
7.7.4 Adding Sinusoids of the Same Frequency
7.7.5 Multiplying Complex Numbers . . . . . .
7.8 Adding Rotating Phasors: an Example . . . . . .
7.9 Multiplying Phasors . . . . . . . . . . . . . . . .
7.10 Summary . . . . . . . . . . . . . . . . . . . . . .
7.11 Review Questions . . . . . . . . . . . . . . . . . .
8 The

8.1
8.2
8.3
8.4
8.5
8.6

z-Transform
The z-Transform . . . . . . . . . . . . . . . . .
Replacing Two FIR Filters in Series . . . . . .
Revisiting Sequential Filter Combination with z
Why Is z −1 the Same as a Delay by One Unit?
What Is z? . . . . . . . . . . . . . . . . . . . .
How the z-Transform Reduces to the Fourier
Transform . . . . . . . . . . . . . . . . . . . . .
8.7 Powers of −z . . . . . . . . . . . . . . . . . . .
8.8 Showing that x[n] ∗ h[n] ↔ X(z)H(z) . . . . .
8.9 Frequency Response of Filters . . . . . . . . . .
8.10 Trends of a Simple IIR Filter, Part II . . . . .
8.11 Summary . . . . . . . . . . . . . . . . . . . . .
8.12 Review Questions . . . . . . . . . . . . . . . . .

.
.
.
.
.
.
.
.

.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.

.
.
.
.
.
.
.
.
.

238
239
240
240
240
243
249
250
250

.
.
.
.
.

.
.

.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.

.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.

.
.
.

253
254
255
257
259
260

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.

.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.

.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.


.
.
.
.
.
.
.

.
.
.
.
.
.
.

261
261
262
263
271
271
272

9 The Wavelet Transform
9.1 The Two-Channel Filter Bank . . . . . . . . . . . . . . . . . .
9.2 Quadrature Mirror Filters and Conjugate
Quadrature Filters . . . . . . . . . . . . . . . . . . . . . . . .
9.3 How the Haar Transform Is a 45-Degree Rotation . . . . . . .

9.3.1 How The Haar Transform Affects a Point’s Radius . .
9.3.2 How The Haar Transform Affects a Point’s Angle . . .
9.4 Daubechies Four-Coefficient Wavelet . . . . . . . . . . . . . .
9.5 Down-Sampling and Up-Sampling . . . . . . . . . . . . . . .
9.5.1 Example Using Down/Up-Samplers . . . . . . . . . .
9.5.2 Down-Sampling and Up-Sampling with 2 Coefficients .
9.5.3 Down-Sampling and Up-Sampling with Daubechies 4 .
9.6 Breaking a Signal Into Waves . . . . . . . . . . . . . . . . . .

275
. . . . 277
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

279
280
281
282
284

288
288
290
292
295


xi

Contents

9.7
9.8
9.9
9.10
9.11
9.12
9.13

Wavelet Filter Design—Filters with Four
Coefficients . . . . . . . . . . . . . . . . .
Orthonormal Bases . . . . . . . . . . . . .
Multiresolution . . . . . . . . . . . . . . .
Biorthogonal Wavelets . . . . . . . . . . .
Wavelet Transform Theory . . . . . . . .
Summary . . . . . . . . . . . . . . . . . .
Review Questions . . . . . . . . . . . . . .

.
.

.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.


.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.

.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

10 Applications
10.1 Examples Working with Sound . . . . . . . . . . . . . . . .
10.2 Examples Working with Images . . . . . . . . . . . . . . . .
10.3 Performing the 2D Discrete Wavelet Transform on an Image
10.3.1 2D DWT of a Grayscale Image . . . . . . . . . . . .
10.3.2 2D DWT of a Color Image . . . . . . . . . . . . . .
10.4 The Plus/Minus Transform . . . . . . . . . . . . . . . . . .
10.5 Doing and Undoing the Discrete Wavelet
Transform . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.6 Wavelet Transform with Matrices . . . . . . . . . . . . . . .
10.7 Recursively Solving a Su Doku Puzzle . . . . . . . . . . . .
10.8 Converting Decimal to Binary . . . . . . . . . . . . . . . . .

10.9 Frequency Magnitude Response of Sound . . . . . . . . . .
10.10 Filter Design . . . . . . . . . . . . . . . . . . . . . . . . . .
10.10.1 Windowing Methods . . . . . . . . . . . . . . . . .
10.10.2 Designing an FIR Filter . . . . . . . . . . . . . . . .
10.11 Compression . . . . . . . . . . . . . . . . . . . . . . . . . .
10.11.1 Experimenting with Compression . . . . . . . . . .
10.11.2 Compressing an Image Ourselves . . . . . . . . . .
10.12 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.13 Review Questions . . . . . . . . . . . . . . . . . . . . . . .

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.

.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

309
311
314
320
324
336
336

.
.

.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.

.
.

339
339
342
344
347
348
350

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

.
.
.
.
.

.
.
.
.
.
.
.
.

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

.
.
.
.
.
.
.

.
.
.
.
.
.

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

352
357
361
369
373
376
376
380
385

387
393
396
396

A Constants and Variables Used in This Book
399
A.1 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399
A.2 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399
A.3 Symbols Common in DSP Literature . . . . . . . . . . . . . . . . . . 401
B Equations
B.1 Euler’s Formula . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
B.2 Trigonometric Identities and Other Math Notes . . . . . . . . . . . .
B.3 Sampling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

403
403
404
405


xii

DSP Using MATLAB and Wavelets

B.4
B.5
B.6
B.7
B.8


Fourier Transform (FT)
Convolution . . . . . . .
Statistics . . . . . . . .
Wavelet Transform . . .
z-Transform . . . . . . .

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.


.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.


.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.


.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.


.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.


.
.
.
.
.

405
407
407
409
409

C DSP Project Ideas

411

D About the CD-ROM

415

E Answers to Selected Review Questions

417

F Glossary

439

Bibliography


445

Index

449


List of Figures
1.1
1.2
1.3
1.4
1.5
1.6
1.7

An example vector. . . . . . . . . . . . . . . . . . . .
Calculating θ = arctan(b/a) leads to a problem when
A sound signal with a tape analog. . . . . . . . . . .
Sampling a continuous signal. . . . . . . . . . . . . .
Three ways of viewing a signal. . . . . . . . . . . . .
An example system. . . . . . . . . . . . . . . . . . .
Three glasses of water. . . . . . . . . . . . . . . . . .

2.1
2.2
2.3
2.4


A 200 Hz sinusoid produced by example MATLAB code.
Using the “plotsinusoids” function. . . . . . . . . . . . .
This signal repeats itself every second. . . . . . . . . . .
A close-up view of two sinusoids from 0.9 to 1 second. .

3.1
3.2
3.3
3.4
3.5
3.6
3.7
3.8
3.9
3.10
3.11
3.12
3.13
3.14
3.15
3.16
3.17

An example signal, filtered. . . . . . . . . . . . . . . . . . . . . . . . 86
The frequency content of the example signal, and low/highpass filters. 87
A digital signal, delayed, appears as a time-shifted version of itself. . 88
An adder with two signals as inputs. . . . . . . . . . . . . . . . . . . 89
A multiplier with two signals as inputs. . . . . . . . . . . . . . . . . 89
An example FIR filter with coefficients 0.5 and -0.5. . . . . . . . . . 90
Signal y is a delayed version of x. . . . . . . . . . . . . . . . . . . . . 91

FIR filter with coefficients {0.5, 0.5}. . . . . . . . . . . . . . . . . . . 91
An example FIR filter with coefficients 0.6 and 0.2. . . . . . . . . . . 92
General form of the FIR filter. . . . . . . . . . . . . . . . . . . . . . 94
An example FIR filter. . . . . . . . . . . . . . . . . . . . . . . . . . . 97
A representation of an FIR filter. . . . . . . . . . . . . . . . . . . . . 97
Linear condition 1: scaling property. . . . . . . . . . . . . . . . . . . 100
Linear condition 2: additive property. . . . . . . . . . . . . . . . . . 100
Multiply accumulate cell. . . . . . . . . . . . . . . . . . . . . . . . . 103
Multiply accumulate cells as a filter. . . . . . . . . . . . . . . . . . . 104
Frequency magnitude response for a lowpass filter. . . . . . . . . . . 105
xiii

.
a
.
.
.
.
.

. . . . . . .
is negative.
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
.
.
.

.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.

.
.
.
.

6
8
15
17
19
20
21

.
.
.
.

57
59
61
62


xiv

DSP Using MATLAB and Wavelets

3.18
3.19

3.20
3.21
3.22
3.23
3.24
3.25
3.26
3.27
3.28
3.29
3.30
3.31

Frequency magnitude response for a highpass filter. . . . . . . . . . . 105
Passband, transition band, and stopband, shown with ripples. . . . . 107
Frequency magnitude response for a bandpass filter. . . . . . . . . . 108
Frequency magnitude response for a bandstop filter. . . . . . . . . . 108
A notch filter. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Frequency magnitude response for a bandpass filter with two passbands.109
A filter with feed-back. . . . . . . . . . . . . . . . . . . . . . . . . . . 111
Another filter with feed-back. . . . . . . . . . . . . . . . . . . . . . . 112
A third filter with feed-back. . . . . . . . . . . . . . . . . . . . . . . 113
General form of the IIR filter. . . . . . . . . . . . . . . . . . . . . . . 114
A simple IIR filter. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
Output from a simple IIR filter. . . . . . . . . . . . . . . . . . . . . . 116
Two rectangles of different size (scale) and rotation. . . . . . . . . . 126
Two rectangles represented as the distance from their centers to their
edges. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
3.32 A rectangle and a triangle. . . . . . . . . . . . . . . . . . . . . . . . 128
3.33 A rectangle and triangle represented as the distance from their centers

to their edges. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129

4.1
4.2
4.3
4.4
4.5
4.6
4.7
4.8
4.9
4.10
4.11
4.12
4.13
4.14
4.15
4.16

A right triangle. . . . . . . . . . . . . . . . . . . . . . . . .
An example circle. . . . . . . . . . . . . . . . . . . . . . . .
An angle specified in radians. . . . . . . . . . . . . . . . . .
An angle specified in radians. . . . . . . . . . . . . . . . . .
A 60 Hz sinusoid. . . . . . . . . . . . . . . . . . . . . . . . .
A vector of −a at angle θ = a at angle (θ + π). . . . . . . .
A harmonic signal. . . . . . . . . . . . . . . . . . . . . . . .
A short signal. . . . . . . . . . . . . . . . . . . . . . . . . .
The short signal, repeated. . . . . . . . . . . . . . . . . . .
A digital signal (top) and its sum of sinusoids representation
The first four sinusoids in the composite signal. . . . . . . .

The last four sinusoids in the composite signal. . . . . . . .
Frequency magnitude spectrum and phase angles. . . . . . .
Spectrum plot: magnitude of x(t) = 2 + 2 cos(2π(200)t). . .
Spectrum plot: magnitudes. . . . . . . . . . . . . . . . . . .
Spectrum plot: phase angles. . . . . . . . . . . . . . . . . .

. . . . . 134
. . . . . 134
. . . . . 136
. . . . . 137
. . . . . 139
. . . . . 139
. . . . . 142
. . . . . 144
. . . . . 145
(bottom).146
. . . . . 147
. . . . . 148
. . . . . 153
. . . . . 154
. . . . . 155
. . . . . 155

5.1
5.2
5.3
5.4

Sampling a noisy signal. . . . . . . . . . . . . . . . . . . . . . . . .
Aliasing demonstrated. . . . . . . . . . . . . . . . . . . . . . . . . .

cos(−2π10t − π/3) and cos(2π10t + π/3) produce the same result.
Replications for f1 = 1 Hz and fs = 4 samples/second. . . . . . . .

.
.
.
.

163
167
170
172


xv

List of Figures

5.5
5.6
5.7
5.8
5.9
5.10
5.11
5.12
5.13

Replications for f1 = 2.5 Hz and fs = 8 samples/second. . .
Replications for f1 = 3 Hz and fs = 4 samples/second. . . .

Replications for f1 = 5 Hz and fs = 4 samples/second. . . .
Replications for f1 = 3 or 5 Hz and fs = 4 samples/second.
Example signal sampled at 2081 Hz. . . . . . . . . . . . . .
Example signal sampled at 100 Hz. . . . . . . . . . . . . . .
Example signal sampled at 103 Hz. . . . . . . . . . . . . . .
Example signal sampled at 105 Hz. . . . . . . . . . . . . . .
Example signal sampled at 110 Hz. . . . . . . . . . . . . . .

.
.
.
.
.
.
.
.
.

173
173
174
175
177
177
179
181
181

6.1
6.2


A person vocalizing the “ee” sound. . . . . . . . . . . . . . . . . . .
J.S. Bach’s Adagio from Toccata and Fuge in C—frequency magnitude response. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A sustained note from a flute. . . . . . . . . . . . . . . . . . . . . . .
Comparing N log2 (N ) (line) versus N 2 (asterisks). . . . . . . . . . .
Spectrum for an example signal. . . . . . . . . . . . . . . . . . . . .
Improved spectrum for an example signal. . . . . . . . . . . . . . . .
Example output of DFT-shift program. . . . . . . . . . . . . . . . .
Frequency content appears at exact analysis frequencies. . . . . . . .
Frequency content appears spread out over analysis frequencies. . . .
Approximating a triangle wave with sinusoids. . . . . . . . . . . . . .
Approximating a saw-tooth wave with sinusoids. . . . . . . . . . . .
Approximating a square wave with sinusoids. . . . . . . . . . . . . .
Approximating a saw-tooth square wave with sinusoids. . . . . . . .
Frequency response of a lowpass filter. . . . . . . . . . . . . . . . . .
Frequency response of a highpass filter. . . . . . . . . . . . . . . . .

188

6.3
6.4
6.5
6.6
6.7
6.8
6.9
6.10
6.11
6.12
6.13

6.14
6.15
7.1
7.2
7.3
7.4
7.5
7.6
7.7
7.8
7.9
7.10
7.11

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.

.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

A complex number can be shown as a point or a 2D vector. . . . . .
A vector forms a right triangle with the x-axis. . . . . . . . . . . . .
A rotating vector. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A vector rotates clockwise by −π/2 when multiplied by −j. . . . . .
Simple versus compounded interest. . . . . . . . . . . . . . . . . . .
Phasors and their complex conjugates. . . . . . . . . . . . . . . . . .

Graph of x(0) where x(t) = 3ejπ/6 ej2π1000t . . . . . . . . . . . . . . .
Two example vectors. . . . . . . . . . . . . . . . . . . . . . . . . . .
Adding two example vectors. . . . . . . . . . . . . . . . . . . . . . .
Adding and multiplying two example vectors. . . . . . . . . . . . . .
Two sinusoids of the same frequency added point-for-point and analytically. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.12 A graphic representation of adding 2 phasors of the same frequency.

189
190
191
198
200
205
213
213
215
217
218
218
220
220
226
226
227
230
232
236
237
241
241

242
245
247


xvi

DSP Using MATLAB and Wavelets

7.13 A graphic representation of adding 2 sinusoids of the same frequency. 248
8.1
8.2
8.3
8.4

FIR filters in series can be combined.
Two trivial FIR filters. . . . . . . . .
Two trivial FIR filters, reduced. . . .
Example plot of zeros and poles. . .

.
.
.
.

.
.
.
.


.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.


.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.


.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

256
259
260
270

9.1
9.2
9.3
9.4
9.5

9.6
9.7
9.8
9.9
9.10
9.11
9.12
9.13
9.14
9.15
9.16
9.17
9.18
9.19
9.20
9.21
9.22
9.23
9.24
9.25
9.26
9.27
9.28
9.29

Analysis filters. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Synthesis filters. . . . . . . . . . . . . . . . . . . . . . . . . . . .
A two-channel filter bank. . . . . . . . . . . . . . . . . . . . . . .
A quadrature mirror filter for the Haar transform. . . . . . . . .
A conjugate quadrature filter for the Haar transform. . . . . . . .

A two-channel filter bank with four coefficients. . . . . . . . . . .
Different ways to indicate down-samplers and up-samplers. . . .
A simple filter bank demonstrating down/up-sampling. . . . . . .
A simple filter bank demonstrating down/up-sampling, reduced.
Tracing input to output of a simple filter bank. . . . . . . . . . .
A two-channel filter bank with down/up-samplers. . . . . . . . .
A filter bank with four taps per filter. . . . . . . . . . . . . . . .
Wavelet analysis and reconstruction. . . . . . . . . . . . . . . . .
Alternate wavelet reconstruction. . . . . . . . . . . . . . . . . . .
Impulse function analyzed with Haar. . . . . . . . . . . . . . . .
Impulse function analyzed with Daubechies-2. . . . . . . . . . . .
Impulse function (original) and its reconstruction. . . . . . . . .
Example function broken down into 3 details and approximation.
Impulse function in Fourier-domain. . . . . . . . . . . . . . . . .
Impulse function in Wavelet-domain. . . . . . . . . . . . . . . . .
Designing a filter bank with four taps each. . . . . . . . . . . . .
Two levels of resolution. . . . . . . . . . . . . . . . . . . . . . . .
Biorthogonal wavelet transform. . . . . . . . . . . . . . . . . . . .
Biorthogonal wavelet transform. . . . . . . . . . . . . . . . . . . .
One channel of the analysis side of a filter bank. . . . . . . . . .
The first graph of the “show wavelet” program. . . . . . . . . . .
The second graph of the “show wavelet” program. . . . . . . . .
Analysis filters. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Synthesis filters. . . . . . . . . . . . . . . . . . . . . . . . . . . .

.
.
.
.
.

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

.
.
.
.
.

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

276
276
277
280
280

284
288
288
289
289
290
292
296
296
298
299
300
301
304
305
310
315
320
322
329
334
335
337
337

10.1 Two-dimensional DWT on an image. . . . . . . . . . . . . . . . . . . 345
10.2 Results of “DWT undo” for a 1D signal: original and approximation. 354
10.3 Results of “DWT undo” for a 1D signal: details for octaves 1–3. . . 355



xvii

List of Figures

10.4 Three octaves of the one-dimensional discrete wavelet transform.
10.5 Example of the “show sound” program. . . . . . . . . . . . . . .
10.6 Two similar filters, with and without a gradual transition. . . . .
10.7 Using nonwindowed filter coefficients. . . . . . . . . . . . . . . . .
10.8 Using windowed filter coefficients. . . . . . . . . . . . . . . . . . .
10.9 Windowed filter coefficients and those generated by fir1. . . . .
10.10 Alternating flip for the windowed filter coefficients. . . . . . . .

.
.
.
.
.
.
.

.
.
.
.
.
.
.

362
377

379
382
383
384
386



List of Tables
1.1

Example signals. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5.1

Frequencies detected with bandpass sampling. . . . . . . . . . . . . . 182

6.1
6.2
6.3

Example DFT calculations. . . . . . . . . . . . . . . . . . . . . . . . 194
Example DFT calculations (rectangular form). . . . . . . . . . . . . 195
Sinusoids that simplify things for us. . . . . . . . . . . . . . . . . . . 211

7.1

Compound interest on $1000 approximates $1000 ×e. . . . . . . . . 232

8.1


Convolution of x and h. . . . . . . . . . . . . . . . . . . . . . . . . . 263

9.1

Impulse function analyzed with Haar. . . . . . . . . . . . . . . . . . 298

10.1
10.2
10.3
10.4
10.5

An example Su Doku puzzle. . . . . . . . . . . .
The example Su Doku puzzle’s solution. . . . . .
Converting from decimal to binary. . . . . . . . .
Converting from a decimal fraction to fixed-point
Hexadecimal to binary chart. . . . . . . . . . . .

. . . . .
. . . . .
. . . . .
binary. .
. . . . .

.
.
.
.
.


.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.


12

363
364
370
371
374

A.1 Greek alphabet. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402

xix



Preface
Digital signal processing is an important and growing field. There have been
many books written in this area, however, I was motivated to write this manuscript
because none of the existing books address the needs of the computer scientist. This
work attempts to fill this void, and to bridge the disciplines from which this field
originates: mathematics, electrical engineering, physics, and engineering mechanics.
Herein, it is hoped that the reader will find sensible explanations of DSP concepts,
along with the analytical tools on which DSP is based.
DSP: Now and Then
Recently, I was asked if a student who took a course in DSP at another university
should be allowed to transfer the credit to our university. The question was an
interesting one, especially when I noticed that the student had taken the course 10
years earlier. For computer science, 10 years is a long time. But how much has DSP
changed in the last decade? It occurred to me that there were several important
changes, but theoretically, the core information has not changed. The curriculum

of the DSP course in question contained all of the same topics that I covered in my
DSP class that summer, with only two exceptions: MATLAB
r and Wavelets.
MATLAB
MATLAB is one of several tools for working with mathematics. As an experienced
programmer, I was skeptical at first. Why should I learn another programming
language when I could do the work in C/C++? The answer was simple: working
with MATLAB is easier! Yes, there are some instances when one would want to
use another language. A compiled program, such as one written in C++, will run
faster than an interpreted MATLAB program (where each line is translated by the
computer when the program is run). For hardware design, one might want to write
a program in Verilog or VHDL, so that the program can be converted to a circuit. If
you already know a programming language such as C, C++, Java, FORTRAN, etc.,
xxi


xxii

DSP Using MATLAB and Wavelets

you should be able to pick up a MATLAB program and understand what it does. If
you are new to programming, you will find MATLAB to be a forgiving environment
where you can test out commands and correct them as needed.
Wavelets
The wavelet transform is an analysis tool that has a relatively short history. It
was not until 1989 that St´ephane Mallat (with some help from Meyers) published
a revolutionary paper on wavelet theory, tying together related techniques that
existed in several disciplines [1]. Other people have made significant contributions
to this theory, such as Ingrid Daubechies [2], Strang and Nguyen [3], and Coifman
and Wickerhauser [4]. It is a daunting task to write about the people who have

contributed to wavelets, since anyone who is left out could be reading this now!
The wavelet transform is an important tool with many applications, such as
compression. I have no doubt that future generations of DSP teachers will rank it
second only to the Fourier transform in terms of importance.
Other Developments
Other recent changes in DSP include embedded systems, the audio format MP3, and
public awareness. Advertising by cellular phone marketers, which tries to explain
to a nontechnical audience that digital signal processing is better than analog, is an
example of the growing public awareness. Actually, the ads do not try to say how
digital is better than analog, but they do point out problems with wireless analog
phones.

Acknowledgments
This book was only possible with the support of many people. I would like to
thank Dr. Rammohan Ragade from the University of Louisville, who guided my
research when I first started out. I would also like to thank Dr. Magdy Bayoumi
at the University of Louisiana, who taught me much about research as well as how
to present research results to an audience. Dr. Marty Fraser, who recently retired
from Georgia State University, was a great mentor in my first years in academia.
My students over the years have been quite helpful in pointing out any problems
within the text. I would especially like to thank Evelyn Brannock and Ferrol Blackmon for their help reviewing the material. I would also like to acknowledge Drs.


Preface

xxiii

Kim King and Raj Sunderraman for their help. Finally, I could not have written this book without the support and understanding of my wife.
-M.C.W., Atlanta, Georgia, 2006




×