DSP for MATLAB and LabVIEW I Fundamentals of Discrete Signal Processing Synthesis Lectures on Signal Processing Isen download
DSP for MATLAB and LabVIEW I Fundamentals of Discrete Signal Processing Synthesis Lectures on Signal Processing Isen download
https://ebookgate.com/product/dsp-for-matlab-and-labview-i-
fundamentals-of-discrete-signal-processing-synthesis-lectures-on-
signal-processing-isen/
https://ebookgate.com/product/dsp-for-matlab-and-labview-
fundamentals-of-discrete-frequency-transforms-forester-w-isen/
https://ebookgate.com/product/think-dsp-digital-signal-
processing-in-python-1st-edition-downey/
https://ebookgate.com/product/prentice-discrete-time-digital-
signal-processing-2nd-edition-oppenheim/
https://ebookgate.com/product/digital-signal-processing-using-
matlab-1st-edition-andre-quinquis/
Instructor Solution Manual Fundamentals of Digital
Signal Processing Using MATLAB 2nd Edition Robert J.
Schilling
https://ebookgate.com/product/instructor-solution-manual-
fundamentals-of-digital-signal-processing-using-matlab-2nd-
edition-robert-j-schilling/
https://ebookgate.com/product/multirate-filtering-for-digital-
signal-processing-matlab-applications-1st-edition-ljiljana-milic/
https://ebookgate.com/product/digital-signal-processing-using-
matlab-3rd-edition-vinay-k-ingle/
https://ebookgate.com/product/discrete-wavelet-transform-a-
signal-processing-approach-1st-edition-d-sundararajan/
https://ebookgate.com/product/digital-signal-processing-
fundamentals-and-application-1st-edition-li-tan/
DSP for
MATLAB™ and LabVIEW™ I:
Fundamentals of
Discrete Signal Processing
Copyright © 2008 by Morgan & Claypool
All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in
any form or by any means—electronic, mechanical, photocopy, recording, or any other except for brief quotations in
printed reviews, without the prior permission of the publisher.
DOI 10.2200/S000161ED1V01Y200811SPR004
Lecture #4
Series Editor: José Moura, Carnegie Mellon University
Series ISSN
Synthesis Lectures on Signal Processing
Print 1932-1236 Electronic 1932-1694
SYNTHESIS LECTURES
ON SIGNAL
PROCESSING
Editor
José Moura, Carnegie Mellon University
Forester W. Isen
M
&C Morgan & cLaypool publishers
ABSTRACT
This book is Volume I of the series DSP for MATLAB ™ and LabVIEW ™ . The entire series consists
of four volumes that collectively cover basic digital signal processing in a practical and accessible man-
ner, but which nonetheless include all essential foundation mathematics. As the series title implies, the
scripts (of which there are more than 200) described in the text and supplied in code form (available
via the internet at http://www.morganclaypool.com/page/isen will run on both MATLAB and
LabVIEW. Volume I consists of four chapters. The first chapter gives a brief overview of the field of dig-
ital signal processing. This is followed by a chapter detailing many useful signals and concepts, including
convolution, recursion, difference equations, LTI systems, etc. The third chapter covers conversion from
the continuous to discrete domain and back (i.e., analog-to-digital and digital-to-analog conversion),
aliasing, the Nyquist rate, normalized frequency, conversion from one sample rate to another, waveform
generation at various sample rates from stored wave data, and Mu-law compression. The fourth and final
chapter of the present volume introduces the reader to many important principles of signal processing,
including correlation, the correlation sequence, the Real DFT, correlation by convolution, matched fil-
tering, simple FIR filters, and simple IIR filters. Chapter 4, in particular, provides an intuitive or “first
principle” understanding of how digital filtering and frequency transforms work, preparing the reader
for Volumes II and III, which provide, respectively, detailed coverage of discrete frequency transforms
(including the Discrete Time Fourier Transform, the Discrete Fourier Transform, and the z-Transform)
and digital filter design (FIR design using Windowing, Frequency Sampling, and Optimum Equirip-
ple techniques, and Classical IIR design). Volume IV, the culmination of the series, is an introductory
treatment of LMS Adaptive Filtering and applications. The text for all volumes contains many examples,
and many useful computational scripts, augmented by demonstration scripts and LabVIEW Virtual In-
struments (VIs) that can be run to illustrate various signal processing concepts graphically on the user’s
computer screen.
KEYWORDS
Higher-Level Terms:
MATLAB, LabVIEW, DSP (Digital Signal Processing), Sampling, LTI Systems, Analog-
to-Digital, Digital-to-Analog, FIR, IIR, DFT,Time Domain, Frequency Domain, Aliasing,
Binary Numbers.
Lower Level Terms:
Correlation, Convolution, Matched Filtering, Orthogonality, Interpolation, Decimation,
Mu-Law, Stability, Causality, Difference Equations, Zero-Order Hold.
This volume is dedicated to the following memorable teachers
of mine: Louise Costa, Cdr. Charles Bradimore Brouillette, Rudd
Crawford, Sheldon Sarnevitz, Dr. C. W. Rector, Dr. Samuel Saul
Saslaw, and Dr. R. D. Shelton.
ix
Contents
SYNTHESIS LECTURES ON SIGNAL PROCESSING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iii
Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
0.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
0.2 The Four Volumes of the Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xv
0.3 Origin and Evolution of the Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi
1 An Overview of DSP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Signals, Waves, and Digital Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Advantages of Digital Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.3 DSP Nomenclature and Topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3.1 Time Domain Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3.2 Frequency Transforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3.3 Frequency Domain Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4
1.4 Organization of this Volume of the Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.5 Contents of Volume II in the Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.6 Contents of Volume III in the Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.7 Contents of Volume IV in the Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Biography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
xiv CONTENTS
Preface to Volume I
0.1 INTRODUCTION
The present volume is Volume I of the series DSP for MATLAB ™ and LabVIEW ™ . The entire series
consists of four volumes which collectively form a work of twelve chapters that cover basic digital signal
processing in a practical and accessible manner, but which nonetheless include the necessary foundation
mathematics. The text is well-illustrated with examples involving practical computation using m-code
or MathScript (as m-code is usually referred to in LabVIEW-based literature), and LabVIEW VIs.
There is also an ample supply of exercises, which consist of a mixture of paper-and-pencil exercises for
simple computations, and script-writing projects having various levels of difficulty, from simple, requiring
perhaps ten minutes to accomplish, to challenging, requiring several hours to accomplish.
As the series title implies, the scripts given in the text and supplied in code form (available via the
internet at http://www.morganclaypool.com/page/isen) are suitable for use with both MATLAB (a
product of The Mathworks, Inc.), and LabVIEW (a product of National Instruments, Inc.). Appendix
A in each volume of the series describes the naming convention for the software written for the book as
well as basics for using the software with MATLAB and LabVIEW.
Forester W. Isen
November 2008
1
CHAPTER 1
An Overview of DSP
1.1 SIGNALS, WAVES, AND DIGITAL PROCESSING
Two of the human senses, sight and hearing, work via the detection of waves. Useful information from
both light and sound is gained by detection of certain characteristics of these waves, such as frequency and
amplitude. Modern telecommunication depends on transducing sound or light into electrical quantities
such as voltage, and then processing the voltage in many different ways to enable the information to
be reliably stored or conveyed to a distant place and then regenerated to imitate (i.e., reconstruct) the
original sound or light phenomenon.
For example, in the case of sound, a microphone detects rapid pressure variations in air and converts
those variations to an output voltage which varies in a manner proportional to the variation of pressure
on the microphone’s diaphragm. The varying voltage can be used to cut a corresponding wave into a
wax disc, to record corresponding wave-like variations in magnetism onto a ferromagnetic wire or tape,
to vary the opacity of a linear track along the edge of a celluloid film (i.e., the sound-track of a motion
picture film) or perhaps to modulate a carrier wave for radio transmission.
In recent decades, signal processing and storage systems have been developed that use discrete
samples of a signal rather than the entire continuous time domain (or analog) signal. Several useful
definitions are as follows:
• A sample is the amplitude of an analog signal at an instant in time.
• A system that processes a signal in sampled form (i.e., a sequence of samples) is known as a Discrete
Time Signal Processing System.
• In a Digital Signal Processing system, the samples are converted to numerical values, and the
values (numbers) stored (usually in binary form), transmitted, or otherwise processed.
The difference between conventional analog systems and digital systems is illustrated in Fig. 1.1.
At (a), a conventional analog system is shown, in which the signal from a microphone is sent directly to
an analog recording device, such as a tape recorder, recorded at a certain tape speed, and then played back
at the same speed some time later to reproduce the original sound. At (b), samples of the microphone
signal are obtained by an Analog-to-Digital Converter (ADC), which converts instantaneous voltages
of the microphone signal to corresponding numerical values, which are stored in a digital memory, and
can later be sent to a Digital-to-Analog Converter (DAC) to reconstruct the original sound.
In addition to recording and reproducing analog signals, most other kinds of processing which
might be performed on an analog signal can also be performed on a sampled version of the signal by
using numerical algorithms. These can be categorized into two broad types of processing, time domain
and frequency domain, which are discussed in more detail below.
(a)
(b)
Figure 1.1: (a) Conventional analog recording and playback system; (b) A digital recording and playback
system.
1. Analog hardware, such as amplifiers, filters, comparators, etc., is very susceptible to noise and
deterioration through aging. Digital hardware works with only two signal levels rather than an infinite
number, and hence has a high signal to noise ratio. As a result, there is little if any gradual deterioration
of performance with age (although as with all things, digital hardware can suddenly and totally fail),
and copies of signal files are generally perfect, absent component failure, media degeneration or damage,
etc. This is not true with analog hardware and recording techniques, in which every copy introduces
significant amounts of additional noise and distortion.
2. Analog hardware, for the most part, must be built for each processing function needed. With
digital processing, each additional function needed can be implemented with a software module, using
the same piece of hardware, a digital computer. The computing power available to the average person
has increased enormously in recent years, as evidenced by the incredible variety of inexpensive, high
quality devices and techniques available. Hundreds of millions or billions of operations per second can
be performed on a signal using digital hardware at reasonable expense; no reasonably-priced alternative
exists using analog hardware and processing.
3. Analog signal storage is typically redundant, since wave-related signals (audio, video, etc.) are
themselves typically redundant. For example, by taking into account this redundancy as well as the
physiological limitations of human hearing, storage needs for audio signals can be reduced up to about
95%, using digitally-based compression techniques, such as MP3, AC3, AAC, etc.
4. Digital processing makes possible highly efficient security and error-correction coding. Using
digital coding, it is possible, for example, for many signals to be transmitted at very low power and to
1.3. DSP NOMENCLATURE AND TOPICS 3
share the same bandwidth. Modern cell phone techniques, such as CDMA (Code Division Multiple
Access) rely heavily on advanced, digitally-based signal processing techniques to efficiently achieve both
high quality and high security.
Time to Frequency
Frequency to Time
Transform Transform
Frequency Domain
Processing
• Chapter 1 (the present chapter) gives a brief overview of DSP. It defines sampling, contrasts the
areas of continuous and discrete signal processing, as well as time domain and frequency domain
processing, and introduces very basic signal processing nomenclature.
• Chapter 2 introduces many useful signals and sequences, followed by a basic introduction to Linear,
Time Invariant (LTI) systems, including convolution, stability and causality, basic FIR and IIR
filters, and difference equations.
• Chapter 1 begins with a short overview of the Fourier and Laplace families of transforms, calling
attention to the uses of each and the differences among them. The remainder of the chapter is
devoted to the Discrete Time Fourier Transform (DTFT), its properties, and its use in evaluation
of the frequency response of an LTI system.
• Chapter 2 introduces the z-transform, its properties, the inverse z-transform, transfer function
and various filter topologies (Direct, Cascade, Parallel, and Lattice Forms), and evaluation of the
frequency response of an LTI system using the z-transform.
• Chapter 3 covers the Discrete Fourier Transform (DFT), including the forward and reverse trans-
forms, properties, the Fast Fourier Transform (FFT), the Goertzel Algorithm, periodic, cyclic, and
linear convolution via the DFT, and DFT leakage. Computation of the IDFT (inverse DFT) via
DFT, computation of the DFT via matrix, and computation of the DTFT via the DFT, are also
discussed.
• Chapter 1 gives an overview of FIR filtering principles in general, and linear phase filter charac-
teristics in particular, and an overview of FIR design techniques.
• Chapter 2 covers FIR design via windowed ideal lowpass filter, frequency sampling with optimized
transition coefficients (as implemented by inverse DFT as well as cosine/sine summation formulas),
and equiripple design. Designs are performed for lowpass, highpass, bandpass, and bandstop filters,
as well as Hilbert transformers and differentiators.
• Chapter 3 is devoted to classical IIR design, including design of digital IIR filters starting from
analog prototype lowpass filters of the Butterworth, Chebyshev (I and II), and Elliptic types,
transformations from lowpass to other passband types in the analog domain, and analog-to-digital
filter transformation. The chapter concludes with a discussion of various filter design functions
provided by MATLAB and LabVIEW.
6 CHAPTER 1. AN OVERVIEW OF DSP
CHAPTER 2
http://www.morganclaypool.com/page/isen
The entire software package should be stored in a single folder on the user’s computer, and the full
file name of the folder must be placed on the MATLAB or LabVIEW search path in accordance with the
instructions provided by the respective software vendor (in case you have encountered this notice before,
which is repeated for convenience in each chapter of the book, the software download only needs to be
done once, as files for the entire series of four volumes are all contained in the one downloadable folder).
See Appendix A for more information.
0.5
Amplitude
−0.5
−1
0 0.5 1 1.5 2
Time, sec
Figure 2.1: An analog or continuous-domain sine wave, with eight samples per second marked.
The samples within a given sample sequence are normally indexed by the numbers 0, 1, 2, etc.,
which represent multiples of the sample period T . For example, in Fig. 2.1, we note that the sample
period is 0.125 second, and the actual sampling times are therefore 0 sec., 0.125 sec., 0.25 sec., etc. The
continuous sine function shown has the value
f (t) = sin(2πf t)
where t is time, f is frequency, and in this particular case, f = 1 Hz. Sampling occurs at times nT
where n = 0, 1, 2,...and T = 0.125 second. The sample values of the sequence would therefore be sin(0),
sin(2π(T )), sin(2π(2T )), sin(2π(3T )), etc., and we would then say that s[0] = 0, s[1] = 0.707, s[2] =
1.0, s[3] = 0.707, etc. where s[n] denotes the n-th sequence value, the amplitude of which is equal to the
underlying continuous function at time nT (note that brackets surrounding a function argument mean
that the argument can only assume discrete values, while parentheses surrounding an argument indicate
that the argument’s domain is continuous). We can also say that
s[n] = sin[2π nT ]
2.4. USEFUL SIGNALS, SEQUENCES, AND CONCEPTS 9
This sequence of values, the samples of the sine wave, can be used to completely reconstruct the
original continuous domain sine wave using a DAC. There are, of course, a number of conditions to
ensure that this is possible, and they are taken up in detail in the next chapter.
To compute and plot the sample values of a 2-Hz sine wave sampled every 0.05 second on the
time interval 0 to 1.1 second, make the following MathScript call:
1
0.8
0.6
0.4
Amplitude
0.2
0
−0.2
−0.4
−0.6
−0.8
−1
Figure 2.2: A plot of the samples of a sine wave having frequency 2 Hz, sampled every 0.05 second up
to time 1.1 second.
s[n] = sin[2πf nT ]
10 CHAPTER 2. DISCRETE SIGNALS AND CONCEPTS
Once we have a sampled sine wave, we can mathematically express it without reference to the
sampling period by defining the sequence length as N . We would then have, in general,
1
Amplitude
−1
0 2 4 6 8 10 12 14 16
Sample
1
Amplitude
−1
0 2 4 6 8 10 12 14 16
Sample
1
Amplitude
−1
0 2 4 6 8 10 12 14 16
Sample
Figure 2.3: (a) Three cycles of a sine wave over 18 samples, with phase angle 0 radians; (b) Same as (a),
with a phase angle of π/2 radians; (c) Three cycles of a cosine wave over 18 samples, with a phase angle
of 0 radians.
The following script will perform addition of offset sequences y1 and y2 that have respective time
indices n1 and n2 using the method of prepending and postpending zeros.
function [y, nOut] = LVAddSeqs(y1,n1,y2,n2)
nOut = [min(min(n1),min(n2)):1:max(max(n1),max(n2))];
mnfv = min(nOut); mxfv = max(nOut);
y = [zeros(1,min(n1)-mnfv),y1,zeros(1,mxfv-max(n1))] + ...
[zeros(1,min(n2)-mnfv),y2,zeros(1,mxfv-max(n2))];
The function
[y, nOut] = LV MultSeqs(y1, n1, y2, n2)
works the same way, with the addition operator (+) in the final statement being replaced with the operator
for multiplying two vectors on a sample-by-sample basis, a period following by an asterisk ( .* ).
We can illustrate use of the function LV AddSeqs by using it to add the following sequences:
y1 = [3,-2,2], n1 = [-1,0,1], y2 = [1,0,-1], n2 = [0,1,2]
12 CHAPTER 2. DISCRETE SIGNALS AND CONCEPTS
4
y1
−2 −1 0 1 2 3 4 5 6
(a) Composite Sample Range n
6
4
y2
−2 −1 0 1 2 3 4 5 6
(b) Composite Sample Range n
Figure 2.4: (a) First sequence, with postpended zeros at sample times 3, 4, and 5; (b) Second sequence,
with prepended zeros at sample times -1, 0, and 1.
LVPlotUnitImpSeq(-2,-10,10)
A version of the script that returns the output sequence and its indices without plotting is
[xVals,xIndices] = LVUnitImpSeq(n,Nlow,Nhigh)
This version is useful for generating composite unit impulse sequences. For example, we can display,
over the sample index interval -5 to 5, the output sequence
by using the following m-code, which computes and displays the desired output sequence using the
function LVUnitImpSeq, as shown in Fig. 2.5.
[y1,y1Ind] = LVUnitImpSeq(2,-5,5),
[y2,y2Ind] = LVUnitImpSeq(-3,-5,5),
y = 3*y1 - 2*y2, stem(y1Ind,y)
2
Amplitude
−1
−2
−3
−5 0 5
Sample Index
Figure 2.5: A graph of the function y[n] = 3[n − 2] − 2[n + 3] for sample indices -5 to +5.
function LVPlotUnitStepSeq(n,Nlow,Nhigh)
xIndices = [Nlow:1:Nhigh];
yVals(1:1:length(xIndices)) = 0;
posZInd = find((xIndices-n)==0)
yVals(posZInd:1:length(xIndices)) = 1;
stem(xIndices,yVals)
An example MathScript call is
LVPlotUnitStepSeq(-2,-10,10)
A version of the script that returns the output sequence and its indices without plotting is
y = u[n + 1] − u[n − 3]
To verify, we can modify the code from the previous example; the results are shown in Fig. 2.6.
[y1,y1Ind] = LVUnitStepSeq(-1,-10,10);
[y2,y2Ind] = LVUnitStepSeq(3,-10,10);
y = y1 - y2; stem(y1Ind,y)
0.5
Amplitude
−0.5
−1
−10 −5 0 5 10
Sample Index
Figure 2.6: A plot over time indices -10 to +10 of the sequence defined as y[n] = u[n + 1] − u[n − 3].
y[n] = a n
16 CHAPTER 2. DISCRETE SIGNALS AND CONCEPTS
where a is a real number and n is real integer, produces a real sequence. In MathScript, to raise a number
to a single power, use the "ˆ" operator; to raise a number to a vector of powers, use the ".ˆ" operator.
To illustrate this, we can generate and plot a real exponential sequence with a = 2 and n = [0:1:6].
A suitable MathScript call is
0.8
Amplitude
0.6
0.4
0.2
0
−7 −6 −5 −4 −3 −2 −1 0 1
n
Figure 2.7: A real exponential sequence formed by raising the number 2 to the powers [-6:1:0].
cos(2*pi*[0:1:10]/11)
and a suitable call that computes and plots the result is therefore
N = 3; y = [cos(2*pi*[0:1:10]/11)]’;
nY = LVMakePeriodicSeq(y,N); stem(nY )
(MaxH ar+1)/2
y[n] = (1/(2k − 1)) sin(2πf (2k − 1)(n/N )) (2.1)
k=1
For a sawtooth wave, all harmonics are included:
ar
MaxH
y[n] = (1/k) sin(2πf k(n/N ))
k=1
To illustrate the above formulas in terms of m-code, we will synthesize square and sawtooth waves
having 10 cycles, up to the 99th harmonic.
We compute the necessary minimum sequence length as 2(10)(99) = 1980. The following Math-
Script call will synthesize a square wave up to the 99th harmonic; note that only odd harmonics are
included, i.e., k = 1:2:99.
N=1980; n = 0:1:N; y = 0; for k = 1:2:99;
y = y + (1/k)*sin(2*pi*10*k*n/N); end; figure; plot(y)
For a sawtooth wave, the harmonic values are specified as 1:1:99, thus including both odd and
even values:
18 CHAPTER 2. DISCRETE SIGNALS AND CONCEPTS
N=1980; n = 0:1:N; y = 0; for k=1:1:99;
y = y + (1/k)*sin(2*pi*10*k*n/N); end; figure; plot(y)
The script
0.5
Amplitude
−0.5
−1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
(a) Component Waves (X−axis = time, sec): Press Any Key to Continue
1
0.5
Amplitude
0
−0.5
−1
0 0.2 0.4 0.6 0.8
(b) Sum of All Components to Harmonic 5; X−axis = time, sec
Figure 2.8: (a) The first three weighted harmonics of a square wave; (b) Superposition of the waves
shown in (a).
xe = 0.5*(x + fliplr(x))
and the corresponding odd decomposition xo is
xo = 0.5*(x - fliplr(x))
We can write a simple function that generates the even and odd components of an input sequence
x[n] as follows:
function [xe,xo] = LVEvenOdd(x)
xe = (x + fliplr(x))/2; xo = (x - fliplr(x))/2;
We can illustrate use of the above script with a simple example; assuming that x[n] = [1,3,5,7], we’ll
generate an even/odd decomposition and verify its correctness by summing the even and odd components,
and comparing to the original input signal x[n].
x = [1,3,5,7];
[xe,xo] = LVEvenOdd(x)
recon = xe + xo, diff = x - recon
From the above we get xe = [4,4,4,4] and xo = [-3,-1,1,3], the sum of which is [1,3,5,7], i.e., the
original sequence x.
Another useful even/odd decomposition is defined such that
xe[n] = xe[−n]
and
xo[n] = −xo[−n]
20 CHAPTER 2. DISCRETE SIGNALS AND CONCEPTS
In this case, the decompositions exhibit their symmetry about n = 0 rather than about the midpoint
of the original sequence x. For example, if x = [1,2,3,4] with corresponding sample indices n = [3,4,5,6],
a decomposition about n = 0 can be accomplished by padding x with zeros in such a manner to create a
new sequence with time indices symmetrical about zero. In this case, the new sequence is
x = [zeros(1,9),1,2,3,4]
having sample indices [-6:1:6]. The new sequence x is then decomposed as above, i.e.,
x = [zeros(1,9),1,2,3,4];
[xe,xo] = LVEvenOdd(x)
recon = xe + xo, diff = x - recon
A script that performs an even-odd decomposition about zero and returns the even and odd parts
and corresponding indices without plotting is
function [xe,xo,m] = LVEvenOddSymmZero(x,n)
m = -fliplr(n); m1=min([m,n]); m2 = max([m,n]); m = m1:m2;
nm = n(1)-m(1); n1 = 1:1:length(n); x1 = zeros(1,length(m));
x1(n1+nm) = x; xe = 0.5*(x1 + fliplr(x1));
xo = 0.5*(x1 - fliplr(x1));
The call
[xe,xo,m] = LVEvenOddSymmZero([1,2,3],[3,4,5])
for example, yields
xe = [1.5,1,0.5,0,0,0,0,0,0.5,1,1.5]
xo = [-1.5,-1,-0.5,0,0,0,0,0,0.5,1,1.5]
m = [-5:1:5]
The script (see exercises below)
LV xEvenOddAboutZero(x, n)
performs a symmetric-about-zero even-odd decomposition and plots the results. Figure 2.9, which was
generated by making the script call
LVxEvenOddAboutZero([0.9.ˆ([0:1:30])],[0:1:30])
shows the result of this process when applied to the sequence x having sample indices n = [0:1:30], where
x = 0.9.ˆ([0:1:30])
2.4. USEFUL SIGNALS, SEQUENCES, AND CONCEPTS 21
1.5
1
xe
0.5
0
−30 −20 −10 0 10 20 30
(a) Sample Index n
0.5
xo
−0.5
−30 −20 −10 0 10 20 30
(b) Sample Index n
1.5
xe + xo
0.5
0
−30 −20 −10 0 10 20 30
(c) Sample Index n
Figure 2.9: (a) Even component of a decaying exponential sequence; (b) Odd component of same;
(c) Reconstruction of original exponential sequence, obtained by summing the even and odd components
shown in (a) and (b).
which allows computation of the sum starting from a value of n greater than 0.
Another way of thinking of this is that the sum of a geometric sequence a n (we assume |a| <1) is
its first term divided by one minus the convergence ratio R, where
22 CHAPTER 2. DISCRETE SIGNALS AND CONCEPTS
R = a n /a n−1
For example, we can determine the sum of the following sequence using Eq. (2.3), where N = 0:
N−1 ∞
∞
1 aN 1 − aN
an = an − an = − =
1−a 1−a 1−a
n=0 n=0 n=N
rand(m, n) or randn(m, n)
where m and n are dimensions of the matrix of random numbers to be created.
2.4. USEFUL SIGNALS, SEQUENCES, AND CONCEPTS 23
The first function above generates a random signal having uniform distribution over the interval
from 0 to 1; the second function above generates a signal having a Gaussian (or normal) distribution with
a mean of 0 and standard deviation of 1 .
As an m-code example, we’ll generate a signal containing noise of standard deviation 0.125 and
a cosine of frequency 11 over 128 samples, and plot the result. The result from running the following
m-code is shown in Fig. 2.10.
1
Amp
0
−1
−2
0 20 40 60 80 100 120
(a) Sample
1
Amp
0
−1
−2
0 20 40 60 80 100 120
(b) Sample
1
Amp
0
−1
−2
0 20 40 60 80 100 120
(c) Sample
Figure 2.10: (a) A cosine sequence of amplitude 1.0; (b) Gaussian or white noise having standard
deviation of 0.125; (c) The sum of the sequences at (a) and (b).
n = 0.125*randn(1,128); c = cos(2*pi*11*[0:127]/128);
figure(3); subplot(311); stem(c);
subplot(312); stem(n)
subplot(313); stem(n+c)
2.4.12 CHIRP
A sinusoid, such as a cosine wave, having a frequency that continuously increases with time, is expressed
in the continuous domain as
y = cos(βt 2 )
Since the sampled version would have discrete sample times at nT , we would have
24 CHAPTER 2. DISCRETE SIGNALS AND CONCEPTS
y[n] = cos[βn2 T 2 ]
Figure 2.11 shows a sampled chirp with β = 49, T = 1/256, and n = 0:1:255.
1
0.8
0.6
0.4
cos(49(nT) )
0.2
2
0
−0.2
−0.4
−0.6
−0.8
−1
0 50 100 150 200 250
n
The chirp is a useful signal for testing the frequency response of a system such as a filter. A similar
continuous domain technique is the use of a sweep generator to reveal the frequency response of analog
circuits, such as the video intermediate frequency circuits in TV sets.
Other common uses for the chirped sinusoid are radar and ultrasonic imaging In both cases, a chirp
is transmitted toward a target, with the expectation of receiving a reflection at a later time. Since the time
of transmission of any frequency in the chirp is known, and the frequency and time received are known for
any reflection, the difference in time between the transmission and reception times is directly available.
Since the velocity of the transmitted wave is known, the distance between the transmitter/receiver and
the point of reflection on the target object can be readily determined.
MathScript’s chirp function, in its simplest form, is
y = chirp(t, f 0, t1, f 1)
where t is a discrete time vector, f 0 and f 1 are the start and end frequencies, respectively, and t1 is the
time at which frequency f 1 occurs.
2.4. USEFUL SIGNALS, SEQUENCES, AND CONCEPTS 25
As an m-code example, we can generate a chirp that starts at frequency 0 and ends at frequency
50, over 1101 samples:
y = ej x
where e is the base of the natural logarithm system and j is the square root of negative one, generates a
complex number lying on the unit circle in the complex plane, i.e., the number has a magnitude of 1.0.
Such an exponential is equivalent to
y = exp(j*2*pi*(1/8))
A complex number that is repeatedly multiplied by itself generates a sequence of numbers (or
samples) having real and imaginary parts which respectively define cosine and sine waves. Think of two
complex numbers in polar form: the product has a magnitude equal to the product of the two magnitudes,
and an angle equal to the sum of the angles. From this it can be seen that repeatedly multiplying a complex
number by itself results in a sequence of complex numbers whose angles progress around the origin of
the complex plane by equal increments, and the real and imaginary parts of which form, respectively, a
sampled cosine sequence and a sampled sine sequence. If n represents a vector of powers, such as 0:1:N ,
for example, then the complex power sequence is
LVxComplexPowerSeries(0.99*exp(j*pi/18),40)
shows the real and imaginary parts of an entire sequence of complex numbers created by raising the
original complex number W (magnitude of 0.99 at an angle of 10 degrees (π /18 radians)) to the powers
0 to 40. Note that the real part, at (c), is a cosine, and the imaginary part, at (d), is a sine wave.
26 CHAPTER 2. DISCRETE SIGNALS AND CONCEPTS
1
1
0.5
Imaginary
Magnitude
0
0.5
−0.5
−1
0
0 10 20 30 40 −1 −0.5 0 0.5 1
(a) n (b) Real
1 1
0.5 0.5
Imaginary
Real
0 0
−0.5 −0.5
−1 −1
0 10 20 30 40 0 10 20 30 40
(c) n (d) n
Figure 2.12: (a) Magnitude of W = (0.99*exp(jπ /18))n where n = 0:1:40; (b) Plot of entire power sequence
in complex plane; (c) Real part of entire power sequence of W for powers 0 to 40; (d) Imaginary part of
entire power sequence of W for powers 0 to 40.
Let’s compute powers 0:1:3 for the complex number [0 + j] and describe or characterize the
resultant real and imaginary parts. The power sequence is [j0 , j1 , j2 , j3 ], which reduces to [1, j, -1, -j],
with the real parts being [1,0,-1,0] and the imaginary parts being [0,1,0,-1]. These may be described as
four-sample, single-cycle cosine and sine waves. Another way to write this would be
y = cos(2*pi*(0:1:3)/4) + j*sin(2*pi*(0:1:3)/4)
which returns the following:
e−j 2πnk/N
where n = [0,1,2,3], N = 4, and k = 2. This reduces to
cos(pi*(0:1:3)) + j*sin(pi*(0:1:3))
W = M exp(j 2π k/N )
the power sequence
[seqCos,seqSin] = LVGenFreq(1,7.5,73);
The result is shown in Fig. 2.13.
To illustrate the generation of a growing complex exponential, we’ll generate a cosine, sine pair
having a frequency of 3 cycles over 240 samples, and which increases in amplitude by a factor of 1.5 per
cycle. Since there are 240/3 samples per cycle, we take the 80th root of 1.5 as M. Code that makes the
computation of M easier and more flexible would be
Other documents randomly have
different content
BROOKLYN VITAL STATISTICS FOR JUNE,
1888.
By J. S. Young, Dep. Commissioner of Health.
Data of comparison:
In the month of June, 1888, there were 1,513 deaths, the rate of mortality being
23.78 in every 1,000 of the population.
Causes:
1. Zymotic 434
2. Constitutional 251
3. Local 644
4. Developmental 121
5. Violence 63
Measles 6
Croup 8
Diphtheria 82
Scarlet Fever 45
Typhoid Fever
Whooping Cough 5
Malarial Diseases 4
Diarrhœal Diseases (all ages) 244
Diarrhœal Diseases (under 5 years) 233
Phthisis 137
Bronchitis 45
Pneumonia 80
All Respiratory Diseases 149
Bright’s Diseases 35
Puerperal Diseases 17
Old Age 17
Suicide 10
Reported cases:
Diphtheria 214
Scarlet Fever 255
Measles 128
Typhoid Fever
During the month 13 cases of small-pox were reported, of which
number 13 were confirmed as small-pox. 13 cases of small-pox were
sent to hospital. No deaths from small-pox occurred in the city and 2
in the hospital.
Deaths by sex, color, and social condition were as follows:
Male 846 Female 667
White Colored 21
Native 1102 Foreign 411
Married 328 Single 1006
Widows, Widowers, and not stated 179
Still-births (excluded from list of deaths) were as follows:
Males 60
Females 53
Total 113
Deaths in public institutions 115
Deaths in tenement houses 745
Inquest cases 156
Homicides
Suicides 10
Age Periods:
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must,
at no additional cost, fee or expense to the user, provide a copy,
a means of exporting a copy, or a means of obtaining a copy
upon request, of the work in its original “Plain Vanilla ASCII” or
other form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.
• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.
ebookgate.com