LabVIEW Signal Processing Course Manual PDF
LabVIEW Signal Processing Course Manual PDF
Course Manual
LabVIEW Signal Processing Course Manual
Copyright
Copyright 1997 by National Instruments Corporation, 6504 Bridge Point Parkway, Austin, TX 78730-5039.
(512) 794-0100. Under the copyright laws, this publication may not be reproduced or transmitted in any form, electronic or
mechanical, including photocopying, recording, storing in an information retrieval system, or translating, in whole or in part,
without the prior written consent of National Instruments Corporation.
Trademarks
TM
LabVIEW , BridgeVIEW , and The Software is the Instrument are trademarks of National Instruments Corporation.
Product and company names listed are trademarks or trade names of their respective companies.
Internet Support
[email protected]
E-mail: [email protected]
FTP Site: ftp.natinst.com
Web Address: http://www.natinst.com
Bulletin Board Support
(512) 418-1111
Telephone Support (U.S.)
Australia 03 9879 5166, Austria 0662 45 79 90 0, Belgium 02 757 00 20, Canada (Ontario) 905 785 0085,
Canada (Qubec) 514 694 8521, Denmark 45 76 26 00, Finland 09 725 725 11, France 01 48 14 24 24,
Germany 089 741 31 30, Hong Kong 2645 3186, Israel 03 5734815, Italy 02 413091, Japan 03 5472 2970,
Korea 02 596 7456, Mexico 5 520 2635, Netherlands 0348 433466, Norway 32 84 84 00, Singapore 2265886,
Spain 91 640 0085, Sweden 08 730 49 70, Switzerland 056 200 51 51, Taiwan 02 377 1200,
U.K. 01635 523545
National Instruments Corporate Headquarters
Table of Contents
Student Guide
A.
B.
C.
D.
E.
F.
G.
Lesson 1
Background
A. Sampling Signals ...................................................................................................1-2
B. Sampling Considerations .......................................................................................1-3
C. Why Do You Need Antialiasing Filters? ...............................................................1-6
D. Why Use Decibels? ................................................................................................1-7
E. Overview of the Advanced Analysis Library ........................................................1-11
Summary ......................................................................................................................1-14
Lesson 2
Signal Generation
A. Normalized Frequency ...........................................................................................2-2
B. Wave and Pattern VIs ............................................................................................2-7
Summary .......................................................................................................................2-16
Lesson 3
Signal Processing
A. The Discrete Fourier Transform (DFT) and the Fast Fourier Transform (FFT) ...3-2
B. Frequency Spacing and Symmetry of the DFT/FFT .............................................3-6
C. The Power Spectrum ..............................................................................................3-16
Summary ......................................................................................................................3-21
iii
Table of Contents
Lesson 4
Windowing
A. About Spectral Leakage and Smoothing Windows .............................................. 4-2
B. Windowing Applications ...................................................................................... 4-6
C. Characteristics of Different Types of Window Functions .................................... 4-7
Summary ...................................................................................................................... 4-22
Lesson 5
Measurement
A. The Measurement VIs ........................................................................................... 5-2
B. Calculating the Frequency Spectrum of a Signal .................................................. 5-3
C. Coherent Gain (CG) and Equivalent Noise Bandwidth (ENBW) ........................ 5-7
D. Harmonic Distortion ............................................................................................. 5-13
Summary ..................................................................................................................... 5-18
Lesson 6
Digital Filtering
A. What Is Filtering? ................................................................................................. 6-2
B. Ideal Filters ........................................................................................................... 6-3
C. Practical (Nonideal) Filters ................................................................................... 6-5
D. Advantages of Digital Filters over Analog Filters ................................................ 6-7
E. IIR and FIR Filters ................................................................................................ 6-8
F. Infinite Impulse Response Filters ......................................................................... 6-10
G. The Transient Response of IIR Filters .................................................................. 6-24
H. Finite Impulse Response Filters ............................................................................ 6-28
I. Digital Filter Design Toolkit ................................................................................. 6-32
Summary ..................................................................................................................... 6-33
Lesson 7
Curve Fitting
A. About Curve Fitting .............................................................................................. 7-2
B. General LS Linear Fit ........................................................................................... 7-12
C. Nonlinear Lev-Mar Fit .......................................................................................... 7-21
D. Fitting a Curve to Gaussian (Normal) Data Points ............................................... 7-25
Summary ..................................................................................................................... 7-31
Lesson 8
Linear Algebra
A. Linear Systems and Matrix Analysis .................................................................... 8-2
B. Basic Matrix Operations and Eigenvalues-Eigenvector Problems ....................... 8-18
C. Matrix Inverse and Solving Systems of Linear Equations ................................... 8-31
D. Matrix Factorization ............................................................................................. 8-36
Summary ..................................................................................................................... 8-42
iv
Table of Contents
Lesson 9
Probability and Statistics
A. Probability and Statistics ...................................................................................... 9-2
B. Statistics ................................................................................................................ 9-4
C. Probability ............................................................................................................. 9-16
Summary ...................................................................................................................... 9-23
Lesson 10
Digital Filter Design Toolkit
A. Review of Digital Filters ...................................................................................... 10-2
B. The Digital Filter Design Toolkit ........................................................................ 10-4
C. Designing IIR Filters ........................................................................................... 10-9
D. Designing FIR Filters ........................................................................................... 10-18
E. Analyzing your Filter Design .............................................................................. 10-29
F. Format of Filter Coefficient Text Files ................................................................ 10-38
Summary .................................................................................................................... 10-41
Lesson 11
G Math Toolkit
A. Organization of the G Math Toolkit .................................................................... 11-2
B. Parser VIs ............................................................................................................. 11-3
C. Solving Differential Equations ............................................................................ 11-14
Summary .................................................................................................................... 11-31
Lesson 12
Third-Octave Analyzers
A. Filter Banks .......................................................................................................... 12-2
B. Octave Analyzers ................................................................................................. 12-4
C. 1/3-Octave Analyzer or Third-Octave Analyzer .................................................. 12-6
D. Applications ......................................................................................................... 12-7
E. The Third-Octave Analyzer Toolkit .................................................................... 12-8
F. Calibration Using the Third-Octave Analyzer ..................................................... 12-19
Summary .................................................................................................................... 12-27
Lesson 13
Joint Time-Frequency Analysis
A. Why Do You Need Joint Time-Frequency Analysis? ......................................... 13-2
B. Joint Time-Frequency Analysis ........................................................................... 13-5
C. The JTFA Toolkit and Its Applications ............................................................... 13-14
Summary .................................................................................................................... 13-22
Table of Contents
Lesson 14
Wavelet and Filter Banks Designer
A. Signal Representation .......................................................................................... 14-2
B. The Wavelet Transform ....................................................................................... 14-9
C. Applications of Wavelets ..................................................................................... 14-12
D. Wavelets and Filter Banks ................................................................................... 14-13
E. Using the Wavelet and Filter Banks Designer ..................................................... 14-17
Summary .................................................................................................................... 14-26
Appendix A
Error Codes
Appendix B
Frequently Asked Questions
Appendix C
References
Appendix D
Glossary
vi
Student Guide
Introduction
Welcome to the LabVIEW Signal Processing Course. This course is
intended for practicing engineers and scientists who want to learn how
to use LabVIEW or BridgeVIEW to process and analyze digital signals
in real-world practical applications. The course focuses on the advanced
analysis library and the various signal processing toolkits that are
specifically devoted to designing digital filters, solving mathematics
problems, and analyzing nonstationary signals. In addition to teaching
you how to use the analysis VIs and toolkits, the course also covers the
basic fundamentals necessary for understanding and interpreting the
analysis results.
This student guide describes the course contents and suggests ways in
which you can most effectively use the course materials. The guide
discusses the following topics:
A. Self-Paced Use
B. Course Description
C. Prerequisites
D. Course Goals
E. Course Non-Goals
F. Course Map
G. Course Conventions
SG-1
Student Guide
A. Self-Paced Use
Thank you for purchasing the LabVIEW Signal Processing Course kit. You
should be able to begin developing your application soon after you have
worked through this manual. This course manual and accompanying
software are used in the two-day, hands-on LabVIEW Signal Processing
Course. Several exercises in this manual use the following National
Instruments hardware products:
To get started, read the information on the next page regarding the
accompanying disks and then follow the instructions on the subsequent
pages for the computer platform you are using. If you have comments,
suggestions for improving this course, or are not satisfied with the material,
please contact:
LabVIEW Signal Processing Technical Support
6504 Bridge Point Parkway
Austin, TX 78730-5039
(512) 795-8248
[email protected]
North America
Telephone: (512) 794-0100
E-mail: [email protected] (information requests only)
24-hour automated retrieval of course outlines/latest course schedule
Fax on Demand: (800) 329-7177 or (512) 418-1111
World Wide Web: http://www.natinst.com/custed
Other Countries
Please contact your local National Instruments branch office (the phone
numbers are on the back cover).
SG-2
Student Guide
Course Disk
The following table lists the contents of the LabVIEW Signal Processing
Course disk. The course disk contains a zip file containing two VI libraries.
Filename
Note:
Description
Lvspc.zip
unzip.exe
The solution VIs have the word Solution at the end of the VI name.
IBM PC AT or compatible.
SG-3
Student Guide
\Labview
Directory
\TOA
Directory
\DFD
Directory
Lvspcex.llb
Lvspcsol.llb
LabVIEW libraries
B. Course Description
The LabVIEW Signal Processing course teaches you how to implement and
use the VIs in the advanced analysis library and the signal processing
toolkits, and also how to interpret and understand the results of your
analysis. The course is divided into lessons, each covering a topic or a set of
topics. Each lesson consists of:
An introduction that describes the lessons purpose and what you
will learn.
Some of the topics have been simplified considerably to make the basic
concepts and ideas easier to understand. The simplification has been
done at the expense of mathematical detail while striving to provide
clear and precise concepts. For a more detailed presentation of such
topics, see the list of references at the end of this manual.
C. Prerequisites
SG-4
Student Guide
D.Course Goals
This course teaches you to:
E. Course Non-Goals
It is not the purpose of this course to do any of the following:
SG-5
Student Guide
F. Course Map
Day 1
Day 2
Lesson 1
Background
Lesson 6
Digital Filtering
Lesson 2
Signal Generation
Lesson 7
Curve Fitting
Lesson 3
Signal Processing
Lesson 8
Linear Algebra
Lesson 4
Windowing
Lesson 9
Probability and
Statistics
Lesson 5
Measurement
Lessons 10-14
Toolkits
SG-6
Student Guide
G.Course Conventions
The following conventions are used in this course manual:
bold
italic
Courier
Courier italic
Courier bold
<>
SG-7
Student Guide
Notes
SG-8
Lesson 1
Background
Introduction
A digital signal is one that can assume only a finite set of values in both the
dependent and independent variables. The independent variable is usually
time or space, and the dependent variable is usually amplitude.
Digital signals are everywhere in the world around us. Telephone
companies use digital signals to represent the human voice. Radio, TV,
and hi-fi sound systems are all gradually converting to the digital
domain because of its superior fidelity, noise reduction, and its signal
processing flexibility. Data is transmitted from satellites to earth ground
stations in digital form. NASAs pictures of distant planets and outer
space are often processed digitally to remove noise and to extract useful
information. Economic data, census results, and stock market prices are
all available in digital form. Because of the many advantages of digital
signal processing, analog signals are also converted to digital form
before they are processed with a computer. This lesson provides a
background in basic digital signal processing and an introduction to the
LabVIEW/BridgeVIEW Analysis Library, which consists of hundreds
of VIs for signal processing and analysis.
1-1
Lesson 1 Background
A. Sampling Signals
To use digital signal processing techniques, you must first convert an analog
signal into its digital representation. In practice, this is implemented by
using an analog-to-digital (A/D) converter. Consider an analog signal x(t)
that is sampled every t seconds. The time interval t is known as the
sampling interval or sampling period. Its reciprocal, 1/t, is known as the
sampling frequency, with units of samples/second. Each of the discrete
values of x(t) at t = 0, t, 2t, 3t, etc., is known as a sample. Thus, x(0),
x(t), x(2t), ...., are all samples. The signal x(t) can thus be represented by
the discrete set of samples
{x(0), x(t), x(2t), x(3t), , x(kt), }.
Figure 1-1 below shows an analog signal and its corresponding sampled
version. The sampling interval is t. Observe that the samples are
defined at discrete points in time.
10t
t
4t 7t
for i = 0, 1, 2,
If N samples are obtained from the signal x(t), then x(t) can be
represented by the sequence
X = {x[0], x[1], x[2], x[3], , x[N-1] }
This is known as the digital representation or the sampled version of
x(t). Note that the sequence X = {x[i]} is indexed on the integer variable
i, and does not contain any information about the sampling rate. So by
knowing just the values of the samples contained in X, you will have no
idea of what the sample rate is.
1-2
Lesson 1
Background
B. Sampling Considerations
A/D converters (ADCs) are an integral part of data acquisition (DAQ)
boards. One of the most important parameters of an analog input system is
the rate at which the DAQ board samples an incoming signal. The sampling
rate determines how often an analog-to-digital (A/D) conversion takes
place. A fast sampling rate acquires more points in a given time and can
form a better representation of the original signal than a slow sampling rate.
Sampling too slowly may result in a poor representation of your analog
signal. Figure 1-2 shows an adequately sampled signal, as well as the effects
of undersampling. The effect of undersampling is that the signal appears as
if it has a different frequency than it truly does. This misrepresentation of a
signal is called an alias.
Adequately Sampled
1-3
Lesson 1 Background
Magnitude
frequencies25 Hz, 70 Hz, 160 Hz, and 510 Hz. These frequencies are
shown in the following figure.
F1
25 Hz
F2
70 Hz
Frequency
s/2=50
Nyquist Frequency
F3
160 Hz
s=100
Sampling Frequency
F4
510 Hz
500
In Figure 1-4, frequencies below the Nyquist frequency (fs/2=50 Hz) are
sampled correctly. Frequencies above the Nyquist frequency appear as
aliases. For example, F1 (25 Hz) appears at the correct frequency, but F2
(70 Hz), F3 (160 Hz), and F4 (510 Hz) have aliases at 30 Hz, 40 Hz, and
10 Hz, respectively. To calculate the alias frequency, use the following
equation:
Alias Freq. = ABS (Closest Integer Multiple of Sampling Freq. Input Freq.)
where ABS means the absolute value. For example,
Alias F2 = |100 - 70| = 30 Hz
Alias F3 = |(2)100 - 160| = 40 Hz
Magnitude
F2 alias
30 Hz
F4 alias
10 Hz
F1
25 Hz
Frequency
F3 alias
40 Hz
s/2=50
Nyquist Frequency
F2
70 Hz
F3
160 Hz
s=100
Sampling Frequency
F4
510 Hz
500
1-4
Lesson 1
Background
A question often asked is, How fast should I sample? Your first
thought may be to sample at the maximum rate available on your DAQ
board. However, if you sample very fast over long periods of time, you
may not have enough memory or hard disk space to hold the data. Figure
1-5 shows the effects of various sampling rates. In case A, the sine wave
of frequency f is sampled at the same frequency f. The reconstructed
waveform appears as an alias at DC. However, if you increase the
sampling rate to 2f, the digitized waveform has the correct frequency
(same number of cycles), but appears as a triangle waveform. By
increasing the sampling rate to well above f, for example 5f, you can
more accurately reproduce the waveform. In case C, the sampling rate is
at 4f/3. Because in this case the Nyquist frequency is below f
(4f/3 * 1 2 = 2f/3), this sampling rate reproduces an alias waveform of
incorrect frequency and shape.
A
Sampled at s
B
Sampled at 2s
C
Sampled at 4s/3
The Nyquist theorem gives you a starting point for the adequate
sampling rategreater than two times the highest frequency component
in the signal. Unfortunately, this rate is often inadequate for practical
purposes. Real-world signals often contain frequency components that
lie above the Nyquist frequency. These frequencies are erroneously
aliased and added to the components of the signal that are sampled
accurately, producing distorted sampled data. Therefore, for practical
purposes, sampling is usually done at several times the maximum
frequencyfive to 10 times is typical in industry.
Note:
1-5
Lesson 1 Background
f1
frequency
filter output
filter output
transition band
frequency
f1
f2
(b) practical anti-alias filter
1-6
Lesson 1
Background
Power Ratio
Voltage Ratio
+40
10000
100
+20
100
10
+6
+3
1.4
-3
1/2
1/1.4
-6
1/4
1/2
-20
1/100
1/10
-40
1/10000
1/100
Thus, you see that the dB scale is useful in compressing a wide range of
amplitudes into a small set of numbers. The decibel scale is often used in
sound and vibration measurements and in displaying frequency domain
information. You will now do an exercise that shows a signal in linear and
logarithmic scales.
1-7
Lesson 1 Background
Exercise 1-1
Objective: To build a VI that displays the signal amplitude in both linear and dB scales.
This VI will display the square of 100 data points on a waveform graph. The
fifth data point will create a spike. You will observe that the spike is visible
on the dB scale.
Front Panel
1.
1-8
Lesson 1
Background
Block Diagram
1-9
Lesson 1 Background
3. Select the Linear option from the Selector control, and run the VI.
Note that the spike at element 5 is barely visible.
4. Select the Logarithm (dB) option from the Selector control and run
the VI. Note that the spike at element 5 is very easily noticeable.
Note:
Observe the change in the y-axis scale as you switch between the Linear
and Logarithm (dB) options.
5. After you have finished, save the VI as dB_linear.vi in the
Lvspcex.llb library.
1-10
Lesson 1
Background
1-11
Lesson 1 Background
1-12
Lesson 1
Background
1-13
Lesson 1 Background
Summary
You can use a lowpass filter before sampling the analog signal to
limit its frequency content to less than fs/2. Such a filter used to
prevent the effect of aliasing is known as an antialias filter.
Review Questions
1. Give some examples of digital signals in everyday life.
2. Given a set of sample values x = {x[i]} where i is an integer variable,
what is the sampling rate?
3. What is aliasing? How can it be avoided?
4. Given that the sampling frequency is 100 Hz, what is the alias
frequency (if any) for the following: 13 Hz, 25 Hz, 40 Hz, 75 Hz,
99 Hz, 101 Hz, 200 Hz, and 350 Hz?
5. Why do we use the decibel scale? In what applications is it normally
used?
6. Which of the following is possible using the analysis VIs?
a. Finding the mean or standard deviation of census data.
b. Designing a filter to remove noise from an electrocardiogram.
c. Detecting peaks in a blood pressure waveform to measure the
heart rate.
d. Interpolating between data points to plot the trajectory of an
object (for example, a comet or a cannonball).
1-14
Lesson 1
Background
Notes
1-15
Lesson 1 Background
Notes
1-16
Lesson 2
Signal Generation
Introduction
In this lesson, you will learn how to use the VIs in the analysis library to
generate many different types of signals. Some of the applications for signal
generation are:
2-1
A. Normalized Frequency
In the analog world, a signal frequency is measured in Hz or cycles per
second. But the digital system often uses a digital frequency, which is
the ratio between the analog frequency and the sampling frequency:
digital frequency = analog frequency / sampling frequency
This digital frequency is known as the normalized frequency. Its units
are cycles/sample.
Some of the Signal Generation VIs use an input frequency control, f, that
is assumed to use normalized frequency units of cycles per sample. This
frequency ranges from 0.0 to 1.0, which corresponds to a real frequency
range of 0 to the sampling frequency fs. This frequency also wraps
around 1.0, so that a normalized frequency of 1.1 is equivalent to 0.1.
As an example, a signal that is sampled at the Nyquist rate (fs/2) means
that it is sampled twice per cycle (that is, two samples/cycle). This
will correspond to a normalized frequency of 1/2 cycles/sample =
0.5 cycles/sample. The reciprocal of the normalized frequency, 1/f, gives
you the number of times that the signal is sampled in one cycle.
When you use a VI that requires the normalized frequency as an input,
you must convert your frequency units to the normalized units of
cycles/sample. You must use these normalized units with the
following VIs.
Sine Wave
Square Wave
Sawtooth Wave
Triangle Wave
Arbitrary Wave
Chirp Pattern
2-2
Lesson 2
Signal Generation
If you are used to working in frequency units of cycles, you can convert
cycles to cycles/sample by dividing cycles by the number of samples
generated. The following illustration shows the Sine Wave VI, which is
being used to generate two cycles of a sine wave.
You need only divide the frequency (in cycles) by the number of
samples. In the above example, the frequency of 2 cycles is
divided by 50 samples, resulting in a normalized frequency of
f = 1/25 cycles/sample. This means that it takes 25 (the reciprocal of f)
samples to generate one cycle of the sine wave.
However, you may need to use frequency units of Hz (cycles/second). If
you need to convert from Hertz (or cycles/second) to cycles/sample,
divide your frequency in cycles/second by the sampling rate given in
samples/second.
cycles/second
cycles
------------------------------------- = ----------------samples/second
sample
National Instruments Corporation
2-3
Below is a block diagram for generating a Hertz sine signal. You divide
the frequency of 60 Hz by the sampling rate of 1000 Hz to get the
normalized frequency of f = 0.06 cycles/sample. Therefore, it takes
almost 17 (1/0.06) samples to generate one cycle of the sine wave.
The signal generation VIs create many common signals required for
network analysis and simulation. You can also use the signal generation
VIs in conjunction with National Instruments hardware to generate
analog output signals.
2-4
Lesson 2
Signal Generation
Exercise 2-1
Objective: To understand the concept of normalized frequency.
1. Build the VI front panel and block diagram shown below.
Front Panel
Block Diagram
2-5
2-6
Lesson 2
Signal Generation
Phase Control
The wave VIs have a phase in control where you can specify the initial
phase (in degrees) of the first sample of the generated waveform. They
also have a phase out indicator that specifies what the phase of the next
sample of the generated waveform is going to be. In addition, a reset
phase control decides whether or not the phase of the first sample
generated when the wave VI is called is the phase specified at the phase
in control, or whether it is the phase available at the phase out control
when the VI last executed. A TRUE value of reset phase sets the initial
phase to phase in, whereas a FALSE value sets it to the value of phase
out when the VI last executed.
The wave VIs are all reentrant (can keep track of phase internally) and
accept frequency in normalized units (cycles/sample). The only pattern
VI that presently uses normalized units is the Chirp Pattern VI. Setting
the reset phase Boolean to FALSE allows for continuous sampling
simulation.
Note:
Wave VIs are reentrant and accept the frequency input in terms of
normalized units.
In the next exercise, you will generate a sine wave using both the Sine
Wave VI and the Sine Pattern VI. You will see how in the Sine Wave
VI you have more control over the initial phase than in the Sine
Pattern VI.
2-7
Exercise 2-2
OBJECTIVE: To generate a sine wave of a particular frequency and see the effect of aliasing.
Front Panel
Block Diagram
2-8
Lesson 2
Signal Generation
2-9
Exercise 2-3
Objective:
To generate a sinusoidal waveform using both the Sine Wave VI and the Sine Pattern
VI and to understand the differences.
1. Build the VI front panel and block diagram shown below.
Front Panel
2-10
Lesson 2
Signal Generation
Block Diagram
2.00
sampling freq:
100
phase in:
0.00
reset phase:
OFF
2-11
2-12
Lesson 2
Signal Generation
Sine Wave
Square Wave
Triangle Wave
Sawtooth Wave
Front Panel
The Signal Source control selects the type of waveform that you
want to generate.
The square duty cycle control is used only for setting the duty cycle
of the square wave.
The samples control determines the number of samples in the plot.
Note that these are all wave VIs, and therefore they require the
frequency input to be the normalized frequency. So, you divide
frequency by the sampling rate and the result is the normalized
frequency wired to the f input of the VIs.
2-13
Block Diagram
2-14
Lesson 2
Signal Generation
4. Change samples to 200, 300, and 400. How many cycles of the
waveform do you see? Explain why.
5. With samples set to 100, change reset phase to OFF. Do you notice
any difference in the plot?
6. Change frequency to 10.01 Hz. What happens? Why?
7. Change reset phase to ON. Now what happens? Explain why.
8. Repeat steps 4 7 for different waveforms selected in the Signal
Source control.
9. When you finish, save the VI as Function Generator.vi in the
Lvspcex.llb library.
2-15
Summary
In this lesson, you learned:
That the wave VIs can keep track of the phase of the generated
waveform.
Review Questions
1. Name two practical applications in which you would want to
generate signals.
2. What is the normalized signal frequency for the following?
a. sampling frequency = 100 Hz
number of samples = 200
signal frequency = 15 Hz
b. sampling frequency = 100 Hz
number of samples = 200
signal frequency = 15 cycles
3. What are two main differences between the Wave and Pattern VIs?
4. Which of the following VIs require a normalized frequency input?
a. Sine wave
b. Sine pattern
c. Chirp pattern
d. Square wave
2-16
Lesson 2
Signal Generation
Notes
2-17
Notes
2-18
Lesson 3
Signal Processing
Introduction
In this lesson, you will learn the basics of transforming a signal from the
time domain into the frequency domain.
3-1
DFT
3-2
Lesson 3
Signal Processing
If the signal is sampled at a sampling rate of fs Hz, then the time interval
between the samples (that is, the sampling interval) is t, where
1
t = --fs
The sample signals are denoted by x[i], 0 i N-1 (that is, you have a
total of N samples). When the discrete Fourier transform, given by
N1
Xk =
x e
j2ik N
for k = 0, 1, 2, , N-1
(1)
i=0
amplitude
In the next section, you will see the exact frequencies to which the N
samples of the DFT correspond. For the present discussion, assume that
X[0] corresponds to DC, or the average value, of the signal. To see the result
of calculating the DFT of a waveform with the use of equation (1), consider
a DC signal having a constant amplitude of +1 V. Four samples of this signal
are taken, as shown in the figure below.
+1 V
time
0
3-3
Each of the samples has a value +1, giving the time sequence
x[0] = x[1] = x[2] = x[3] = 1
Using equation (1) to calculate the DFT of this sequence and making use
of Eulers identity,
exp (j) = cos( ) - jsin( )
you get:
N1
X[0] =
x e
j2i0 N
i=0
3
3
x [ 3 ] cos ------ j sin ------ = ( 1 j 1 + j ) = 0
2
2
X [ 2 ] = x [ 0 ] + x [ 1 ] ( cos ( ) j sin ( ) ) + x [ 2 ] ( cos ( 2 ) j sin ( 2 ) ) +
x [ 3 ] ( cos ( 3 ) j sin ( 3 ) ) = ( 1 1 + 1 1 ) = 0
3
3
X [ 3 ] = x [ 0 ] + x [ 1 ] cos ------ j sin ------ + x [ 2 ] ( cos ( 3 ) j sin ( 3 ) ) +
2
2
9
9
x [ 3 ] cos ------ j sin ------ = ( 1 j 1 j ) = 0
2
2
Therefore, except for the DC component, X[0], all the other values are
zero, which is as expected. However, the calculated value of X[0]
depends on the value of N (the number of samples). Because you had
N = 4, X[0] = 4. If N = 10, then you would have calculated X[0] = 10.
This dependency of X[.] on N also occurs for the other frequency
components. Thus, you usually divide the DFT output by N, so as to
obtain the correct magnitude of the frequency component.
and
The terms used to describe this symmetry are that the magnitude of X[k]
is even symmetric, and phase(X[k]) is odd symmetric. An even
symmetric signal is one that is symmetric about the y-axis, whereas an
3-4
Lesson 3
Signal Processing
odd symmetric signal is symmetric about the origin. This is shown in the
following figures.
even symmetry
odd symmetry
If the input signal is complex, the DFT will be nonsymmetric and you
cannot use this trick.
3-5
( f = ----s ) means that the kth sample of the DFT occurs at a frequency of
kf Hz. (Actually, as you will soon see, this is valid for only up to about
half the number of samples. The other half represent negative frequency
components.) Depending on whether the number of samples, N, is even or
odd, you can have a different interpretation of the frequency corresponding
to the kth sample of the DFT.
shows the frequency to which each element of the complex output sequence
X corresponds.
Array Element
Corresponding Frequency
X[0]
DC component
X[1]
X[2]
2f
X[3]
3f
.
.
.
.
.
.
X[p-2]
(p-2)f
X[p-1]
(p-1)f
X[p]
pf (Nyquist frequency)
X[p+1]
- (p-1)f
X[p+2]
- (p-2)f
.
.
.
.
.
.
X[N-3]
- 3f
X[N-2]
- 2f
X[N-1]
- 1f
3-6
Lesson 3
Signal Processing
Note that the pth element, X[p], corresponds to the Nyquist frequency.
The negative entries in the second column beyond the Nyquist frequency
represent negative frequencies.
For example, if N = 8, p = N/2 = 4, then
X[0]
DC
X[1]
X[2]
2f
X[3]
3f
X[4]
4f (Nyquist freq)
X[5]
-3f
X[6]
-2f
X[7]
-f
Here, X[1] and X[7] will have the same magnitude, X[2] and X[6] will
have the same magnitude, and X[3] and X[5] will have the same
magnitude. The difference is that whereas X[1], X[2], and X[3]
correspond to positive frequency components, X[5], X[6], and X[7]
correspond to negative frequency components. Note that X[4] is at the
Nyquist frequency.
The following illustration represents this complex sequence for N = 8.
DC
positive
frequencies
negative
frequencies
Nyquist component
Such a representation, where you see both the positive and negative
frequencies, is known as the two-sided transform.
3-7
Corresponding Frequency
X[0]
DC component
X[1]
X[2]
2f
X[3]
3f
.
.
.
.
.
.
X[p-1]
(p-1)f
X[p]
pf
X[p+1]
-pf
X[p+2]
- (p-1)f
.
.
.
.
.
.
X[N-3]
- 3f
X[N-2]
- 2f
X[N-1]
- f
Note that when N is odd, N/2 is not an integer, and thus there is no
component at the Nyquist frequency.
For example, if N = 7, p = (N-1)/2 = (7-1)/2 = 3, and you have
X[0]
DC
X[1]
X[2]
2f
X[3]
3f
X[4]
-3f
X[5]
-2f
X[6]
-f
3-8
Lesson 3
Signal Processing
Now X[1] and X[6] have the same magnitude, X[2] and X[5] have the
same magnitude, and X[3] and X[4] have the same magnitude. However,
whereas X[1], X[2], and X[3] correspond to positive frequencies, X[4],
X[5], and X[6] correspond to negative frequencies. Because N is odd,
there is no component at the Nyquist frequency.
The following illustration represents the preceding table for N = 7.
DC
positive
frequencies
negative
frequencies
This is also a two-sided transform, because you have both the positive
and negative frequencies.
3-9
Zero Padding
A technique employed to make the input sequence size equal to a power
of 2 is to add zeros to the end of the sequence so that the total number of
samples is equal to the next higher power of 2. For example, if you have
10 samples of a signal, you can add six zeros to make the total number of
samples equal to 16 (= 24a power of 2). This is shown below:
3-10
Lesson 3
Signal Processing
The block diagram below shows a simplified version of how you can
generate 10 cycles of a complex signal:
To next stage
3-11
Exercise 3-1
Objective:
To display the two-sided and the one-sided Fourier transform of a signal using the
Real FFT VI, and to observe the effect of aliasing in the frequency spectrum.
1. Build the VI front panel and block diagram as shown below.
Front Panel
3-12
Lesson 3
Signal Processing
Block Diagram
3-13
Two-Sided FFT
3. Examine the frequency spectrum (the Fourier transform). You will
notice two peaks, one at 10 Hz and the other at 90 Hz. The peak at
90 Hz is actually the negative frequency of 10 Hz. The plot you see
is known as the 2-sided FFT because it shows both the positive and
the negative frequencies.
4. Run the VI with frequency (Hz) = 10 and then with
frequency (Hz) = 20. For each case, note the shift in both peaks of
the spectrum.
Note:
Also observe the time domain plot for frequency (Hz) = 10 and 20. Which
one gives a better representation of the sine wave? Why?
5. Because fs = 100 Hz, you can accurately sample only signals having
a frequency < 50 Hz (Nyquist frequency = fs/2). Change frequency
(Hz) to 48 Hz. You should see the peaks at +- 48 Hz on the spectrum
plot.
6. Now change frequency (Hz) to 52 Hz. Is there any difference
between the result of step 5 and what you see on the plots now?
Because 52 > Nyquist, the frequency of 52 is aliased to
|100 - 52| = 48 Hz.
7. Change frequency (Hz) to 30 Hz and 70 Hz and run the VI. Is there
any difference between the two cases? Explain why.
8. Save this VI as FFT_2sided.vi in the library Lvspcex.llb.
One-Sided FFT
9. Modify the block diagram of the VI as shown in the following
diagram. You have seen that the FFT had repetition of information
because it contained information about both the positive and the
negative frequencies. This modification now shows only half the
FFT points (only the positive frequency components). This
representation is known as the 1-sided FFT. The 1-sided FFT shows
only the positive frequency components. Note that you need to
multiply the positive frequency components by two to obtain the
correct amplitude. The DC component, however, is left untouched.
3-14
Lesson 3
Signal Processing
3-15
X[0]
---and X N
2
, respectively.
3-16
Lesson 3
Signal Processing
Interpretation
Sxx[0]
Power in DC component
Sxx[1] = Sxx[N-1]
Power at frequency f
Sxx[2] = Sxx[N-2]
Power at frequency 2f
Sxx[3] = Sxx[N-3]
Power at frequency 3f
.
.
.
.
.
.
Sxx[p-2]= Sxx[N-(p-2)]
Sxx[p-1] = Sxx[N-(p-1)]
Sxx[p]
DC
negative
frequencies
positive
frequencies
Nyquist component
The output units of the Power Spectrum VI are in Volts rms squared
(V2rms). So, if the peak amplitude (Vpk) of the input signal is 2 Vpk, its
2
rms value is Vrms = ------ =
2
3-17
2,
Interpretation
Sxx[0]
Power in DC component
Sxx[1] = Sxx[N-1]
Power at frequency f
Sxx[2]= Sxx[N-2]
Power at frequency 2f
Sxx[3] = Sxx[N-3]
Power at frequency 3f
.
.
.
.
.
.
Sxx[p-2] = Sxx[N-(p-2)]
Sxx[p-1] = Sxx[N-(p-1)]
Sxx[p] = Sxx[p]
Power at frequency pf
DC
positive
frequencies
3-18
negative
frequencies
Lesson 3
Signal Processing
Exercise 3-2
Objective: To observe the difference between the FFT and the power spectrum representations.
1. Open the FFT_1sided VI (from the library Lvspcex.llb) that
you built in the previous exercise. Modify the block diagram and
front panel as shown below.
Front Panel
Block Diagram
3-19
You could also have wired the output of the Sine Wave VI directly to the
input of the Power Spectrum VI (Analysis Digital Signal Processing
subpalette). The output of the Power Spectrum VI would directly be the
power spectrum of the signal. However, in that case, the phase information
would be lost.
2. Enter the following values in the controls: amplitude = 1.414,
frequency = 20 Hz, sampling freq = 100, and # of samples = 100,
and run the VI. Do you notice any difference in the FFT and power
spectrum representations?
3. Change the amplitude to 1.00 and run the VI. What difference do you
notice in the FFT and power spectrum representations?
4. Save the VI as FFT and Power Spectrum.vi in the library
Lvspcex.llb.
3-20
Lesson 3
Signal Processing
Summary
The DFT, FFT, and power spectrum are useful for measuring the
frequency content of stationary or transient signals. The FFT
provides the average frequency content of the signal over the entire
time that the signal was acquired. For this reason, you use the FFT
mostly for stationary signal analysis (when the signal is not
significantly changing in frequency content over the time that the
signal is acquired), or when you want only the average energy at each
frequency line.
3-21
Review Questions
1. Which of the following provides you with both the magnitude and
phase information?
a. FFT
b. Power spectrum
c. DFT
d. Time domain waveform
2. Which of the following are true?
a. The magnitude spectrum is always even symmetric.
b. The DFT is a fast algorithm for computing the FFT.
c. The frequency spacing is given by
fs
f = --------------------------------------------number of samples
3-22
Lesson 3
Signal Processing
Notes
3-23
Notes
3-24
Lesson 4
Windowing
Introduction
In this lesson, you will learn about windows and how they affect the spectral
characteristics of a signal.
4-1
Lesson 4 Windowing
discontinuity
One period
time
4-2
Lesson 4
Windowing
In Figure 4-3, you see the spectral representation when you sample a
noninteger number of cycles of the time waveform (namely 1.25).
Graph1 now consists of 1.25 cycles of the sine wave. When you repeat
this periodically, the resulting waveform, as shown in Graph 2, consists
of discontinuities. The corresponding spectrum is shown in Graph 3.
Notice how the energy is now spread over a wide range of frequencies.
This smearing of the energy is spectral leakage. The energy has leaked
out of one of the FFT lines and smeared itself into all the other lines.
4-3
Lesson 4 Windowing
Leakage exists because of the finite time record of the input signal. To
overcome leakage, one solution is to take an infinite time record, from
- to +. Then the FFT would calculate one single line at the correct
frequency. Waiting for infinite time is, however, not possible in practice.
So, because you are limited to having a finite time record, another
technique, known as windowing, is used to reduce the spectral leakage.
The amount of spectral leakage depends on the amplitude of the
discontinuity. The larger the discontinuity, the more the leakage, and
vice versa. You can use windowing to reduce the amplitude of the
discontinuities at the boundaries of each period. It consists of
multiplying the time record by a finite length window whose amplitude
varies smoothly and gradually towards zero at the edges. This is shown
in Figure 4-4, where the original time signal is windowed using a
Hamming window. Notice that the time waveform of the windowed
signal gradually tapers to zero at the ends. Therefore, when performing
Fourier or spectral analysis on finite-length data, you can use windows
to minimize the transition edges of your sampled waveform. A
smoothing window function applied to the data before it is transformed
into the frequency domain minimizes spectral leakage.
4-4
Lesson 4
Windowing
4-5
Lesson 4 Windowing
B. Windowing Applications
There are several reasons to use windowing. Some of these are:
4-6
Lesson 4
Windowing
for n = 0, 1, 2........N-1
for n = 0, 1, 2.......N - 1
where f is the final value. The initial value of the window is one, and
it gradually decays towards zero. The final value of the exponential
4-7
Lesson 4 Windowing
final
value
for n = 0, 1, 2, .....N-1
4-8
for n = 0, 1, 2, .....N-1
Lesson 4
Windowing
You see that the Hanning and Hamming windows are somewhat
similar. However, note that in the time domain, the Hamming
window does not get as close to zero near the edges as does the
Hanning window.
5. Kaiser-Bessel: This window is a flexible window whose shape the
user can modify by adjusting the parameter beta. Thus, depending on
your application, you can change the shape of the window to control
the amount of spectral leakage. The Kaiser-Bessel window for
different values of beta are shown below:
4-9
Lesson 4 Windowing
Note that for small values of beta, the shape is close to that of a
rectangular window. Actually, for beta = 0 .0, you do get a
rectangular window. As you increase beta, the window tapers off
more to the sides.
This window is good for detecting two signals of almost the same
frequency, but significantly different amplitudes.
6. Triangle: The shape of this window is that of a triangle. It is given by
w[n] = 1 - | (2n-N) / N | for n = 0, 1, 2, ..., n1
A triangle window for N = 32 is shown below:
4-10
Lesson 4
Windowing
Window
Rectangular
Exponential, Hanning
General-purpose applications
Hanning
Order tracking
Rectangular
Separation of two tones with frequencies very close to each other, but
with widely differing amplitudes
Kaiser-Bessel
Separation of two tones with frequencies very close to each other, but
with almost equal amplitudes
Rectangular
In many cases, you may not have sufficient prior knowledge of the
signal, so you need to experiment with different windows to find the
best one.
4-11
Lesson 4 Windowing
Exponential
Equation
Shape
w [ n ] = 1.0
Detecting transients
whose duration is
shorter than the length
of the window; order
tracking; separating two
tones with frequencies
and amplitudes very
close to each other;
system response
n
w [ n ] = ------------- ln ( f )
N1
where f = final value
Hanning
2n
w [ n ] = 0.5 0.5 cos ----------
N
Hamming
2n
w [ n ] = 0.54 0.46 cos ----------
N
Kaiser-Bessel
I0 ( 1 a )
w [ n ] = -----------------------------I0 ( )
Triangle
N
w [ n ] = 1 2n
---------------N
Transients whose
duration is longer than
the length of the
window
General-purpose
applications; system
analysis; transients
whose duration is longer
than the length of the
window
Applications
4-12
Lesson 4
Windowing
Exercise 4-1
Objective: To see the effect of windowing on spectral leakage.
1. Open the Spectral Leakage VI from the library Lvspcex.llb.
The VI is running when it opens. Using this VI, you can see the effect
of windowing on spectral leakage.
Note:
The Spectral Leakage VI searches for the Nyquist Shift VI. The Nyquist
Shift VI is in LabVIEW Examples Analysis dspxmpl.llb.
You can see three plots on the front panel:
Graph 1 shows the time record of the signal that has been sampled.
Graph 2 shows the repeated time record (assuming periodicity).
Graph 3 shows the frequency spectrum (in dB). The white line
shows the spectrum without windowing and the yellow line shows
the spectrum by windowing using a Hanning window.
You can use the cycles dial to control the number of time domain
waveform cycles that have been sampled. The display below the
Cycles dial tells you the exact number of cycles (to two decimal
places). You can also type a specific value in this display.
2. First, you will see the effect of windowing when you sample an
integral number of cycles.
Set the Cycles dial to 1.0. (or type 1.0 in the display beneath it.)
4-13
Lesson 4 Windowing
As you can see in Graph 1, you have exactly one cycle of the time
waveform. Graph 2 shows the repeated time record. Notice the
absence of any discontinuities, and the peak corresponding to the
sine wave in the frequency domain (Graph 3). You see two peaks
because you have the two-sided spectrum.
Notice the spreading around the frequency components. This
spreading is the effect of using a window function. In this case, you
used the Hanning window. Different windows have different
amounts of spreading.
3. Now see what happens when you sample a nonintegral number of
cycles. Set the Cycles dial to 1.3 and observe the difference in the
plots in Graph 3. Experiment by changing the cycles dial and
observing the waveforms in graphs 2 and 3.
In the white plot corresponding to No Window, the energy in the
frequency of interest spreads out across the spectrum. Hence the
frequency of interest is sometimes not clearly distinguishable. In the
yellow plot corresponding to Hanning Window, the spectral leakage
across the spectrum is reduced and the energy is more concentrated
around the frequency of interest.
4. Stop the VI by pressing the STOP button.
5. Close the VI. Do not save any changes.
4-14
Lesson 4
Windowing
To see the difference (both time and frequency domains) between a windowed and
nonwindowed signal.
1. Build the VI front panel and block diagram as shown below.
Front Panel
4-15
Lesson 4 Windowing
Block Diagram
4-16
Lesson 4
Windowing
4-17
Lesson 4 Windowing
Exercise 4-3
Objective:
The topmost plot shows you the shapes (in the time domain) of six
different types of windows in the Analysis library. They are all
shown on the same plot for comparison purposes.
The bottom three plots show the effect of multiplying a time domain
signal (a sine wave) by the window. The left plot shows the original
time signal, the middle plot shows the shape of the window being
applied, and the right plot shows the resulting signal.
In the Window Selector control, you can select one of the six
different types of windows.
The final value (exponential) control specifies the value to which
the exponential window should decay. This value is normally
between 0 and 1.
The value in the beta (Kaiser-Bessel) control can be adjusted to
change the shape of the Kaiser-Bessel window. The higher the value
of beta, the lower the spectral leakage, and vice versa.
2. Select different windows in the Window Selector control and
observe their shapes.
LabVIEW Signal Processing Course Manual
4-18
Lesson 4
Windowing
4-19
Lesson 4 Windowing
Exercise 4-4
Objective:
To use windows to separate two sine waves of almost the same frequency, but
widely differing amplitudes.
In this exercise, two sine waves of different amplitudes are summed
together and then transformed into the frequency domain. Sine wave 1
has a much smaller amplitude than sine wave 2. Without windowing, it
is not possible to distinguish between the two sine waves in the
frequency domain. With an appropriate choice of a window, you can
clearly separate the peaks in the frequency domain corresponding to the
two sine waves. The frequency domain plot shows the results so that you
can compare the effect of different window functions.
1. Open and run the Window Comparison VI from the library
Lvspcex.llb.
2. Using the digital controls, set the amplitude of Sine Wave 1 as 0.001,
and that of Sine Wave 2 as 1.000. With the knob controls, set the
4-20
Lesson 4
Windowing
frequency of Sine Wave 1 to near 70, and that of Sine Wave 2 to near
60. In effect, you are adjusting the frequency of Sine Wave 2 using
the knob control, so that the smaller amplitude is nearer the larger
amplitude in the frequency domain plot.
3. Notice in the graph that when the frequency of the smaller amplitude
signal (Sine Wave 1) is closer to that of the larger amplitude signal
(Sine Wave 2), the peak corresponding to the smaller signal is not
detected. Applying a window function is the only way to detect the
smaller signal. The discontinuity is what causes the spectrum to
spread out. Signals at smaller amplitudes are lost in the sidelobes of
the larger amplitude signal.
4. Compare different window functions by choosing another window
from the window 1 and window 2 controls. Which one(s) can
distinguish between the two frequency components?
5. When you are done, stop the VI by clicking on the STOP button.
Close the VI. Do not save any changes.
4-21
Lesson 4 Windowing
Summary
The DFT/FFT assumes that the finite time waveform that you obtain
is one period of a periodic signal that exists for all time. This
assumption of periodicity could result in discontinuities in the
periodic signal and gives rise to a phenomenon known as spectral
leakage, whereby the energy at a particular frequency leaks
throughout the spectrum.
Windows can be used to separate two sine waves that have widely
different amplitudes, but are very close in frequency.
Review Questions
1. Why does spectral leakage occur?
2. Name four applications of using windows.
3. Which window(s) would you use for the following?
a. Separation of two tones with frequencies very close to each other.
b. System analysis.
c. Detecting the modes of vibration of a machine.
4-22
Lesson 4
Windowing
Notes
4-23
Lesson 4 Windowing
Notes
4-24
Lesson 5
Measurement
Introduction
You will now learn about some of the VIs that are already available in the
analysis library to perform various signal processing tasks. These VIs are
collectively referred to as measurement VIs.
5-1
Lesson 5 Measurement
In general, you can directly connect the inputs of the measurement VIs
to the output of data acquisition VIs. The outputs of the measurement
VIs can be connected to graphs for an appropriate visual display.
DAQ VIs
Measurement VIs
Graphing and
Plotting VIs
5-2
Lesson 5
Measurement
5-3
Lesson 5 Measurement
Exercise 5-1
OBJECTIVE: To compute the frequency spectrum of a signal.
Front Panel
5-4
Lesson 5
Measurement
Block Diagram
The input time domain signal is applied at the Signal (V) control. The
magnitude and phase of the input signal spectrum are available at the
Amp Spectrum Mag (Vrms) and Amp Spectrum Phase (radians)
outputs, respectively.
Note:
Note:
If the units of the input time domain signal are in volts peak (Vp), the units
of the magnitude of the amplitude spectrum is in volts rms (Vrms). The
relationship between the units is Vrms = Vp/ 2 = 0.707*Vp.
4. Run the VI.
The graph should display two peaks, one at 2 Hz and the other at
10 Hz. The amplitude of the 2 Hz sine wave is 0.717 V, and that of
the 10 Hz waveform is 1.414 V, which are the rms values for sine
waveforms of amplitudes 1 and 2 V, respectively. (The RMS of a
sine waveform = 0.707*peak amplitude.)
5-5
Lesson 5 Measurement
5. Change the phase of the sine waves by adjusting the Initial Phase 1
and Initial Phase 2 controls, and run the VI.
Do you notice any change in the time waveform? The spectrum?
6. Make the parameters of both the sine waves equal. That is, set
amplitude 1 = amplitude 2 = 2, frequency 1 = frequency 2 = 10,
Initial Phase 1 = Initial Phase 2 = 0, and sampling frequency = 200,
and run the VI.
Is the amplitude of the peak in the power spectrum the value that you
would expect?
7. When you are done, close the VI. Do not save any changes.
5-6
Lesson 5
Measurement
Coherent Gain
The coherent gain of a window is the zero frequency gain (or the dc gain)
of the window. It is calculated by normalizing the maximum amplitude of
the window to one, and then summing the values of the window amplitudes
over the duration of the window. The result is then divided by the length of
the window (that is, the number of samples).
For example, consider the rectangular window shown below with
amplitude equal to A and nine samples:
A
0
You first normalize (divide) all the heights by A to get the maximum
height equal to one:
1
0
Then you add all the heights to get nine (nine lines each with a height
equal to one). This sum is then divided by the number of samples (nine)
to get a value of one. Thus, the CG of the rectangular window is equal
to one. Mathematically, the CG is given by
N1
1
CG = ---N
w[n]
n=0
where N is the total number of samples over the duration of the window
and w[n] are the normalized amplitudes of the samples.
5-7
Lesson 5 Measurement
CG
Uniform (None)
1.00
Hamming
0.54
Hanning
0.5
Triangle
0.5
Exact Blackman
0.46
Blackman
0.42
Blackman-Harris
0.42
4 Term B-Harris
0.36
Flat Top
0.28
7 Term B-Harris
0.27
5-8
Lesson 5
Measurement
Suppose that the solid line in the figure below shows the frequency
response of a window, and the dashed line shows the ideal rectangular
response. The responses are first adjusted to have a gain of unity at zero
frequency (DC).
amplitude
ideal
rectangular
response
frequency
response
of window
ENBW
frequency
ENBW
Uniform (None)
1.00
Hamming
1.36
Hanning
1.5
Triangle
1.33
Exact Blackman
1.57
Blackman
1.73
Blackman-Harris
1.71
4 Term B-Harris
2.00
Flat Top
2.97
7 Term B-Harris
2.63
5-9
Lesson 5 Measurement
Exercise 5-2
Objective: To learn about the Coherent Gain and Equivalent Noise Bandwidth properties of
windows.
This exercise will familiarize you with different window shapes and their
CG and ENBW. The values of the CG and ENBW are used in other
measurement VIs such as the Power and Frequency Estimate VI and
Spectrum Unit Conversion VI.
1. Open the Time Domain Windows VI found in the library
Lvspcex.llb.
2. Open and examine the block diagram.
The VI that windows the input signal (a sine wave generated by the
Sine Wave VI) and gives as the output the resulting windowed
waveform is the Scaled Time Domain Window VI. The
connections to this VI are shown below.
The input time waveform is applied at the Waveform control, and the
window selection is done by the window control. The VI also outputs the
CG and the ENBW of the selected window at the window constants
terminal.
The resulting output waveform is automatically scaled so that when you
compute the amplitude or power spectrum of the windowed waveform,
all the windows will give the same value.
5-10
Lesson 5
Measurement
You will pass the sine wave through two of these VIs and compare the
resulting windowed waveforms.
3. Switch to the front panel.
The Window 1 and Window 2 controls select the two types of windows
that you want to apply to your signal (the sine wave).
The number of samples and the frequency of the sine wave are controlled
by the # samples and frequency controls, respectively. The sampling
frequency is adjusted by the fs control.
The topmost plot shows you the original time domain waveform
(without windowing). The lower two plots show you the signal after
application of the two windows specified in the Window 1 and
Window 2 controls.
4. Select Window 1 as None (Uniform) and Window 2 as Hanning and
run the VI. Leave all the controls at their default values.
Compare the waveforms in Plot 1 and Plot 2 and observe that using
the Uniform window is equivalent to not using any window.
5-11
Lesson 5 Measurement
Observe from Plot 2 and Plot 3 the difference in the windowed time
domain waveform due to the application of the uniform and Hanning
windows, respectively.
Note the differences in the CG and ENBW of the two windows.
5. The shapes of the Hamming and Hanning windows are very close to
each other. Choose these windows in the Window 1 and Window 2
controls. Run the VI and compare the waveforms in Plot 2 and
Plot 3.
Can you notice any difference? Which one is wider? In particular,
compare the values of the ENBW and the CG.
6. As mentioned before, the CG was the same as the DC gain. Choose
different windows and run the VI. Observe that multiplying the
maximum amplitude of the windowed signal by the CG of the
window gives unity.
7. When you finish, close the VI. Do not save any changes.
5-12
Lesson 5
Measurement
D.Harmonic Distortion
When a signal, x(t), of a particular frequency (for example, f1) is passed
through a nonlinear system, the output of the system consists of not only the
input frequency (f1), but also its harmonics (f2 = 2*f1, f3 = 3*f1, f4 = 4*f1,
and so on). The number of harmonics, and their corresponding amplitudes,
that are generated depends on the degree of nonlinearity of the system. In
general, the more the nonlinearity, the higher the harmonics, and vice versa.
f1
nonlinear system
cos3(t)
A 1 + A 2 + A 3 + ...A N
THD = ------------------------------------------------------------A1
100 A 1 + A 2 + A 3 + ...A N
%THD = ---------------------------------------------------------------------------A1
5-13
Lesson 5 Measurement
In the next exercise, you will generate a sine wave and pass it through a
nonlinear system. The block diagram of the nonlinear system is shown
below:
Verify from the block diagram that if the input is x(t) = cos(t), the
output is
y(t) = cos(t) + 0.5cos2(t) + 0.1n(t)
= cos(t) + [1 + cos(2t)]/4 + 0.1n(t)
= 0.25 + cos(t) + 0.25cos(2t) + 0.1n(t)
Therefore, this nonlinear system generates an additional DC component
as well as the second harmonic of the fundamental.
To use this VI, you need to give it the power spectrum of the signal
whose THD you want it to calculate. Thus, in this example, you need to
make the following connections:
5-14
Lesson 5
Measurement
where sum(APS) is the sum of the Auto Power Spectrum elements minus
the elements near DC and near the index of the fundamental frequency.
National Instruments Corporation
5-15
Lesson 5 Measurement
Exercise 5-3
Objective: To use the Harmonic Analyzer VI for harmonic distortion calculations.
1. Open the THD Example VI from the Lvspcex.llb library.
2. Switch to the block diagram.
Some of this will already be familiar to you. Your System is the nonlinear
system that you saw previously. Its output is windowed, and the power
spectrum calculated and given to the Harmonic Analyzer VI.
The Sine Wave VI generates a fundamental of frequency specified in the
fundamental frequency control.
The output of the Harmonic Analyzer VI is in Vrms (if the input from the
Auto Power Spectrum is in V2rms). This output is then squared to convert
it to V2rms.
3. Switch to the front panel.
At the bottom, you see a plot of the power spectrum of the output of
the nonlinear system. On the top right side are the array indicators
for the frequencies and amplitudes of the fundamental and its
harmonics. The size of the array depends on the value entered in the
# harmonics control.
5-16
Lesson 5
Measurement
5-17
Lesson 5 Measurement
Summary
Review Questions
1. Why is it important to know the coherent gain of a window?
2. Which Measurement VIs calculate both the amplitude and phase
spectrum of the input waveform?
3. Name some applications where you would use the Measurement VIs.
4. When a Measurement VI calculates the spectrum of a signal, is it a
one-sided or a two-sided spectrum?
5. What is the peak value corresponding to 2Vrms?
6. Which window has the highest coherent gain? Why?
7. What is the difference between %THD and %THD + Noise? Which
is larger?
5-18
Lesson 5
Measurement
Notes
5-19
Lesson 5 Measurement
Notes
5-20
Lesson 6
Digital Filtering
Introduction
In this lesson, you will learn about the characteristics of different types of
digital filters and how to use them in practical filtering applications.
6-1
A. What Is Filtering?
Filtering is the process by which the frequency content of a signal is altered.
It is one of the most commonly used signal processing techniques. Common
everyday examples of filtering are the bass and treble controls on your
stereo system. The bass control alters the low-frequency content of a signal,
and the treble control alters the high-frequency content. By varying these
controls, you are actually filtering the audio signal. Some other applications
where filtering is useful are removing noise and performing decimation
(lowpass filtering the signal and reducing the sample rate).
6-2
Lesson 6
Digital Filtering
B. Ideal Filters
Filters alter or remove unwanted frequencies. Depending on the frequency
range that they either pass or attenuate, they can be classified into the
following types:
frequency
fc
Lowpass
frequency
fc
Highpass
amplitude
amplitude
amplitude
amplitude
fc1 fc2
Bandpass
frequency
fc1 fc2
Bandstop
frequency
You see that the lowpass filter passes all frequencies below fc, whereas the
highpass filter passes all frequencies above fc. The bandpass filter passes all
frequencies between fc1 and fc2, whereas the bandstop filter attenuates all
frequencies between fc1 and fc2. The frequency points fc, fc1 and fc2 are
known as the cutoff frequencies of the filter. When designing filters, you
need to specify these cut-off frequencies.
fc
Lowpass
freq
SB
PB
fc
Highpass
freq
SB
PB
SB
fc1 fc2
Bandpass
6-3
amplitude
SB
amplitude
PB
amplitude
amplitude
The frequency range that is passed through the filter is known as the
passband (PB) of the filter. An ideal filter has a gain of one (0 dB) in the
passband so that the amplitude of the signal neither increases nor
decreases. The stopband (SB) corresponds to that range of frequencies
that do not pass through the filter at all and are rejected (attenuated). The
passband and the stopband for the different types of filters are shown
below:
freq
PB
SB
PB
fc1 fc2
Bandstop
freq
Note that whereas the lowpass and highpass filters have one passband and
one stopband, the bandpass filter has one passband, but two stopbands, and
the bandstop filter has two passbands, but one stopband.
10
10
30 50
30 50
freq
freq
20
Lowpass
20
Highpass
30 50
20
10
10
30 50
30 50
freq
freq
6-4
freq
10
freq
40
Bandpass
freq
30
20 40
Bandstop
10
50
freq
Lesson 6
Digital Filtering
PB
TR
SB
SB
TR
PB
0dB
-3dB
0dB
-3dB
fc
Lowpass
SB
TR
PB
fc
Highpass
TR
SB
PB
0dB
-3dB
TR
SB
TR
PB
0dB
-3dB
fc1
fc2
Bandpass
fc1
fc2
Bandstop
6-5
amplitude
which means the output amplitude is 1/1000 of the input amplitude. The
following figure, though not drawn to scale, illustrates this concept.
0 dB
1.0
0.9977
-0.02 dB
passband
ripple
stopband
attenuation
0.001
-60 dB
frequency
Note:
6-6
Lesson 6
Digital Filtering
They are software programmable, and so are easy to build and test.
They are stable (do not change with time nor temperature) and
predictable.
6-7
1.0
Filter
amplitude
amplitude
IMPULSE
IMPULSE
RESPONSE
time
Fourier
Transform
amplitude
FREQUENCY
RESPONSE
time
frequency
If the impulse response of the filter falls to zero after a finite amount of time,
it is known as a finite impulse response (FIR) filter. However, if the
impulse response exists indefinitely, it is known as an infinite impulse
response (IIR) filter. Whether the impulse response is finite or not (that is,
whether the filter is FIR or IIR) depends on how the output is calculated.
The basic difference between FIR and IIR filters is that for FIR filters,
the output depends only on the current and past input values, whereas for
IIR filters, the output depends not only on the current and past input
values, but also on the past output values.
As an example, consider a cash register at a supermarket. Let x[k] be the
cost of the kth item that a customer buys, where 1 k N, and N is the
total number of items. The cash register adds the cost of each item to
produce a running total. This running total y[k] , up to the kth item,
is given by
y[k] = x[k] + x[k-1] + x[k-2] + x[k-3] + .....+ x[1]
(1a)
Thus, the total for N items is y[N]. Because y[k] is the total up to the kth
item, and y[k-1] is the total up to the (k-1)st item, you can rewrite
equation (1a) as
y[k] = y[k-1] + x[k]
(1b)
6-8
Lesson 6
Digital Filtering
If you add a sales tax of 8.25%, equations (1a) and (1b) can be
rewritten as
y[k] = 1.0825x[k] + 1.0825x[k-1] + 1.0825 x[k-2] + 1.0825x[k-3] +
... + 1.0825x[1]
(2a)
y[k] = y[k-1] + 1.0825x[k]
(2b)
Note that both equations (2a) and (2b) are identical in describing the
behavior of the cash register. The difference is that whereas (2a) is
implemented only in terms of the inputs, (2b) is implemented in
terms of both the input and the output. Equation (2a) is known as the
nonrecursive, or FIR, implementation. Equation (2b) is known as the
recursive, or IIR, implementation.
Filter Coefficients
In equation (2a), the multiplying constant for each term is 1.0825. In
equation (2b), the multiplying constants are 1 (for y[k-1]) and 1.0825 (for
x[k]). These multiplying constants are known as the coefficients of the
filter. For an IIR filter, the coefficients multiplying the inputs are known as
the forward coefficients, and those multiplying the outputs are known as
the reverse coefficients.
Equations of the form 1a, 1b, 2a, or 2b that describe the operation of the
filter are known as difference equations.
6-9
1
y [ i ] = -----
a0
Ny 1
Nx 1
a [ j ]y [ i j ] +
j=1
b [ k ]x [ i k ]
k=0
(3)
Butterworth filters
Chebyshev filters
6-10
Lesson 6
Digital Filtering
Butterworth Filters
normalized amplitude
f / fNyquist
The region where the output of the filter is equal to 1 (or very close to 1)
is the passband of the filter. The region where the output is 0 (or very
close to 0) is the stopband. The region in between the passband and the
stopband where the output gradually changes from 1 to 0 is the transition
region.
The advantage of Butterworth filters is a smooth, monotonically
decreasing frequency response in the transition region. As seen from the
figure, the higher the filter order, the steeper the transition region.
Chebyshev Filters
The frequency response of Butterworth filters is not always a good
approximation of the ideal filter response because of the slow rolloff
between the passband (the portion of interest in the spectrum) and the
stopband (the unwanted portion of the spectrum). On the other hand,
Chebyshev filters have a smaller transition region than a Butterworth filter
of the same order. However, this is achieved at the expense of ripples in the
passband. Using LabVIEW or BridgeVIEW, you can specify the maximum
6-11
amount of ripple (in dB) in the passband for a Chebyshev filter. The
frequency response characteristics of Chebyshev filters have an equiripple
(ripples all have the same magnitude) magnitude response in the passband,
monotonically decreasing magnitude response in the stopband, and a
sharper rolloff in the transition region as compared to Butterworth filters of
the same order.
amplitude (dB)
f / fNyquist
The advantage of Chebyshev filters over Butterworth filters is the
sharper transition between the passband and the stopband with a
lower-order filter. As mentioned before, this produces smaller absolute
errors and higher execution speeds.
6-12
Digital Filtering
amplitude (dB)
Lesson 6
f / fNyquist
The advantage of Chebyshev II filters over Butterworth filters is that
Chebyshev II filters give a sharper transition between the passband and the
stopband with a lower order filter. This difference corresponds to a smaller
absolute error and higher execution speed. One advantage of Chebyshev II
filters over regular Chebyshev filters is that Chebyshev II filters have the
ripples in the stopband instead of the passband.
Elliptic Filters
You saw that Chebyshev (type I or II) filters have a sharper transition region
than a Butterworth filter of the same order. This is because they allowed
ripples in the passband (type I) or the stopband (type II). Elliptic filters
distribute the ripples over both the passband as well as the stopband.
Equiripples in the passband and the stopband characterize the magnitude
response of elliptic filters. Therefore, compared with the same order
Butterworth or Chebyshev filters, the elliptic design provides the sharpest
transition between the passband and the stopband. For this reason, elliptic
filters are quite popular in applications where short transition bands are
required and where ripples can be tolerated. The following graph plots the
response of a lowpass elliptic filter of different orders. The x-axis scaling is
in terms of f / fNyquist, whereas the y-axis is scaled so that the gain in the
passband is unity.
6-13
normalized amplitude
f / fNyquist
Notice the sharp transition edge for even low-order elliptic filters. For
elliptic filters, you can specify the amount of ripple (in dB) in the
passband as well as the attenuation (in dB) in the stopband.
f/fNyquist
6-14
Lesson 6
Digital Filtering
Response
Characteristics
Butterworth
No ripples
Chebyshev
Ripples in PB
Inverse
Chebyshev
Ripples in SB
Elliptic
Ripples in PB and SB
Widest
Highest
Narrowest
Lowest
The LabVIEW and BridgeVIEW digital filter VIs handle all the design
issues, computations, memory management, and actual data filtering
internally, and are transparent to the user. You do not need to be an
expert in digital filters or digital filter theory to process the data. All you
need to do is to specify the control parameters such as the filter order,
cutoff frequencies, amount of ripple, and stopband attenuation.
6-15
linear phase?
FIR Filter
N
ripple OK?
narrow
transition band?
Y
Elliptic
high order
Butterworth
Y
narrowest possible transition region?
low order
Butterworth
ripple
in PB?
Inv. Chebyshev
ripple
in SB?
Chebyshev
arbitrary
filter specs?
Elliptic
Y
FIR
6-16
Lesson 6
Digital Filtering
Exercise 6-1
Objective:
To filter data samples that consist of both high-frequency noise and a sinusoidal
signal.
In this exercise, you combine a sine wave generated by the Sine
Pattern VI with high-frequency noise. (The high-frequency noise is
obtained by highpass filtering uniform white noise with a
Butterworth filter.) The combined signal is then lowpass filtered by
another Butterworth filter to extract the sine wave.
6-17
6-18
Lesson 6
Digital Filtering
Exercise 6-2
Objective: To compare the frequency response characteristics of various IIR filters.
1. Open the IIR Filter Design VI from the Lvspcex.llb library.
6-19
6-20
Lesson 6
Digital Filtering
6-21
Front Panel
6-22
Lesson 6
Digital Filtering
Block Diagram
6-23
(4)
(5)
To calculate the current output (at the ith instant) of the filter, you need
to know the past two outputs (at the (i-1)st and the (i-2)nd time instants)
as well as the current input (at the i th time instant) and past two inputs
(at the (i-1)st and (i-2)nd time instants).
Now suppose that you have just started the filtering process by taking the
first sample of the input data. However, at this time instant you do not
yet have the previous inputs (x[i-1] and x[i-2]) or previous outputs
(y[i-1] and y[i-2]). So, by default, these values are assumed to be zero.
When you get the second data sample, you already have the previous
input (x[i-1]) and the previous output (y[i-1]) that you calculated from
the first sample, but not yet x[i-2] and y[i-2]. Again, by default, these are
assumed to be zero. It is only after we start processing the third input
data sample that all the terms on the right hand side of equation (5) above
now have the previously calculated values. Thus, there is a certain
amount of delay before which there are calculated values for all the
terms on the RHS of the difference equation describing the filter. The
output of the filter during this time interval is a transient and is known
as the transient response. For lowpass and highpass filters implemented
in the LabVIEW/BridgeVIEW Analysis library, the duration of the
transient response, or delay, is equal to the order of the filter. For
bandpass and bandstop filters, this delay is 2*order.
IIR filters in the analysis library contain the following properties.
6-24
Lesson 6
Digital Filtering
So, each time one of the filter VIs is called, this transient appears at the
output. You can eliminate this transient response on successive calls by
enabling the state memory of the VI. To enable state memory, set the
init/cont control of the VI to TRUE (continuous filtering). You will see
how to do this in a later exercise.
Original Signal
Filtered Signal
The filter retains the internal filter state values when the filtering
completes.
6-25
Exercise 6-4
Objective: To see the difference in the filter response with and without enabling state memory.
1. Open the Low Pass Filter VI from Lvspcex.llb.
2. Run the VI with the values shown on the front panel above, but with
order = 7. (Do not worry about the init/cont (init: F) control for
now.)
Observe the upper Sine Waveform graph, which shows two plots.
The white dashed plot is the combined signal, whereas the green full
line plot is the filtered signal.
3. Change the filter order to 10 and run the VI. Observe the first few
values of the plot corresponding to the filtered signal.
4. Change the filter order to 15, 20, and 25, and run the VI. Each time,
observe the transient that occurs at the beginning of the plot
corresponding to the filtered signal. This transient can be removed
after the first call to the VI by enabling its state memory. This is done
by setting the init/cont control of the VI to TRUE. Setting this
control to TRUE is equivalent to continuous filtering, and except for
the first call to the VI, each successive call will not have the
transient.
6-26
Lesson 6
Digital Filtering
6. With the init/cont(init:F) control set to OFF, and order = 15, run the
VI several times. Note the presence of the transient at the beginning
of the filtered signal each time the VI runs.
7. Now set the init/cont(init:F) control to ON, and run the VI several
times. Observe that the transient is present only the first time that the
VI is run. On successive calls to the VI, the transient no longer exists.
8. When you finish, save the VI.
6-27
1.20
1.00
0.80
0.60
0.40
0.20
f (Hz)
0.00
0.00
0.10
0.20
0.30
0.40
0.50
Phase(radians)
(radians)
Phase
0.0
-2.0
-4.0
-6.0
-8.0
-10.0
f (Hz)
-12.0
0.00
0.10
6-28
0.20
0.30
0.40
0.50
Lesson 6
Digital Filtering
Exercise 6-5
Objective: To see the frequency response characteristics of FIR filters.
In this exercise, you will see the magnitude and phase response
characteristics of FIR filters. You will also see the effect of using different
windows on the filter response characteristics.
1. Open the FIR Windowed Filter Design VI from Lvspcex.llb.
6-29
The Magnitude and Phase plots show you the magnitude and phase
response of the filter. Note that because the filter under consideration is
an FIR filter, it is expected to have a linear phase response.
2. Observe the block diagram.
6-30
Lesson 6
Digital Filtering
You are not using any window on the input signal (that is, you are using
a rectangular window) that is sampled at 100 Hz.
3. Run the VI with the default values. Observe the linear phase
response in the passband.
4. Select different types of windows using the window control and
observe both the magnitude and phase responses. Notice how the
choice of a window affects both the responses. The phase in all cases
will be linear.
The taps control affects the width of the transition region.
5. Observe the Magnitude response plot with the Filter Type control set
to lowpass filter, the low cutoff frequency: fl set to 15 Hz, sampling
frequency: fs set to 100 Hz, window set to Kaiser-Bessel, and taps
set to 33.
6. Change taps to 55 and observe how the transition region becomes
narrower.
7. Change taps to 10 and observe the increase in the width of the
transition region.
8. You can experiment with different values of the other controls.
When you are done, stop the VI by clicking on the STOP button in
the lower right corner.
9. Close the VI without saving any changes.
6-31
6-32
Lesson 6
Digital Filtering
Summary
For practical filters, the gain in the passband may not always be
equal to 1, the attenuation in the stopband may not always be -, and
there exists a transition region of finite width.
The width of the transition region depends on the filter order, and the
width decreases with increasing order.
The output of FIR filters depends only on the current and past input
values, whereas the output of IIR filters depends on the current and
past input values as well as the past output values.
Review Questions
1. Name three practical examples where filtering is used.
2. If the stopband attenuation of a filter is -80 dB, what is the output of
the filter to an input signal of 5 V peak if the frequency of the signal
lies in the stopband of the filter?
3. Which filter would you use for the following applications?
a. When you want the narrowest possible transition region with the
smallest order.
b. When you cannot tolerate any ripples in either the passband or
the stopband.
c. When linear phase is important.
4. Why does a transient initially appear at the output of a filter? How
can it be eliminated on successive calls to a VI?
6-33
Notes
6-34
Lesson 7
Curve Fitting
Introduction
In this lesson, you will learn about the Analysis VIs that are used to fit
curves to data points.
7-1
Note that y[i] is a function of both the parameters ak, as well as the data
x[i]. The following discussion refers to the terms linear and nonlinear
often. These terms refer to the relationship between y and a, and not y
and x.
The Analysis library offers both linear and nonlinear curve fitting
algorithms. The different types of curve fitting in LabVIEW are outlined
below:
7-2
Lesson 7
Curve Fitting
The least squares algorithm estimates the values for a from the values of
y[i] and x[i]. After you have the values for a, you can obtain an estimate
of the observed data set for any value of x using the functional
description f(x,a). The curve fitting VIs automatically set up and solve
the necessary equations and return the set of coefficients that best
describes your data set. You can thus concentrate on the functional
description of your data and not worry about the methods used for
solving for a.
For each of the observed data points x[i], the differences between the
polynomial value f(x[i],a) and the original data y(x[i]) are called the
residuals and are given by
ei(a) = fi(x[i],a) - yi(x[i])
National Instruments Corporation
7-3
1
MSE = ---N
N1
1
( f i y i ) = ---N
2
i=0
(e (a))
i=0
Integration of digital data (for example, to find the area under a curve
when you have only the discrete points of the curve).
7-4
Lesson 7
Curve Fitting
Exercise 7-1
OBJECTIVE: To perform a linear curve fit on experimental data.
Front Panel
7-5
Block Diagram
7-6
Lesson 7
Curve Fitting
Exercise 7-2
OBJECTIVE: To perform a polynomial curve fit on experimental data.
Front Panel
7-7
Block Diagram
7-8
Lesson 7
Curve Fitting
Exercise 7-3
OBJECTIVE: To use and compare the Linear, Exponential and Polynomial Curve Fit VIs to obtain
the set of least square coefficients that best represent a set of data points.
1. Open the Regressions Demo VI from the library Lvspcex.llb.
The front panel and block diagram are already built for you.
Front Panel
7-9
Block Diagram
2. Select Linear in the Algorithm Selector control, and set the Noise
Level control to about 0.1. Run the VI. Note the spread of the data
points and the fitted curve (straight line).
3. Experiment with different values of Order and Noise Level. What do
you notice? How does the mse change?
4. Change the Algorithm Selector to Exponential and run the VI.
Experiment with different values of Order and Noise Level. What do
you notice?
5. Change the Algorithm Selector to Polynomial and run the VI.
Experiment with different values of Order and Noise Level. What do
you notice?
7-10
Lesson 7
Curve Fitting
7-11
The data that you collect (x[i] and y[i]) is to be given to the inputs H and
Y Values. The Covariance output is the matrix of covariances between
the coefficients ak, where cij is the covariance between ai and aj, and ckk
is the variance of ak. At this stage, you need not be concerned about the
inputs Standard Deviation, covariance selector, and algorithm. For
7-12
Lesson 7
Curve Fitting
now, you will just use their default values. You can refer to the LabVIEW
Analysis VI Reference Manual for more details on these inputs.
The matrix H is known as the observation matrix and will be explained
in more detail later. Y Values is the set of observed data points y[i]. For
example, suppose you have collected samples (Y Values) from a
transducer and you want to solve for the coefficients of the model:
y = a o + a 1 sin ( x ) + a 2 cos ( x ) + a 3 x
H =
1 sin ( x 0 ) cos ( x 0 ) x 0
1 sin ( x 1 ) cos ( x 1 ) x 1
1 sin ( x 2 ) cos ( x 2 ) x 2
1 sin ( x 99 ) cos ( x 99 ) x 99
If you have N data points and k coefficients (a0, a1, ....ak-1) for which to
solve, H will be an N-by-k matrix with N rows and k columns. Thus, the
number of rows of H is equal to the number of elements in Y Values,
whereas the number of columns of H is equal to the number of
coefficients for which you are trying to solve.
In practice, H is not available and must be built. Given that you have the
N independent X Values and observed Y Values, the following block
diagram demonstrates how to build H and use the General LS Linear
Fit VI.
7-13
Exercise 7-4
OBJECTIVE: To learn how to set up the input parameters and use the General LS Linear Fit VI.
This exercise demonstrates how to use the General LS Linear Fit VI to
obtain the set of least square coefficients a and the fitted values, and also
how to set up the input parameters to the VI.
The purpose is to find the set of least square coefficients a that best
represent the set of data points (x[i], y[i]). As an example, suppose you
have a physical process that generates data using the relationship
y = 2h 0 ( x ) + 3h 1 ( x ) + 4h 2 ( x ) + noise
(1)
where
2
h 0 ( x ) = sin ( x ),
h 1 ( x ) = cos ( x ),
1
h 2 ( x ) = ------------ , and
x+1
noise is a random value. Also, assume you have some idea of the general
form of the relationship between x and y, but are not quite sure of the
coefficient values. So, you may think that the relationship between x and
y is of the form
y = a0 f0 ( x ) + a1 f1 ( x ) + a2 f2 ( x ) + a3 f3 ( x ) + a4 f4 ( x )
(2)
where
f o ( x ) = 1.0,
2
f 1 ( x ) = sin ( x ),
f 2 ( x ) = 3 cos ( x ),
1
f 3 ( x ) = ------------ ,
x+1
f4 ( x ) = x
7-14
Lesson 7
Curve Fitting
experiment. A simple way to build the matrix H is to use the Formula Node
as shown in the following block diagram.
You can easily edit the formula node to change, add, or delete functions.
At this point, you have all the necessary inputs to use the General LS
Linear Fit VI to solve for a. To obtain equation (1) from equation (2),
you need to multiply f0(x) by 0.0, f1(x) by 2.0, f2(x) by 1.0, f3(x) by 4.0
and f4(x) by 0.0. Thus, looking at equations (1) and (2), note that the
expected set of coefficients are
a = { 0.0, 2.0, 1.0, 4.0, 0.0 }
7-15
Linear Fit. Executing the General LS Linear Fit VI with the values of
X, Y, and H returns the following set of coefficients.
You will now see the VI in which this particular example has been
implemented.
1. Open the General LS Fit Example VI from the library
Lvspcex.llb.
2. Examine the block diagram and the front panel.
noise amplitude: can change the amplitude of the noise added to the
data points. The larger this value, the more the spread of the data
points.
NumData: the number of data points that you want to generate.
algorithm: provides a choice of six different algorithms to obtain the
set of coefficients and the fitted values. In this particular example,
there is no significant difference among different algorithms. You
can select different algorithms from the front panel to see the results.
In some cases, different algorithms may have significant differences,
depending on your observed data set.
7-16
Lesson 7
Curve Fitting
MSE: gives the mean squared error. The smaller the MSE, the better
the fit.
error: gives the error code in case of any errors. If error code = 0, it
indicates no error. For a list of error codes, see the appendix.
Coefficients: the calculated values of the coefficients (a0, a1, a2, a3,
and a4) of the model.
3. Run the VI with progressively larger values of the noise amplitude.
What happens to the observed data plotted on the graph? What about
the MSE?
4. For a fixed value of noise amplitude, run the VI by choosing
different algorithms from the algorithm control. Do you find that any
one algorithm is better than the other? Which one gives you the
lowest MSE?
5. When you finish, close the VI. Do not save any changes.
7-17
Exercise 7-5
OBJECTIVE: To predict production costs using the General LS Linear Fit VI.
The VIs that you have seen so far have been used to fit a curve to a function
of only one variable. In this exercise, you will use the General LS Linear
Fit VI to fit a curve to a multivariable function. In particular, the function
will have two variables, X1 and X2. You can, however, generalize it to
functions of three or more variables.
Suppose you are the manager of a bakery and want to estimate the total
cost (in dollars) of a production of baked scones using the quantity
produced, X1, and the price of one pound of flour, X2. To keep things
simple, the following five data points form this sample data table.
Cost (dollars)
Quantity
Flour Price
X1
X2
$150
295
3.00
$75
100
3.20
$120
200
3.10
$300
700
2.80
$50
60
2.50
295
100
200
700
60
3.00
3.20
3.10
2.80
2.50
7-18
Lesson 7
Curve Fitting
Block Diagram
7-19
Front Panel
After running the Predicting Cost VI, the following coefficients are
obtained.
and the resulting equation for the total cost of scone production is
therefore:
Y=-20.34 + 0.38X1 + 19.05X2
4. Experiment with different values of X2 (flour price).
5. When you finish, close the VI. Do not save any changes.
7-20
Lesson 7
Curve Fitting
When using the Nonlinear Lev-Mar Fit VI, you also need to specify the
nonlinear function in the Formula Node on the block diagram of the
Target Fnc and Deriv NonLin VI.
The connections to the Nonlinear Lev-Mar Fit VI are shown below:
7-21
Exercise 7-6
OBJECTIVE: To create a general exponential signal a*exp(b*x) + c + noise. Then, use the
Nonlinear Lev-Mar Fit VI to fit the data and get the best guess coefficients a, b,
and c of the general exponential signal.
In this exercise, you will see how to use the Nonlinear Lev-Mar Fit VI to
determine the coefficients a, b, and c, of a nonlinear function given by
a*exp(b*x) + c.
1. Open the Nonlinear Lev-Mar Exponential Fit VI from the library
Lvspcex.llb. The front panel is shown below.
Front Panel
7-22
Lesson 7
Curve Fitting
Block Diagram
7-23
Observe the formula node at the bottom. It has the form of the
function whose parameters (a0, a1, and a2) you are trying to
evaluate.
5. Close the front panel and the block diagram of the Target Fnc and
Deriv NonLin VI.
6. Run the NonLinear Lev-Mar Exponential Fit VI. Note that the
values of the coefficients returned in Best Guess Coef are very close
to the actual values entered in the Initial Coefficients control. Also
note the value of the mse.
7. Increase the noise level from 0.1 to 0.5. What happens to the mse and
the coefficient values in Best Guess Coef? Why?
8. Change the noise level back to 0.1 and the Initial Coefficients to 5.0,
-2.0, and 10.0, and run the VI. Note the values returned in the Best
Guess Coef and the mse indicators.
9. With the noise level still at 0.1, change your guess of the Initial
Coefficients to 5.0, 8.0, and 10.0, and run the VI. This time, your
guess is further away than the one you chose in step 4. Note the error!
This goes to show how important it is to have a reasonably educated
guess for the coefficients.
10. When you finish, close the VI. Do not save any changes.
7-24
Lesson 7
Curve Fitting
(3)
As seen from the figure, the curve is bell shaped and is symmetric about the
mean, . The peak of the curve occurs at . The standard deviation, ,
determines the spread of the curve around the mean. The smaller the value
of , the more concentrated the curve around the mean, the higher the peak
at the mean, and the steeper the descents on both sides.
If you have data that is Normally distributed, you will find that the
standard deviation is an important parameter in determining the limits
within which a certain percentage of your data values are expected to
occur. For example,
1. About two-thirds of the values will lie between - and +.
2. About 95% of the values will lie between -2 and +2.
7-25
3. About 99.75% of the values will lie between -3 and +3. Thus,
you see that almost all the data values lie between -3 and +3. This
is illustrated in the figures below:
68%
16%
16%
+
95.5%
2.25%
2.25%
+ 2
99.76%
0.12%
0.12%
+ 3
Notice that the two parameters that completely describe Gaussian data
are the mean and the standard deviation of the data. If you believe your
data has a Gaussian distribution, you could determine its mean and
standard deviation. This has numerous applications, such as determining
whether:
The dimensions of products being manufactured (for example,
thickness of plates) are to within specified limits.
The values of components (for example, resistance of resistors) are
to within a specified tolerance.
LabVIEW Signal Processing Course Manual
7-26
Lesson 7
Curve Fitting
Exercise 7-7
Objective:
7-27
Block Diagram
7-28
Lesson 7
Curve Fitting
4. Modify the block diagram of the Target Fnc & Deriv Nonlin VI as
shown below.
Block Diagram
1.0
mean
0.0
noise level
0.1
7-29
7-30
Lesson 7
Curve Fitting
Summary
Review Questions
1. Name five applications of curve fitting.
2. Which curve fitting VI would you use to determine the parameters
(denoted by the ai...i integer) of the following models?
a. y = a0exp(a1x)
b. y = a0exp(a1x) + a2
c. y = a1x + a2x2
a
x+1
3
d. y = a1sin(x) + a2cos(x) = -----------
7-31
Notes
7-32
Lesson 8
Linear Algebra
Introduction
In this lesson, you will learn the basic theory behind the Linear Algebra VIs
in the Analysis library and how these VIs can be used in different
applications. Matrix computations, such as matrix-matrix multiplication
and many others discussed throughout this lesson, form a significant
component of linear algebra and are very important in analysis. The VIs
discussed in this lesson form the basis of different algorithms used in many
DSP, control, and measurement applications. Therefore, it is important that
you completely understand the theory and different VIs discussed in this
lesson.
8-1
Types of Matrices
Whatever the application, it is always necessary to find an accurate solution
for the system of equations in a very efficient way. In matrix-vector
notation, such a system of linear algebraic equations has the form Ax = b,
where A is an n n matrix, b is a given vector consisting of n elements, and
x is the unknown solution vector to be determined. A matrix is represented
by a 2D array of elements. These elements may be real numbers, complex
numbers, functions, or operators. The matrix A shown below is an array of
m rows and n columns with m n elements.
A =
a 0, 0
a 0, 1
a 0, n 1
a 1, 0
a 1, 1
a 1, n 1
a m 1, 0 a m 1, 1 a m 1, n 1
Here, ai,j denotes the (i,j)th element located in the ith row and the jth
column. In general, such a matrix is called a rectangular matrix. When
m = n , so that the number of rows is equal to the number of columns, it
is called a square matrix. An m 1 matrix (m rows and one column) is
called a column vector. A row vector is a 1 n matrix (1 row and n
columns). If all the elements other than the diagonal elements are zero
(that is, ai,j = 0, i j ), such a matrix is called a diagonal matrix. For
example,
4 0 0
A = 0 5 0
0 0 9
8-2
Lesson 8
Linear Algebra
Determinant of a Matrix
One of the most important attributes of a matrix is its determinant. In
the simplest case, the determinant of a 2 x 2 matrix A = a b is given
c d
= 253
= 2 1 7 5 6 7 + 3 6 1
6 1 7
1 9
1 6
69
1 6 9
= 2 ( 33 ) 5 ( 47 ) + 3 ( 35 )
=-196
The determinant tells many important properties of the matrix. For
example, if the determinant of the matrix is zero, then the matrix is
singular. In other words, the above matrix (with nonzero determinant) is
nonsingular. You will revisit the concept of singularity later in section
C, when the lesson discusses the solution of linear equations and matrix
inverses.
Transpose of a Matrix
The transpose of a real matrix is formed by interchanging its rows and
columns. If the matrix B represents the transpose of A, denoted by AT, then
bj,i=ai,j . For the matrix A defined above,
2 6 1
T
B = A = 5 1 6
3 7 9
8-3
y = 3
4
Notice that 1 = 0 and 2 = 0 are the only values for which the relation
1 x + 2 y = 0 holds true. Hence, these two vectors are linearly
independent of each other. Now, consider vectors
x = 1
2
y = 2
4
8-4
Lesson 8
Linear Algebra
other columns. Hence, the rank of the matrix is 3. Consider one more
example matrix, B, where
0 1 1
B = 1 2 3
2 0 2
This matrix has only two linearly independent columns, because the
third column of B is linearly dependent on the first two columns. Hence,
the rank of this matrix is 2. It can be shown that the number of linearly
independent columns of a matrix is equal to the number of independent
rows. So, the rank can never be greater than the smaller dimension of the
matrix. Consequently, if A is an n m matrix, then
( A ) min ( n, m )
where min denotes the minimum of the two numbers. In matrix theory,
the rank of a square matrix pertains to the highest order nonsingular
matrix that can be formed from it. Remember from the earlier discussion
that a matrix is singular if its determinant is zero. So, the rank pertains
to the highest order matrix that you can obtain whose determinant is not
zero. For example, consider a 4 x 4 matrix
1
B = 0
1
1
2
1
0
1
3
1
1
0
4
0
2
2
= 1
Hence, the rank of B is 3. A square matrix has full rank if and only if its
determinant is different from zero. Matrix B is not a full-rank matrix.
8-5
There are several ways to compute the norm of a matrix. These include
the 2-norm (Euclidean norm), the 1-norm, the Frobenius norm (F-norm),
and the Infinity norm (inf-norm). Each norm has its own physical
interpretation. Consider a unit ball containing the origin. The Euclidean
norm of a vector is simply the factor by which the ball must be expanded
or shrunk to encompass the given vector exactly. This is shown in the
figures below:
22
22
1
2
Figure 1a
Figure 1b
Figure 1c
8-6
Lesson 8
Linear Algebra
Some matrix norms are much easier to compute than others. The 1-norm
is obtained by finding the sum of the absolute value of all the elements
in each column of the matrix. The largest of these sums is called the
1-norm. In mathematical terms, the 1-norm is simply the maximum
absolute column sum of the matrix.
n1
= max j
i, j
i=0
For example, A = 1 3
2 4
= max i
i, j
j=0
In this case, you add the magnitudes of all elements in each row of the
matrix. The maximum value that you get is called the inf-norm. For the
above example matrix, A = max ( 4, 6 ) = 6 .
The 2-norm is the most difficult to compute because it is given by the
largest singular value of the matrix. Singular values are discussed in
Section D, and Exercise 8-9 verifies the validity of the above statement.
1
p
where p can be one of the four norm types discussed above. For example,
to find the condition number of a matrix A, you can find the 2-norm of
A, the 2-norm of the inverse1 of the matrix A, denoted by A-1, and then
multiply them together. As mentioned earlier, the 2-norm is difficult to
calculate on paper. You can use the Matrix Norm VI from the Analysis
library to compute the 2-norm. For example,
1
A = 1 2 , A = 2 1 , A
3 4
1.5 0.5
= 5.4650, A
1
2
1. The inverse of a square matrix A is a square matrix B such that AB=I, where I is the identity matrix.
Matrix inverses and their applications are described in more detail later in section C.
8-7
The condition number can vary between 1 and infinity. A matrix with a
large condition number is nearly singular, while a matrix with a
condition number close to 1 is far from being singular. The matrix A
above is nonsingular. However, consider the matrix B =
1 0.99
1.99 2
The condition number of this matrix is 47168, and hence the matrix is
close to being singular. As you might recall, a matrix is singular if its
determinant is equal to zero. However, the determinant is not a good
indicator for assessing how close a matrix is to being singular. For the
matrix B above, the determinant (0.0299) is nonzero; however, the large
condition number indicates that the matrix is close to being singular.
Remember that the condition number of a matrix is always greater than
or equal to one; the latter being true for identity and permutation
matrices1. The condition number is a very useful quantity in assessing
the accuracy of solutions to linear systems.
In this section, you have become familiar with some basic notation and
fundamental matrix concepts such as determinant of a matrix and its
rank. The following exercise should help you further understand these
terms, which will be used frequently throughout the rest of the lesson.
1. A permutation matrix is an identity matrix with some rows and columns exchanged.
8-8
Lesson 8
Linear Algebra
Exercise 8-1
Objective:
8-9
V =
n1
n1
t0
t0 t0
t1
t1 t1
2
tn 1 tn 1
n1
tn 1
8-10
Lesson 8
Linear Algebra
Block Diagram
3. Open the block diagram for this VI and complete it as shown above.
Matrix Condition Number VI (Analysis Linear Algebra
Advanced Linear Algebra subpalette). In this exercise, this
function computes the matrix condition number.
Determinant VI (Analysis Linear Algebra subpalette). In this
exercise, this function computes the matrix determinant.
Matrix Rank VI (Analysis Linear Algebra Advanced
Linear Algebra subpalette). In this exercise, this function
computes the matrix rank.
Bundle function (Cluster subpalette) In this exercise, this
function assembles the population array and the year array to
plot the population array against the year array.
8-11
8-12
Lesson 8
Linear Algebra
built for you. You need only complete the subdiagram in Case
((t-1940)/40)^j.
8-13
11. You will now use the matrices (computed in the Construct Matrices
VI) to calculate the population for any year between 1900 and 1980.
To do so, open the Compute Population VI from Lvspcex.llb.
This VI computes a polynomial to interpolate the data values to the
population data. It then computes the population for a specified year
using the Horners nested evaluation scheme1.
12. Return to the front panel for the VI opened in step 10. Set the
choose year control to 1950. Using each of the four polynomial
functions, run the VI to compute the population for this year. The red
dot on the population graph shows the population value for the year
chosen. Which of these values is closest to the true value of
151,325,798, according to the 1950 census?
13. Save the VI and close it.
1. For more information on this method, refer to Scientific Computing, An Introduction Survey by M.T.
Heath, McGraw-Hill, 1997.
8-14
Lesson 8
Linear Algebra
Exercise 8-2
Objective: To study special matrices.
In this exercise, you will learn to use the Create Special Matrix VI in
the Analysis library. Examine the different types of special matrices that
this VI creates. Note that this VI also generates the Vandermonde matrix
used in the previous exercise.
Front Panel
1. Build the front panel as shown above. You can resize the
two-dimensional matrices D, U, and L to see all the elements in the
matrix.
8-15
Block Diagram
8-16
Lesson 8
Linear Algebra
value? If yes, what is it? If no, take a close look at the diagonal
elements of the matrix D.
8. Select the Upper Lower Symmetric Matrix VI from
Lvspcex.llb. Set Select Matrix Type = 0 (upper triangular
matrix). Set matrix Size = 6. Wire the matrix D to the input matrix
terminal. The output matrix U is an upper triangular matrix.
The determinant for all the three matrices is equal to the product of the
diagonal elements of the matrices.
8-17
For example,
2 1 2 = 2 4
3 4
6 8
Two (or more) matrices can be added or subtracted if and only if they
have the same number of rows and columns. If both matrices A and B
have m rows and n columns, then their sum C is an m-by-n matrix
defined as C = A B , where c i, j = a i, j bi, j . For example,
1 2 + 2 4 = 3 6
3 4
5 1
8 5
c i, j =
i , k b k, j
k=0
For example,
1 2 2 4 = 12 6
3 4
5 1
26 16
8-18
Lesson 8
Linear Algebra
So, you multiply the elements of the first row of A by the corresponding
elements of the first column of B and add all the results to get the
elements in the first row and first column of C. Similarly, to calculate
the element in the ith row and the jth column of C, multiply the elements
in the ith row of A by the corresponding elements in the jth column of C,
and then add them all. This is shown pictorially as:
R1
Cm
R1 C1
R1 Cm
Rn C1
Rn Cm
C1
Rn
XY =
x y
i i
i=0
8-19
a=2i+4j
= 36.86
b=2i+j
Force a
Body
On the other hand, the outer product of these two vectors is a matrix. The
(i,j)th element of this matrix is obtained using the formula
a i, j = x i y j
For example, 1 3 = 3 4
2
6 8
8-20
Lesson 8
Linear Algebra
1.00
8-21
The eigenvalues of a diagonal matrix are its diagonal entries, and the
eigenvectors are the corresponding columns of an identity matrix of
the same dimension.
1. General Matrix: A matrix with no special property such as symmetry or triangular structure.
8-22
Lesson 8
Linear Algebra
Exercise 8-3
Objective: To learn basic matrix manipulations
You will build a VI that will help you further understand the basic matrix
manipulations discussed in the first part of the previous section. You will
also learn some very interesting matrix properties.
1. Build the front panel as shown above. You can resize the
two-dimensional matrices A, B, and C to see all the elements in the
matrix.
2. In this exercise, you will experiment with three different types of
matrices, namely upper triangular, lower triangular, and symmetric
matrix. You will use the Upper Lower Symmetric Matrix VI that
you used in the previous exercise.
8-23
8-24
Lesson 8
Linear Algebra
1. Description of Error Code -20039: The number of columns in the first matrix is not equal to the number
of rows in the second matrix or vector.
8-25
Exercise 8-4
Objective: To study positive definite matrices.
In many applications, it is advantageous to determine if your matrix is
positive definite. This is because if your matrix is indeed positive
definite, you can save a significant amount of computation time when
using VIs to compute determinants, solve linear systems of equations, or
compute the inverse of a matrix. All these VIs let you choose the matrix
type, and properly identifying the matrix can significantly improve
performance.
In this exercise, you will learn about complex positive definite matrices.
A complex matrix is positive definite if and only if it is Hermitian; that
is, A = A H , and the quadratic form X H AX > 0 for all nonzero vectors X.
Front Panel
1. Build the matrix A and the rest of the front panel as shown in the front
panel above.
2. Switch to the block diagram and use the Test Complex Positive
Definite VI to check if this matrix is positive definite.
Test Complex Positive Definite VI (Analysis Linear
Algebra Complex Linear Algebra Advanced Complex
Linear Algebra subpalette). Use this function to check if the
input matrix A is positive definite.
3. Enter the vector X shown below in the array of controls x.
x =
2.34 + 9.8i
1.23 + 4.5i
3.45 4.56i
8-26
Lesson 8
Linear Algebra
8-27
Exercise 8-5
Objective: To compute the eigenvalues and eigenvectors of a real matrix.
As explained earlier, the eigenvalues-eigenvector problem is widely
used in a number of different practical applications. For example, in the
design of control systems, the eigenvalues help determine whether the
system is stable or unstable. If all the eigenvalues have nonpositive real
parts, the system is stable. However, if any of the eigenvalues have a
positive real part, it means that the system is unstable. If the system is
unstable, you can design a feedback system to obtain the desired
eigenvalues and ensure stability of the overall system.
In this exercise, you will use the EigenValues and Vectors VI to
compute all the eigenvalues and eigenvectors of a real matrix. You will
also learn an alternative definition of eigenvalues and numerically verify
this definition.
1. Build the front panel as shown above. You can resize the controls to
view all the elements in the matrices A and EigenVectors and the
array EigenValues. The size of the matrix A is 10 10 .
Eigenvalues is a one-dimensional complex array of size 10
containing all the computed eigenvalues of the input matrix.
Eigenvectors is a 10 10 complex matrix containing all the
computed eigenvectors of the input matrix. The ith column of
Eigenvectors is the eigenvector corresponding to the ith component
of the Eigenvalues vector.
8-28
Lesson 8
Linear Algebra
8-29
5. Run the VI several times. You will notice that the eigenvalues can be
real or complex numbers although the matrix is purely real. The same
holds true for the eigenvectors also. Furthermore, you will notice
that complex eigenvalues of a real matrix always occur in complex
conjugate pairs (that is, if + i is an eigenvalue of a real matrix, so
is i ).
6. Did the definition stated above in step 3 always hold true?
7. Save the VI as My EigenValues and Vectors.vi and close it.
8-30
Lesson 8
Linear Algebra
A A = AA
= I
where I is the identity matrix. The inverse of a matrix exists if and only
if the determinant of the matrix is not zero (that is, it is nonsingular). In
general, you can find the inverse of only a square matrix. You can,
however, compute the pseudoinverse of a rectangular matrix, as
discussed later in section D.
Az = 0
8-31
use the Gaussian Elimination1 technique. The three basic steps involved
in the Gaussian Elimination technique are as follows. First, express the
matrix A as a product A = LU where L is a unit lower triangular matrix
and U is an upper triangular matrix. Such a factorization is known as LU
factorization. Given this, the linear system Ax = b can be expressed as
LUx = b . Such a system can then be solved by first solving the lower
triangular system Ly = b for y by forward-substitution. This is the
second step in the Gaussian Elimination technique. For example, if
L = a 0
b c
y = p
q
b = r
s
s bp )
then p = --r- ,q = (------------------ . The first element of y can be easily determined
a
due to the lower triangular nature of the matrix L. Then you can use this
value to compute the remaining elements of the unknown vector
sequentially. Hence, the name forward-substitution. The final step
involves solving the upper triangular system Ux = y by
back-substitution. For example, if
U = a b
0 c
x = m
n
y = p
q
p bn )
then n = q---, m = (------------------- . In this case, this last element of x can be easily
c
1. For more information on Gaussian Elimination, see Matrix Computations by G.H. Golub and C.F. Van
Loan. The John Hopkins University Press, Baltimore, 1989.
T
2. A real matrix is positive definite if and only if it is symmetric and the quadratic form X AX > 0 for all
nonzero vectors X.
8-32
Lesson 8
Linear Algebra
Exercise 8-6
Objective: To compute the inverse of a matrix.
You will build a VI that computes the inverse of a matrix A. Further, you
will compute a matrix B, which is similar to matrix A. A matrix B is similar
to a matrix A if there is a nonsingular matrix T such that B = T1 AT so that
A and B have the same eigenvalues. You will verify this definition of similar
matrices.
Front Panel
8-33
Block Diagram
8-34
Lesson 8
Linear Algebra
Exercise 8-7
Objective: To solve a system of linear equations.
Many practical applications require you to solve a system of linear
equations. A very important area of application is related to military
defense. This includes analysis of electromagnetic scattering and radiation
from large targets, performance analysis of large radomes, and design of
aerospace vehicles having low radar cross sections (the stealth technology).
A second area of application is in the design and modeling of wireless
communication systems such as hand-held cellular phones. This list of
applications goes on and on, and therefore it is very important for you to
properly understand how to use the VIs in the Analysis library to solve a
linear system of equations.
2
2 4 2
4 9 3 , b = 8
10
2 1 7
8-35
D.Matrix Factorization
The previous section discussed how a linear system of equations can be
transformed into a system whose solution is simpler to compute. The basic
idea was to factorize the input matrix into the multiplication of several,
simpler matrices. You looked at one such technique, the LU decomposition
technique, in which you factorized the input matrix as a product of upper
and lower triangular matrices. Other commonly used factorization methods
are Cholesky, QR, and the Singular Value Decomposition (SVD). You can
use these factorization methods to solve many matrix problems, such as
solving linear system of equations, inverting a matrix, and finding the
determinant of a matrix.
If the input matrix A is symmetric and positive definite, then an LU
factorization can be computed such that A = U T U , where U is an upper
triangular matrix. This is called Cholesky factorization. This method
requires only about half the work and half the storage compared to LU
factorization of a general matrix by Gaussian elimination. As you saw
earlier in Exercise 1-4, it is easy to determine if a matrix is positive
definite by using the Test Positive Definite VI in the Analysis library.
A matrix Q is orthogonal if its columns are orthonormal. That is, if
T
Q Q = I , the identity matrix. QR factorization technique factors a matrix
as the product of an orthogonal matrix Q and an upper triangular matrix
R. That is, A = QR . QR factorization is useful for both square and
rectangular matrices. A number of algorithms are possible for QR
factorization, such as the Householder transformation, the Givens
transformation and the fast Givens transformation.
The singular value decomposition (SVD) method decomposes a matrix
into the product of three matrices: A = USV T . U and V are orthogonal
matrices. S is a diagonal matrix whose diagonal values are called the
singular values of A. The singular values of A are the nonnegative square
roots of the eigenvalues of A T A , and the columns of U and V, which are
called left and right singular vectors, are orthonormal eigenvectors of
T
T
AA and A A , respectively. SVD is useful for solving analysis problems
such as computing the rank, norm, condition number, and pseudoinverse
of matrices. The following section discusses this last application.
Pseudoinverse
The pseudoinverse1 of a scalar is defined as 1 if 0 , and zero
otherwise. You can now define the pseudoinverse of a diagonal matrix by
transposing the matrix and then taking the scalar pseudoinverse of each
8-36
Lesson 8
Linear Algebra
8-37
Exercise 8-8
Objective: To compute Cholesky decomposition and QR decomposition.
Exercise 1-4 discussed complex positive definite matrices. You verified that
the matrix A
A =
139
91.30 + 47.06i 67.64 + 62.35i
91.30 47.06i
152.41
94.32 + 47.52i
67.64 62.35i 94.32 47.52i
262.00
Front Panel
1. Build the front panel as shown above. You can resize the array of
controls to see all the elements of the matrix.
2. The matrix U is an upper triangular matrix that is the result of the
Cholesky Decomposition of the matrix A.
3. The matrix B is a rectangular matrix. That is, the number of rows m
is different from the number of columns n. The result of the QR
factorization is an m m orthogonal matrix Q and an upper triangular
matrix R of size m n .
4. In this exercise, you will also verify the definition of orthogonal
matrices, Q T Q = I . The Result matrix contains the product of the
transpose of the orthogonal matrix and the orthogonal matrix itself.
8-38
Lesson 8
Linear Algebra
Block Diagram
8-39
9. Choose a value for the number of rows and the number of columns.
Run the VI. Notice the upper triangular structure of the output of the
Cholesky decomposition and the R output of the QR factorization.
Notice the structure of the orthogonal matrix Q. You can run the VI
a number of times to generate different matrices and check if this
definition is true.
10. Save the VI as QR Factor.vi and close it.
8-40
Lesson 8
Linear Algebra
2
5
8
11
3
6
9
12
8-41
Summary
Review Questions
0 1 1
8-42
Lesson 8
Linear Algebra
Notes
8-43
Notes
8-44
Lesson 9
Probability and Statistics
Introduction
In this lesson, you will learn some of the fundamental concepts in
probability and statistics such as mean or average, variance, histogram, and
others. The lesson describes different LabVIEW/BridgeVIEW VIs that
compute these quantities and show how they can be used in different
applications.
9-1
9-2
the Most Valuable Player (MVP) for the season. Thus, in a broad sense,
the term statistics implies different ways to summarize data to derive
useful and important information from it.
The next question is, what is probability? You have looked at ways to
summarize lots of data into single numbers. These numbers then help
draw conclusions for the present. For example, looking at Jordans
statistics for the 1996 season helped the NBA officials elect him the
MVP for that season. It also helped people to infer that he is one of the
best players in the game. But can you say anything about the future? Can
you measure the degree of accuracy in the inference and use it for
making future decisions? The answer lies in the theory of probability.
Whereas, in laymens terms, one would say that it is probable that
Jordan will continue to be the best in the years to come, you can use
different concepts in the field of probability, as discussed later in this
lesson, to make more quantitative statements.
In a completely different scenario, there may be certain experiments
whose outcomes cannot be predetermined, but certain outcomes may be
more probable. This once again leads to the notion of probability. For
example, if you flip an unbiased coin in the air, what is the chance that
it will land heads up? The chance or probability is 50 %. That means, if
you repeatedly flip the coin, half the time it will land heads up. Does this
mean that 10 tosses will result in exactly five heads? Will 100 tosses
result in exactly 50 heads? Probably not. But in the long run, the
probability will work out to be 0.5.
To summarize, whereas statistics allows you to summarize data and
draw conclusions for the present, probability allows you to measure the
degree of accuracy in those conclusions and use them for the future.
9-3
B. Statistics
In this section, you will look at different concepts and terms commonly used
in statistics and see how to use the Analysis VIs in different applications.
Mean
Consider a data set X consisting of n samples x 0 , x 1 , x 2 , x 3 , , x n 1 . The
mean value (a.k.a. average) is denoted by x and is defined by the formula
1
x = --- ( x 0 + x 1 + x 2 + x 3 + + x n 1 )
n
In other words, it is the sum of all the sample values divided by the
number of samples. As you saw in the Michael Jordan example above,
the data set consisted of 51 samples. Each sample was equal to the
number of points that Jordan scored in each game. The total of all these
points was 1568, divided by the number of samples (51) to get a mean
or average value of 30.7.
The input-output connections for the Mean VI are shown below.
Median
Let S = {s 0, s 1, s 2, , s n 1} represent the sorted sequence of the data set X.
The sequence can be sorted either in the ascending order or in
descending order. The median of the sequence is denoted by x median and
is obtained by the formula
si
x median =
0.5 ( s k 1 + s k )
n is odd
n is even
n
1
where i = n----------- and k = --- .
2
9-4
student X scored 4.5 points on a test and another student Y scored 1 point
on the same test, the median is a very useful quantity for making
qualitative statements such as X lies in the top half of the class or Y
lies in the bottom half of the class.
The input-output connections for the Median VI are shown below.
Sample Variance
The sample variance of the data set X consisting of n samples is denoted by
2
s and is defined by the formula
2
2
2
1
2
s = ------------ [ ( x 1 x ) + ( x 2 x ) + + ( x n x ) ]
n1
where x denotes the mean of the data set. Hence, the sample variance is
equal to the sum of the squares of the deviations of the sample values
from the mean divided by n-1.
Note:
The above formula does not apply for n = 1. However, it does not mean
anything to compute the sample variance if there is only one sample in the
data set.
The input-output connections for the Sample Variance VI are shown
below.
9-5
Standard Deviation
The positive square root of the sample variance s 2 is denoted by s and is
called the standard deviation of the sample.
The input-output connections for the Standard Deviation VI are shown
below.
Mode
The mode of a sample is a sample value that occurs most frequently in the
sample. For example, if the input sequence X is
X = { 0, 1, 3, 3, 4, 4, 4, 5, 5, 7 }
then the mode of X is 4, because that is the value that most often occurs
in X.
The input-output connections for the Mode VI are shown below.
9-6
1
= --n
(x x)
i=0
Histogram
So far, this lesson has discussed different ways to extract important features
of a data set. The data is usually stored in a table format, which many people
find difficult to grasp. It is generally useful to display the data in some form.
The visual display of data helps us gain insights into the data. Histogram is
one such graphical method for displaying data and summarizing key
information. Consider a data sequence X = { 0, 1, 3, 3, 4, 4, 4, 5, 5, 8 } . Divide
the total range of values into 8 intervals. These intervals are 0-1, 1-2,
2-3, ..., 7-8. The histogram for the sequence X then plots the number of data
samples that lie in that interval, not including the upper boundary.
3
The figure above shows that one data sample lies in the range 0-1 and 1-2,
respectively. However, there is no sample in the interval 2-3. Similarly, two
9-7
samples lie in the interval 3-4, and three samples lie in the range 4-5.
Examine the data sequence X above and be sure you understand this
concept.
There are different ways to compute data for a histogram. Next you will
see how it is done in the Histogram VI using the sequence X.
As shown above, the inputs to this VI are the input sequence X and the
number of intervals m. The VI obtains Histogram:h(x) as follows. It
scans X to determine the range of values in it. Then the VI establishes
the interval width, x , according to the specified value of m
max min
x = -------------------------m
where max is the maximum value found in X, min is the minimum value
found in X, and m is the specified number of intervals.
0
Let m = 8 . Then x = 8----------- = 1
8
for
i = 0, 1, 2, , m 1
i = 0, 1, 2, , m 1
hi =
y (x )
i
i = 0, 1, 2, , m 1
for
j=0
9-8
1
mse = --n
(x y )
i
i=0
S1
y1
S2
y2
Consider a digital signal x fed to a system, S1. The output of this system
is y1. Now you acquire a new system, S2, which is theoretically known
to generate the same result as S1 but has two times faster response time.
Before replacing the old system, you want to be absolutely sure that the
output response of both the systems is the same. If the sequences y1 and
y2 are very large, it is difficult to compare each element in the
sequences. In such a scenario, you can use the MSE VI to calculate the
mean square error (mse) of the two sequences y1 and y2. If the mse is
smaller than an acceptable tolerance, the system S1 can be reliably
replaced by the new system S2.
The input-output connections for the MSE VI are shown below.
9-9
x =
1
--n
2
i
i=0
mean square voltage Vrms is given by ------p- . The following figure shows a
2
9-10
Exercise 9-1
Objective:
Front Panel
9-11
Block Diagram
9-12
6. You will compute the Sample Variance using the Sample Variance
VI in the Analysis library. Once again, connect the Points control to
the input terminal X and the output sample variance to the Sample
Variance indicator.
Note:
9-13
7. You will compute the Median using the Median VI in the Analysis
library. Connect the Points control to the input terminal X and the
output median to the Median indicator.
8. You will compute the Mode using the Mode VI in the Analysis
library. Connect the Points control to the input terminal X. Choose
the number of intervals equal to 3. Connect the output mode to the
Mode indicator.
9. You first will compute the data for the histogram using the
Histogram VI. Connect the control Points to the input terminal X
and set the number of intervals equal to 3. This VI generates
histogram values and X values, which are the midpoints of the
different intervals as discussed above. You can plot the histogram by
using the X values for the X axis and the histogram values for the Y
axis. If you are interested, try doing this and observe the histogram.
10. Generally, you may want to view the histogram in a different way.
Select the PostProcessing VI from Lvspcex.llb. Connect the
Points control to the Points input terminal, the histogram output of
the Histogram VI to the Histogram input terminal, and set the
number of intervals equal to 3 (same value you chose earlier for the
Histogram VI). This VI generates the data for plotting the histogram
in a better way. The X axis values are stored in the Boundaries
output terminal, and the Y axis values are stored in the PlotValues
9-14
output terminal. You can use the output of this VI for plotting the
histogram on the Histogram of Points XY graph.
11. Return to the front panel. Set the number of intervals equal to 3 and
run the VI. Study the different output values. See how the histogram
(on the left) provides more information than just plotting the points
in each game (on the right).
12. Save the VI and close it.
9-15
C. Probability
In any random experiment, there is always a chance that a particular event
will or will not occur. A number between 0 and 1 is assigned to measure this
chance, or probability, that a particular event occurs. If you are absolutely
sure that the event will occur, its probability is 100% or 1.0, but if you are
sure that the event will not occur, its probability is 0.
Consider a simple example. If you roll a single unbiased die, there are
six possible events that can occureither a 1, 2, 3, 4, 5, or 6 can result.
What is the probability that a 2 will result? This probability is one in six,
or 0.16666. You can define probability in simple terms as: The
probability that an event A will occur is the ratio of the number of
outcomes favorable to A to the total number of equally likely outcomes.
Random Variables
Many experiments generate outcomes that you can interpret in terms of real
numbers. Some examples are the number of cars passing a stop sign during
a day, number of voters favoring candidate A, and number of accidents at a
particular intersection. The values of the numerical outcomes of this
experiment can change from experiment to experiment and are called
random variables. Random variables can be discrete (if they can take on
only a finite number of possible values) or continuous. As an example of the
latter, weights of patients coming into a clinic may be anywhere from, say,
80 to 300 pounds. Such random variables can take on any value in an
interval of real numbers. Given such a situation, suppose you want to find
the probability of encountering a patient weighing exactly 172.39 pounds.
You will see how to calculate this probability next using an example.
Consider an experiment to measure the life lengths x of 50 batteries of a
certain type. These batteries are selected from a larger population of
such batteries. The histogram for observed data is shown below.
histogram
9-16
This figure shows that most of the life lengths are between zero and 100
hours, and the histogram values drop off smoothly as you look at larger
life lengths.
You can approximate the histogram shown above by an exponentially
decaying curve. You could take this function as a mathematical model
for the behavior of the data sample. If you want to know the probability
that a randomly selected battery will last longer than 400 hours, this
value can be approximated by the area under the curve to the right of the
value 4. Such a function that models the histogram of the random
variable is called the probability density function.
To summarize all the information above in terms of a definition, a
random variable X is said to be continuous if it can take on the infinite
number of possible values associated with intervals of real numbers, and
there is a function f(x), called the probability density function, such that
1. f ( x ) 0
for all x
2.
3.
f ( x ) dx = 1
P( a X b) =
f ( x ) dx
a
Notice from equation (3) above that for a specific value of the
a
9-17
Normal Distribution
The normal distribution is one of the most widely used continuous
probability distributions. This distribution function has a symmetric bell
shape, as shown above. The curve is centered at the mean value x = 0 , and
its spread is measured by the variance s 2 = 1 . These two parameters
completely determine the shape and location of the normal density function,
whose functional form is given by
1 ( x x )2 ( 2s2 )
f ( x ) = ------------- e
s 2
9-18
want to find the probability that the height of a male is greater than or
equal to 170 cm. You can use the Normal Distribution VI to find this
probability. Set the input x = 170 . Thus, the choice of the probability
density function is fundamental to obtaining a correct probability value.
1. Interested readers should refer to the latest edition of the Schaums Outline Series on Theory and Problems of Probability and Statistics by Murray Spiegel, McGraw-Hill, Inc., 1975, for detailed discussion on
these three types of distributions.
9-19
Exercise 9-2
Objective: To understand key probability concepts.
In this exercise, you will first generate a data sample with standard normal
distribution and then use the Normal Distribution VI to check the
probability of a random variable x.
Front Panel
9-20
Block Diagram
2. Build the block diagram as shown above. The Gaussian White Noise
VI generates a Gaussian-distributed pattern with mean value equal
to 0 and standard deviation set by the user using the input standard
deviation. Samples is the number of samples of the Gaussian noise
pattern. Seed is the seed value used to generate the random noise.
Gaussian White Noise VI (Analysis Signal Generation
subpalette). In this exercise, this function generates a Gaussian
white noise pattern.
Histogram VI (Analysis Probability and Statistics
subpalette). In this exercise, this function computes the
histogram of the Gaussian noise pattern.
Normal Distribution VI (Analysis Probability and
Statistics subpalette). In this exercise, this function computes
the one-sided probability of the normally distributed random
variable Random Variable.
Connect the Gaussian noise pattern to the waveform graph Noise
Plot.
3. You will compute the histogram of the Gaussian noise pattern using
the Histogram VI used in the previous exercise.
9-21
It is very important that you carefully choose the proper type of distribution
function to approximate your data. In this example, you actually plotted
the histogram to make this decision. Many times, you can make an
intelligent decision based solely on prior knowledge of the behavior and
characteristics of the data sample.
9. Return to the front panel and enter a value for Random Variable.
This VI will compute the one-sided probability of this normally
distributed random variable. Remember, you have assumed that the
variable is normally distributed by looking at the histogram.
10. Save the VI as Probability.vi and close it.
9-22
Summary
Mean, median, sample variance, and mode are some of the statistics
techniques to help in making inferences from a sample to a
population.
Review Questions
1. What is the difference between probability and statistics? Which
VI(s) would you use in each case?
2. What is the difference between:
a. Mode and median?
b. Sample variance and population variance?
Which VI(s) would you use in each case?
3. Name some real-world practical applications of using:
a. Histograms
b. The Gaussian probability density function
4. What is the difference between the Normal Distribution VI and the
Inv Normal Distribution VI?
9-23
Notes
9-24
Lesson 10
Digital Filter Design Toolkit
Introduction
In this lesson, you will learn how to use the Digital Filter Design (DFD)
Toolkit to design FIR and IIR filters to meet required specifications. You
will also see how to use the DFD toolkit to analyze your filter design in
terms of its frequency response, impulse and step responses, and its
pole-zero plot.
10-1
Lesson 10
Filtering
Filtering is one of the most common signal processing techniques and is the
process by which the frequency content of a signal is altered. Some of the
practical applications of filtering are in the bass and treble controls of your
stereo to adjust the frequency response, in the tuning circuits of your radio
and television receivers to select a particular channel, in telephone handsets
to limit the frequency content of the sound signals to 3 KHz, and many
others in the audio, telecommunications, geophysics, and medical fields.
They are software programmable, and so are easy to build and test.
They are stable (do not change with time nor temperature) and
predictable.
10-2
Lesson 10
passband
transition
region
stopband
passband ripple
stopband
attenuation
cutoff frequency
The figure above also shows the passband ripple, the stopband
attenuation, and the cut-off frequency, three specifications that are needed
in designing digital filters. The passband ripple (in dB) is the maximum
deviation in the passband from 0 dB, whereas the stopband attenuation
is the minimum attenuation (in dB) in the stopband. In the DFD toolkit,
the passband ripple is also referred to as the passband response.
10-3
Lesson 10
Digital Filter
Design
Application
Save
Load
Filter
Specification
Files
Save
LabVIEW
HiQ
LabWindows/CVI
Data Acquisition
and Filtering
10-4
Windows DLL
Lesson 10
Main Menu
When you launch the DFD application, you get the following panel, which
is referred to as the Main Menu:
Design Options
From the Main Menu, you can choose any of the following four methods of
designing digital filters:
10-5
Lesson 10
The selections in the window above tell the DFD application to preload
one or more of the filter design panels into memory when it is started.
Preloading filter designs increases the time taken for the Main Menu to
open. However, when you select a particular design panel from the Main
Menu, the corresponding design panel opens almost immediately. If you
have limited amount of memory on your computer, you may want to
reconsider how many (if any) of the design panels you preload into
memory.
10-6
Lesson 10
is included with many DFD graphs. A graph with its accompanying graph
palette is shown below.
Graph
Palette
If you press the x autoscale button, shown at left, the DFD application
autoscales the X data of the graph. If you press the y autoscale button,
shown at left, the DFD application autoscales the Y data of the graph. If
you want the graph to autoscale either of the scales continuously, click
on the lock switch, shown at the left, to lock autoscaling on.
The scale format buttons, shown left, give you run-time control over the
format of the X and Y scale markers, respectively.
You use the remaining three buttons to control the operation mode for
the graph.
Normally, you are in standard operate mode, indicated by the plus or
crosshatch. In operate mode, you can click in the graph to move cursors
around.
The panning tool switches to a mode in which you can scroll the visible
data by clicking and dragging sections of the graph.
The zoom tool zooms in on a section of the graph by dragging a selection
rectangle around that section. If you click on the zoom tool, you get a
pop-up menu you can use to choose some other methods of zooming.
This menu is shown below.
10-7
Lesson 10
For the last two modes, you can zoom in and zoom out about a point.
Shift-clicking zooms in the other direction.
Graph Cursors
Below are illustrations of a waveform graph showing two cursors and the
cursor movement control.
cursor movement
control
10-8
Lesson 10
1
y [ i ] = ------
a0
Ny 1
Nx 1
a [ j ]y [ i j ] +
j=1
b [ k ]x [ i k ]
k=0
(1)
In the above equation, the b[k] are known as the forward coefficients and
the a[j] are known as the reverse coefficients. The output sample at the
present sample index i is the sum of scaled present and past inputs (x[i]
and x[i-k] when k 0) and scaled past outputs (y[i-j]). Usually Nx is equal
to Ny, and this value is known as the order of the filter.
stage 1
y[i]
stage 1
stage 2
stage Ns
y[i]
(b) Cascaded Direct Form Filter Stages (each filter is of lower order than the filter in (a))
10-9
Lesson 10
(2)
The implementation can also be done in the more efficient direct form II,
where you maintain two internal states (s[i-1] and s[i-2]). The output of
the filter is then calculated as follows:
s[i] = x[i] - a1s[i-1] - a2s[i-2]
(3)
10-10
Lesson 10
10-11
Lesson 10
Exercise 10-1
Objective: To design an IIR bandpass filter for use in an octave analyzer.
1. Launch the Digital Filter Design Toolkit application. The Main
Menu panel opens as shown.
2. In the Main Menu, select Classical IIR Design and click on the Open
button. The design panel of the Classical IIR Design opens as shown.
10-12
Lesson 10
filter can be entered in the text entry portion at the upper right side
of the design panel.
Lowpass
Highpass
Bandpass
Bandstop
The design control specifies one of the four classical filter design
algorithms:
Butterworth
Chebyshev
10-13
Lesson 10
Inverse Chebyshev
Elliptic
Below the text entry portion is an indicator showing the order of the
IIR filter.
You will use the Classical IIR Design panel to design an IIR bandpass
filter that can be used in an octave analyzer. Octave analyzers (see the
lesson on the Third-Octave Analyzer Toolkit) are used in applications
where you need to determine how the signal power is distributed over a
particular frequency range. These applications include the fields of
architectural acoustics, noise and vibration tests in aircraft and
submarines, testing of household appliances, etc.
An octave analyzer uses bandpass filters to separate the signal power
into several frequency bands. The American National Standards Institute
requires that these filters adhere to certain specifications. Some
specifications for one of these filters are:
fp1 = 890.90 Hz
fp2 = 1122.46 Hz
maximum passband ripple 50 millibels
fs1 = 120.48
fs2 = 8300
stopband attenuation 65 dB
Because the purpose of the bandpass filter is to determine the level of
sound power in a particular frequency band, and the phase information
in the signal is not being used, it is not necessary for the filter to be linear
phase. Hence, you can choose an IIR filter for this application. You will
use the DFD toolkit to design the IIR filter to meet these specifications.
10-14
Lesson 10
fs2
fs1
The explanation of the controls in the text entry box is the same as
before, except note that because you have selected a bandpass filter,
there are two controls for the passband frequencies and the stopband
frequencies. They are denoted by fp1, fp2, fs1, and fs2, as shown in the
following figure, and bear the following relationship:
fs1 < fp1 < fp2 < fs2
fs1
fp1
fp2
fs2
-0.5
passband frequencies
stopband attenuation
-65
stopband frequencies
sampling rate
25600
type
bandpass
design
elliptic
50
-----------1000
50
- deciBels = 0.5 dB. That is
Bels = -------100
10-15
Lesson 10
10-16
Lesson 10
8. You can also save the designed filter coefficients in a file for later
use with the DFD toolkit, or with other programs. From the DFD
menu, select Save Coeff.... When asked for the name of the file in
which to save the filter coefficients, type bpiir.txt. Save the file
as a text file. The appendix gives the format of the text file in which
the coefficients are stored.
9. Now that you have saved the filter specifications, and the filter
coefficients, you can close the application. Select File Close to
close the Classical IIR Design panel. Then select Quit in the Main
Menu to exit the DFD Toolkit.
10-17
Lesson 10
(4)
where N is the order of the filter and b0, b1, .... bN, are its coefficients.
FIR filters have certain advantages as compared to IIR filters.
They can achieve linear phase response, and hence they can pass a
signal without phase distortion.
10-18
Lesson 10
10-19
Lesson 10
You can also design FIR filters with an arbitrary frequency response by
selecting Arbitrary FIR Design in the Main Menu.
Arbitrary means that you can specify exactly what the magnitude of the
filter response should be at specific frequencies. In the next exercise, you
will design an FIR filter by specifying an arbitrary frequency response.
10-20
Lesson 10
Exercise 10-2
Objective:
Weighting (dB)
Frequency (Hz)
Weighting (dB)
10
-70.4
500
-3.2
12.5
-63.4
630
-1.9
16
-56.7
800
-0.8
20
-50.5
1000
25
-44.7
1250
+0.6
31.5
-39.4
1600
+1.0
40
-34.6
2000
+1.2
50
-30.3
2500
+1.3
63
-26.2
3150
+1.2
80
-22.5
4000
+1.0
100
-19.1
5000
+0.5
125
-16.1
6300
-0.1
160
-13.4
8000
-1.1
200
-10.9
10000
-2.5
250
-8.6
12500
-4.3
315
-6.6
400
-4.8
10-21
Lesson 10
10-22
Lesson 10
The graph below plots the desired and actual magnitude response of the
designed FIR filter.
The y-axis is in linear or decibel units, depending on how you set the
button in the upper left corner of the graph. The x-axis is in Hertz. The
full scale ranges from 0.0 to Nyquist (sampling rate/2).
dB
The dB button controls the display units (linear or decibel) of all the
magnitude controls and displays. These controls and displays include the
Magnitude vs. Frequency graph (y-axis) and the magnitudes in the array
of frequency-magnitude points.
The following array is the array of frequency-magnitude points the DFD
application uses to construct the desired filter magnitude response. The
DFD application forms the desired filter response by interpolating
between these points.
10-23
Lesson 10
10-24
Lesson 10
Clicking on a point you already selected removes that point from the
selection list.
ins
del
10-25
Lesson 10
The filter order control specifies the total number of coefficients in the
digital FIR filter.
The ripple indicator displays the largest absolute error (linear) between
the desired and actual filter responses.
ripple 1.3709E-2
The message window displays errors that occurred during the FIR design
procedure.
message
The locked frequencies box allows you to lock the present frequency
values of the frequency-magnitude points. If you click in this box, you
can alter only the magnitude or y-value of the frequency-magnitude
points.
The uniform spacing box is used to space the frequency values of the
frequency-magnitude points. If you click in this box, the DFD
application spaces the frequency-magnitude points uniformly from 0.0
to sampling rate/2, inclusive.
Clicking in the sort by frequency box tells the DFD application to sort
the frequency-magnitude points in both the response graph and the array
according to ascending frequency. The value of each frequencymagnitude point remains unchanged; however, the point order may
change.
Clicking on import from file enables you to import frequency-magnitude
points from a text file.
10-26
Lesson 10
The sampling rate control specifies the sampling rate in samples per
second (Hertz).
sampling rate
8000.00
3. The filter specifications shown in the table on page 10-21 have been
saved in the Dfd\Aweight.fir file. Load these specifications by
selecting DFD Menu Load Spec... and choosing the
Aweight.fir file.
4. You could also have entered these values directly on the front panel
and then saved them by selecting Save Specs... from the DFD Menu.
Hold down the left mouse button and move the point. Observe how
the response of the filter changes as the point is moved.
6. Choose locked frequencies and try to do the same as in the previous
step. Now you should be able to change the magnitude of the selected
point, but not its frequency.
10-27
Lesson 10
10-28
Lesson 10
Impulse Response
The output of the filter when the input is an impulse is known as the impulse
response of the filter. An impulse in the digital world has an amplitude of 1
at index 0 and an amplitude of 0 for all other indices. An impulse and the
impulse response are shown in the figures below.
The impulse response has a very special meaning in the case of FIR
filters. The impulse response of an FIR filter gives the coefficients of
that filter. Thus, the impulse response is a useful method for determining
the coefficients of an FIR filter. Furthermore, the number of nonzero
terms in the impulse response gives the number of coefficients in the
filter. (For an IIR filter, the relationship is much more complicated, and
the above discussion does not apply.)
Another use of the impulse response is that, for both FIR and IIR filters,
the output of the filter is given by the convolution of the input signal and
the impulse response of the filter.
Step Response
The output of the filter when the input is a unit step is known as the step
response of the filter. A unit step in the digital world has an amplitude of 0
10-29
Lesson 10
for all negative indices, and an amplitude of 1 at index zero and for all
positive indices. A unit step and the step response are shown in the figures
below.
The step response is important if you will use the filter in a control
system. You can then see how the parameters of the control system (such
as the rise time, overshoot, etc.) are affected by the filter. The step
response also shows you how long the filter will take to respond to a
sudden change in the input.
1.20
1.00
0.80
0.60
0.40
0.20
f (Hz)
0.00
0.00
0.10
10-30
0.20
0.30
0.40
0.50
Lesson 10
Phase(radians)
(radians)
Phase
0.0
-2.0
-4.0
-6.0
-8.0
-10.0
f (Hz)
-12.0
0.00
0.10
0.20
0.30
0.40
0.50
Not only does the frequency response enlighten you as to the effect that
the filter has on signals of specific frequencies, it also allows you to
determine what happens to arbitrary signals as they pass through the
filter. Because most signals can be expressed as a sum of exponentials
(sines and cosines), you can break a signal down into its individual
components and determine the effect of the filter on those components.
10-31
Lesson 10
The Digital Filter Design Toolkit gives you both the transfer function of
the filter and its corresponding pole-zero plot. The figures below show
the pole-zero plots for both a stable and an unstable filter. Each o depicts
a zero and each x depicts a pole.
1.0
1.0
x
x
o
0.0
0.0
o
o
x
-1.0
-1.0
0.0
x
1.0
stable filter
-1.0
-1.0
0.0
1.0
unstable filter
10-32
Lesson 10
Exercise 10-3
Objective:
10-33
Lesson 10
In this panel, you can view the filter magnitude response, phase
response, impulse response, step response, and pole-zero plot of the
filter you designed in the first exercise. You can also view and print
full-screen plots of each response. From the full-screen views, you can
save the analysis results to text files.
If you select DFD Menu Analysis from a filter design panel, the
Analysis of Filter Design panel uses that particular filter design to
compute the various filter responses. You can also analyze any of the
four filter designs from the Design Analyzed ring selector; the Analysis
of Filter Design panel uses the filter parameters from the selected filter
design.
The DFD Menu can be used to load filter designs from previous work,
open the DAQ and Filter panel, go to the selected filter design panel, or
return to the Filter Design Main Menu.
10-34
Lesson 10
Analysis Displays
zoom
box
Each of the five filter plots has a zoom box in the upper right corner.
Clicking in this box brings up a full-screen version of that plot. In the
full-screen versions of these plots, you can change the units from linear
to decibel (magnitude response), from radians to degrees (phase
response) or from seconds to samples (impulse and step responses).
From each full-screen view, you can save the response data to text files.
Magnitude Response
5. The magnitude response is the magnitude of the filters response
H(f) as frequency varies from zero to half the sampling rate. Look at
the magnitude response of the designed filter. You can see that it is
indeed a bandpass filter.
Phase Response
6. The phase response is the phase of the filters response H(f) as
frequency varies from zero to the sampling rate. The following figure
illustrates the phase response of the selected filter design. Note that
the phase is displayed in radians. You can obtain a display in degrees
by clicking on the zoom box of the Phase Response plot. A new
window will appear, which will give you the option of choosing
between the appropriate display units.
10-35
Lesson 10
Impulse Response
7. The impulse response of a digital filter is the filters output when the
input is a unit sample sequence (1, 0, 0, ...). The input before the
unity sample is also zero. The following figure shows the impulse
response of the selected filter design.
Step Response
8. The step response of a digital filter is the filters output when the
input is a unit step sequence (1, 1, 1, ...). The input samples before
the step sequence are defined as zero. The following figure shows the
step response of the designed filter.
Z-Plane Plot
9. The following figure illustrates the z-plane plot of the filter poles and
zeros.
10-36
Lesson 10
Previously, you saw that the IIR filters are implemented as cascaded
second-order stages. For an IIR filter, H(z) can be represented by a
product of fractions of second-order z polynomials.
Ns
H(z) =
Nk ( z )
------------Dk ( z )
k=1
10-37
Lesson 10
description
type of file
Sampling Rate
8.000000E+3
sampling rate in Hz
22
filter order
h[0..21]
coefficients label
6.350871E-3
-8.833535E-3
-2.847674E-2
4.626607E-2
4.103986E-2
-1.114579E-1
-1.412791E-2
1.810791E-1
-5.984635E-2
-2.002337E-1
1.516199E-1
1.516199E-1
-2.002337E-1
-5.984635E-2
1.810791E-1
10-38
Lesson 10
description
-1.412791E-2
-1.114579E-1
4.103986E-2
4.626607E-2
-2.847674E-2
-8.833535E-3
6.350871E-3
You can implement the FIR filter using equation (4) directly.
description
coefficient type
Sampling Rate
8.000000E+3
sampling rate in Hz
Stage Order
Number of Stages
number of stages
a Coefficients
a coefficients label
number of a coefficients
3.801467E-1
a1 for stage 1
10-39
Lesson 10
description
8.754090E-1
a2 for stage 1
-1.021050E-1
a1 for stage 2
9.492741E-1
a2 for stage 2
8.460304E-1
a1 for stage 3
9.540986E-1
a2 for stage 3
b Coefficients
b coefficients label
number of b coefficients
1.514603E-2
b0 for stage 1
0.000000E+0
b1 for stage 1
1.514603E-2
b2 for stage 1
1.000000E+0
b0 for stage 2
6.618322E-1
b1 for stage 2
1.000000E+0
b2 for stage 2
1.000000E+0
b0 for stage 3
1.276187E+0
b1 for stage 3
1.000000E+0
b2 for stage 3
You can implement the IIR filter in cascade stages by using equation (2)
(maintaining two past inputs and two past outputs for each stage), or by
using the direct form II equations (maintaining two past internal states),
as in equation (3).
10-40
Lesson 10
Summary
You have learned that FIR filters are used for applications where you need
a linear phase response, such as for applications that require reconstructing
the original waveform after filtering, noise removal, and data compression.
For applications where phase is not an important consideration (such as for
simple signal monitoring) and where faster speeds are necessary, you can
use IIR filters.
You saw that the DFD toolkit allows you to interactively design both
FIR and IIR filters. The design could be done either by specifying the
filter parameters (classical IIR design and classical FIR design),
deciding the location of the poles and zeros in the z-plane (pole-zero
placement), or arbitrarily specifying the magnitude response
characteristics (arbitrary FIR design) of the filter.
After the filter has been designed, you can analyze your filter in terms
of its magnitude and phase responses, impulse and step responses, and
the pole-zero plot. You can also save the filter coefficients for use in
other applications.
10-41
Lesson 10
Notes
10-42
Lesson 11
G Math Toolkit
Introduction
The G Math Toolkit offers a new paradigm for mathematics, numerical
recipes in G, with hundreds of math VIs for solving differential equations,
optimization, root finding, and so on. All VIs in the G Math Toolkit are
written in G, so you can quickly modify them for your custom applications.
A main feature of the G Math Toolkit is that it adds to LabVIEW and
BridgeVIEW the ability to enter complex formulas directly onto the front
panel of a VI.
This toolkit is intended for use by scientists, engineers, and
mathematicians, and by anyone needing to solve mathematical problems
in a simple, quick, and efficient manner. It can also be used as an
educational aid by those interested in expanding their knowledge of
mathematics.
11-1
Lesson 11
G Math Toolkit
11-2
Lesson 11
G Math Toolkit
B. Parser VIs
The VIs in the Parser library act as the interface between the user and the
VIs in the other libraries. The formulas entered on the front panel can have
any number of variables. The formulas are first parsed to determine the
variables and the values to be assigned to them. They are then evaluated to
a number by substituting numeric values for the variables.
On the other hand, the indirect forms split the VI in two subVIs, as
shown in the following illustration. You can use the indirect form in
larger applications, where a two-step process (parsing and then
evaluating) is more efficient.
11-3
Lesson 11
G Math Toolkit
Example
No Variables
sin(1.2) + 5
Single Variable
Eval Single-Variable
Scalar
cos(x) at x = 3.142
Eval Single-Variable
Array
cos(x) at
x = 0, 0.1, 0.2, ...
x = a + b at a = 1, b = 2
Eval Multi-Variable
Scalar
sin(x) + cos(y) + z
at x = 1.0, y = 2.5,
z = 3.1
Eval Multi-Variable
Array
sin(x) + cos(y) + z
at x = 1, y = 2, z = 3 and
x = 3, y = 10, z = 1 and
x = 0.1, y = -2, z = 0.0
Many Variables
Substitute Variables
x = sin(z) + 7 * y
x=a+b
y=a*b
Others
Note:
The front panel of each parser VI has an example that shows how to enter
values in the control inputs.
11-4
Lesson 11
G Math Toolkit
The direct form of parser VIs are more widely used than the indirect
form. The following flowchart guides you through the selection of a
specific parser VI of the direct form.
Select one of
the indirect form
Parser VIs
one
Evaluation
at single or
multiple points?
single
How many
variables?
multiple
many
Evaluate both
sides of formula?
Y
Eval
Formula Node
single
Evaluation
at single or
multiple points?
multiple
Variables
Formula Node
No restrictions
Parser VI Routines
(G Math Toolkit)
Only a, a0, ..., a9, ...
z, z0, ..., z9, are valid
11-5
Lesson 11
G Math Toolkit
Meaning
Formula Node
Parser VI Routines
(G Math Toolkit)
Binary functions
Not available
Not available
Assignment
Not available
Logical, conditional,
inequality, equality
Not available
pi
pi ( 1 ) = ,pi ( 2 ) = 2
The precedence of operators is the same for the G Math Toolkit parser
VIs as those of the formula nodes in LabVIEW and BridgeVIEW.
Error Structure
The parser VIs use the following error handling structure. This structure
consists of a Boolean status button, a signed 32-bit integer numeric code
indicator, and a string source indicator. These error handler components are
explained below:
status is TRUE if an error occurred. If status is TRUE, this VI does not
perform any operations.
code is the error code number identifying the error.
source explains the error in more detail.
The default status of the error in structure is FALSE (no error),
indicated by an error code of 0.
11-6
Lesson 11
G Math Toolkit
11-7
Lesson 11
G Math Toolkit
Exercise 11-1
Objective:
To build an arbitrary waveform generator using the Eval Single-Variable Array VI.
In this exercise, you will build an arbitrary waveform generator using the
parser VIs. You will enter the formula for the waveform on the front panel
and see the output waveform on a graph indicator.
Selection of Parser VI
Looking at the table on page 11-4, depending on the number of variables in
your formula, you need to choose the appropriate VI from several available
choices of VIs of the direct form. Because you will plot a 1D function, you
need a VI that can handle functions of at least one variable. And because you
want to evaluate that function at more than one point, choose the Eval
Single-Variable Array VI (G Math Parser subpalette). The inputs and
outputs of this VI are shown below.
11-8
Lesson 11
G Math Toolkit
Front Panel
Block Diagram
11-9
Lesson 11
G Math Toolkit
Note that sin(x) has only one variable, called x. You could also call
the variable y or z or anything else. The appendix lists the rules for
variable names.
4. Change the equation to sin(x) + cos(x/2) and run the VI.
5. Change the equation to step(y-1) + sinc(y-2) + sin(y*10) and run the
VI. Note that now you have changed the variable to y.
6. Type in any other equation in the formula control and run the VI. The
appendix contains a list of available functions you can use in the
equation.
Note:
If you get an error, refer to the appendix for a list of error codes.
7. Save the VI as EvalSVA.vi in the library Lvspcex.llb.
8. Close the VI.
You have now seen how easy it is to build the waveform generator where
the user can specify the formula for an arbitrary waveform on the front
panel. In the next exercise, you will modify this waveform generator to
have the functionality of easily specifying even more complex
waveforms.
11-10
Lesson 11
G Math Toolkit
Exercise 11-2
Objective:
11-11
Lesson 11
G Math Toolkit
The original formula string control is where you enter your formula of
one variable. The formula may have one or more parameters.
Each element (cluster) in the Substitution Rules array specifies a
parameter and its corresponding substitution.
Y Values is an array digital indicator that shows the result of calculating
the formula at specified points.
1. Build the VI as shown in the figures above. The formula after
substitution output of the Substitute Variables VI goes to the
formula input of the Eval Single-Variable Array VI.
Hint: Build the block diagram first, pop up to create the controls and
indicators, and then add the waveform graph.
2. In the original formula control, type in the formula sin(A) + cos(B).
This will be the generic formula. In the Substitution Rules control,
you will provide the user with the capability of specifying the
functions to be substituted for A and B.
11-12
Lesson 11
G Math Toolkit
parameter content:
sin(x)
In element 1, type in
parameter name:
parameter content:
cos(x)
Note that this is the same as if you had typed sin(sin(x)) + cos(cos(x))
in the formula control in Exercise 11-1.
4. Run the VI and see the waveform on the graph display.
5. Change the values in the Substitution Rules control to
element 0
element 1
parameter name:
parameter content:
sin(x)
parameter name:
parameter content:
square(x)
Run the VI. The resulting equation is the same as if you had typed
sin(sin(x)) + cos(square(x)) in the formula control in Exercise 1-1.
6. Now change the control to
element 0
element 1
parameter name:
parameter content:
step(x-5)
parameter name:
parameter content:
square(x)
11-13
Lesson 11
G Math Toolkit
11-14
Lesson 11
G Math Toolkit
For all other cases, choose the ODE Runge-Kutta 4th Order VI or
the ODE Cash Karp 5th Order VI.
dy
d y
a -------- + b ------ + cy = g ( t )
dt
dt
(1)
dy ( 0 ) dy 0
- = -------with y ( 0 ) = y 0 and ------------dt
dt
11-15
Lesson 11
G Math Toolkit
md y cdy
------------ + --------- + ky = F ( t )
2
dt
dt
dQ Q dE ( t )
d Q
- + R ------- + ---- = ------------L --------2
dt C
dt
dt
d c d g
--------2 + ------ ------ + --- sin ( ) = 0
ml dt l
dt
(2)
dx 2 g ( t ) cx 1 bx 2
-------- = -------------------------------------dt
a
(3)
You will use G Math to solve this set of equations in the next exercise.
11-16
Lesson 11
G Math Toolkit
Exercise 11-3
Objective:
d y bdy
a -------2- + --------- + cy = g ( t )
dt
dt
dy ( 0 ) dy 0
- = -------with y ( 0 ) = y 0 and ------------dt
dt
11-17
Lesson 11
G Math Toolkit
11-18
Lesson 11
G Math Toolkit
Front Panel
The time start and the time end controls contain the starting and
ending time instants.
The differential equations are typed in the F(x,t) control.
The dependent variables are entered into the X control.
The independent variable is entered into the time control.
X0 contains the initial values (initial conditions) of the dependent
variables.
h contains the step size.
Substitution Rules contains the parameters and the corresponding
substitution.
Note:
11-19
Lesson 11
G Math Toolkit
Block Diagram
11-20
Lesson 11
G Math Toolkit
11-21
Lesson 11
G Math Toolkit
Exercise 11-4
Objective: To design the suspension system of an automobile.
You will now use the VI you built in the previous exercise to solve a
typical mechanical modeling problem. In particular, you will design the
suspension system of an automobile to have a suitable response when the
automobile goes over a pothole, a speed bump, and so on.
You can model the suspension system by the nonhomogeneous
differential equation given in equation (1) (reproduced below),
2
d y bdy
a -------2- + --------- + cy = g ( t )
dt
dt
dy ( 0 ) dy 0
- = -------with y ( 0 ) = y 0 and ------------dt
dt
where
y(t) is the position of the automobile. y(t) = 0 indicates that the
vehicle is in a balanced or a stable position.
dy/dt is the up and down speed of the automobile.
c is the coil constant of the spring used in the suspension system. It
is proportional to the displacement of the spring from its equilibrium
position. A larger value of c indicates a strong spring coil and thus a
tough suspension system. c is known as the spring constant.
b is a resistance coefficient that is proportional to the up and down
speed of the automobile. A larger value of b indicates a stronger
resistance to the up and down movement of the automobile, and thus
a smoother suspension system. b is known as the shock constant.
a is the weight of the vehicle.
g(t) is the external force that causes the suspension system of the
automobile to deviate from its equilibrium position. Some possible
causes may include a speed bump, a pothole, or a stone in the middle
of the road.
1. Using the VI developed in the previous exercise, enter the following
values in the controls on the front panel:
time start: 0
time end: 100
h: 0.1
Substitution Rules
parameter name:
parameter content:
1000
125
1000
X0:
11-22
Lesson 11
G Math Toolkit
11-23
Lesson 11
G Math Toolkit
11-24
Lesson 11
G Math Toolkit
Exercise 11-5
Objective: To see some of the capabilities of the G Math Toolkit for 1D functions.
1. Launch the 1D Explorer Example VI from the
Labview/Examples/Gmath/Math.llb folder. This VI shows
a good overview of some of the mathematical functionalities of G
Math.
Integration Graph
Roots
Maxima
3. Run the VI and click the Start button on the bottom right of the
panel. Plots of the above selections are displayed. Note that you can
enter the start and end points directly on the front panel through the
start and end controls. Also, note that LabVIEW returned the graphs
quickly because LabVIEW runs compiled. (Other math packages are
not compiled.)
11-25
Lesson 11
G Math Toolkit
11-26
Lesson 11
G Math Toolkit
340*square(t)
sin(t) + 1
11-27
Lesson 11
G Math Toolkit
0.01
5. Select the Calculation button and then the Simulation button. Notice
that the tank is now gradually emptying.
6. Select the STOP button.
11-28
Lesson 11
G Math Toolkit
11-29
Lesson 11
G Math Toolkit
z
observer
phi
x
psi
2. Change the psi value on the slider control. Note what happens.
3. Change the phi value on the slider control. Note what happens.
4. To return to the main VI, select the stop button on the front panel.
5. When you are done, close the VI.
11-30
Lesson 11
G Math Toolkit
Summary
In this lesson, you saw the basic components of the G Math Toolkit and how
to use it for solving problems in engineering, math, and education. In
particular, you built a simple arbitrary waveform generator using the VIs in
the parser library, and you also designed the suspension system of an
automobile by making use of the differential equation VIs. Finally, you
experimented with other VIs that showed some of the more advanced
capabilities of G Math.
11-31
Lesson 11
G Math Toolkit
Notes
11-32
Lesson 12
Third-Octave Analyzers
Introduction
A third-octave analyzer measures the spectral energy contained in a
specific set of third-octave bands and provides a standardized
narrowband spectral analysis. It consists of a set of bandpass filters
connected in parallel. It is widely used in the field of acoustics and audio
signal processing to measure sound or acoustic intensity in various
frequency bands. Its applications lie in the fields of vibration tests of
machines, architectural acoustics, power measurements, etc. In this
lesson, you will learn about the specifics of the bandpass filters used in
third-octave analyzers, their applications, and how to use the
Third-Octave Analyzer Toolkit.
12-1
Lesson 12
Third-Octave Analyzers
A. Filter Banks
A filter bank is a group of bandpass filters connected in parallel. Each filter
is tuned to a different frequency range. A simple filter bank consisting of
five filters is shown in the figure below. The center frequencies of each
bandpass filter are denoted by f1, f2, f3, f4, and f5, whereas their bandwidths
are denoted by B1, B2, B3, B4, and B5, respectively. There is a special name
given to the center frequencies. For the mth filter, let the center frequency be
fm. Then fm is known as the center frequency, the midband frequency, or
the geometric mean frequency.1 Note that in the figure, the bandwidths of
all the filters are the same. That is, B1 = B2 = B3 = B4 = B5.
B1
B2
B3
B4
B5
f1
f2
f3
f4
f5
frequency
1. Note that the actual term used depends on the relationship between f m and the upper and lower passband
frequency (fU and fL, respectively). This will be discussed in more detail later.
12-2
Lesson 12
Third-Octave Analyzers
12-3
Lesson 12
Third-Octave Analyzers
B. Octave Analyzers
Now consider the filter bank shown in the figure below. It consists of four
bandpass filters each with a different center frequency and different
bandwidths. The center frequencies are denoted by f1, f2, f3, and f4, whereas
the bandwidths are denoted by B1, B2, B3, and B4. The filters with higher
center frequencies have larger bandwidths, and filters with lower center
frequencies have lower bandwidths.
The special feature of this filter bank is that the center frequency of any
of the filters is exactly twice (one octave higher) that of the center
frequency of the filter just below it and exactly 1/2 (one octave lower)
that of the center frequency of the filter just above it.
f
m
That is, ---------- = 2
fm 1
and
fm
1
---------- = --fm + 1
2
B1
B2
B3
B4
f1
f2
f3
f4
frequency
This same relationship holds true for the bandwidths of any two adjacent
filtersthe bandwidth of any filter is exactly twice that of the bandwidth
of the filter just below it and exactly 1/2 that of the bandwidth of the
filter just above it.
B
Bm 1
m
That is, ------------ = 2
and
Bm
1
------------ = --Bm + 1
2
Note that the quality factor = Q = fm/Bm is now the same for all filters,
because both fm and the bandwidth of adjacent filters increase (or
decrease) by the same amount. Therefore, these bandpass filters are
known as constant Q bandpass filters.
Such a filter bank, where the ratios of center frequencies and bandwidths
of adjacent filters are powers of 2 (21 = one octave), is known as an
12-4
Lesson 12
Third-Octave Analyzers
fL
fm
fU
fu fL
12-5
Lesson 12
Third-Octave Analyzers
and
fm
1 3
---------- = 2
fm + 1
Bm
13
------------ = 2
Bm 1
and
Bm
1 3
------------ = 2
Bm + 1
2f
one octave
Note:
freq
In general, you can have a 1/n-octave analyzer where the ratio of center
frequencies and bandwidths of adjacent bandpass filters is 21/n. In
practice, the most popular ones are 21, 21/3, and 21/12. These correspond to
ratios with numeric values of 2, 1.26, and 1.06, respectively.
For 1/3-octave analyzers also, there is f m =
geometric mean frequency.
fU fL
The filters in both octave and third-octave analyzers are also known as
constant percentage bandwidth filters. That is, the bandwidth of the
filters are a constant percentage of the center frequency. For an octave
filter, the ratio of f2/f1 = 2, and its bandwidth is 1/ 2 = 71% of the center
frequency. For a 1/3-octave filter, the ratio f2/f1 = 3 2 , and its bandwidth
is 21/6 - 2-1/6 = 23% of the center frequency.
12-6
Lesson 12
Third-Octave Analyzers
D.Applications
The applications of 1/n-octave analyzers are mainly in the fields of acoustics
and audio signal processing. Basically, you want to measure the sound or
acoustic intensity in various frequency bands. A specific example is in the
aviation industry, where measurement of noise emissions from an aircraft
are necessary for it to get airworthiness certification. Federal aviation
regulations require the use of real-time 1/3-octave analyzers for data
analysis. Manufacturers of appliances and office equipment also tend to
specify sound power levels in their product documentation so that
customers can compare their products and choose the quieter one. By
measuring sound power levels in a room or other enclosure such as a concert
hall, acoustic engineers determine the proper material and design for the
enclosure.
Other applications are in
Audio equalization
Architectural acoustics
Appliance testing
12-7
Lesson 12
Third-Octave Analyzers
Passband (Hz)
Passband (Hz)
Passband (Hz)
25
22.4 - 28.2
400
355 - 447
6300
5620 - 7080
31.5
28.2 - 35.5
500
447 - 562
8000
7080 - 8910
40
33.5 - 44.7
630
562 - 708
10000
8910 - 11200
50
44.7 - 56.2
800
708 - 891
12500
11200 - 14100
63
56.2 - 70.8
1000
891 - 1120
16000
14100 - 17800
80
70.8 - 89.1
1250
1120 - 1410
20000
17800 - 22400
100
89.1 - 112
1600
1410 - 1780
125
112 - 141
2000
1780 - 2240
160
141 - 178
2500
2240 - 2820
200
178 - 224
3150
2820 - 3550
250
224 - 282
4000
3550 - 4470
315
282 - 355
5000
4470 - 5620
12-8
Lesson 12
Third-Octave Analyzers
On the front panel above, Acquire retrieves and analyzes a block of data.
The analyzer does not start acquiring data until you click on this button.
The data can be acquired in single or continuous mode. The mode can be
chosen by clicking on the up or down arrows on the control to the left of
the Acquire button. When you select single, every time that you click the
Acquire button, the analyzer acquires and analyzes a new block of data
and displays the result on the corresponding graph. When you choose
continuous, the analyzer starts to acquire and analyze data when you
click the Acquire button. After it has displayed the data on the
corresponding graph, it acquires the next block of data and analyzes and
displays it. This continues until you click on the Stop Acquire button.
12-9
Lesson 12
Third-Octave Analyzers
12-10
Lesson 12
Third-Octave Analyzers
sampling rate determines the rate at which the signal is sampled, and
thus the frequency range being analyzed (this is because as you have
already seen, the sampling frequency must be at least twice the
maximum frequency of the signal). Three choices of sampling rates are
available: 12.8 KHz, 25.6 KHz, and 51.2 KHz. The corresponding
frequency ranges being analyzed are: 5 Hz - 5 KHz, 10 Hz - 10 KHz, and
20 Hz - 20 KHz. These sampling rates were chosen because they are
software selectable with the National Instruments dynamic signal
acquisition boards (AT-A2150, NB-A2150F, and AT-DSP2200), which
you can use with the TOA. The sample rate of 51.2 KHz conforms to the
Extended range ANSI specifications.
Channel # indicates the channels from which to acquire the data and
display it. Up to four channels can be chosen (and the channel number
can also be the same in every control). Each channel has a box with a
cross in it. If you do not need to use a channel, click inside the box until
the cross disappears. This will disable all the parameters associated with
that particular channel.
Window Type selects one of four commonly used windows
(Rectangular, Hamming, Hanning, and Blackman) for each channel. The
Window Type parameter defaults to the Hanning window.
Next, you will complete an exercise which uses the third-octave analyzer
and highlights more of its features.
12-11
Lesson 12
Third-Octave Analyzers
Exercise 12-1
Objective:
To analyze a signal consisting of a sine wave with harmonics and added white
noise.
Note:
Front Panel
You see four graphs on the screen. This is because you can analyze
signals coming from up to four channels. The number of graphs
displayed on the screen depends on the number of channels you are
analyzing.
The two controls (Frequency and Amplitude) on the right side of the
front panel have been added only for the purpose of this exercise.
They do not exist in the actual Third-Octave Analyzer Toolkit. They
adjust the amplitude and frequency of a sine wave (with harmonics)
that has been corrupted by white noise. On the front panel of the
TOA, use the Frequency dial to control the frequency of the
fundamental component of the sine wave between 0 - 10 KHz. Use
the Amplitude slider control to adjust the amplitude of the
fundamental between 0 - 20.
12-12
Lesson 12
Third-Octave Analyzers
Although you do not need to be concerned about this for now, for
those who are interested, the block diagram of the VI (Signal.vi) used
to generate this simulated signal is shown below:
The above VI also adds to the fundamental its 3rd and 7th harmonics
of amplitudes 1/5th and 1/15th, respectively. The addition of
harmonics is simulated by the lower two Sine Wave VIs.
Setup Window
2. With the Amplitude and Frequency controls both set to 0.00, run
the VI.
12-13
Lesson 12
Third-Octave Analyzers
The Setup window gives you control over the number of channels to
sample, the sampling rate, FFT size, and much more. For now, you
will leave the following controls at their default values:
device
sampling rate
25.6 K Hz
FFT size
512
no averaging
3. In the Setup window, click on the white box to the left of the labels
ChB, ChC, and ChD. When you click on the white boxes, the
crosses in them disappear, and the selections for those channels are
grayed out.
12-14
Lesson 12
Third-Octave Analyzers
4. Now, because only the white box to the left of ChA has a cross in it,
you will use only ChA to acquire the signal.
The device control corresponds to the number of the DAQ board in
your computer. You can obtain the correct device number for your
DAQ board by using the NI-DAQ Configuration Utility. For the
purpose of this exercise, leave device set to 1.
The Channel # control determines the particular channel on the DAQ
board from which you will acquire the sampled signal. (A DAQ
board usually has more than one channeltypically 8 or 16.) Leave
this set to 0.
The Window Type control determines the type of window you want
to apply to the data samples.
5. Click on the Done button. The Setup window will disappear, and you
will return to the main panel of the TOA. You can bring up the Setup
window at any time to change the configuration parameters by
clicking on the Setup button on the bottom left of the main panel of
the TOA. Note that only one graph is displayed, because you had
selected only 1 channel in the Setup window.
12-15
Lesson 12
Third-Octave Analyzers
12-16
Lesson 12
Third-Octave Analyzers
Cursor Control
12. Move the cursor around the display. On the top left, you can see the
power output (in dB) and the corresponding center frequency (in Hz)
of the BPF corresponding to the rectangle on which you place the
cursor.
12-17
Lesson 12
Third-Octave Analyzers
15. In the Setup window, click on the View Weighting bar to see a table
showing the weighting values for each frequency band for each
channel. Click on the OK button to close the window showing the
table.
12-18
Lesson 12
Third-Octave Analyzers
Frequency
Range
Analog
Out
DAQ
Signal Accessory
Ch 0
Analog
In
Frequency
Adjust
Function
Generator
You will use this box to generate a sinusoidal signal of frequency 200 Hz
and peak amplitude of 1 V. This will be your reference signal.
12-19
Lesson 12
Third-Octave Analyzers
Exercise 12-2
Objective:
ribbon cable
A B
Frequency
Range
Frequency
Adjust
13 kHz 1 MHz
1 kHz 100 kHz
100 Hz 10 kHz
Analog
Out
DAQ
Signal Accessory
Ch 0
Analog
In
Function
Generator
wire
connection
12-20
Lesson 12
Third-Octave Analyzers
With a sampling rate of 20000 and number of samples selected as 1000, the
frequency spacing is 20000/1000 = 20 Hz. The FFT lines will thus fall on
frequency values of 0, 20, 40, 60, and so on. The signal of 200 Hz will
therefore fall exactly on the eleventh FFT line.
4. Run the VI. In the Est Power Peak and the Est Frequency Peak
indicators on the top, you will see the estimate of the power and
frequency of the highest peak in the spectrum.
5. Adjust the Frequency Adjust control on the DAQ Signal Accessory
to get an Est Frequency Peak of 200 Hz (or as close to it as possible).
(You will need to run the VI each time after you change the
Frequency Adjust control.)
6. Once you obtain a frequency of 200 Hz, note the value in the Est
Power Peak indicator. This value is in units of V2rms. You can
12-21
Lesson 12
Third-Octave Analyzers
2 V rms
The method you have used in the previous exercise to generate the
reference signal is just to illustrate the principles involved in calibration of
the TOA. In practice, the reference signal should be obtained from a more
accurate and reliable source.
12-22
Lesson 12
Third-Octave Analyzers
Exercise 12-3
Objective:
To save the results obtained from the TOA for a standard reference signal.
In this exercise, you will use the same connections (between the DAQ
Signal Accessory box and your computer) as those you had before in the
previous exercise.
1. Run the Third-Octave Analyzer from the Start Programs menu.
2. In the Setup panel, make sure only ChA is selected. This is done by
clicking in the white box to the left of ChB, ChC, and ChD, so that
the white box does not have a cross in it, and also that the selections
for these channels are grayed out.
3. Change the Channel # setting to 1. Leave the other settings at their
default values as shown:
device:
sampling rate:
51.2KHz
Average Type:
linear
Weighting:
no weighting
FFT size:
512
Internal Data
Averaging:
no
averaging
4. When you are finished, click on the Done button at the bottom right.
5. On the TOA front panel, press the Acquire button. The VI has now
obtained samples of the sinusoidal signal of frequency 200 Hz and
12-23
Lesson 12
Third-Octave Analyzers
Move the cursor so that it aligns with the band corresponding to the
largest peak in the display. The frequency reading on the top of the
display should read 200 Hz. The amplitude reading should be near
-3.0 dB (which corresponds to a peak amplitude of 1.0 V).
You will now save these results as a reference that can be compared
with other signals.
6. Click on the Save button. When prompted for the filename, type in
standard.ref. You could use any filename, but it is
recommended that you use one with a .ref extension if you plan to
use it as a reference file.
The file standard.ref now contains the results of third-octave
analysis on the reference signal.
7. Exit the VI by clicking on the Quit button at the bottom right.
12-24
Lesson 12
Third-Octave Analyzers
Exercise 12-4
Objective:
To compare the results of third-octave analysis on a given signal with that obtained
from a standard reference signal.
In the previous exercise, you had saved the results of third-octave
analysis on our standard reference signal. In this exercise, you will
compare these results with those obtained from another source.
Exchange your DAQ Signal Accessory with someone else in the class
and make the connections as you had done in the previous two exercises.
Assume that your previous DAQ Signal Accessory was well calibrated
and of high enough quality to generate the standard reference signal.
You will now compare those results with those obtained using the other
DAQ Signal Accessory.
Note:
sampling rate:
51.2KHz
Average Type:
linear
Weighting:
no weighting
FFT size:
512
Internal Data
Averaging:
no averaging
12-25
Lesson 12
Third-Octave Analyzers
6. Move the cursor around the plot. For the band on which the cursor is
placed, the top left of the display shows you the center frequency, the
dB levels of the two plots, and the difference in dB levels of the two
plots. The figure below shows the display for the band with the
200 Hz center frequency.
center frequency
current power value
reference power value
7. To calibrate the new DAQ Signal Accessory that you obtained, you
need to adjust the amplitude and frequency on the new box so that
the difference in power reading in the band with a center frequency
of 200 Hz is zero. That will mean that both the DAQ Signal
Accessory boxes are producing signals with exactly the same
frequency and amplitude.
8.
12-26
Lesson 12
Third-Octave Analyzers
Summary
In this lesson, you learned the basic theory behind the operation of octave
analyzers. You have seen that they consist of a set of bandpass filters. The
ratio of the center frequencies and bandwidths of adjacent bandpass filters
is equal to 2 for an octave analyzer and 21/3 (approximately 1.26) for a TOA.
That means that as you go higher in frequency, the center frequency and
bandwidth of one BPF is twice that of the adjacent lower frequency BPF for
the octave analyzer (or 1.26 times that of the adjacent lower frequency BPF
for a third-octave analyzer).
You used the TOA on a signal consisting of a sine wave (and its
harmonics) with added white noise. Specifically, you learned:
How to see the power output and center frequency values by using
the cursor or the Amplitude Table control.
Finally, you saw how to use the TOA to compare the power levels
between two signals, one of which is a reference signal.
12-27
Lesson 12
Third-Octave Analyzers
Notes
12-28
Lesson 13
Joint Time-Frequency
Analysis
Introduction
In this lesson, you will learn the basic theory behind joint time-frequency
analysis (JTFA) and how to use the JTFA Toolkit in a variety of
applications.
13-1
Lesson 13
13-2
Lesson 13
The figure above shows the time-frequency plot of a bird sound. The plot
on the right is the standard Fourier spectrum. From this spectrum alone,
you cannot tell how the frequencies have changed over time. Beneath the
time-frequency plot is a plot of the time waveform of the bird sound.
This shows you only how the sound level changes as a function of time.
The advantage of having a time frequency plot is that not only can you
tell what the range of frequencies were, but also how these frequencies
changed as a function of time. For this bird sound, you can see that at the
beginning, the bird was making a sound at higher frequency, which then
changed as a function of time, as indicated on the graph. Furthermore, in
the time-frequency plot, not only can you see how the frequency
changed in time, but you can see the intensity of the frequency, indicated
by the relative brightness levels of the plot.
13-3
frequency
Lesson 13
time
The figure above shows graphs of a speech signal. The plot at the bottom
of the figure is the time waveform of such a signal. This plot shows how
the magnitude of this signal changes as a function of time. The plot in
the upper right corner is the frequency representation of the same signal.
This representation reveals four prominent frequency tones in the
spectrum. However, from the spectrum alone, you cannot tell how these
frequencies evolve over time. This is where joint time-frequency
analysis comes into the picture. The 2-D contour plot in the figure above
is the result of such an analysis. This plot is the time-dependent
spectrum, a function of both time and frequency, and reveals how
different frequency tones evolved as a function of time. From this, not
only can you see how the frequency changed, but you can also see the
intensity of the frequencies, as shown by the relative brightness levels of
the plot. Consequently, by using JTFA, you can better understand the
mechanism of human speech.
From these two examples, you have seen that time-frequency analysis
offers a better understanding of the nature of the signal. Several other
applications in this lesson illustrate this point.
13-4
Lesson 13
F ( ) f ( t )e
jt
f ( t ) F ( )e
jt
jt
mk
STFT [ i, k ] =
s [ i m ]g [ m ]W L
m = L--
2
13-5
Lesson 13
t0
t18
t11
t4
time-slice 1
time-slice 2
time-slice 3
FFT
FFT
FFT
Square
Magnitude
Square
Magnitude
Square
Magnitude
time
t18
t11
t4
time
b0
Digital
Transmitter
input stream
b1
Assume that two bits are being transmitted simultaneously over two
transmission lines. Let the frequency corresponding to the combination
13-6
Lesson 13
Wigner-Ville Distribution
There are different ways to obtain bilinear1 joint time-frequency
representations. The first is the Wigner-Ville distribution. This technique is
very simple and it better characterizes the signals time-dependent spectra
than the STFT spectrogram. Also, this distribution possesses many
properties useful for signal analysis.
1. Called bilinear because the signal x(t) appears twice in the equations for each representation. For more information,
refer to Joint Time-Frequency Analysis: Methods and Applications by Shie Qian and Dapang Chen, Prentice Hall,
NJ, 1996.
13-7
Lesson 13
The figure above shows the time waveform of a frequency hopper signal,
the corresponding spectrum as calculated by FFT, and the Wigner-Ville
distribution of this signal. From the time waveform, you cannot see the
frequency information. From the spectrum, you can see four distinct
frequency components but cannot tell when those components occurred
in time. The Wigner-Ville distribution provides both the time and
frequency information in the same plot. However, as you can see from
the plot, the main deficiency of this distribution is the cross-term
interference. This cross-term interference occurs at frequencies midway
between the two main frequencies. If there are four main frequencies (as
in the example above), there are six terms due to cross interference.
However, a good characteristic of these cross-term interferences is that
they highly oscillate between positive and negative values. These
positive and negative parts cancel out each other on averaging. To do so,
you can apply a low-pass filter to retain the low frequency components
and remove the high frequency parts. Because the discarded
high-frequency parts have small averages, the lowpass filtered
Wigner-Ville distribution presumably preserves the useful properties
with reduced cross-term interference.
There are two types of lowpass filters, namely the linear type and the
nonlinear type. There are different types of linear filters. It is interesting to
note that all these linear representations can be written in a general form that
was introduced by L. Cohen1.
1. Interested readers should refer to Generalized Phase-Space Distribution Functions, L. Cohen, in the
Journal of Mathematical Physics, vol. 7, pp. 781-806, 1966.
13-8
Lesson 13
Cohens Class
Linear filters fall into a general category known as Cohens class of filters.
With no filtering, the Cohens class distribution is the same as the
Wigner-Ville Distribution. In the JTFA Toolkit, two of the most commonly
used linear filters are implemented below. They are the cone-shaped
distribution and the Choi-Williams distribution.
Cone-Shaped Distribution
frequency
time
When the lowpass filter has a cone shape as shown above, the Cohens
class distribution is known as the cone-shaped distribution. The figure
below shows the cone-shaped distribution of the frequency hopper
signal.
13-9
Lesson 13
Choi-Williams Distribution
frequency
time
When the lowpass filter has an exponential shape, as shown above, the
Cohens class distribution is known as the Choi-Williams distribution
(CWD). The figure below shows the Choi-Williams distribution of the
frequency hopper signal.
13-10
Lesson 13
Gabor Spectrogram
This section discusses the nonlinear type of low-pass filters described by the
time-frequency distribution series, also known as the Gabor Spectrogram1.
The advantage of the nonlinear type of filters is that it gives both good
resolution and small cross-term interference. The Gabor spectrogram
decomposes the Wigner-Ville distribution as DC plus a group of oscillated
time-frequency functions.
1. The Gabor spectrogram was invented by researchers at National Instruments and is a National
Instruments patent. It has won several technological awards. For more information on how to construct
such a filter, refer to S.Qian and D.Chen, Discrete Gabor Transform, IEEE Transactions on Signal
Processing, vol. 41, no. 7, July 1993, pp. 2429-2439
13-11
Lesson 13
When you select the Gabor spectrogram using the JTFA selector on the
toolkit front panel, you are asked to choose the order of the filter. The
lower order Gabor spectrogram has less cross-term interference but
lower resolution. The higher order Gabor spectrogram has better
resolution but more cross-term interference. For order = 0, the Gabor
spectrogram is similar to the STFT when using Gaussian window
function. As the order gets larger, the Gabor spectrogram converges to
the Wigner-Ville distribution. However, it is computationally more
expensive. The best choice is usually order three to four. In this case, the
Gabor spectrogram not only has better resolution than the STFT, but also
possesses much less cross-term interference than the Choi-Williams and
Wigner-Ville distributions. You can choose the Gabor basis to be
wideband, mediumband or narrowband. The matching indicator tells
you how closely the basis function approximates your input signal. The
larger the value, the closer the match. The figure on the following page
shows the third-order Gabor Spectrogram of the Frequency Hopper
signal.
13-12
Lesson 13
13-13
Lesson 13
Acquiring Data
When you start the JTFA application, it prompts you to adjust the
parameters and then press Process. You first read in the signal to be
analyzed. This signal can be stored in an existing file, which must be either
a datalog format file (an internal file format used by LabVIEW) or an ASCII
text file. If your file is text, JTFA converts it to datalog format when you
click on the Read file button. You must convert the file to datalog, but you
can save the converted file under a new name to preserve your original file.
After conversion, the JTFA analyzer opens your file as a datalog file. On the
front panel, you see two more buttons labeled Set DAQ and Read DAQ. If
your computer is equipped with a National Instruments DAQ board, click
13-14
Lesson 13
on the Read DAQ button; the JTFA analyzer starts collecting data from the
DAQ board and stores it a specified data file. When you first click on the
Read DAQ button, it prompts you to set the DAQ parameters. The
application then uses these parameters until you exit. You can use the Set
DAQ button to change the DAQ parameters. After you select the file to
analyze, the toolkit reads a block of data or frame of samples from the file.
Analyzing Data
You can select one of the different algorithms discussed in the previous
section to analyze your data using the JTFA selector control. Each control
has a different set of parameters. The default is set to the short-time Fourier
transform (STFT) algorithm. In this case, the parameters to be selected are
the window selector control and the window length control. The other five
choices are the Gabor Spectrogram, the Choi-Williams distribution, the
cone-shaped distribution, the Wigner-Ville distribution, and the Adaptive
Spectrogram1. The application then analyzes the samples and displays the
resultant spectrogram using an intensity plot. It also displays the traditional
spectrum to the right and the time-waveform below the two-dimensional
spectrogram.
The parameters start at and block length control the time range of the
analyzed signal. While the former determines the start time, the latter
determines the length of one frame of the analyzed signal. If the length
of the signal is less than start at + block length, the JTFA analyzer
processes whatever is available. Because of memory limitations, if the
length of the signal is too long, JTFA displays the longest time duration
allowed in a status indicator dialog box and stops processing.
The parameters start freq. and bandwidth control the frequency range
of the analyzed signal. start freq determines the lower boundary of the
frequency. The selection of the bandwidth is limited to 2-k * Nyquist
frequency, 0 k 5 . If start freq. + bandwidth is greater than the
Nyquist frequency, the JTFA ignores the setting of start freq. and
automatically sets the lower boundary of the frequency to zero (default
value).
By clicking on the subband button, you can select the preemphasis
control. You can use the preemphasis filter to reduce the influence of the
DC component and enhance the high-frequency component. The degree
of preemphasis is controlled by the preemphasis parameter. When this
value is equal to zero (default), there is no preemphasis. When this value
is equal to one, JTFA completely removes the DC component, and the
1. For a detailed discussion on the Adaptive Spectrogram, refer to Joint Time-Frequency Analysis: Methods and Applications, by Shie Qian and Dapang Chen, Prentice Hall, NJ, 1996.
13-15
Lesson 13
13-16
Lesson 13
Exercise 13-1
Objective:
Remember that the application will not start computing until you click on
the Process button.
5. After the computation is complete, three waveforms will appear on
the JTFA window. You will now analyze these waveforms. The time
13-17
Lesson 13
waveform of the doppler signal can be seen in the bottom left part of
the figure. The standard Fourier spectrum can be seen on the top right
part. From this plot, you can see the range of frequencies present in
the spectrum. But the plot does not tell how these frequencies
evolved as a function of time. The larger plot in the upper left corner
is the time-dependent spectrum, a function of both time and
frequency. From it, not only can you see how the frequency changed
with time, but you also can see the intensity of the frequencies as
shown by the relative brightness levels of the plot.
6. You can now select different algorithms in the JTFA selector control
and see how the time-frequency spectrogram looks in each case.
13-18
Lesson 13
Exercise 13-2
Objective:
test
site
non-linear
chirp
13-19
Lesson 13
1. Open the front panel of the JTFA Toolkit as shown above, if it is not
already open from the previous exercise.
2. You will analyze data in the file c:\jtfa\data\impulse.log.
Click on the Read file button and choose this data file. The name of
the data file can now be seen in the current file box.
3. Adjust some of the parameters. Change the panel color to gray using
the front panel switch. You will experiment with all the available
algorithms using the JTFA selector. First, select the Gabor
spectrogram. Use the default values for all the other parameters.
4. After setting all parameters, click on the Process button. Remember
that the application will not start computing until you have done this.
5. After the computation is complete, three waveforms will appear on
the JTFA front panel. The time waveform of the ionized impulse
signal can be seen in the bottom left part of the figure. As explained
earlier, after passing through dispersive media, such as the
ionosphere, the impulse signal becomes a nonlinear chirp signal with
added random noise. Because of the low signal-to-noise ratio, you
can hardly see this chirp signal in the time waveform. It is
completely hidden by the noise signal. The standard Fourier
spectrum can be seen on the top right part. From this plot, you can
see the range of frequencies that are present in the spectrum. The
13-20
Lesson 13
6. You can now select different algorithms and see how the
time-frequency spectrogram looks in each case.
7. Exit the JTFA analyzer by pressing the Quit button.
13-21
Lesson 13
Summary:
The JTFA toolkit is an excellent tool to learn this technique and use
it in many real-world applications.
13-22
Lesson 13
Notes
13-23
Lesson 13
Notes
13-24
Lesson 14
Wavelet and Filter Banks
Designer
Introduction
Wavelets are being applied in a diverse range of applications for the analysis
of nonstationary signals. These applications include removing noise from
signals, detecting abrupt discontinuities, and compressing large amounts of
data. The design of wavelets is closely related to the design of filters. The
Wavelet and Filter Banks Designer provides you with the flexibility to
interactively design the filters, and hence wavelets, for your specific
application.
14-1
Lesson 14
A. Signal Representation
Before learning about the wavelet transform and its applications, you first
need to understand some basic concepts from linear algebra. In particular,
you need to be familiar with inner products and basis vectors.
Inner Product
The inner product of two vectors is a mathematical operation that
determines the similarity of these vectors with respect to each other. For
example, given the vectors x = (x1, x2), and y = (y1, y2), their inner
product is
<x,y> = x1*y1 + x2*y2
The inner product determines the similarity by calculating the projection
(or component) of one vector in the direction of the other. For example,
if you have two vectors, say v and x, the projection (denoted by p) of v
on x is given by
<v,x>
p = -------------x
x
p=0
p>0
x
p<0
The larger the value of |p|, the more similar the vectors are to one
another, and vice versa. When the inner product is equal to zero, the two
vectors are perpendicular to each other. Another way to say this is that
the two vectors are orthogonal when their inner product is equal to zero.
Basis Vectors
Consider a vector in 2D. Any such vector can be written as the weighted
sum of two other unit vectors, i = (1,0) and j = (0,1). For example, the vector
14-2
Lesson 14
j
0
The vectors i and j are known as the basis vectors in 2D. Every other
vector in 2D can be written as a combination of these two basis vectors.
An important property of basis vectors is that they are perpendicular
(orthogonal) to each other. That corresponds to their inner product being
equal to zero. Also, their magnitudes are equal to one. For the basis
vectors i and j in 2D,
<i, j> = < (1,0), (0,1) > = 1*0 + 0*1 = 0
In other words, this means that they are linearly independent (see Lesson
8, Linear Algebra) and you cannot express one of them in terms of the
other.
For the vector v = (4,1), you can take its inner product with respect to the
unit vectors i and j:
<v,i> = 4*1 + 1*0 = 4 and
<v,j> = 4*0 + 1*1 = 1
This gives the projection of v on the unit vectors. Because <v,i> is
greater than <v,j>, you can say that the vector v is more similar to i than
to j. This is readily apparent from the figure above, where v is more
horizontal than vertical. (Note that because i and j are unit vectors, their
magnitude is equal to 1.0. Thus, in the above equations, we did not
specifically normalize by the magnitude.)
If you know the values of the inner product of v with the basis vectors i
and j, you can obtain v from the basis vectors by multiplying them with
the values of the corresponding inner products and adding up the results.
For the example given,
4*i + 1*j = 4*(1,0) + 1*(0,1) = (4,0) + (0,1) = (4,1) = v.
The important points to remember from the above discussion are:
14-3
Lesson 14
The larger the value of the inner product, the greater the similarity of
the given vector with respect to that particular basis vector.
You can reconstruct the vector v by knowing the values of its inner
product with each of the basis vectors. The reconstruction is
achieved by multiplying the inner product with the corresponding
basis vector and adding the results.
Fourier Transform
Just as you can break up any vector in 2D in terms of a set of basis
vectors i and j, you can also break up a time signal s(t) in terms of a set
of basis functions. A well known popular example of basis functions in
signal analysis are the sines and cosines of the Fourier transform. These
sines and cosines are harmonically related to each other, which means
that their frequencies are all integer multiples of a fundamental
frequency. In addition, the sines and cosines are orthogonal (if you take
their inner product, the result is zero).
When you take the Fourier transform of a time signal s(t), you are
actually taking the inner product of the signal with each of the basis
functions. So you actually are seeing the similarity of the signal to each
of the sines and cosines of different frequencies. If you get a large value
of the inner product with a basis function at a particular frequency, it
means that quite a bit of that frequency is present in the signal. If the
inner product happens to be zero, it means that frequency is not present
in s(t).
Although the Fourier transform is a useful tool in obtaining information
about the frequency content of a signal, its disadvantage is that it is
unable to tell us when in time a particular frequency occurs. For
example, consider the two chirp signals shown in the top two plots of the
figure on the next page. The frequency of the top signal is increasing,
whereas that of the bottom signal is decreasing. However, both have
exactly the same magnitude of the Fourier transform, as shown in the
lowermost figure.
14-4
Lesson 14
Looking at the Fourier transform of a signal, you cannot tell how its
frequency changes with time. All that you observe is the frequency
content of the sampled signal in the given time interval. The drawback
of this form of traditional Fourier transform analysis is that it is only
useful for the analysis of stationary signals (that is, signals whose
frequency content does not vary with time).
14-5
Lesson 14
0
0
200
2
400
4
600
6
800
8
1000
10
time
(secs)
Fourier
Transform
signal spectrum
amplitude
frequency
14-6
Lesson 14
However, you can also divide the signal into five equal time intervals of
two seconds each, and analyze the frequency content of each interval
separately. In each of these time intervals, you will have 200 samples of
the signal. You can then take the Fourier transform of successive
2-second time intervals, as shown below.
0
0
200
2
400
4
600
6
800
8
200 samples
200 samples
200 samples
200 samples
200 samples
Fourier
Transform
Fourier
Transform
Fourier
Transform
Fourier
Transform
Fourier
Transform
1000
10
time
(secs)
freq
color or grayscale
corresponds to
amplitude
10
time
The result is a 3D spectrum, where the x-axis represents time, the y-axis
represents frequency, and the z-axis (out of the page) represents the
amplitude of the frequencies during the time for which the transform was
taken. The z-axis can be in color or gray scale to represent the amplitude
values. This method of dividing the signal into smaller time intervals and
then taking the Fourier transform of successive intervals is known as the
short-time Fourier transform (STFT).
Note that each spectrum is obtained over a time interval of 2 seconds.
So, you know that any frequency component indicated in the spectrum
occurred somewhere within those 2 seconds. Thus this method provides
you with better time resolution than the first case, where you had an
interval of 10 seconds, somewhere during which a frequency shown in
the spectrum could have occurred. However, note that the frequency
14-7
Lesson 14
resolution is now f = fs/200, and is now five times larger than in the first
case.
Good time resolution is necessary for the rapidly changing
(high-frequency) parts of a signal, whereas good frequency resolution is
necessary for the smoothly varying (low frequency) parts of a signal. To
improve the frequency resolution, you can (for a given sampling
frequency) increase the size of the time interval during which you obtain
the samples, but then the time resolution is affected. If you improve the
time resolution by decreasing the time interval, the frequency resolution
is affected, because now you have fewer samples, so f is larger. Hence,
there is a trade-off between the time resolution and the frequency
resolution when using the STFT.
14-8
Lesson 14
Basis function
for
wavelet
transform
Using the wavelet basis functions, you can obtain both good time
resolution and good frequency resolution. You first select (or design) a
prototype wavelet known as a mother wavelet. This wavelet is then
either stretched or compressed in time to obtain other wavelets for
the basis. The wavelet obtained by stretching has a longer time
duration than the mother wavelet and is good for extracting the
low-frequency information of the signal. The wavelet obtained by
compressing has a shorter time duration than the mother wavelet and
is good for extracting the high-frequency information of the signal.
Thus, it is useful for temporal analysis. The scale change (compressing
or stretching) is done in powers of two. The figure below shows a mother
wavelet and two other wavelets obtained from it:
14-9
Lesson 14
mother wavelet
compress to 1/2
stretch by 2
14-10
Lesson 14
Fourier Transform
Wavelet Transform
Basis functions
Wavelets
Assumption
Type of signal
Stationary
Nonstationary
Analysis
Multiresolution
14-11
Lesson 14
C. Applications of Wavelets
The wavelet transform is useful for the analysis of nonstationary signals,
whose frequency contents vary with time. Examples of nonstationary
signals are biomedical (for example, electrocardiogram), music, turbulence,
seismic, sound, and vibration data that change slowly or abruptly. For
signals like these, information about when the changes occur can often be
very important.
You have seen that you can use the wavelet transform to have both good
time and good frequency resolution simultaneously. Wavelets with a
short time duration are good for extracting high-frequency information
(such as discontinuities and abrupt changes) from a signal, whereas
wavelets with a longer time duration are useful for low-frequency
analysis. Thus, it is possible to see both the forest and the trees.
Wavelets have been used in diverse fields covering a wide variety of
applications. Some of the practical uses of wavelets are:
Detection of discontinuities.
14-12
Lesson 14
10 kHz
G0
s[n]
G0
G1
5 kHz
2
s1[n]
s2[n]
s3[n]
2
G1
20 kHz
10 kHz
14-13
Lesson 14
s(t) 0 20 kHz
s1[n] 0 5 kHz
s2[n] 5 10 kHz
s3[n] 10 20 kHz
In practice, you do not need to stop after only two stages of filtering. You
could continue to split the lowpass filtered signal into even more
frequency bands, as shown below:
s[n]
G1
G1
G0
G0
G1
G0
G1
G0
Note:
14-14
Lesson 14
output of each highpass filter is the value of the inner product of the
signal with one of the wavelets. This value is the wavelet coefficient and
indicates the similarity of the signal with respect to the corresponding
wavelet.
s[n]
G1
wavelet coefficient
G0
G1
wavelet coefficient
G0
G1
G0
wavelet coefficient
G1
G0
wavelet coefficient
(impulse response
could be
mother wavelet)
If the filters that make up the filter bank satisfy certain conditions, it is
possible to reconstruct the original signal s[n] from s1[n], s2[n],
and s3[n].
s1[n] 0 - 5 KHz
s2[n] 5 - 10 KHz
s3[n] 10 - 20 KHz
s[n] 0 - 20 KHz
This can be achieved by using another set of lowpass filters, H0, and
highpass filter, H1, and adding their outputs together, as shown below:
14-15
Lesson 14
5 kHz
s1[n]
10 kHz
H0
20 kHz
H0
+
s2[n]
2
+
s[n]
H1
s3[n]
2
H1
10 kHz
14-16
Lesson 14
P0
G0
H0
The final step involves splitting the filter P0 into G0 and H0. These three
steps are outlined below:
Step 1: Select the type of filter bank. The available choices are:
Orthogonal
Biorthogonal
Step 2: Select the type of filter for P0. The available choices are:
Maxflat
Positive equiripple
General equiripple
Any of the three types of filters mentioned in step 2 can be used with
biorthogonal filter banks. However, with orthogonal filter banks, you
can have only maxflat or positive equiripple filters, but not general
equiripple.
14-17
Lesson 14
14-18
Lesson 14
Step 1:
select type of
filter banks
frequency
response of
lowpass filter G0
and highpass
filter G1
Step 2:
select type
of filter P0
(P0 is the
cascade of
the lowpass
filters G0 and H0)
distribution of zeros
of lowpass filters
G0 and H0
x: G0
o: H0
Step 3:
select type of
lowpass filter G0
14-19
Lesson 14
Exercise 14-1
Objective:
To design a wavelet that captures the important features of an ECG signal, but with
less than half the number of data points.
1. Launch the WFBD from the Programs menu.
2. The Design Panel appears. It gives you the power of designing
arbitrary wavelets for your particular application. The Design Panel
is shown below:
14-20
Lesson 14
14-21
Lesson 14
14-22
Lesson 14
Exercise 14-2
Objective:
14-23
Lesson 14
The lowermost figures show the images obtained after the process of
lowpass and highpass filtering (refer to section D). To recapitulate,
if the input image is s[n], then the resulting images after filtering are
s1[n], s2[n], s3[n], and s4[n], as shown below.
G1
s4[n]
G0
s3[n]
G1
s2[n]
G0
s1[n]
G1
s[n]
G0
14-24
Lesson 14
LL
s1[n]
LH
s2[n]
HL
s3[n]
HH
s4[n]
14-25
Lesson 14
Summary
You have seen that the basis functions for the wavelet transform are known
as wavelets and are compressed and stretched versions of one another, with
a finite time duration. Wavelets with a short time duration are good for
high-frequency analysis, whereas those with a longer time duration are good
for low-frequency analysis. Using wavelets, it is possible to simultaneously
get good time as well as frequency resolution. Depending on your
application, a particular wavelet may be more suitable than another wavelet.
Hence, designing an appropriate wavelet is an important part of wavelet
analysis. The design of wavelets is closely related to the design of filter
banks. Using the Wavelet and Filter Banks Designer, you can interactively
design the filters in the filter bank and simultaneously monitor the effect
they have on the signal. Because of their ability for effective feature
extraction, wavelets are widely used for data compression.
14-26
Lesson 14
Notes
14-27
Lesson 14
Notes
14-28
Appendix A
Error Codes
Analysis Error Codes
Table A-1. Analysis Error Codes
Code
Name
Description
NoErr
20001
OutOfMemErr
20002
EqSamplesErr
20003
SamplesGTZeroErr
20004
SamplesGEZeroErr
20005
SamplesGEOneErr
20006
SamplesGETwoErr
20007
SamplesGEThreeErr
20008
ArraySizeErr
20009
PowerOfTwoErr
20010
MaxXformSizeErr
20011
DutyCycleErr
A-1
Appendix A
Error Codes
Name
Description
20012
CyclesErr
20013
WidthLTSamplesErr
20014
DelayWidthErr
20015
DtGEZeroErr
20016
DtGTZeroErr
20017
IndexLTSamplesErr
20018
IndexLengthErr
20019
UpperGELowerErr
20020
NyquistErr
20021
OrderGTZeroErr
20022
DecFactErr
20023
BandSpecErr
20024
RippleGTZeroErr
20025
AttenGTZeroErr
20026
WidthGTZeroErr
20027
FinalGTZeroErr
20028
AttenGTRippleErr
20029
StepSizeErr
A-2
Appendix A
Error Codes
Name
Description
20030
LeakErr
20031
EqRplDesignErr
20032
RankErr
20033
EvenSizeErr
20034
OddSizeErr
20035
StdDevErr
20036
MixedSignErr
20037
SizeGTOrderErr
20038
IntervalsErr
20039
MatrixMulErr
20040
SquareMatrixErr
20041
SingularMatrixErr
20042
LevelsErr
20043
FactorErr
20044
ObservationsErr
20045
DataErr
A-3
Appendix A
Error Codes
Name
Description
20046
OverflowErr
20047
BalanceErr
20048
ModelErr
20049
DistinctErr
20050
PoleErr
20051
ColumnErr
20052
FreedomErr
20053
ProbabilityErr
20054
InvProbErr
20055
CategoryErr
20056
TableErr
20061
InvSelectionErr
20062
MaxIterErr
20063
PolyErr
20064
InitStateErr
20065
ZeroVectorErr
A-4
Appendix A
Error Codes
No error
23001
23002
23003
23004
23005
Negative distance
23006
23007
23008
23009
23010
23011
23012
Nonpositive accuracy
23013
23014
23015
Empty X0
23016
23017
Multiple roots
23018
23019
23020
23021
23022
23023
23024
No root found
A-5
Appendix A
Error Codes
Table A-2.
Error Code
Number
23025
23026
No optimum found
23027
23028
23029
23030
23031
No valid point
23032
23033
23034
23035
Nonpositive number
23036
Different parameters
23037
23038
No variables in expression
23039
Parameter problem
23040
23041
23042
Negative argument
23043
23044
23045
n<k
23046
Empty array
23047
23048
23049
23050
A-6
Appendix A
Table A-2.
Error Codes
Error Code
Number
23051
23052
23053
23054
Nonunique variables
Corresponding G Math
Function name
Description
abs(x)
Absolute Value
acos(x)
Inverse Cosine
acosh(x)
asin(x)
Inverse Sine
asinh(x)
atan(x)
Inverse Tangent
atanh(x)
ci(x)
Cosine Integral
ceil(x)
Round to +Infinity
cos(x)
Cosine
cosh(x)
Hyperbolic Cosine
cot(x)
Cotangent
csc(x)
Cosecant
A-7
Appendix A
Error Codes
Table A-3. Functions for Use with G Math Toolkit Parser VIs (Continued)
Function
Corresponding G Math
Function name
Description
exp(x)
Exponential
expm1(x)
Exponential(Arg)1
floor(x)
Round to Infinity
gamma(x)
Gamma Function
getexp(x)
getman(x)
int(x)
intrz
ln(x)
Natural Logarithm
lnpl(x)
Natural Logarithm
(Arg + 1)
log(x)
Logarithm Base 10
log2(x)
Logarithm Base 2
pi(x)
pi(x) = x*
pi(1) =
pi(2.4) = 2.4*
rand( )
sec(x)
Secant
si(x)
Sine Integral
sign(x)
Sign
A-8
Appendix A
Error Codes
Table A-3. Functions for Use with G Math Toolkit Parser VIs (Continued)
Function
Corresponding G Math
Function name
Description
sin(x)
Sine
sinc(x)
Sinc
sinh(x)
Hyperbolic Sine
spike(x)
Spike function
spike(x) returns:
1 if 0 x 1
0 for any other value of x.
sqrt(x)
Square Root
square(x)
Square function
step(x)
Step function
step(x) returns:
0 if x < 0
1 if any other condition obtains.
tan(x)
Tangent
tanh(x)
Hyperbolic Tangent
Error Example
No error
sin(x)
1+x)
Incomplete function
expression
sin(x)+
Bracket problem
()
(1+x
A-9
Appendix A
Error Codes
Table A-4.
1,2 (US)
sin()
sins(x)
Incomplete expression
x+
10
a11
11
Wrong letter
sin(X)
12
1.23.45
21
1+x+y4
22
Inconsistency in variables
or numbers
Depends on application
23
Contains variables
Depends on application
24
Depends on application
A-10
Appendix B
Frequently Asked Questions
Background
1. Can the antialias filter be a hybrid filter?
When going from the analog to the digital domain, the antialias
filter must be an analog filter. In general, when going from a domain
P to a domain Q, the filter should be in domain P to avoid the
problem of aliasing in the domain Q. Thus, when sampling to go
from an analog to a digital signal, the filter should be an analog filter.
However, when performing decimation to reduce the sampling rate,
you are going from the digital domain (with a higher sampling rate)
to the digital domain (with a lower sampling rate). In this case, the
filter before the decimation is performed will be a digital filter.
Signal Generation
1. Why are there Pattern VIs, when the Wave VIs will do all that the
pattern VIs can and more?
The historical reason is that Pattern VIs were created first. Also, the
Pattern VIs are meant to be used to generate a block of data at a time,
whereas the Wave VIs can be called iteratively in a loop.
2. Why do I need normalized frequency? Why not just use the
common frequency unit of Hertz in the input controls and have the
VI automatically convert it internally into normalized frequency if
necessary?
Because some people think in terms of Hertz (cycles per second) and
some think in terms of cycles. Normalized frequency handles both.
3. What does it mean that the Wave VIs are reentrant?
You can have several of them on the same block diagram, and each
one will have its own code. They will all work independently of each
other.
B-1
Appendix B
Signal Processing
1. What are the limits/problems of zero padding? Does it introduce
harmonics? Does it affect the frequency content of a signal in any
way?
Zero padding performs interpolation in the frequency domain. No, it
does not introduce harmonics. In addition to improving (that is,
lowering) the frequency resolution, faster algorithms (using the FFT
instead of the DFT) are possible.
2. What is the physical meaning of the cross power spectrum?
It is a measure of the similarity of two signals in the frequency
domain. It is the frequency-domain equivalent of the
cross-covariance function. It shows the joint presence of energy in
the two signals.
Windows
1. Why do different toolkits provide only some specific window
choices? Why not all window choices?
One reason is that the windows chosen are the most common
windows for that particular application. The other is that several of
the windows give very similar results, so there is no point in
including all of them.
Digital Filters
1. What is meant by linear phase?
Linear phase in digital filters means that the phase distortion is
nothing more than a digital delay. All input samples will be shifted
by some constant number of samples, so this phase change can be
easily fixed and/or modeled.
Nonlinear phase means that the individual sine waves that make up
the input signal get shifted in time by different amounts. This sort of
phase change is very difficult to work around. Some signals (like the
square wave) are very sensitive to this sort of phase distortion.
2. What does it mean when the IIR filters execute in place?
In place means that the input array space (memory locations) are
being reused as the output array space. In place usually implies lower
demands on memory.
3. Do the FIR filters have only zeros?
FIR filters do have zeros, but they also have poles at the origin. If you
take the Z-transform of an FIR filter, and rewrite it as the product of
factored terms, you will find that in addition to zeros, they also have
poles at the origin.
B-2
Appendix B
Curve Fitting
1. What is the limit in LabVIEW and BridgeVIEW on the number of
parameters used for curve fitting?
There is no limit. However, keep in mind that the memory
requirements, as well as the time required to find the solution, will
increase with increasing number of parameters.
2. Some curve fitting algorithms allow you to give weight to certain
data points. Can I do that in the VIs from the advanced analysis
library of LabVIEW and BridgeVIEW?
No, it is not possible.
3. In performing a fit, is there any rule of thumb as to how many data
points to use?
Normally, you need at least one more than the number of parameters
for which you are trying to solve. But there is no such rule as to
whether you should use at least five times more, 10 times more, etc.
As an example, in performing a polynomial fit, the number of data
points to be used to obtain a good fit may be correlated to how
close the data is to the underlying polynomial (that is, how much
noise). It depends.
4. In the Levenberg-Marquardt VI, why is the derivative information
needed?
The information is needed to calculate the Jacobian, which is needed
in the algorithm to solve for the coefficients that you are trying to
determine. See the Analysis VI Reference Manual for details.
Wavelets
1. When I do the decimation (by 2), what options do I have? Can I
throw away every even sample, every odd sample, the first half, the
second half, etc?
National Instruments Corporation
B-3
Appendix B
B-4
Appendix C
References
The following documents contain more detailed information about the
topics discussed in this course.
Other Documents
C-1
Appendix C
References
C-2
Appendix D
Glossary
Prefix
Meaning
Value
M-
mega-
106
K-
kilo-
103
m-
milli-
10-3
micro-
10-6
n-
nano-
10-9
Numbers/Symbols
1D
One-dimensional.
2D
Two-dimensional.
Infinity.
Pi.
A
AC
Alternating current.
ADC
analog signal
A signal whose values are continuous and are defined at each and
every instant of time.
D-1
Appendix D Glossary
ANSI
antialias filter
array
B
bandpass filter
bandstop filter
BPF
Bandpass filter.
BSF
Bandstop filter.
Butterworth filter
C
Chebyshev filter
Chebyshev II filter
complex conjugate
transpose
complex matrix
condition number
1
p
D-2
Appendix D
curve fitting
Glossary
D
DAQ
Data acquisition.
data acquisition
dB
Decibels.
DC
Direct current.
decibel
DFT
difference equations
digital signal
A signal that can take on only specific amplitude values that are
defined at discrete points in time.
discrete-time signal
DSP
E
elliptic filter
equivalent noise
bandwidth (ENBW)
D-3
Appendix D Glossary
F
FFT
filter bank
FIR filter
forward coefficients
frequency response
G
Gaussian probability
density function
H
harmonic distortion
Hermitian matrix
highpass filter
D-4
Appendix D
HPF
Highpass filter.
Hz
Glossary
I
IEEE
IIR filter
IMAQ
Image acquisition.
impulse
A signal that has a value of one at a particular time instant and zero
everywhere else.
impulse response
inf
in place
In place means that the input array space (memory locations) are
being reused as the output array space. In place usually implies
lower demands on memory.
inverse Chebyshev filter A filter characterized by a smooth response in the passband, but
with ripples in the stopband.
I/O
J
joint time-frequency
analysis (JTFA)
K
Levenberg-Marquardt
D-5
Appendix D Glossary
L
linear phase
A matrix whose elements above the main diagonal are all zero.
lowpass filter
LPF
Lowpass filter.
LU decomposition
M
matrix
Two-dimensional array.
MB
Megabytes of memory.
mother wavelet
MSE
N
NaN
norm
D-6
Appendix D
Glossary
nonlinear phase
nonrecursive filter
nonsingular matrix
normalized frequency
Nyquist theorem
O
observation matrix (H)
octave
A doubling in frequency.
one-sided transform
P
passband
D-7
Appendix D Glossary
passband ripple
o
ripple (dB) = 20log 10 ------------
These are signal generation VIs that do not keep track of the phase
of the signal that they generate each time they are called. The Chirp
Pattern VI is the only pattern VI that requires its frequency input
in terms of normalized frequency.
pole-zero plot
A plot showing the positions of the poles and zeros of a system. The
pole-zero plot is useful in determining the stability of the system.
power spectrum
The power spectrum of a signal gives you the power in each of its
frequency components. It can be calculated by squaring the
magnitude of the Fourier transform (DFT or FFT) of the signal.
Q
quality factor (Q)
R
rank
where min denotes the minimum of the two numbers. The rank of a
square matrix pertains to the highest order nonsingular matrix that
can be formed from it. So, the rank pertains to the highest order
matrix that we can obtain whose determinant is not zero. A square
D-8
Appendix D
Glossary
regression analysis
reverse coefficients
RHS
ripple
RMS
S
sampling frequency
short-time Fourier
transform (STFT)
singular value
decomposition (SVD)
spectral leakage
step response
stopband
D-9
Appendix D Glossary
stopband attenuation
symmetric matrix
T
total harmonic distortion
THD =
A 1 + A 2 + A 3 + ... + A N
------------------------------------------------------------------A1
+A
+A
+ ... + A
N
1
2
3
% THD = ----------------------------------------------------------------------------------
A1
transient response
The transient that initially appears at the output of a filter when the
VI is run. The time duration of the transient depends on the order
of the filter. It can be eliminated by setting the init/cont control of
the VI to TRUE.
transition region
The region between the passband and the stopband where the gain
of the filter varies from one (0 dB) or almost one (in the passband)
to a very small value (in the stopband).
transpose
two-sided transform
U
upper triangular matrix
A matrix whose elements below the main diagonal are all zero.
D-10
Appendix D
Glossary
V
vector
One-dimensional array.
W
wavelets
wavelet transform
The transform whose basis functions are time limited and are
known as wavelets. Using the wavelet transform, it is possible to
have both good time and good frequency resolution
simultaneously. The selection of a suitable wavelet is an important
consideration in the use of the wavelet transform.
wave VIs
Signal generation VIs that keep track of the phase of the signal that
they generate each time they are called. They require their
frequency input to be in terms of normalized frequency.
windowed Fourier
transform
Z
zero padding
D-11
Appendix D Glossary
Notes
D-12