matlabgb
-
Upload
srinivaskaredla -
Category
Documents
-
view
223 -
download
0
Transcript of matlabgb
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 1/114
Computer Explorations in Discrete-Time Signals and Systems
and Digital Signal Processing Using MATLAB
–A Laboratory Manual–
Dr. Mateo Aboy
October 22, 2005
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 2/114
SUMMARY TABLE OF CONTENTS
1 Introduction to Sampling and Aliasing 10
2 Discrete-Time Signals 18
3 Discrete-Time Systems and Convolution 25
4 DTFT, DFT, and FFT 33
5 Sampling and Aliasing 42
6 The Z-Transform 52
7 Digital Filtering 62
8 Digital Filtering 77
9 Pro ject: Design of an Automatic Beat Detection Algorithm 92
10 Appendix 99
1
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 3/114
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 4/114
2.2.4 Other Functions and Operations . . . . . . . . . . . . . . . . . . . . . . 21
2.3 Computer Exploration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.3.1 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.4 Example MATLAB code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.5 Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3 Discrete-Time Systems and Convolution 25
3.1 Objective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.2 Theoretical Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.2.1 Development of the Convolution Sum . . . . . . . . . . . . . . . . . . . 27
3.2.2 Stability and Causality . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.3 Computer Exploration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.3.1 Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.3.2 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.4 Example MATLAB code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.5 Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
4 DTFT, DFT, and FFT 33
4.1 Objective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.2 Theoretical Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.2.1 Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.2.2 Zero Padding, Windowing and Other Considerations . . . . . . . . . . . 36
4.3 Computer Exploration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
4.3.1 Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
4.3.2 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384.4 Example MATLAB code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
4.5 Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
3
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 5/114
5 Sampling and Aliasing 42
5.1 Objective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.2 Theoretical Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.2.1 Spectra of Sampled Signals . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.2.2 Reconstruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.3 Computer Exploration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.3.1 Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.3.2 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.4 Example MATLAB code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495.5 Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
6 The Z-Transform 52
6.1 Objective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
6.2 Theoretical Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
6.2.1 Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
6.2.2 Causality and Stability . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
6.2.3 Finding Z-transforms Analytically . . . . . . . . . . . . . . . . . . . . . 556.2.4 Inverse Z-transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
6.3 Computer Exploration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
6.3.1 Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
6.3.2 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
6.4 Example MATLAB code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
6.5 Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
7 Digital Filtering 628.1 Objective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
8.2 Theoretical Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
4
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 6/114
8.2.1 Design Ob jective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
8.2.2 FIR and IIR Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
8.3 Computer Exploration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
8.3.1 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
8.4 Example MATLAB code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
8.5 Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
8 Digital Filtering 77
8.1 Objective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
8.2 Theoretical Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
8.2.1 Design Ob jective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
8.2.2 FIR and IIR Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
8.3 Computer Exploration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
8.3.1 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
8.4 Example MATLAB code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
8.5 Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
9 Pro ject: Design of an Automatic Beat Detection Algorithm 92
9.1 General Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
9.2 Pro ject Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
9.3 Significance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
9.4 Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
9.5 Development and Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
9.6 Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
9.7 Report Sections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 959.8 Report Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
9.9 Assessment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
5
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 7/114
10 Appendix 99
10.1 Appendix I: IEEE-EMBS Detection Paper . . . . . . . . . . . . . . . . . . . . . 99
10.2 Appendix II: IEEE-TBME Detection Paper . . . . . . . . . . . . . . . . . . . . 99
10.3 Appendix III: IEEE-TBME Kalman Filter Paper . . . . . . . . . . . . . . . . . 99
6
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 8/114
LIST OF FIGURES
1.1 The first plot shows xa(t) and the next three plots show the effect of sampling
at f s1 = 10f max = 25, f s2 = 2.5f max = 6.25, f s3 = 1. The first two sampling
frequencies meet the sampling theorem requirement. On the other hand, the
third sampling frequency is less than twice the maximum frequency. We can
see how in this case the signal reconstructed is an aliased version of the original
at a lower frequency. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.1 Plots showing discrete-time signals generated using MATLAB. The upper left
plot corresponds to x(n) = 2δ (n+3)+1δ (n+2)−δ (n)−3δ (n−4), −5 ≤ n ≤ 5,
the upper right plot is the sequence x(n) = [ 1, 2, 4, 5, 9,−3,−2,−1, 4]
generated using a sum of delayed δ (n). The bottom left plot is a complex
exponential x(n) = e(−0.2+ j0.3)n, − 10 ≤ n ≤ 10, and the bottom right
corresponds to a cosine at 30 Hz in Gaussian noise with zero mean and unit
variance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
7
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 9/114
3.1 Example of a discrete system that smoothes an input signal and improves the
signal to noise ratio. The underlying signal is a 10 Hz sinusoid sampled at 300
Hz which is corrupted by Gaussian noise. Notice the output is a smooth delayed
version of the input. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.1 Example of calculating the DFT using the FFT. The plot shows the time–
and frequency–domain representations of a signal xa(t) = 3sin(πt) + 2sin(5πt)
sampled at twice the maximum frequency (f s = 5 Hz). We can see how the
magnitude of the DFT has two peaks at 0.5 Hz and 2.5 Hz, as we expected. In
the next plot we show the DFT of the same signal, but corrupted by Gaussian
noise. Notice how we can still identify the two frequency components even
though the signal is distorted. The final plot shows the FFT in dB scale. We
can see the effect of having a finite-rectangular window. . . . . . . . . . . . . . 39
5.1 The first plot shows xa(t) and the next three plots show the effect of sampling
at f s1 = 10f max = 25, f s2 = 2.5f max = 6.25, f s3 = 2. The first two sampling
frequencies meet the sampling theorem requirement. On the other hand, the
third sampling frequency is less than twice the maximum frequency. We can
see how in this case the signal reconstructed is an aliased version of the original
at a lower frequency. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
5.2 The three plots show the effect of sampling at f s1 = 10f max = 25, f s2 =
2.5f max = 6.25, f s3 = 2 in the frequency domain. The first two sampling
frequencies meet the sampling theorem requirement. On the other hand, the
third sampling frequency is less than twice the maximum frequency. The
aliasing effect is evident in the third plot. . . . . . . . . . . . . . . . . . . . . . 48
6.1 z-plane of H (z) = 0.0061431−1.87834z−10.975156z−2 . . . . . . . . . . . . . . . . . . . . . . . 58
8
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 10/114
6.2 Magnitude and phase response of H (z) = 0.0061431−1.87834z−10.975156z−2 . We can see
that the system is a digital resonator filter which has a peak at ω = 0.1π . . . . 59
8.1 Frequency response of the lowpass filter. . . . . . . . . . . . . . . . . . . . . . . 82
8.2 Result of the lowpass filtering operation. Notice that the lowpass filter smooths
the effects of quantization noise. Notice also that this filter was implemented
with filtfilt (no delay of the output with respect to the input) and therefore it
is a noncausal filter. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
8.3 Result of the highpass filtering operation. Notice that the highpass filter
eliminated the signal trend. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
8.1 Frequency response of the lowpass filter. . . . . . . . . . . . . . . . . . . . . . . 82
8.2 Result of the lowpass filtering operation. Notice that the lowpass filter smooths
the effects of quantization noise. Notice also that this filter was implemented
with filtfilt (no delay of the output with respect to the input) and therefore it
is a noncausal filter. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
8.3 Result of the highpass filtering operation. Notice that the highpass filter
eliminated the signal trend. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
9
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 11/114
CHAPTER 1
Introduction to Sampling and Aliasing
10
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 12/114
1.1 Objective
The objective of this lab is to explore the concept of sampling and reconstruction of analog
signals. Specifically, we will simulate the sampling process of an analog signal using MATLAB,
investigate the effect of sampling in the time domain, and introduce the concept of aliasing.
In a later lab, after studying the DTFT and DFT, we will revisit this topic and explore these
two concepts in the frequency domain.
1.2 Theoretical Introduction
The signals that we encounter in the real world are mostly analog signals, which vary
continuously in time and amplitude. These signals can be processed using analog filters.
Analog filters are implemented using electrical networks containing active and passive circuit
elements. In many cases, however, we are interested in processing real world analog signals
digitally. In order to process analog signals using digital hardware such as a digital signal
processors (DSPs), one needs to convert the analog signals into a digital form which is suitable
for digital hardware. The conversion of an analog signal to a digital form is performed by an
analog-to-digital converter (ADC), which produces a stream of binary numbers from analog
signals, that is, it takes samples of the analog signal and digitizes the amplitude at these
discrete times. It is for this reason that a digital signal is said to be discrete in time and
discrete in amplitude. Prior to the ADC conversion, an analog filter called the prefilter or
antialiasing filter is applied to the analog signal in order to prevent an effect known as aliasing ,
which we will explore in this laboratory experiment. When the signal is in a digital form, it can
be processed by a digital signal processor (DSP). After performing the digital signal processing,
the signal must be converted back into an analog signal. This is done by a digital-to-analog converter (DAC) and an analog postfilter which smooths out the staircase waveform.
In order to do digital signal processing we must first perform other tasks. It may appear
11
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 13/114
that DSP is more complicated than ASP. We must therefore ask ourselves the question:
Why does anybody want to process the signal digitally? The answer to this question is
that DSP provides many advantages over ASP. The primary reasons for using DSP are
programmability, reliability, accuracy, availability, and cost of the digital hardware. Systems
using DSP approach are programmed and can be tested or reprogrammed to perform a different
DSP task easily. Also, DSP operations are based solely on additions and multiplications, which
lead to a very stable processing (stability independent of temperature, etc). Furthermore, DSP
operations can easily be modified in real-time by simple programming changes or reloading of
registers.
1.2.1 Sampling and aliasing
In this lab we focus our attention in the process of sampling and how to avoid the so called
problem of aliasing . During sampling, an analog signal x(t) is periodically measured every T
seconds, that is, time is discretized in units of the sampling interval or sampling period T :
t = nT, n = 0, 1, 2,...
where T is the sampling period. The inverse of T is called the sampling frequency, that is,
the samples per second:
f s = 1
T
When we sample an analog signal we must make sure that we are taking enough samples
(sampling fast enough) so that the samples are a good representation of the original analog
signal. In some cases, when the sampling frequency f s is not fast enough the samples taken
may not represent the original analog signal. The potential confusion of the original signalwith another of a different frequency is known as aliasing . Aliasing can be avoided if one
satisfies the conditions of the sampling theorem.
12
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 14/114
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 15/114
1.3.2 Example
As an example, let’s follow this procedure to simulate the effect of sampling the analog signal:
xa(t) = 3sin(πt) + 2sin(5πt)
This signal contains two frequency components at f 1 = 1/2 and f 2 = 2.5 Hz. We explore the
effect of sampling and aliasing by sampling xa(t) with three different sampling frequencies:
f s1 = 10f max = 25, f s2 = 2.5f max = 6.25, f s3 = 1. The first two sampling frequencies meet
the sampling theorem requirement. On the other hand, the third sampling frequency is less
than twice the maximum frequency and therefore we should expect to see aliasing. Figure 1.1
shows the results of the MATLAB simulation.
14
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 16/114
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 17/114
1.4 Example MATLAB code
Below we show the MATLAB code used to generate this example:
%==================================================
% Simulated Analog Signal: f1 = 1/2 Hz, f2 = 2.5 Hz
%==================================================
f1 = 1/2; % f1 = 1/2 Hz
f2 = 2.5; % f2 = 2.5 Hz
T = 1/ 10 00 ; N = 10 00 ; n = 0: 10 *N ; t = n* T; x =
3*sin(2*pi*f1.*t) + 2*sin(2*pi*f2.*t);
subplot(4,1,1);
h = plot(t,x); ylabel(’x(t)’); box off;
%==================================================
% Sampling at fs = 10*fmax = 10*f2
%==================================================
fs = 10*f2; % Sampling Frequency
T = 1/fs; % Sampling Period
n = 0:10*fs; % Plot 10 seconds
k = n*T; % Time Index
xs = 3*sin(2*pi*f1.*k) + 2*sin(2*pi*f2.*k);
subplot(4,1,2);
h = plot(t,x,’:’,k,xs, ’r.’); ylabel(’x(nT)’);
%==================================================
% Sampling at fs = 2.5*fmax = 2.5*f2
%==================================================
fs = 2.5*f2; % Sampling Frequency
T = 1/fs; % Sampling Period
n = 0:10*fs; % Plot 10 seconds
k = n*T; % Time Index
xs = 3*sin(2*pi*f1.*k) + 2*sin(2*pi*f2.*k);
subplot(4,1,3);
h = plot(t,x,’:’,k,xs, ’r.’); ylabel(’x(nT)’);
%==================================================
% Sampling at fs = 1 (fs < fmax = f2)
%==================================================
fs = 1; % Sampling Frequency
T = 1/fs; % Sampling Period
n = 0:10*fs; % Plot 10 seconds
k = n*T; % Time Index
xs = 3*sin(2*pi*f1.*k) + 2*sin(2*pi*f2.*k);
xa = 3*sin(2*pi*f1.*t)+2*sin(2*pi*0.5*t);
subplot(4,1,4);
h = plot(t,x,’:’,t,xa, k,xs, ’r.’);
xlabel(’Time, s’);
ylabel(’x(nT)’);
16
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 18/114
1.5 Tasks
Use MATLAB to perform the following computer exploration:
1. Simulate the continuous time signal xa(t) = cos(1πt)+cos(3πt)+cos(5πt)+cos(7πt) by
sampling at a high sampling frequency (f s = 50f max).
2. Plot, observe, and describe the effect of sampling xa(t) with f s = 10f max.
3. Plot, observe, and describe the effect of sampling xa(t) with f s = 5f max.
4. Plot, observe, and describe the effect of sampling xa(t) with f s = 2f max.
5. Plot, observe, and describe the effect of sampling xa(t) with f s = f max without prefilter.
6. Plot, observe, and describe the effect of sampling xa(t) with f s = f max an ideal prefilter.
17
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 19/114
CHAPTER 2
Discrete-Time Signals
18
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 20/114
2.1 Objective
In this laboratory we will create MATLAB functions to efficiently implement the most common
discrete-time signals such as the unit sample sequence, the unit step sequence, real– and
complex–valued exponential sequences, and sinusoidal sequences. Furthermore, we will explore
the concept of unit sample synthesis.
2.2 Theoretical Introduction
A discrete-time signal is a sequence of numbers. In this lab manual we will denote a continuous-
time signal as x(t), where t represents the independent time variable. We will use x(n) to
denote a discrete-time signal, where n is the time index . We can use MATLAB to implement
any finite-duration sequence by a row vector of appropriate values. A vector, however, does
not have any information about the sample position n. For this reason we need to use two
vectors to represent a signal x(n), one for x and another for one n. For example, a sequence
x(n) = {2, 3, 5,−2, 9, 7}, where the underlined value represents the sample at time zero, can
be represented in MATLAB by:
n=[-2,-1,0,1,2,3]; x = [2, 3, 5, -2, 9, 7];
In the cases where the sample position information is not needed we can represent a signal
using the vector x alone.
There are a few discrete-time signals that we encounter very often. For this reason, it
is convenient to create MATLAB functions that can be used to implement these important
sequences.
19
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 21/114
2.2.1 Unit Sample Sequence
The unit sample sequence, δ (n) can be implemented using the logical relation n==0 as
follows:1.
function [x,n] = ImpSeq(n0,n1,n2)
%ImpSeq: Generates x(n) = delta(n-n0); n1<= n <= n2
%
% [x,n] = ImpSeq(n0,n1,n2)
%
n = [n1:n2]; x = [(n-n0) == 0];
2.2.2 Unit Step Sequence
function [x,n] = StepSeq(n0,n1,n2)
%StepSeq: Generates x(n) = u(n-n0); n1<= n <= n2
%
% [x,n] = StepSeq(n0,n1,n2)
%
n = [n1:n2]; x = [(n-n0) >= 0];
2.2.3 Real– and Complex–Valued Exponential Sequences
The MATLAB operator for exponentiation can be used to implement a real exponential
sequence. For example, to implement x(n) = (0.8)n, 0 ≤ n ≤ 10, we can use:
n = [0:10]; x = (0.8).^n;
In the case of complex–valued sequences we must use the MATLAB function exp. For
example, to generate x(n) = e(3+ j2)n, 0 ≤ n ≤ 10, we write:
1The implementation is based on the code given by V. K. Ingle and J. G. Proakis on “Digital Signal
Processing Using MATLAB”, BookWare Companion Series. The MATLAB code can be downloaded from the
book’s website
20
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 22/114
n = [0:10]; x = exp((3+2j)*n);
2.2.4 Other Functions and Operations
It is also important to create MATLAB functions to perform operations on the basic functions
described above. For instance, we must be able to multiply, add, perform time shifts, folding,
even and odd decompositions, sample summations (sum ), sample products (prod ), etc. An
important fact is that any arbitrary sequence x(n) can be synthesized as a weighted sum of
delayed and scaled unit sample sequences, that is
x(n) =∞
k=−∞
x(k)δ (n − k)
This result will be used to develop the concept of convolution, and the response of a linear-
time-invariant (LTI) system to an arbitrary input.
2.3 Computer Exploration
In this section we show some examples of how to use the basic signals to create more complex
ones. Furthermore, we explore the concept of how to synthesize any signal as a weighted sum
of delayed and scaled unit sample sequences.
2.3.1 Example
As an example, let’s generate and plot the following sequences:
1. x(n) = 2δ (n + 3) + 1δ (n + 2) − δ (n) − 3δ (n − 4), − 10 ≤ n ≤ 10
2. x(n) = [1, 2, 4, 5, 9,−3,−2,−1, 4] using a sum of δ (n)
3. x(n) = e(−0.2+ j0.3)n, − 10 ≤ n ≤ 10.
4. A cosine at 30 Hz in Gaussian noise with zero mean and unit variance.
21
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 23/114
−10 −5 0 5 10−3
−2
−1
0
1
2
Time Index, n
−5 0 5 10−4
−2
0
2
4
6
8
10
Time Index, n
−10 −5 0 5 10−8
−6
−4
−2
0
2
Time Index, n
−10 −5 0 5 10−2
−1.5
−1
−0.5
0
0.5
1
1.5
Time Index, n
Figure 2.1: Plots showing discrete-time signals generated using MATLAB. The upper left plotcorresponds to x(n) = 2δ (n + 3 ) + 1δ (n + 2)− δ (n)− 3δ (n− 4), − 5 ≤ n ≤ 5, the upper rightplot is the sequence x(n) = [1, 2, 4, 5, 9,−3,−2,−1, 4] generated using a sum of delayedδ (n). The bottom left plot is a complex exponential x(n) = e(−0.2+ j0.3)n, − 10 ≤ n ≤ 10, andthe bottom right corresponds to a cosine at 30 Hz in Gaussian noise with zero mean and unit
variance.
22
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 24/114
2.4 Example MATLAB code
%==================================================
% Generate and Plot x1(n)
%==================================================
n = [-10:10];
x = 2*impseq(-3,-10,10)+1*impseq(-2,-10,10) ...
- impseq(0,-10,10) - 3*impseq(4,-10,10);
subplot(2,2,1); stem(n,x);
xlabel(’Time Index, n’); box off;
%==================================================
% Generate and Plot x2(n)
%==================================================
n = [-2:10];
x = 1*impseq(0,-2,10)+ 2*impseq(1,-2,10) ...
+ 4*impseq(2,-2,10)+ 5*impseq(3,-2,10) ...
+ 9*impseq(4,-2,10)- 3*impseq(5,-2,10) ...
- 2*impseq(6,-2,10)- 1*impseq(7,-2,10) ...
+ 4*impseq(8,-2,10);
subplot(2,2,2); stem(n,x);
xlabel(’Time Index, n’); box off;
%==================================================
% Generate and Plot x3(n)
%==================================================
n = [-10:10]; alpha = -0.2+0.3*j;
x = real(exp(alpha*n));
subplot(2,2,3); stem(n,x);
xlabel(’Time Index, n’); box off;
%==================================================
% Generate and Plot x4(n)
%==================================================
n = [-10:10]; % Time Index
fs = 12*30; % Sampling Frequency
ns = 0.2*randn(1,length(n)); % Gaussian Noise
x = sin(2*pi*30*n.*1/fs); % Signal
xn = x+ns; % Signal + Noise
subplot(2,2,4);
stem(n,xn); xlabel(’Time Index, n’); box off;
23
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 25/114
2.5 Analysis
Use MATLAB to perform the following computer exploration:
1. Generate the real–valued signal x(n) = an, − 10 ≤ n ≤ 10 for at least four different
values of a. Consider the cases where a is positive, negative, in between −1 and 1, etc.
Plot the results as a subplot.
2. Generate the complex-valued signal x(n) = e(α+ jβ )n for different values of α and β . Plot
the real and imaginary parts, and the magnitude and phase.
3. Generate a cosine waveform at 125 Hz. Use a sampling frequency f s of 15 KHz.
4. Using the cosine sequence generated in the previous part, add Gaussian noise to it and
plot the results.
24
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 26/114
CHAPTER 3
Discrete-Time Systems and Convolution
25
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 27/114
3.1 Objective
In this laboratory we investigate discrete-systems. In particular, we will focus our attention
on a subclass of systems known as linear-time invariant (LTI) systems. We will see that in the
case of an LTI system we can write an expression for the output of the system to an arbitrary
input. Using the concepts of impulse-response and convolution, we will introduce the concept
of digital filtering.
3.2 Theoretical Introduction
A discrete time system can be modelled mathematically as a transformation, a function, or
an operator, that takes an input sequence and produces an output sequence, that is
y(n) = T [x(n)]
In the context of DSP we say that a system processes an input signal and produces an output
signal. In general, systems are divided into two broad classes: linear and nonlinear. Linear
systems are those that obey the principle of superposition,
L[a1x1(n) + a2x2(n)] = a1L[x1(n)] + a2L[x2(n)]
Linear systems can be further subdivided into two classes: time-invariant and time-variant
or time-dependent. A linear system in which an input-output pair is invariant to a time-shift
n is called a linear-time-invariant system or LTI system.
LTI systems are very important in practice because there is a well developed mathematical
theory that enables us to analyze, design, and study these systems in great detail. In particular,
we can completely characterize LTI systems by their impulse response. If we have an LTI
26
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 28/114
system and we want to predict what the system does, the only thing we need to do is to input
an impulse and record the output (the impulse response). Once we have the impulse response,
we can use the convolution sum to find the output of the system for an arbitrary input.
3.2.1 Development of the Convolution Sum
Let’s try to find an expression for the output of a LTI system for an arbitrary input. Since
we are not making any assumptions about the input sequence x(n), we must find a way to
express this sequence in terms of some other for which we do know what the output is. By
definition, the output of an LTI system L[·] to a unit sample is the impulse response, denotedh(n). We can, therefore, express the arbitrary input signal x(n) using δ (n − k) as our basis
functions. This is convenient because we know the output of the system for a single impulse.
The procedure to develop an expression for the output of the system to an arbitrary input
is as follows:
1. Goal: we want to find an expression for y(n) for any input signal x(n)
2. Given: we know that the output of a system when the input is an impulse is h(n).
y = L[x(n)] = L[δ (n)] = h(n)
3. Since we know what the output is for an impulse δ (n) we just have to represent the
input signal x(n) using the impulses as our basis functions.
x(n) =∞
k=−∞
x(k)δ (n − k)
4. Since the system is time invariant we know that
L[δ (n − k)] = h(n − k)
27
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 29/114
5. Therefore, we can express the output of the system as:
y(n) = L[x(n)] = L[∞
k=−∞
x(k)δ (n − k)] =∞
k=−∞
x(k)L[δ (n − k)] =∞
k=−∞
x(k)h(n − k)
where we have used the fact that the system is linear and time-invariant.
The expression we obtained for the output y(n) is called the linear-convolution sum and
is denoted by y (n) = x(n) ∗ h(n).
3.2.2 Stability and Causality
In linear system theory we are interested in systems that are stable . There are several
definitions for stability. In general we can say that a system is stable if bounded input signals
produce bounded output responses (BIBO). In terms of the impulse response, an LTI system
is stable if its impulse response is absolutely summable , that is,
∞n=−∞
|h(n)| < ∞
Another important concept is causality . We say that a system is causal if the output at
time n0 depends only of the inputs at time n0 and before, but not on future values of n. In
general, only causal systems can be implemented in real-time. However, in cases where the
system is not completely causal we may still be able to implement them in a close–to–real–time
fashion by using a buffer.
3.3 Computer Exploration
In this section we show some examples of how to use the concept of convolution in a practical
sense. In particular, we can see how a system with a very simple impulse response can be
used as a filter to smooth noisy signals.
28
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 30/114
3.3.1 Procedure
1. Generate a sinusoidal signal in Gaussian noise.
2. Generate a sequence for the impulse response h(n)
3. Using convolution filter the noisy input signal x(n) with the filter characterized by h(n)
4. Plot the results and experiment using different numbers of filter coefficients and shapes
of h(n)
3.3.2 Example
As an example let’s generate a sinusoidal signal with a frequency of 10 Hz, sampled at 300 Hz
which is corrupted by zero mean, unit variance Gaussian noise. Next, we generate a sequence
h(n) = 18 [u(n) − u(n − 8)], that is, a constant impulse response. Using convolution we filter
the noisy input signal x(n) with the filter characterized by h(n). Finally, we plot the results
and experiment using different numbers of filter coefficients and shapes of h(n)
In Figure 3.1 we show the output of the system presented in the previous example. Notice
that the use of this filter with a very simple impulse response can help to reduce the Gaussian
noise. The output of the system is less noisy than the original sequence. This system is called
a moving-average filter , because the output is an average, that is
y(n) = 1
8[x(n) + x(n − 1) + x(n − 2) + x(n − 3) + x(n − 4) + x(n − 5) + x(n − 6) + x(n − 7)]
In this case all the coefficients are constant and equal to 1 /8. Notice the relationship between
this expression and convolution. We can rewrite y(n) as
y(n) = 1
8
7k=0
x(n − k) =7
k=0
1
8x(n − k)
29
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 31/114
In general, the coefficients don’t have to be constant,
7k=0
h(k)x(n − k) =7
k=0
x(k)h(n − k)
This equation is the convolution sum of a finite-impulse response filter (FIR) of order 7. The
problem in digital filtering design is how we go about choosing these h(n) coefficients so that
we can filter-out the undesired noise present in the input signal. We are usually interested
in filtering out some particular frequencies while leaving the others unchanged, therefore we
need techniques that allow us to find specific coefficients to remove specific frequencies. This
design is done in the frequency domain. We will revisit this topic once we have introduced
the concepts of DTFT, DFT, and FFT.
0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5
−1
−0.5
0
0.5
1
1.5
Figure 3.1: Example of a discrete system that smoothes an input signal and improves thesignal to noise ratio. The underlying signal is a 10 Hz sinusoid sampled at 300 Hz which iscorrupted by Gaussian noise. Notice the output is a smooth delayed version of the input.
30
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 32/114
3.4 Example MATLAB code
%==================================================
% Generate sinusoidal signal corrupted by noise
%==================================================
N = 150; % Number of samples
n = 1:N; % Time index
fs = 300; % Sampling frequency
T = 1/fs; % Sampling period
f = 10; % Frequency of sinusoid
x = cos(2*pi*f*n.*T); % Clean Sinusoidal signal
a = 0.25; % 1% Noise
ns = a*randn(1,length(x)); % Gaussian Noise
xn = x+ns; % Signal in noise
%==================================================
% Generate the impulse response
%==================================================
h = 1/8*stepseq(0,0,7)
%==================================================
% Filter noisy signal using h(n), xf(n) = xs(n)*h(n)
%==================================================
xf = conv(xn,h); % Filtered output
%==================================================
% Plotting of results
%==================================================
h1 = plot(n*T, xn, (1:length(xf))*T, xf);
axis tight; box off;
31
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 33/114
3.5 Analysis
Use MATLAB to perform the following computer exploration:
1. Download the ICP signal from the class website. Plot the signal in the time domain
(f s = 125 Hz).
2. Filter the signal using an impulse response of the form h(n) = u(n) − u(n − β ), where
β is a user-specified parameter. Filter the signal and plot the results for different values
of β . Comment on the results.
3. MATLAB has two functions that can be used to implement filters by providing the
coefficients, one of them is called filter and the other filtfilt . Using the MATLAB help,
repeat the first experiment using both functions. Comment on the differences. Is a filter
implemented using filtfilt a causal system?
4. Use the moving average filter to smooth the ICP and eliminate the high– frequency
effects due to quantization.
5. Use the moving average filter to eliminate frequency components higher than the
fundamental component. Try to filter the ICP signal in such a way that the filtered
signal will be as sinusoidal as possible.
6. Use the moving average filter to eliminate the ICP trend.
32
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 34/114
CHAPTER 4
DTFT, DFT, and FFT
33
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 35/114
4.1 Objective
In this laboratory we will introduce the tools to perform Fourier analysis in discrete-time,
namely the Discrete-Time Fourier Transform (DTFT), the Discrete-Fourier Transform (DFT),
and an efficient algorithm to compute the DFT called the Fast-Fourier Transform (FFT).
4.2 Theoretical Introduction
We have seen already how any signal can be decomposed as a weighted sum of delayed unit
sample impulses. We saw that representing the input signal using impulses as our basis
function was useful in the development of the convolution sum.
Fourier analysis consist of decomposing a signal as a sum of sinusoids (or complex
exponentials). Depending on whether we are working on continuous–time or discrete–time, or
whether we are working with periodic or non–periodic signals there are different Fourier tools
to perform this decomposition. In the continuous–time, we have the Fourier Series (FS) and
the Fourier Transform (FT) for working with periodic and non–periodic signals, respectively.
Analogously, in discrete–time we have the Discrete–Fourier Series (DFS) and the Discrete–
Fourier Transform (DTFT).
Most signals of practical interest can be decomposed into a sum of sinusoidal signal
components. These decompositions are extremely important in the analysis and design of
LTI systems because complex exponentials (sinusoids) are eigenfuntions of LTI systems. This
means that the response of an LTI system to a sinusoidal input signal is another sinusoid of
the same frequency but of different amplitude and phase.
Frequency analysis involves the resolution of the signal into its frequency components
34
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 36/114
(just as the resolution of light into its different colors). When we decompose a signal into its
frequency components we are doing frequency analysis . The opposite problem, reconstructing
the original signal from its frequency components, is known as frequency synthesis . The term
spectrum is used to refer to the frequency content of a signal. The process of obtaining
the spectrum of deterministic signals , signals for which we have a mathematical equation to
represent them, is called frequency or spectral analysis . On the other hand, the process of
determining the spectrum of the signals we encounter in practice, for which we do not have a
mathematical formula, is called spectral estimation .
4.2.1 Definitions
DTFT
If x(n) is absolutely summable, then its discrete-time Fourier transform (DTFT) is given by:
X (e jw ) =∞
n=−∞
x(n)e− jwn
The inverse-time Fourier transform (IDTFT) of X (e jw ) is given by:
x(n) = 1
2π
π
−πX (e− jw )e jwn dw
DFS, DFT, and FFT
From the definition of the DTFT we can see that its computation involves summing an infinite
number of terms. Furthermore, even though we are analyzing discrete-time signals, the DTFT
is a function of the continuous-time frequency variable w. For this two reasons, the DTFT is
not a numerically computable transform. The discrete-Fourier Series (DFS) and the discrete-
Fourier transform (DFS) provide us with a mechanism for numerically computing the DTFT
35
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 37/114
at specific points.
The discrete-Fourier transform of any signal x(n) is defined as
X (k) =N −1n=0
x(n)e− j2πkn/N , k = 0, 1, 2, . . . , N − 1
This formula shows how to transform a sequence of length L ≤ N into a sequence of
frequency samples X (k) of length N . These samples are obtained by evaluation of the DTFT
X (e jw ) at a set of N equally spaced discrete frequencies. From X (k) we can reconstruct the
original sequence x(n) by using the inverse-discrete Fourier transform (IDFT):
x(n) = 1
N
N −1k=0
X (k)e j2πn/N, n=0,1,2,...,N −1
The fast-Fourier transform FFT is not really a new transform, it is just a very efficient
algorithm (actually there are several FFT algorithms) that is used to compute the DFT.
Matlab provides a function called fft to compute the DFT of a vector x.
4.2.2 Zero Padding, Windowing and Other Considerations
The above definition of the DFT allows us to compute the DTFT of a signal x(n) at N equally
spaced values. Sometimes, this is a very coarse estimate of the DTFT. If we are interested in
evaluating the frequency at more values than N we can make longer the original sequence x(n)
by appending zeros at the end. This procedure for increasing the computational frequency
resolution is called zero-padding . It is important to realize that even though we are computing
the DFT at more points, we are not increasing the physical frequency resolution , which depends
on the length of our window.
Anytime we are computing the DFT of an infinite sequence x(n) we must first truncate x(n)
36
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 38/114
into a finite-sequence. This operation can be modelled as a multiplication in the time domain
by a rectangular window . Since multiplication in the time domain corresponds to convolution
in the frequency domain, the effect of this operation is a convolution of the original spectrum
of x(n) by the sinc function. The distortion introduced due to the effect of window causes
the original spectrum to have artificial sidelobes , which correspond to the sidelobes of the
sinc function. As we increase the length of our window we improve the frequency resolution,
and the artifact caused by the rectangular window become less significant. Depending on the
application we may decide to use a different window from the rectangular. In particular, there
are many other windows which reduce the sidelobe leakage at the expense of increasing themainlobe width. Some of the most important windows are the hanning, hamming, blackman,
blackman-harris, harris and triangular windows. MATLAB provides direct implementations
for all of these.
4.3 Computer Exploration
The most basic application of the DFT (or FFT) is to approximate the DTFT. Having a
signal x(n) we are interested in performing frequency analysis on it, that is, calculate thespectral content (spectrum) of the signal. Next, we indicate a simple procedure of a computer
exploration to investigate the FFT as a tool for spectral analysis, then show an example of
how to perform this task.
4.3.1 Procedure
1. Generate a signal composed of several different frequency components.
2. Estimate the amplitude spectrum using the FFT.
3. Zero-pad to the next power of 2 and perform the FFT again.
4. Change the window length and repeat the experiments.
37
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 39/114
5. Change the type of window and repeat the experiment.
4.3.2 Example
As an example of calculating the DFT using the FFT we generated the following figure. The
plot shows the time– and frequency–domain representations of a signal xa(t) = 3sin(πt) +
2sin(5πt) sampled at twice the maximum frequency (f s = 5 Hz). We can see how the
magnitude of the DFT has two peaks at 0 .5 Hz and 2.5 Hz, as we expected. In the next
plot we show the DFT of the same signal, but corrupted by Gaussian noise. Notice how we
can still identify the two frequency components even though the signal is distorted. The finalplot shows the FFT in dB scale. We can see the effect of having a finite-rectangular window.
38
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 40/114
0 2 4 6 8 10
−4
−2
0
2
4
x ( n T )
0 2 4 6 8 10
−6
−4
−2
0
2
4
6
x n ( n T )
0 2 4 6 8 10
−4
−2
0
2
4
x n ( n
T )
0 2 4 6 80
50
100
150
0 2 4 6 80
50
100
150
1 2 3 4 5 6
−500
−400
−300
−200
−100
0
100
Figure 4.1: Example of calculating the DFT using the FFT. The plot shows the time– andfrequency–domain representations of a signal xa(t) = 3sin(πt) + 2sin(5πt) sampled at twicethe maximum frequency (f s = 5 Hz). We can see how the magnitude of the DFT has twopeaks at 0.5 Hz and 2.5 Hz, as we expected. In the next plot we show the DFT of the samesignal, but corrupted by Gaussian noise. Notice how we can still identify the two frequencycomponents even though the signal is distorted. The final plot shows the FFT in dB scale.We can see the effect of having a finite-rectangular window.
39
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 41/114
4.4 Example MATLAB code
Below we show the MATLAB code used to generate this example:
%==================================================
% Sinusoidal signal with two frequencies
%==================================================
f1 = 0.5; % 1 Hz component
f2 = 2.5; % 2.5 Hz component
fs = 5*f2; % Sampling Frequency
T = 1/fs; % Sampling Period
n = 0:10*fs; % Plot 10 seconds
k = n*T; % Time Index
xs = 3*sin(2*pi*f1.*k) + 2*sin(2*pi*f2.*k);
subplot(3,2,1);
h = plot(k,xs); set(h, ’Markersize’, 15);
ylabel(’x(nT)’); box off;
axis tight;
%==================================================
% FFT of original sequence
%==================================================
subplot(3,2,2);
X = abs(fft(xs)); % FFT Magnitude
f = (1:length(X))*fs/length(X);% Frequency axis
stem(f(1:end/2),X(1:length(X)/2)); box off; axis tight;
%==================================================
% Signal with noise and FFT
%==================================================
xn = xs + 1.75*randn(1,length(xs)); subplot(3,2,3); h =
plot(k,xn); set(h, ’Markersize’, 15); ylabel(’xn(nT)’); box off;
axis tight; subplot(3,2,4);
X = abs(fft(xn)); % FFT Magnitude
f = (1:length(X))*fs/length(X);% Frequency axis
stem(f(1:end/2),X(1:length(X)/2)); box off; axis tight;
%==================================================
% FFT ploted in db scale
%==================================================
xn = xs + 0*randn(1,length(xs)); subplot(3,2,5); h = plot(k,xn);
set(h, ’Markersize’, 15); ylabel(’xn(nT)’); box off; axis tight;
subplot(3,2,6);
X = 20*log(abs(fft(xn))); % FFT Magnitude dB
f = (1:length(X))*fs/length(X);% Frequency axis
plot(f(1:end/2),X(1:length(X)/2)); box off; axis tight;
40
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 42/114
4.5 Analysis
Use MATLAB to perform the following computer exploration:
1. Perform the FFT of the same signal given in the example but using a different window
length. Plot, and comment on the results.
2. Repeat the experiment using a different window type. How do the results obtained with
this window compare with the ones using the rectangular window?
3. Generate 512 samples of a pure sinusoid and perform the FFT. Can you observe the
effect of the window? Why?
4. Perform the FFT on the impulse response used on the previous lab h(n) = u(n)−u(n−
10). Comment on the results.
5. Implement the DFT directly using the definition and compare its performance (speed of
execution) with the FFT algorithm.
6. Since convolution in the time domain equal multiplication in the frequency domain, we
could calculate the convolution of two sequences by first computing the FFT of each
one of them, multiply them in the frequency domain, and then perform an inverse DFT.
Create a function that uses this procedure to compute convolution.
41
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 43/114
CHAPTER 5
Sampling and Aliasing
42
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 44/114
5.1 Objective
In this laboratory we will revisit the topic of sampling and aliasing. We will discuss the effects
of sampling using Fourier transforms. Looking at the spectra of sampled signals will enable
us to get a better understanding of the concept of aliasing.
5.2 Theoretical Introduction
An ideal sampler instantaneously measures the analog signal x(t) at the sampling instants
t = nT . We can consider the output of the sampling process to be an analog signal which
consists of a linear superposition of impulses occurring at the sampling times. In this model,
each impulse is weighted by the corresponding sample value, that is
xs(t)δ (t − nT ) = x(nT )δ (t − nT )
xs(t) = x(t)
∞n=−∞
δ (t − nT ) =
∞n=−∞
x(nT )δ (t − nT )
In practical sampling, each sample must be held constant for a short period of time for the A/Dconverter to accurately convert the sample to digital form. This process can be mathematically
modelled substituting the impulses by rectangular pulses of time duration τ T ,
x p(t) =
∞n=−∞
x(nT ) p(t − nT )
5.2.1 Spectra of Sampled Signals
The spectrum of the sampled signal can be obtained by finding the Fourier transform of xs(t),
X s(f ) =
∞
−∞
xs(t)e−2πjftdt
43
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 45/114
X s(t) = ∞
−∞
∞
n=−∞
x(nT )δ (t − nT )e−2πjftdt
=∞
n=−∞
x(nT )
∞
−∞
δ (t − nT )e−2πjftdt
X s(t) =∞
n=−∞
x(nT )e−2πjfnT
We see that the spectrum of the sampled signal is the DTFT of x(nT ). Furthermore, we
see that X s(t) is a periodic function of f with period f s, that is, X s(f + f s) = X (f ),
X s(f ) = 1
T
∞m=−∞
X (f − mf s)
this equation indicates that the spectrum of a sampled signal is equal to a scaled version of the
original analog spectrum periodically replicated at intervals of the sampling rate f s. We see
that if x(t) is bandlimited to some maximum frequency f max, the replicas are separated from
each other by a distance d = f s − 2f max. Therefore, if we are interested in the replicas not
overlapping each other, we require that d ≥ 0, that is f s ≥ 2f max, which is the requirement
to avoid aliasing introduced in the first laboratory. We see that aliasing occurs when the
replicated spectra overlap, d < 0, since this overlapping results in a distortion of the original
spectrum.
5.2.2 Reconstruction
If the signal is bandlimited and f s is large enough so the replicas do not overlap, that is,
f s ≥ 2f max, then the portion of the spectrum X s(f ) that lies within the Nyquist interval
44
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 46/114
[−f s/2, f 2/2] will be identical to the original analog spectrum X (f ) by a scaled constant,
T X s(t) = X (f ), − f s
2 ≤ f ≤
f s2
5.3 Computer Exploration
As we saw in the first laboratory, in order to explore the concepts of sampling and aliasing
we can perform a MATLAB simulation where we create an analog signal (simulated), take
samples at different frequencies, and observe the effect of f s. In the first lab, we saw the effect
of sampling in the time domain. Now we explore this concept in the frequency domain by
using the DFT/FFT.
5.3.1 Procedure
1. Simulate an analog signal with different frequency components.
2. Take samples at different sampling frequencies.
3. Plot the results.
4. Take the FFT of the samples at the different sampling frequencies.
5. Plot the spectrum within the Nyquist interval and observe the frequency content of the
sampled signal.
5.3.2 Example
As an example, let’s follow this procedure to simulate the effect of sampling the analog signal
we already saw in the first lab:
xa(t) = 3sin(πt) + 2sin(5πt)
45
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 47/114
This signal contains two frequency components at f 1 = 1/2 and f 2 = 2.5 Hz. We explore the
effect of sampling and aliasing by sampling xa(t) with three different sampling frequencies:
f s1 = 10f max = 25, f s2 = 2.5f max = 6.25, f s3 = 2. The first two sampling frequencies
meet the sampling theorem requirement. On the other hand, the third sampling frequency
is less than twice the maximum frequency and therefore we should expect to see aliasing.
Figure 5.1 shows the results of the MATLAB simulation in the time domain. Figure 5.2 shows
the frequency domain representation of the signals. We can see how in the first two cases,
when the sampling theorem requirements were met, the spectrum of the sampled signal that
lies within the Nyquist interval represents the original frequency content. On the other hand,we see that when we sampled the signal with a rate less than twice the maximum frequency,
the spectrum is different.
46
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 48/114
0 1 2 3 4 5 6 7 8 9 10−5
0
5
x ( t )
0 1 2 3 4 5 6 7 8 9 10−5
0
5
x ( n T )
0 1 2 3 4 5 6 7 8 9 10−5
0
5
x ( n T )
0 1 2 3 4 5 6 7 8 9 10−5
0
5
Time, s
x ( n T )
Figure 5.1: The first plot shows xa(t) and the next three plots show the effect of sampling atf s1 = 10f max = 25, f s2 = 2.5f max = 6.25, f s3 = 2. The first two sampling frequencies meetthe sampling theorem requirement. On the other hand, the third sampling frequency is lessthan twice the maximum frequency. We can see how in this case the signal reconstructed isan aliased version of the original at a lower frequency.
47
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 49/114
0 2 4 6 8 10 12 140
100
200
300
0 0.5 1 1.5 2 2.5 3 3.50
20
40
60
80
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.90
10
20
30
40
Figure 5.2: The three plots show the effect of sampling at f s1 = 10f max = 25, f s2 = 2.5f max =6.25, f s3 = 2 in the frequency domain. The first two sampling frequencies meet the samplingtheorem requirement. On the other hand, the third sampling frequency is less than twice themaximum frequency. The aliasing effect is evident in the third plot.
48
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 50/114
5.4 Example MATLAB code
Below we show the MATLAB code used to generate this example:
%==================================================
% Simulated Analog Signal: f1 = 1/2 Hz, f2 = 2.5 Hz
%==================================================
f1 = 1/2; % f1 = 1/2 Hz
f2 = 2.5; % f2 = 2.5 Hz
T = 1/ 10 00 ; N = 10 00 ; n = 0: 10 *N ; t = n* T; x =
3*sin(2*pi*f1.*t) + 2*sin(2*pi*f2.*t);
figure(1); subplot(4,1,1);
h = plot(t,x); ylabel(’x(t)’); box off;
%==================================================
% Sampling at fs = 10*fmax = 10*f2
%==================================================
fs = 10*f2; % Sampling Frequency
T = 1/fs; % Sampling Period
n = 0:10*fs; % Plot 10 seconds
k = n*T; % Time Index
xs = 3*sin(2*pi*f1.*k) + 2*sin(2*pi*f2.*k);
figure(1); subplot(4,1,2);
h = plot(t,x,’:’,k,xs, ’r.’);
set(h, ’Markersize’,15); ylabel(’x(nT)’);
figure(2); subplot(3,1,1);
X = abs(fft(xs)); % FFT Magnitude
f = (1:length(X))*fs/length(X);% Frequency axis
stem(f(1:end/2),X(1:length(X)/2)); box off; axis tight;
%==================================================
% Sampling at fs = 2.5*fmax = 2.5*f2
%==================================================
fs = 2.5*f2; % Sampling Frequency
T = 1/fs; % Sampling Period
n = 0:10*fs; % Plot 10 seconds
k = n*T; % Time Index
xs = 3*sin(2*pi*f1.*k) + 2*sin(2*pi*f2.*k);
figure(1);
subplot(4,1,3);
h = plot(t,x,’:’,k,xs, ’r.’)
set(h, ’Markersize’,15); ylabel(’x(nT)’);
figure(2); subplot(3,1,2);
X = abs(fft(xs)); % FFT Magnitude
f = (1:length(X))*fs/length(X);% Frequency axis
stem(f(1:end/2),X(1:length(X)/2)); box off; axis tight;
%==================================================
49
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 51/114
% Sampling at fs = 1 (fs < fmax = f2)
%==================================================
f1 = 1/2; % f1 = 1/2 Hz
f2 = 2.5; % f2 = 2.5 Hz
fs = 2; % Sampling Frequency
T = 1/fs; % Sampling Period
n = 0:10*fs; % Plot 10 seconds
k = n*T; % Time Index
xs = 3*sin(2*pi*f1.*k) + 2*sin(2*pi*f2.*k);
xa = 3*sin(2*pi*f1.*t)+2*sin(2*pi*0.5*t);
figure(1); subplot(4,1,4);
h = plot(t,x,’:’,t,xa, k,xs, ’r.’);
set(h, ’Markersize’, 15);
xlabel(’Time, s’); ylabel(’x(nT)’);
figure(2); subplot(3,1,3);
X = abs(fft(xs)); % FFT Magnitude
f = (1:length(X))*fs/length(X);% Frequency axis
stem(f(0:end/2),X(1:length(X)/2)); box off; axis tight;
50
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 52/114
5.5 Analysis
Use MATLAB to perform the following computer exploration:
1. Sample xa(t) = sin(10000πt) + sin(30000πt) + sin(50000πt) + sin(70000πt) at a rate of
40 KHz.
2. Plot, observe, and describe the effect of sampling xa(t) without the use of any prefilter
in the frequency domain.
3. Filter the signal xa(t) with an ideal lowpass filter with cutoff frecuency at 30 KHz.
Plot, observe, and describe the effect of sampling after using this filter in the frequency
domain.
4. Filter the signal with an ideal lowpass filter with f c = 20 KHz (half the sampling
frequency). Plot, observe, and describe the effect of sampling after using this filter in
the frequency domain.
5. Filter the signal with a practical filter with a flat response up to 20 KHz, and with an
attenuation of 40 dB/octabe beyond 20 KHz. Plot, observe, and describe the effect of
sampling after using this filter in the frequency domain.
6. Compare the results obtained with the ideal and the practical filter.
51
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 53/114
CHAPTER 6
The Z-Transform
52
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 54/114
6.1 Objective
In this laboratory we will introduce the Z-transform. This transform is a tool for the analysis,
design, and implementation of digital filters. We will also introduce the concept of system
transfer function, which is defined in terms of the z-transform of the impulse response.
6.2 Theoretical Introduction
Transform techniques such as the DTFT or Z-transforms are important tools in the analysis
and design of linear-time invariant (LTI) systems. The DTFT allows us to represent a discrete-
time signal in terms of complex exponentials. We also saw that this transform enabled us to
study LTI systems in the frequency domain by taking the DTFT of the system’s impulse
response sequence, h(n), obtaining the frequency response function , H (e jw ). The frequency
response function enabled us to study the sinusoidal steady-state response, and the response
to any arbitrary signal, x(n), for which the DTFT was defined by evaluating the inverse DTFT
of X (e jw )H (e jw ).
In this chapter we introduce a new transform, the Z-transform . The Z-transform can be
considered an extension of the DTFT for two reasons: 1) it provides another domain in which
a larger class of sequences and systems can be analyzed, and 2) it can be used to analyze
transient system responses (not only steady-state) and systems with initial conditions.
6.2.1 Definition
The Z-transform of a discrete-time signal x(n) is defined as the power series
X (z) ≡∞
n=−∞
x(n)z−n
53
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 55/114
where z is a complex variable, z = α + jβ = re jθ . Since the Z-transform is an infinite power
series, it only exists for those values of z for which this series converges. The problem of finding
the region of convergence (ROC) for X (z) is equivalent to determining the range of values of
r for which the sequence x(n)r−n is absolutely summable. Using the fact that z = re− jθ , we
can express the Z-transform as
X (z)|z=rejθ =∞
n=−∞
x(n)r−ne− jθn
We can easily see that the Z-transform reduces to the DTFT for r = 1, that is, the evaluation of
the Z-transform on the unit circle z = e jω provides information about the frequency spectrum.
X (z)|z=ejω =
∞n=−∞
x(n)e− jω
6.2.2 Causality and Stability
The concepts of causality and stability can be redefined in terms of the Z-transform.
Causal signals (right-sided) are characterized by ROCs that are outside the maximum pole
circle. Anticausal signals have ROCs that are inside the minimum pole circle. Mixed signals
have ROCs that are an annular region between two circles, with the poles that lie inside the
inner circle contributing causally and the poles that lie outside the outer circle contributing
anticausally.
Stability can be also characterized in the z -domain in terms of the ROC. A necessary and
sufficient condition for the stability of a signal x(n) is that the ROC of the corresponding
Z-transform contains the unit circle .
For a system to be simultaneously stable and causal , it is necessary that all its poles lie
54
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 56/114
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 57/114
which converges for |x| ≤ 1 and diverges otherwise; and
∞n=1
xn = x + x2 + x3 + . . . = x
1 − x
Examples
As an example of how to used the previous equations, let’s find the Z-transform of
x(n) = (0.5)nu(n) = {1, 0.5, 0.52, 0.53, . . . }
Its Z-transform is:
X (z) =∞
n=−∞
(0.5)nu(n)z−n =∞
n=0
(0.5)nz−n =∞
n=0
(0.5z−1)n = 1
1 − 0.5z−1
|0.5z−1| ≤ 1 ⇒ |z| ≥ 0.5
Notice that the Z-transform of x(n) = (0.5)nu(−n − 1) is
X (z) = 1
1 − 0.5z−1, |z| ≤ 0.5
A Z-transform and its ROC are uniquely determined by the time signal x(n).
6.2.4 Inverse Z-transform
The definition of the inverse Z-transform requires an evaluation of the complex contour
integral. In general, we do not use the definition to find the inverse Z-transform. Instead, we
use partial fraction expansions. The central idea is that when X (z) is a rational function of
z−1, we can express it as a sum of simple first-order factors using the partial fraction expansion
that can be inverted by inspection.
56
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 58/114
6.3 Computer Exploration
MATLAB provides several functions very useful to work in the z-domain. In this laboratory
we will focus in the functions zplane , residuez , and freqz .
6.3.1 Procedure
1. Given a Z-transform, plot the poles and the zeros in the z-plane.
2. Given a transfer function for a system, plot the magnitude and phase responses.
3. Given a transfer function, perform a partial fraction expansion.
6.3.2 Example
Given a transfer function such as
H (z) = 0.006143
1 − 1.87834z−10.975156z−2
let’s plot the poles and zeros in the z-plane. Plot the magnitude and phase response and
perform a partial fraction expansion.
Figures 6.1 and 6.2 show the z-plane and frequency response of H (z). From the frequency
response we can see that the system is a digital resonator filter which has a peak at ω = 0.1π.
From the z-plane we can see that the system has complex poles close to the unit circle. Using
the residuez function we can find the partial fraction expansion and the exact location of the
zeros and poles.
57
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 59/114
−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
2
Real Part
I m a g i n a r y P a r t
Figure 6.1: z-plane of H (z) = 0.0061431−1.87834z−10.975156z−2 .
58
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 60/114
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1−150
−100
−50
0
50
Normalized Frequency (×π rad/sample)
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
−50
−40
−30
−20
−10
0
Normalized Frequency (×π rad/sample)
M a g
n i t u d e ( d B )
Figure 6.2: Magnitude and phase response of H (z) = 0.0061431−1.87834z−10.975156z−2 . We can see that
the system is a digital resonator filter which has a peak at ω = 0.1π
59
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 61/114
6.4 Example MATLAB code
Below we show the MATLAB code used to generate this example:
%===================================================
% Plot the Poles and Zeros in the Z-Plane
%===================================================
num = [0.006143]; den = [1 -1.87834 0.975156]; figure;
zplane(num,den); box off;
%===================================================
% Plot the Magnitude
%===================================================
figure; freqz(num,den); box off;
%===================================================
% Partial Fraction Expansion
%===================================================
num = [0.006143]; den = [1 -1.87834 0.975156];
[r,p,k]=residuez(num,den)
60
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 62/114
6.5 Analysis
Use MATLAB to perform the following computer exploration:
1. Plot the poles and zeros in the z -plane of the filter H (z) = 11−0.9z−1 , |z| ≥ 0.9. Plot the
frequency response. What type of filter is this: lowpass, highpass, or bandpass?
2. An FIR filter is described by the I/O equation y(n) = x(n) − x(n − 4). Find the poles
and zeros, plot them in the z-plane, and plot the frequency response. What type of filter
is this: lowpass, highpass, or bandpass?
3. Given H (z) = 6+z−1
1−0.25z−2 . Find the poles and zeros, plot them in the z-plane, and plot
the frequency response. What type of filter is this: lowpass, highpass, or bandpass?
4. Given a moving average filter with impulse response h(n) = u(n) − u(n − β ). Find the
poles and zeros, plot them in the z-plane, and plot the frequency response for 3 different
values of β . What type of filter is this: lowpass, highpass, or bandpass? What is the
cut-off frequency in each case? What is the effect of increasing β ?
5. Given H (z) = 1−1.25z−1
(1+4z−2)(1−0.81z−2) , find the poles and zeros, plot them in the z-plane,
and plot the frequency response. Notice that H (z) has poles and zeros outside the unit
circle, find another system G(z) such that |G(z)| = |H (z)| by reflecting all the poles
and zeros inside the unit circle. Plot the poles and zeros of the new system G(z) in
the z-plane and verify that both systems have the same magnitude response. A system
with all its poles and zeros inside the unit circle is said to be a minimal-phase system .
Given any system H (z) we can find a minimal phase system with the same magnitude
response, why is this important?
61
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 63/114
CHAPTER 7
Digital Filtering
62
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 64/114
7.1 Objective
In this laboratory we will investigate the concept of digital filtering. Emphasis will be placed
in the specification of these filters and in computer-aided (CAD) design. Specifically, we will
learn how to correctly specify the desired filter characteristics, and how to use MATLAB to
obtain the filter coefficients.
7.2 Theoretical Introduction
Filters are frequency selective systems, that is, the magnitude and phase response of these
systems id a function of the input frequency. However, in the area of DSP we often use the
terms of filter and system interchangeably.
In previous labs we introduced the concept of a moving average filter in the time domain.
Specifically, we saw that a system with an impulse response of the form h(n) = 1β (u(n) −
u(n−β )), could be used to remove high frequency components (smooth), and that β controls
how much smoothing is done. We also saw that the output of any system is given by the
convolution of the input with the impulse response. In this particular case, the output of the
system, that is, the result of the filtering operation, is given by
y(n) = 1
β x(n) +
1
β x(n − 1) +
1
β x(n − 2) + . . . +
1
β x(n − β )
y(n) =
k=β k=0
1
β x(n − k)
The impulse response of the filter doesn’t have to be a constant, that is, a more general
63
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 65/114
expression would be
y(n) = b0x(n) + b1x(n − 1) + . . . + bM −1x(n − M + 1) =M −1k=0
bkx(n − k)
where b0, b1, . . . , bM −1 is the set of filter coefficients coefficients. Notice that bk = h(k), that is
M −1k=0
bkx(n − k) =
M −1k=0
h(k)x(n − k)
We see that in this case the filter coefficients are equal to the filter’s impulse response. We
can also recognize the output as being the convolution of the input with the impulse response.
7.2.1 Design Objective
When designing digital filters, the objective is how to choose the filter coefficients bk so that the
system removes the undesired frequencies while keeping the desired frequencies. This problem
is very difficult to solve in the time domain. In the design of frequency–selective filters, the
desired filter characteristics are specified in the frequency domain in terms of the desired
magnitude and phase response of the filter. Once the filter is fully specified, the objective is
to determine the coefficients that provide the desired frequency response specification.
7.2.2 FIR and IIR Filters
Filters can be classified into finite–impulse response (FIR) or infinite–impulse response (IIR)
filters .
64
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 66/114
FIR Filters
An FIR filter has an impulse response h(n) that extends only over a finite time interval and
it is zero beyond that interval, that is
h(n) = [h0, h1, . . . , hM , 0, 0, 0, . . .]
where M is referred as the filter order . The impulse response coefficients h0, h1, . . . , hM , 0, 0, 0, . . .
are referred by various names, such as filter coefficients, filter weights, filter taps, etc . As we
already saw before, the output of an FIR filter can be written as
y(n) = h0x(n) + h1x(n − 1) + h2x(n − 2) + . . . + hM x(n − M ) =M
k=0
h(k)x(n − k)
We can see that the output of an FIR filter is a weighted average of the present input sample
x(n) and the past M samples x(n − 1), x(n − 2), . . . , x(n − M ). FIR filters are referred as
non-recursive filters because the output only depends on the inputs and not on the previous
outputs.
IIR Filters
An IIR filter has an impulse response h(n) of infinite duration. The expression for the output
of a causal IIR filter is
y(n) =
∞k=0
h(k)x(n − k)
In general, IIR filters are recursive , that is, the output of the system depends not only on the
inputs but also on the previous outputs, for example
y(n) = y(n − 1) + x(n)
65
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 67/114
FIR vs. IIR Filters
FIR filters are used in filtering problems where there is a requirement for a linear-phase
characteristic within the passband of the filter. If there is no requirement for a linear-phase
characteristic, either an IIR or an FIR filter may be used. In general, IIR filters require fewer
filter coefficients to meet a specific magnitude response requirement.
7.3 Computer Exploration
MATLAB provides several functions very useful to design and simulate digital filters. In thislaboratory we will focus on the functions filter , filtfilt , ellipord , ellip, cheby1, cheby2 , butter ,
etc .
7.3.1 Example
Let’s write two MATLAB functions to implement a lowpass and a highpass filter that allow us
to choose the cutoff frequency and types of filter we want to implement. The inputs to these
functions are the samples of the signal, the sampling frequency, and the desired type of filter
(causal, noncausal, elliptic, etc). The outputs are the filtered signal and the filter coefficients.
The following figure shows an example of using the lowpass filter to filter out the high–
frequencies of a biomedical signal corrupted by quantization noise. The sampling frequency
of the input signal is 125 Hz and we would like to filter out frequencies beyond 15 Hz. The
next example shows the effect of filtering the same signal with a highpass filter to remove the
low–frequency components and eliminate the signal trend (remove frequencies below 0.1 Hz).
66
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 68/114
0 10 20 30 40 50 60−400
−300
−200
−100
0
Frequency (Hz)
P h a s e ( d e g r e e s )
0 10 20 30 40 50 60−100
−50
0
50
Frequency (Hz)
M a g n i t u d e ( d B )
Figure 7.1: Frequency response of the lowpass filter.
67
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 69/114
422 422.2 422.4 422.6 422.8 423 423.2
12.5
13
13.5
14
14.5
15
15.5
Raw Signal and Lowpass Filtered Signal
Time,s
A m p l i t u d e
Raw SignalLowpass Filtered
Figure 7.2: Result of the lowpass filtering operation. Notice that the lowpass filter smoothsthe effects of quantization noise. Notice also that this filter was implemented with filtfilt (nodelay of the output with respect to the input) and therefore it is a noncausal filter.
68
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 70/114
0 200 400 600 800 1000 1200−10
−5
0
5
10
15
20
25Raw Signal and Highpass Filtered Signal
Time,s
A m p l i t u d e
Raw SignalHighpass Filtered
Figure 7.3: Result of the highpass filtering operation. Notice that the highpass filter eliminatedthe signal trend.
69
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 71/114
7.4 Example MATLAB code
Below we show the MATLAB code used to implement the lowpass and highpass funtions:
function [y,n] = LowPass(x,fsa,fca,fta,cfa,pfa);
%LowPass: Lowpass filter
%
% [y,n] = LowPass(x,fs,fc,ft,cf,pf)
%
% x Input signal
% fs Signal sample rate (Hz). Default=125 Hz
% fc Cutoff frequency (Hz). Default=fs/4 Hz
% ft Type: 1=Elliptic (default), 2=Butterworth,
% 3=FIR based on Blackman Window, 4=Minimun Ringing
% cf Causality flag: 1 = causal, 2 = noncausal (default) for tp=1,2
% pf Plot flag: 0=none (default), 1=screen
%
% y F il ter ed Si gn al
% n O rd er of th e fil te r
%
% Filters the input signal x with a cutoff frequency fc using an
% elliptical butterworth filter. The lowpass filter can be causal
% or noncausal. The causal implementation uses only the present and
% previous values to determine the filter’s output y, and therefore
% it is physically realizable for realtime processing. The noncausal
% implementation filters the data in the forward direction, and the
% filtered sequence is then reversed and run back through the filter.
% The result has precisely zero phase distortion and magnitude
% modifiedby the square of the filter’s magnitude response.
%
% Example: Filter the raw intracranial pressure signal using an
% elliptic lowpass filter with zero phase (noncausal) and with
% cutoff frequency fs/4 Hz.This will filter out the high frequency
% components (frequencies above fs/4 Hz) and smooth the data.
%
% load ICP;
% [y,n] = LowPass(icp,fs,fs/4,1,2,1);
%
% Version 1.00 MA
%
% See also HighPass, filter, filtfilt, ellip, and butter.
%=====================================================================
% Process function arguments
%=====================================================================
if nargin<1 | nargin>6,
help LowPass;
return;
end;
70
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 72/114
fs = 125; % Default sampling rate, Hz
if exist(’fsa’) & ~isempty(fsa),
fs = fsa;
end;
fc = fs/4; % Default cutoff frequency, Hz
if exist(’fca’) & ~isempty(fca),
fc = fca;
end;
ft = 1; % Default filter type
if exist(’fta’) & ~isempty(fta),
ft = fta;
end;
cf = 2; % Default causality flag
if exist(’cfa’) & ~isempty(cfa),
cf = cfa;
end;
pf = 0; % Default - no plotting
if nargout==0, % Plot if no output arguments
pf = 1;
end;
if exist(’pfa’) & ~isempty(pfa),
pf = pfa;
end;
%=========================================================================
% Process Inputs
%=========================================================================
x = x(:); LD = length(x); k = 1:LD;
%=========================================================================
% LowPass Filtering
%=========================================================================
nf = fs/2; wlp = fc/nf; Ws = wlp*1.2; Wp = wlp*0.8; Rp = 0.5;
Rs = 40 ;
%-----------------------------------------------------------------------
% Elliptic Filter (tp==1)
%-----------------------------------------------------------------------
if ft==1,
if cf==1, % causal
[N,Wn] = ellipord(Wp, Ws, Rp, Rs);
[B,A ] = ellip(N, Rp, Rs, Wn);y = f il te r( B, A, x) ;
else % non-causal
[N,Wn] = ellipord(Wp, Ws, Rp, Rs);
[B,A ] = ellip(N, Rp, Rs, Wn);
y = f il tf il t( B, A, x) ;
71
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 73/114
end;
%-----------------------------------------------------------------------
% Butterworth Filter (tp==2)
%-----------------------------------------------------------------------
elseif ft == 2,
if cf==1, % causal
[N, Wn] = buttord(Wp,Ws,Rp,Rs);
[B,A] = butter(N,Wn);
y = fi lt er( B, A,x );
else % non-causal
[N, Wn] = buttord(Wp,Ws,Rp,Rs);
[B,A] = butter(N,Wn);
y = f il tf il t( B, A, x) ;
end;
%-----------------------------------------------------------------------
% Eliminate start-up transients (tp==3)
%-----------------------------------------------------------------------
elseif ft==3,
NX = length(x);
N = min([500 floor(NX/4)]);
if rem(N,2), % Make N even
N = N + 1 ;
end;
B = fir1(N,wlp,Blackman(N+1),’noscale’); % B should be odd
B = B/sum(B);
A = 0 ;
y = conv(B,x);
y = y(N/2 + (1:NX));
ci = [1:(N/2) (NX+1-N/2):NX];
for c1 = 1:length(ci),
in = c i(c 1) ;
xi = max( 1,in-N/2):min(NX,in+N/2);
bi = (N/2+1) + (max(1-in,-N/2):min(NX-in,N/2));
y(in) = sum(x(xi)’.*B(bi))/sum(B(bi));
end;
%=========================================================================
% Plotting
%=========================================================================
if pf==1
close all
figureset(1)
h = plot(k./fs, x, ’b’, k./fs, y, ’r’);
title(’Raw Signal and Lowpass Filtered Signal’);xlabel(’Time,s’);
ylabel(’Amplitude’);
legend(’Raw Signal’, ’Lowpass Filtered’);
box off; axisset;
72
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 74/114
if (ft ~= 3 & ft ~=4),
figure(2)
figureset(2)
freqz(B,A, 512, fs)
set(h, ’Linewidth’, 1.5);
box off; axisset
end;
end;
%=========================================================================
% Take care of outputs
%=========================================================================
if nargout==0,
clear(’y’,’n’);
end;
function [y,n] = HighPass(x,fsa,fca,cfa,pfa)
%HighPass: Highpass filter
%
% [y,n] = HighPass(x,fs,fc,cf,pf)
%
% x Input signal
% fs Signal sample rate (Hz). Default=125 Hz
% fc Cutoff frequency (Hz). Default=fs/4 Hz
% cf Causality flag: 1 = causal, 2 = noncausal (default) for tp=1
% pf Plot flag:hig 0=none (default), 1=screen
%
% y F il ter ed Si gn al
% n O rd er of th e fil te r
%
% Filters the input signal x with a cutoff frequency fc using an
% elliptical filter. The highpass filter can be causal or noncausal.
% The causal implementation uses only the present and previous values
% to determine the filter’s output y, and therefore it is physically
% realizable for realtime processing. The noncausal implementation
% filters the data in the forward direction, and the filtered sequence
% is then reversed and run back through the filter; Y is the time
% reverse of the output of the second filtering operation. The result
% has precisely zero phase distortion and magnitude modified by the
% square of the filter’s magnitude response.
%
% Example: Filter the raw intracranial pressure signal using a
% highpass filter with zero phase (noncausal) and with cutoff
% frequency 0.5 Hz. This will filter out the low frequency
% components (frequencies below 0.5 Hz) and detrend the data:
%% load ICP;
% [y,n] = Highpass(icp,fs,0.5,2,1);
%
% Version 1.00 MA
%
73
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 75/114
% See also HighPass, Lowpass, filter, filtfilt, ellip, and butter.
%=======================================================================
% Process function arguments
%=======================================================================
if nargin<1 | nargin>6,
help Highpass;
return;
end;
fs = 125; % Default sampling rate, Hz
if exist(’fsa’) & ~isempty(fsa),
fs = fsa;
end;
fc = fs/4; % Default cutoff frequency, Hz
if exist(’fca’) & ~isempty(fca),
fc = fca;
end;
cf = 2; % Default flag
if exist(’cfa’) & ~isempty(cfa),
cf = cfa;
end;
pf = 0; % Default - no plotting
if nargout==0, % Plot if no output arguments
pf = 1;
end;
if exist(’pfa’) & ~isempty(pfa),
pf = pfa;
end;
%=======================================================================
% Process Inputs
%=======================================================================
x = x(:); LD = length(x); k = 1:LD;
%=======================================================================
% LowPass Filtering
%=======================================================================
nf = fs/2; whp = fc/nf; Wp = whp*1.2; Ws = whp*0.8; Rp = 0.5;
Rs = 40 ;
if cf==1, % causal[n,Wn] = ellipord(Wp, Ws, Rp, Rs);
[B,A ] = ellip(n, Rp, Rs, Wn, ’high’);
y = f il te r( B, A, x) ;
else % non-causal
[n,Wn] = ellipord(Wp, Ws, Rp, Rs);
74
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 76/114
[B,A ] = ellip(n, Rp, Rs, Wn, ’high’);
y = f il tf il t( B, A, x) ;
end;
%=======================================================================
% Plotting
%=======================================================================
if pf == 1
figure(1)
figureset(1)
h = plot(k./fs, x, ’b’, k./fs, y, ’r’);
title(’Raw Signal and Highpass Filtered Signal’);
xlabel(’Time,s’);
ylabel(’Amplitude’);
legend(’Raw Signal’, ’Highpass Filtered’);
box off; axisset
figure(2)
figureset(2)
freqz(B,A, 512, fs)
end;
%=======================================================================
% Take care of outputs
%=======================================================================
if nargout==0, clear(’y’,’n’); end;
75
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 77/114
7.5 Analysis
Download the signals ECGNoisy60Hz, ECGQuantization, ECGBaselineDrift, and ECG-
NoiseCombined from the class website. Use MATLAB to perform the following computer
exploration.
1. Load and plot the signal ECGNoisy60Hz in MATLAB. Use the FFT to evaluate the
frequency spectrum. Notice the noise present at 60 Hz. Use MATLAB to design a filter
to eliminate this problem. Plot and compare the initial signal and the filtered signal.
2. Repeat the procedure with ECGQuantization. In this case the signal is severely affected
by quantization noise. Use MATLAB to design a filter to eliminate this noise and show
the results.
3. Repeat the procedure with ECGBaselineDrift. In this case the signal is severely affected
by baseline drift due to patient movement. Use MATLAB to design a filter to eliminate
this noise and show the results.
4. Repeat the procedure with ECGBaselinedCombined. The signal contains all the above
types of noise combined. Use MATLAB to design a system to eliminate this noise and
show the results.
76
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 78/114
CHAPTER 8
Digital Filtering
77
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 79/114
8.1 Objective
In this laboratory we will investigate the concept of digital filtering. Emphasis will be placed
in the specification of these filters and in computer-aided (CAD) design. Specifically, we will
learn how to correctly specify the desired filter characteristics, and how to use MATLAB to
obtain the filter coefficients.
8.2 Theoretical Introduction
Filters are frequency selective systems, that is, the magnitude and phase response of these
systems id a function of the input frequency. However, in the area of DSP we often use the
terms of filter and system interchangeably.
In previous labs we introduced the concept of a moving average filter in the time domain.
Specifically, we saw that a system with an impulse response of the form h(n) = 1β (u(n) −
u(n−β )), could be used to remove high frequency components (smooth), and that β controls
how much smoothing is done. We also saw that the output of any system is given by the
convolution of the input with the impulse response. In this particular case, the output of the
system, that is, the result of the filtering operation, is given by
y(n) = 1
β x(n) +
1
β x(n − 1) +
1
β x(n − 2) + . . . +
1
β x(n − β )
y(n) =
k=β k=0
1
β x(n − k)
The impulse response of the filter doesn’t have to be a constant, that is, a more general
78
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 80/114
expression would be
y(n) = b0x(n) + b1x(n − 1) + . . . + bM −1x(n − M + 1) =M −1k=0
bkx(n − k)
where b0, b1, . . . , bM −1 is the set of filter coefficients coefficients. Notice that bk = h(k), that is
M −1k=0
bkx(n − k) =
M −1k=0
h(k)x(n − k)
We see that in this case the filter coefficients are equal to the filter’s impulse response. We
can also recognize the output as being the convolution of the input with the impulse response.
8.2.1 Design Objective
When designing digital filters, the objective is how to choose the filter coefficients bk so that the
system removes the undesired frequencies while keeping the desired frequencies. This problem
is very difficult to solve in the time domain. In the design of frequency–selective filters, the
desired filter characteristics are specified in the frequency domain in terms of the desired
magnitude and phase response of the filter. Once the filter is fully specified, the objective is
to determine the coefficients that provide the desired frequency response specification.
8.2.2 FIR and IIR Filters
Filters can be classified into finite–impulse response (FIR) or infinite–impulse response (IIR)
filters .
79
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 81/114
FIR Filters
An FIR filter has an impulse response h(n) that extends only over a finite time interval and
it is zero beyond that interval, that is
h(n) = [h0, h1, . . . , hM , 0, 0, 0, . . .]
where M is referred as the filter order . The impulse response coefficients h0, h1, . . . , hM , 0, 0, 0, . . .
are referred by various names, such as filter coefficients, filter weights, filter taps, etc . As we
already saw before, the output of an FIR filter can be written as
y(n) = h0x(n) + h1x(n − 1) + h2x(n − 2) + . . . + hM x(n − M ) =M
k=0
h(k)x(n − k)
We can see that the output of an FIR filter is a weighted average of the present input sample
x(n) and the past M samples x(n − 1), x(n − 2), . . . , x(n − M ). FIR filters are referred as
non-recursive filters because the output only depends on the inputs and not on the previous
outputs.
IIR Filters
An IIR filter has an impulse response h(n) of infinite duration. The expression for the output
of a causal IIR filter is
y(n) =
∞k=0
h(k)x(n − k)
In general, IIR filters are recursive , that is, the output of the system depends not only on the
inputs but also on the previous outputs, for example
y(n) = y(n − 1) + x(n)
80
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 82/114
FIR vs. IIR Filters
FIR filters are used in filtering problems where there is a requirement for a linear-phase
characteristic within the passband of the filter. If there is no requirement for a linear-phase
characteristic, either an IIR or an FIR filter may be used. In general, IIR filters require fewer
filter coefficients to meet a specific magnitude response requirement.
8.3 Computer Exploration
MATLAB provides several functions very useful to design and simulate digital filters. In thislaboratory we will focus on the functions filter , filtfilt , ellipord , ellip, cheby1, cheby2 , butter ,
etc .
8.3.1 Example
Let’s write two MATLAB functions to implement a lowpass and a highpass filter that allow us
to choose the cutoff frequency and types of filter we want to implement. The inputs to these
functions are the samples of the signal, the sampling frequency, and the desired type of filter
(causal, noncausal, elliptic, etc). The outputs are the filtered signal and the filter coefficients.
The following figure shows an example of using the lowpass filter to filter out the high–
frequencies of a biomedical signal corrupted by quantization noise. The sampling frequency
of the input signal is 125 Hz and we would like to filter out frequencies beyond 15 Hz. The
next example shows the effect of filtering the same signal with a highpass filter to remove the
low–frequency components and eliminate the signal trend (remove frequencies below 0.1 Hz).
81
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 83/114
0 10 20 30 40 50 60−400
−300
−200
−100
0
Frequency (Hz)
P h a s e ( d e g r e e s )
0 10 20 30 40 50 60−100
−50
0
50
Frequency (Hz)
M a g n i t u d e ( d B )
Figure 8.1: Frequency response of the lowpass filter.
82
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 84/114
422 422.2 422.4 422.6 422.8 423 423.2
12.5
13
13.5
14
14.5
15
15.5
Raw Signal and Lowpass Filtered Signal
Time,s
A m p l i t u d e
Raw SignalLowpass Filtered
Figure 8.2: Result of the lowpass filtering operation. Notice that the lowpass filter smoothsthe effects of quantization noise. Notice also that this filter was implemented with filtfilt (nodelay of the output with respect to the input) and therefore it is a noncausal filter.
83
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 85/114
0 200 400 600 800 1000 1200−10
−5
0
5
10
15
20
25Raw Signal and Highpass Filtered Signal
Time,s
A m p l i t u d e
Raw SignalHighpass Filtered
Figure 8.3: Result of the highpass filtering operation. Notice that the highpass filter eliminatedthe signal trend.
84
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 86/114
8.4 Example MATLAB code
Below we show the MATLAB code used to implement the lowpass and highpass funtions:
function [y,n] = LowPass(x,fsa,fca,fta,cfa,pfa);
%LowPass: Lowpass filter
%
% [y,n] = LowPass(x,fs,fc,ft,cf,pf)
%
% x Input signal
% fs Signal sample rate (Hz). Default=125 Hz
% fc Cutoff frequency (Hz). Default=fs/4 Hz
% ft Type: 1=Elliptic (default), 2=Butterworth,
% 3=FIR based on Blackman Window, 4=Minimun Ringing
% cf Causality flag: 1 = causal, 2 = noncausal (default) for tp=1,2
% pf Plot flag: 0=none (default), 1=screen
%
% y F il ter ed Si gn al
% n O rd er of th e fil te r
%
% Filters the input signal x with a cutoff frequency fc using an
% elliptical butterworth filter. The lowpass filter can be causal
% or noncausal. The causal implementation uses only the present and
% previous values to determine the filter’s output y, and therefore
% it is physically realizable for realtime processing. The noncausal
% implementation filters the data in the forward direction, and the
% filtered sequence is then reversed and run back through the filter.
% The result has precisely zero phase distortion and magnitude
% modifiedby the square of the filter’s magnitude response.
%
% Example: Filter the raw intracranial pressure signal using an
% elliptic lowpass filter with zero phase (noncausal) and with
% cutoff frequency fs/4 Hz.This will filter out the high frequency
% components (frequencies above fs/4 Hz) and smooth the data.
%
% load ICP;
% [y,n] = LowPass(icp,fs,fs/4,1,2,1);
%
% Version 1.00 MA
%
% See also HighPass, filter, filtfilt, ellip, and butter.
%=====================================================================
% Process function arguments
%=====================================================================
if nargin<1 | nargin>6,
help LowPass;
return;
end;
85
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 87/114
fs = 125; % Default sampling rate, Hz
if exist(’fsa’) & ~isempty(fsa),
fs = fsa;
end;
fc = fs/4; % Default cutoff frequency, Hz
if exist(’fca’) & ~isempty(fca),
fc = fca;
end;
ft = 1; % Default filter type
if exist(’fta’) & ~isempty(fta),
ft = fta;
end;
cf = 2; % Default causality flag
if exist(’cfa’) & ~isempty(cfa),
cf = cfa;
end;
pf = 0; % Default - no plotting
if nargout==0, % Plot if no output arguments
pf = 1;
end;
if exist(’pfa’) & ~isempty(pfa),
pf = pfa;
end;
%=========================================================================
% Process Inputs
%=========================================================================
x = x(:); LD = length(x); k = 1:LD;
%=========================================================================
% LowPass Filtering
%=========================================================================
nf = fs/2; wlp = fc/nf; Ws = wlp*1.2; Wp = wlp*0.8; Rp = 0.5;
Rs = 40 ;
%-----------------------------------------------------------------------
% Elliptic Filter (tp==1)
%-----------------------------------------------------------------------
if ft==1,
if cf==1, % causal
[N,Wn] = ellipord(Wp, Ws, Rp, Rs);
[B,A ] = ellip(N, Rp, Rs, Wn);y = f il te r( B, A, x) ;
else % non-causal
[N,Wn] = ellipord(Wp, Ws, Rp, Rs);
[B,A ] = ellip(N, Rp, Rs, Wn);
y = f il tf il t( B, A, x) ;
86
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 88/114
end;
%-----------------------------------------------------------------------
% Butterworth Filter (tp==2)
%-----------------------------------------------------------------------
elseif ft == 2,
if cf==1, % causal
[N, Wn] = buttord(Wp,Ws,Rp,Rs);
[B,A] = butter(N,Wn);
y = fi lt er( B, A,x );
else % non-causal
[N, Wn] = buttord(Wp,Ws,Rp,Rs);
[B,A] = butter(N,Wn);
y = f il tf il t( B, A, x) ;
end;
%-----------------------------------------------------------------------
% Eliminate start-up transients (tp==3)
%-----------------------------------------------------------------------
elseif ft==3,
NX = length(x);
N = min([500 floor(NX/4)]);
if rem(N,2), % Make N even
N = N + 1 ;
end;
B = fir1(N,wlp,Blackman(N+1),’noscale’); % B should be odd
B = B/sum(B);
A = 0 ;
y = conv(B,x);
y = y(N/2 + (1:NX));
ci = [1:(N/2) (NX+1-N/2):NX];
for c1 = 1:length(ci),
in = c i(c 1) ;
xi = max( 1,in-N/2):min(NX,in+N/2);
bi = (N/2+1) + (max(1-in,-N/2):min(NX-in,N/2));
y(in) = sum(x(xi)’.*B(bi))/sum(B(bi));
end;
%=========================================================================
% Plotting
%=========================================================================
if pf==1
close all
figureset(1)
h = plot(k./fs, x, ’b’, k./fs, y, ’r’);
title(’Raw Signal and Lowpass Filtered Signal’);xlabel(’Time,s’);
ylabel(’Amplitude’);
legend(’Raw Signal’, ’Lowpass Filtered’);
box off; axisset;
87
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 89/114
if (ft ~= 3 & ft ~=4),
figure(2)
figureset(2)
freqz(B,A, 512, fs)
set(h, ’Linewidth’, 1.5);
box off; axisset
end;
end;
%=========================================================================
% Take care of outputs
%=========================================================================
if nargout==0,
clear(’y’,’n’);
end;
function [y,n] = HighPass(x,fsa,fca,cfa,pfa)
%HighPass: Highpass filter
%
% [y,n] = HighPass(x,fs,fc,cf,pf)
%
% x Input signal
% fs Signal sample rate (Hz). Default=125 Hz
% fc Cutoff frequency (Hz). Default=fs/4 Hz
% cf Causality flag: 1 = causal, 2 = noncausal (default) for tp=1
% pf Plot flag:hig 0=none (default), 1=screen
%
% y F il ter ed Si gn al
% n O rd er of th e fil te r
%
% Filters the input signal x with a cutoff frequency fc using an
% elliptical filter. The highpass filter can be causal or noncausal.
% The causal implementation uses only the present and previous values
% to determine the filter’s output y, and therefore it is physically
% realizable for realtime processing. The noncausal implementation
% filters the data in the forward direction, and the filtered sequence
% is then reversed and run back through the filter; Y is the time
% reverse of the output of the second filtering operation. The result
% has precisely zero phase distortion and magnitude modified by the
% square of the filter’s magnitude response.
%
% Example: Filter the raw intracranial pressure signal using a
% highpass filter with zero phase (noncausal) and with cutoff
% frequency 0.5 Hz. This will filter out the low frequency
% components (frequencies below 0.5 Hz) and detrend the data:
%% load ICP;
% [y,n] = Highpass(icp,fs,0.5,2,1);
%
% Version 1.00 MA
%
88
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 90/114
% See also HighPass, Lowpass, filter, filtfilt, ellip, and butter.
%=======================================================================
% Process function arguments
%=======================================================================
if nargin<1 | nargin>6,
help Highpass;
return;
end;
fs = 125; % Default sampling rate, Hz
if exist(’fsa’) & ~isempty(fsa),
fs = fsa;
end;
fc = fs/4; % Default cutoff frequency, Hz
if exist(’fca’) & ~isempty(fca),
fc = fca;
end;
cf = 2; % Default flag
if exist(’cfa’) & ~isempty(cfa),
cf = cfa;
end;
pf = 0; % Default - no plotting
if nargout==0, % Plot if no output arguments
pf = 1;
end;
if exist(’pfa’) & ~isempty(pfa),
pf = pfa;
end;
%=======================================================================
% Process Inputs
%=======================================================================
x = x(:); LD = length(x); k = 1:LD;
%=======================================================================
% LowPass Filtering
%=======================================================================
nf = fs/2; whp = fc/nf; Wp = whp*1.2; Ws = whp*0.8; Rp = 0.5;
Rs = 40 ;
if cf==1, % causal[n,Wn] = ellipord(Wp, Ws, Rp, Rs);
[B,A ] = ellip(n, Rp, Rs, Wn, ’high’);
y = f il te r( B, A, x) ;
else % non-causal
[n,Wn] = ellipord(Wp, Ws, Rp, Rs);
89
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 91/114
[B,A ] = ellip(n, Rp, Rs, Wn, ’high’);
y = f il tf il t( B, A, x) ;
end;
%=======================================================================
% Plotting
%=======================================================================
if pf == 1
figure(1)
figureset(1)
h = plot(k./fs, x, ’b’, k./fs, y, ’r’);
title(’Raw Signal and Highpass Filtered Signal’);
xlabel(’Time,s’);
ylabel(’Amplitude’);
legend(’Raw Signal’, ’Highpass Filtered’);
box off; axisset
figure(2)
figureset(2)
freqz(B,A, 512, fs)
end;
%=======================================================================
% Take care of outputs
%=======================================================================
if nargout==0, clear(’y’,’n’); end;
90
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 92/114
8.5 Analysis
Download the signals ECGNoisy60Hz, ECGQuantization, ECGBaselineDrift, and ECG-
NoiseCombined from the class website. Use MATLAB to perform the following computer
exploration.
1. Load and plot the signal ECGNoisy60Hz in MATLAB. Use the FFT to evaluate the
frequency spectrum. Notice the noise present at 60 Hz. Use MATLAB to design a filter
to eliminate this problem. Plot and compare the initial signal and the filtered signal.
2. Repeat the procedure with ECGQuantization. In this case the signal is severely affected
by quantization noise. Use MATLAB to design a filter to eliminate this noise and show
the results.
3. Repeat the procedure with ECGBaselineDrift. In this case the signal is severely affected
by baseline drift due to patient movement. Use MATLAB to design a filter to eliminate
this noise and show the results.
4. Repeat the procedure with ECGBaselinedCombined. The signal contains all the above
types of noise combined. Use MATLAB to design a system to eliminate this noise and
show the results.
91
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 93/114
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 94/114
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 95/114
methods of intracranial ICP signal analysis are primarily based on time- or frequency-
domain metrics such as mean, standard deviation, and spectral power at the heart rate
frequency. Few investigators have analyzed variations in the beat-level morphology of
the pressure signals because detection algorithms that can automatically identify each
of the beat components are generally unavailable.
• Many researchers manually annotate desired components of physiologic pressure signals
because detection algorithms for these signals are not widely available. This approach
is labor-intensive, subjective, expensive, and can only be used on short signal segments.
• There are numerous current and potential applications for pressure beat detection
algorithms. Many pulse oximeters perform beat detection as part of the signal processing
necessary to estimate oxygen saturation, but these algorithms are proprietary and cannot
be used in other applications. Systolic peak detection is necessary for some measures
of baroreflex sensitivity. Identification of the pressure components is necessary for some
methods that assess the interaction between respiration and beat-by-beat ventricular
parameters and the modulation effects of respiration on left ventricular size and stroke
volume. Detection is a necessary task when analyzing arterial compliance and the
pressure pulse contour. Beat-to-beat morphology analysis of ICP also requires robust
automatic detection.
9.4 Specifications
• Design a DSP system to perform automatic detection of ICP signals.
• Function Structure: fi = PressureDetect(x,fs,pf);
– xi Input signal
– fs Signal sample rate (Hz). Default = 125 Hz
94
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 96/114
– pf Plot flag: 0=none (default), 1=screen
– fi Percussion peak (P1) index, samples
9.5 Development and Test
• A composite ICP signal containing examples of different ICP morphologies is provided
in the course website.
• This signal will be used for algorithm development and validation.
9.6 Resources
• A paper entitled: An Automatic Beat Detection Algorithm for Pressure Signals published
in IEEE Transactions of Biomedical Engineering has been posted on the course website.
• This paper describes a general detection algorithm that can be used in pressure signals
(not only ICP).
9.7 Report Sections
• Abstract: Concisely state what was done, how it was done, principal results, and their
significance. The abstract should contain the most critical information of the paper.
• Introduction: State what the problem is specifically, the significance of finding a solution
to the problem, and the work that other researchers have done on this problem. If you
have a long report, the last paragraph in this section should describe the organization
of the rest of the paper.
• Methodology: In short, how did you do what you did. This section should include an
explanation of the methods you used, a description of the data set, and you should
95
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 97/114
describe how the data was collected or where you obtained it from.
• Results: What are the results of applying your method. This should be strictly factual
stating only how well your model performed, the outcome of your hypothesis tests, etc.
It should not include your interpretation or ideas; just the facts.
• Discussion: What did you learn from the results listed in the earlier section. If the
results were different than what you (or the reader) would expect, try to explain why.
If you have ideas for futher research, this is where you should describe those ideas.
• Conclusion: This section should summarize your main discoveries or findings from the
project.
9.8 Report Requirements
• The paper should be written for someone that understands the key concepts and methods
covered in this class. You may assume the reader is a graduate of an engineering program.
• The reports must conform to IEEE requirements for journal papers.
• Do not include code or raw data that you’ve written for the project.
• Avoid passive sentence construction. If you don’t like using first person pronouns (“I”),
you can often use “this paper” or “this report” as the subject of sentences. For example,
“This paper describes an analysis of...” instead of “An analysis of ... is described” or “I
describe an analysis of ...”.
• If English is not your native language, have someone at the Writing Center review your
report for organization, style, and grammar. Must be in Final Submission Format
• Must use LaTeX or MS Word stylesheet.
96
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 98/114
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 99/114
• Organization: Is the report well organized? Are the section headings appropriate and
clear?
• Clarity of Writing: Was the report clearly written? Could I understand what was done
and why after reading it?
• Scope: Was the project of sufficient scope for the class?
• Abstract: Does the abstract give an accurate and concise summary of the report?
• Significance: Does the report explain the significance of the project?
• Objectives: Are the project objectives clearly specified in the introduction?
• Methodology: Were the methods and algorithms used appropriate for the data and
project objectives?
• Results: Were the results sufficient? Were they clearly stated? Was a table or plot used
to display the results appropriately?
• Discussion: Are the results discussed? Were there any surprises and, if so, were ideasabout the reasons for the surprises given? Was the significance of the results explained?
• Citations: Were appropriate citations made to previous work?
98
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 100/114
CHAPTER 10
Appendix
10.1 Appendix I: IEEE-EMBS Detection Paper
10.2 Appendix II: IEEE-TBME Detection Paper
10.3 Appendix III: IEEE-TBME Kalman Filter Paper
99
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 101/114
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 102/114
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 103/114
1664 IEEE TRANSACTIONS ON BIOMEDICAL ENGINEERING, VOL. 52, NO. 10, OCTOBER 2005
Fig. 4. Block diagram showing the architecture and individual stages of the new detection algorithm for peak component detection in pressure signals.
Fig. 5. Example illustrating the output of some of the stages performed by thedetector during peak component detection in pressure signals.
relative amplitude and slope. Finally, the interbeat-intervalstage uses this classification together with the estimated heart
rate to make the final classification and detection of signalcomponents. Since detection is made on the filtered signal,a second nearest neighbor algorithm finds the peaks in theraw signal that are closest to the detected components. Fig. 5shows an example illustrating the output of some of the stagesperformed by the detector during peak component detection.Table I lists the pseudocode for this algorithm.
B. Maxima Detection
Peak detection is performed at several stages in the algorithm.It is first used to detect all peaks in the raw signal prior to anypreprocessing. Peak detection is also employed on each datapartition of the filtered signal to find the relative amplitudes of
the component candidates and on the inflection points. Thepseudocode for this function is shown in Table VI.
TABLE IALGORITHM PSEUDOCODE
C. Preprocessing Stages
The preprocessing stage consists of three bandpass filters.The first filter removes the trend and eliminates high frequencynoise. The resulting signal is used to estimate the heart ratewhich, in turn, is used to determine the cutoff frequency of theother two bandpass filters. The second filter further attenuateshigh frequency components and passes only frequencies thatare less than 2.5 times the heart rate. The output of this filteronly contains one cycle per heart contraction and eliminatesenough high frequency power to ensure the signal derivative isnot dominated by high frequency noise. The third bandpassfilter
detrends the signal by eliminating frequencies below half theminimum expected heart rate and slightly smoothes the signal
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 104/114
ABOY et al.: AUTOMATIC BEAT DETECTION ALGORITHM FOR PRESSURE SIGNALS 1665
with an upper cutoff frequency equal to 10 times the estimatedheart rate.
D. Spectral Heart Rate Estimation
In this stage, the pressure signal is partitioned and the powerspectral density (PSD), , of each segment is estimated. Forthe results reported here, we used the Blackman-Tukey methodof spectral estimation. In general, any of the standard methodsof spectral estimation could be used. The algorithm uses a har-monic PSD technique that combines spectral components ac-cording to (1)
(1)
where ensures that the power of the harmonics added todoes not exceed the power at the fundamental by more thana factor of . For our results we used and .Table VII list the pseudocode for this function. The harmonicPSD technique combines the power of the fundamental and har-
monic components. This technique has two main benefits: 1) itis less sensitive to signal morphology than traditional PSD es-timates because it accounts for variations in the power distri-bution among harmonic frequencies, and 2) it achieves betterfrequency resolution of the lower harmonics by leveraging therelatively better resolution at the harmonic frequencies [26].
E. Peak Detection and Decision Logic
The detector uses nonlinear filters based on ranks for peak detection and decision logic. After preprocessing, a rank filterdetects the peaks in each signal partition above the 60th per-centile using a running window of 10 s. Since the signal hasbeen detrended and smoothed, most of these peaks correspond
to the signal components. In the case of high-pressure ICPsignals, components are usually misclassified as at thisstage. Another rank filter applied to the derivative signal detectsall maxima above the 90th percentile. These peaks correspondto the points of maximum slope, the signal inflection points.
This decision logic calculates the interbeat intervals of thedetected candidate components. Whenever the detector hasmissed a component (false negative), the interbeat interval hasan impulse which exceeds 1.75 the estimated heart rate. Inthe cases where the detector has over-detected a component(false positive), the impulse is “negative” showing an interbeatinterval (IBI) less than 0.75 the estimated heart rate. Sincemissed and over-detected components create impulses in theinterbeat series, this stage uses median-based filters to removethis impulsive noise. These detection errors can be easily locatedby applying a simple set of thresholds to the residual signal,i.e., the difference between the IBI series and the filter output.
F. Nearest Neighbor Decision Logic
This stage combines slope and beat amplitude informationto decide whether a peak in the smoothed signal is a valid .These two metrics are combined by using a simple nearestneighbor algorithm. The inputs to this stage are two arrays con-taining the time location of inflection points (slope maxima),and the candidate peak components obtained using the rank filter. The nearest neighbor algorithm locates each candidatecomponent that immediately follows each inflection point. This
selects the peaks that meet the relative amplitude requirementand that are immediately preceded by a large slope, which
eliminates components with higher amplitude than inhigh-pressure waves. In the case of low-frequency waves,has usually the highest amplitude component, but the amplitudeof components may be above the 60th percentile threshold.These are also eliminated in this stage.
G. IBI Classi fication Logic
After the candidate peaks have passed the relative amplitudeand slope criteria in the previous stage, the final classificationis performed based on the interbeat-intervals (IBI) of the timeseries containing the candidate peaks. Assuming subjects donot have significant arrhythmias, the number of false positivesand false negatives can be reduced by imposing time constrainson the IBI series. As mentioned earlier, whenever the detectorhas missed a peak, the interbeat interval has an impulse whichexceeds twice the estimated heart rate. In the cases where thedetector has over-detected, the impulse is in the opposite direc-tion and is less than half the estimated heart rate.
This stage calculates the first difference, ,of the peak-to-peak interval series. It then searches the time
series for instances where the interbeat distance is less than0.75 the median IBI. This is considered an over-detection, and
is removed from the candidate time series. This stage thensearches for cases were the IBI is greater than 1.75 the medianIBI, which are considered missed peaks. To correct this the al-gorithm searches the initial maxima time series, obtained beforepreprocessing and adds the component that minimizes the in-terbeat variability. This process is repeated until all the candi-date components fall within the expected range or the maximumnumber of allowed corrections is reached.
Finally, two rank-order filters at the 90th and 10th percentileare applied to the IBI series in order to detect the locations of possible misdetections and over detections that were within theaccepted heart rate limits.
III. METHODS
A. Validation Database and Manual Annotation
Several standard databases are available for the evaluation of QRS detection algorithms. These include the MIT-BIH, AHA,and CSE databases [27]. Presently, there are no benchmark databases available to assess the performance of pressuredetection algorithms on ICP, ABP, or POX. There are twofree databases of blood pressure waveforms: Physionet andEurobavar but neither of these has manually annotated pressurecomponents.
We assessed the performance of our algorithm on ICP, ABP,
and signals acquired from the Pediatric Intensive CareUnit (PICU) at Doernbecher Children’s Hospital, OregonHealth & Science University. The signals were acquired by adata acquisition system in the Complex Systems Laboratory(CSL) and are part of the CSL database. The patient populationfor this study was limited to subjects admitted for traumaticbrain injury, sepsis, and cardiac conditions. The sampling ratewas 125 Hz and the resolution was (8 bits, 256levels). Although this sampling rate is not suf ficient for sometypes of cardiac arrhythmia analysis, it is adequate for pressurepulse contour analysis and the other applications listed earlier.A total of 42 539 beats were selected using a random numbergenerator from a population of 210 patients (60 TBI, 60 Sepsis,and 90 cardiac). Two patients from each group were randomly
selected. A 60 minute record was then randomly chosen fromthe entire recording available for each patient.
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 105/114
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 106/114
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 107/114
1668 IEEE TRANSACTIONS ON BIOMEDICAL ENGINEERING, VOL. 52, NO. 10, OCTOBER 2005
Fig. 8. Example showing a
signal and the systolic peak (SBP) identified by the two experts and the detection algorithm. In this case the experts andalgorithm labeled different peaks in the regions of artifact. Clearly Expert-1 (DT) made the correct choice and Expert-2 (JM) needs more training.
TABLE VIFUNCTION PSEUDOCODE: D ETECTMAXIMA
TABLE VIIFUNCTION PSEUDOCODE: E STIMATEHEARTRATE
pressure detection algorithms. Validation databases with man-
ually annotated beats by human experts are needed in order toprovide reproducible and comparable performance assessmentof pressure detection algorithms.
Our validation dataset is publicly available at http:// bsp.pdx.edu to provide other developers annotated exam-ples that can be used to validate their beat detection algorithms.Nonetheless, we caution developers and users about the risk of validation databases. If developers use these datasets fordevelopment, the performance is favorably biased by the tuningand algorithm design that occurs during development. Thesealgorithms may have worse performance when applied prospec-tively to new datasets. Although validation databases containlarge number of annotated peaks, detection algorithms can stillbe favorably tuned to the common cardiac physiology of the
patient population, which is often a narrow subgroup that hasbeen targeted for their common pathologies. Ideally, validationshould be performed prospectively by a third party on datathat is unavailable to developers. Some progress toward thishigher standard of performance has been achieved through theComputers and Cardiology challenges. Independent third-partyvalidation of algorithms on proprietary data with standardizedperformance measures would significantly advance the qualityof detection algorithms as a whole.
VI. CONCLUSION
We described a new automatic beat detection algorithm that
can be used to detect the percussion component in ICP signalsand the systolic peak in ABP and signals. Although thereis a substantial body of literature describing QRS detection al-gorithms, there are almost no published descriptions or assess-ments of pressure detection algorithms. These algorithms are
needed needed for many applications and research.Our algorithm consists of several stages. It relies on the esti-
mated heart rate to choosethe cutoff frequencies used by the pre-processing bandpass filters and to aid the discrimination of falsenegatives and false positives on the interbeat-interval decision
logic stage. It uses three bandpass filters to eliminate drift and at-tenuate high frequency noise. It uses nonlinear rank order filtersfor peak detection and decision logic. The algorithm was vali-dated prospectively (validation dataset was not available during
algorithm development). The algorithm was run only once onthe dataset and achieved a sensitivity of 99.36% and a positive
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 108/114
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 109/114
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 110/114
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 111/114
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 112/114
IEEE TRANSACTIONS ON BIOMEDICAL ENGINEERING, VOL. 52, NO. 8, AUGUST 2005 1487
Fig. 1. Representativeresults of thefirst comparative study between a nonparametric methodology (Welch’s)and theproposed DKFPSD estimator. (a)Plot showsan example of the 10-s ICP segment (light grey) and the 2-s subsegment used for this simulation. (b) Plot of the 2-s subsegment highlighted in (a). (c) Welch’sPSD (dark) and DKF PSD (light) estimates corresponding to the 10-s segment. (d) Welch’s PSD (dark) and DKF PSD (light) estimates on the 2-s subsegment. Thethin line corresponds to Welch’s estimate based on the 10-s segment. (e) Welch’s PSD (dark) and DKF PSD (light) estimates in the 10-s segment with -axis in dBscale. (f) Welch’s PSD (dark) and DKF PSD (light) est imates in the 2-s subsegment with -axis in dB scale. The dotted line is the Welch estimate based on the 10 s.
Therefore, the nonstationary PSD given the instantaneous estimates of
model parameters
can be computed according to
(19)
0
(20)
III. RESULTS
We tested the reliability of the instantanous PSD estimation algo-
rithm with synthetic data generated from different models (AR, MA,
ARMA, and harmonic), and with real data from physiologic pressure
signals. In the following, we demonstrate its usefulness by a sample
application involving PSD estimation of ICPs from patients with trau-
matic brain injury (TBI).
A. Subjects and Material
This study included ICP signals from patients with significant headinjuries who were admitted to thepediatric intensive care unit at Doern-
becher Children’s Hospital. ICP was monitored continuously using a
ventricular catheter or parenchymal fiber-optic pressure transducer (In-
tegra NeuroCare, Integra LifeSciences, Plainsboro, NJ). The ICP mon-
itor was connected to a Philips Merlin CMS patient monitor (Philips,
Best, Netherlands) that sampled the ICP signals at 125 Hz. An HPUX
workstation automatically acquired these signals through a serial data
network and they were stored in files on CD-ROM. Patients were man-
aged according to the standards of care in pediatric intensive care unit
at Doernbecher Children’s Hospital. The data acquisition protocol was
reviewed and approved by the Institutional Review Board at Oregon
Health and Science University, and the requirement on informed con-
sent was waived.
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 113/114
8/10/2019 matlabgb
http://slidepdf.com/reader/full/matlabgb 114/114
IEEE TRANSACTIONS ON BIOMEDICAL ENGINEERING, VOL. 52, NO. 8, AUGUST 2005 1489
In Fig. 1, we show representative results of the first comparative
study between a nonparametric methodology (Welch’s) and the pro-
posed PSD estimator based on the DKF. For the purposes of this
study, Welch’s method was always used with the maximum possible
window length, since this yields to the best frequency resolution.
Fig. 1(a) shows the 10-s ICP segment (light grey) and the 2-s sub-
segment subsegment used in this simulation. Fig. 1(b) show a plot
of the 2-s subsegment highlighted in Fig. 1(a). In Fig. 1(c), we showthe Welch’s PSD (dark) and DKF PSD (light) estimates in the 10-s
segment, and in Fig. 1(d) we show the results of both methodologies
on the 2-s segment. The dotted line corresponds the Welch estimate
based on the 10-s segment. Fig. 1(e) and Fig. 1(f) show Welch’s
PSD (dark) and DKF PSD (light) estimates in dB scale. In Fig. 1(f),
the dotted line corresponds to the Welch estimate based on the 10 s.
From this results, we can conclude that the PSD estimate generated
by our proposed algorithm has better frequency resolution. We also
note that the estimate based on the 2-s segment using the Kalman
PSD algorithm has even better frequency resolution than Welch’s
PSD estimate based on 10 s. Observing the plots in dB scale, we
can also see how the Kalman PSD estimate does not have sidelobes
caused by windowing effects and is smoother.
Results from thesecond simulation areshown in Fig. 2. In this figure,we show representative results of the second comparative study be-
tween a nonparametric PSD estimator and the proposed PSD estimator
based on the DKF, which consisted in comparing the two methods
time-frequency resolution for nonstationary signals. Fig. 2(a) shows
the ICP segment during a period of hypertension
and the reduction in mean ICP after mechanical hyperventilation (ap-
proximately 800 s). In Fig. 2(b), we show the spectrogram of the ICP
signal centered around the time of therapeutic intervention (hyperven-
tilation) using a 40-s window. Examining this spectrogram we can see
the cardiac component around 2 Hz and the respiratory component in
therangeof 0.1–0.55 Hz.In theevolution of therespiratory component,
we cannote a periodof spontaneous breathing (approximately 0–225 s)
and a period of mechanical hyperventilation (
225 s). Fig. 2(c) shows
the spectrogram of the ICP signal centered around the time of ther-apeutic intervention (hyperventilation) generated using nonparametric
PSDestimationwith a window of 15 s with 50%overlap,whichenables
us to know the time instant of the therapeutic intervention with a time
resolution of 15 s. In Fig. 2(d), we show spectrogram of the ICP signal
centered around the time of therapeutic intervention (hyperventilation)
short, and we need good time-frequency resolution, the instantaneous
DKF technique we proposed here may be useful.
IV. CONCLUSION
The authors described an algorithm to perform instantaneous AR
modeling and spectral estimation in nonstationary signals using dual
Kalman filters, and demonstrated its potential applicability and use-
fulness by means of two comparative studies, one on simulated signalsandanother involving PSD estimation in ICP signals from patientswith
TBI. The proposed algorithm was compared with Welch’s method of
PSD estimation. Similar results were obtained when the DKF PSD es-
timator was compared against other standard nonparametric methods
such as the Blackman-Tukey or the modified periodogram. Based on
this preliminary study, we conclude that the DKF estimator is able to
track changes in the PSD better than a moving window technique, and
exhibits good time-frequency resolution when compared with bench-
mark nonparametric PSD techniques at the task of estimating the PSD
of very short data records which are nonstationary. Furthermore, the
proposed method does not assume a piecewise stationary model on the
data.
REFERENCES
[1] M. Barlett, “Smoothing periodograms from time series with continuousspectra,” Nature (London), vol. 161, no. 8, pp. 686–687, 1948.
[2] P. Welch, “The use of fast fourier transform for estimation of powerspectra: a method based on time averaging over short modified peri-odograms,” IEEE Trans. Audio Electoacust., vol. 12, pp. 70–73, 1967.
[3] R. Blackman and J. Tukey, The Measurement of Power Spectra. NewYork: Dover, 1958.
[4] D. G. Manolakis, V. K. Ingle, and S. M. Kogon, Statistical and Adap-
tive Signal Processing. Spectral Estimation, Signal Modeling, Adaptive
Filtering and Array Processing. New York: McGraw-Hill, 2000.[5] J. Burg, “Maximum entropy spectral analysis,” Ph.D. dissertation, Dept.
Elect. Eng., Stanford Univ., Stanford, CA, 1975.[6] S. Kay, Modern Spectral Estimation. Englewood Cliffs, NJ: Prentice-
Hall, 1988.
[7] R. Kalman, “A new approach to linear filtering and prediction prob-lems,” Trans. ASME—J. Basic Eng., vol. 82, pp. 35–45, 1960.[8] M. S. Grewaland A. P. Andrews,Kalman Filtering: Theory and Practice
Using MATLAB. New York: Wiley, 2001.[9] T. Kailath, A. H. Sayed, and B. Hassibi, Linear Estimation. Engle-
wood Cliffs, NJ: Prentice-Hall, 2000.[10] A. Gelb, J. Kasper, R. Nash, C. Price, and A. Sutherland, Applied Op-