Title: Agenda
1Agenda
- 1. Difference equations
- 2. Z-transforms
- 3. Discrete Fourier transform
- 4. Power spectral density
21. Difference equations
- Definition
- Examples
- Sample-date systems
- Response of discrete LTI system
1. Difference equations
3Definition
- Difference equations are equations that relate
the state of the system at discrete points. - Difference equations normally assume that there
is a single, fixed time between samples - Difference equations are easily handled by
computers and even by spreadsheets - Difference equations are a special-case of
sampled-data systems
1. Difference equations
4Examples (1 of 4)
Example 1
?
xn
yn
2
unit delay
yn-1
yn 2 yn-1 xn yn - 2 yn-1 xn
- A first-order, linear, time-invariant (LTI)
- difference equation
1. Difference equations
5Examples (2 of 4)
Example 2
qn
?
?
xn
yn
unit delay
2
4
qn-1
yn qn 4 qn-1 qn 2 qn-1 xn
qn-1 1/6(-xn yn) qn
1/3(2 xn yn) qn-1 1/3(2 xn-1
yn-1)
4 qn-1 qn yn -2 qn-1 qn xn
yn - 2 yn-1 xn 4 xn-1
1. Difference equations
6Examples (3 of 4)
Example 3
?
yn
?
xn
2
4
unit delay
unit delay
yn-2
yn-1
yn 4 yn-1 2 yn-2 xn
1. Difference equations
7Examples (4 of 4)
Example 4
?
?
1/3
xn
yn
1/3
1/3
unit delay
unit delay
xn-2
xn-1
yn 1/3 (xn xn-1 xn-2)
1. Difference equations
8Sample-data systems
- A system that receives information intermittently
- Sampling may be periodic, aperiodic, or random
- State information is not available between samples
sampler
e(t)
x(t)
computer
hold circuit
plant
y(t)
-
1. Difference equations
9Response of discrete LTI system
- Impulse response
- hn T?n
- Arbitrary input
- xn ? xk ?n-k
- Response to arbitrary input
- yn T xn T ? xk ?n-k
- ? xk hn-k
- convolution sum
?
k-?
?
k-?
?
k-?
1. Difference equations
102. Z-transform
- Introduction
- Z transformation
- Definition
- Transforms
- Examples
2. Z-transforms
11Introduction
- The z-transform is the discrete-time counterpart
of the Laplace transform - The Laplace transform converts integro-differentia
l equations into algebraic equations. - The z-transform converts difference equations
into algebraic equations - Properties of z-transforms parallel those of
Laplace transforms, but there are important
distinctions
2. Z-transforms
12Z transformation
time domain
linear difference equation
time domain solution
summing
z transform
inverse z transform
z transformed equation
z transform solution
algebra
z domain or complex frequency domain
2. Z-transforms
13Definition
?
X(z) ? xn z -n where z is a complex number
n-?
2. Z-transforms
14Transforms (1 of 4)
Unit impulse
- Unit impulse sequence, ?n
?
X(z) ? ?n z -n 1
n-?
2. Z-transforms
15Transforms (2 of 4)
Unit step
?
X(z) ? u0 z -n ? z -n 1/(1 - z-1)
z/(z 1)
n-?
?
0
2. Z-transforms
16Transforms (3 of 4)
an
- Unit step sequence times an, an u0
?
X(z) ? u0 an z -n ? an z -n 1/(1 - a
z-1) z/(z - a)
n-?
?
0
2. Z-transforms
17Transforms (4 of 4)
Properties
x1n ? x2n xn - m zon xn z-n ? xn
X1(z) X2(z) z-m X(z) X(z/zo) X(1/z) z/(z
-1) X(z)
Linearity Time shift Multiplication by
zon Time reversal Accumulation
n
k-?
18Examples
- yn 2 yn-1 xn
- Y(z)/X(z) 1/(1-2 z-1)
- yn - 2 yn-1 xn 4 xn-1
- Y(z)/X(z) (1 4 z-1) /(1-2 z-1)
- yn 4 yn-1 2 yn-2 xn
- Y(z)/X(z) 1 /(1- 4 z-1 - 2 z-2 )
2. Z-transforms
193. Discrete Fourier transform
- DFT
- Aliasing
- Sampling theorem
- Frequency, resolution, and length
- Linear convolution
- Circular convolution
- Block filtering
- Filtering
- Windowing
3. Discrete Fourier transform
20DFT (1 of 4)
DFT
N-1
N-1
Xk ? x n e -j(2?/N)kn ? x n WNkn
n0
n0
Inverse DFT
N-1
N-1
xn 1/N ? Xk e j(2?/N)nk 1/N ? Xk WN-kn
k0
k0
Where
WN e -j(2?/N)
3. Discrete Fourier transform
21DFT (2 of 4)
Matrix format
X DN x
1 1 1
1 1 WN1 WN2
WN(N-1) 1 WN2 WN4
WN2(N-1) . . . 1 WN(N-1)(N-1)
WN(N-1)(N-1) WN(N-1)(N-1)
X0 X1 X2 . . . XN-1
x0 x1 x2 . . . xN-1
3. Discrete Fourier transform
22DFT (3 of 4)
Example DFT
e -j(2?/4)00 e -j(2?/4)10 e -j(2?/4)20 e
-j(2?/4)30 e -j(2?/4)01 e -j(2?/4)11 e
-j(2?/4)21 e -j(2?/4)31 e -j(2?/4)02 e
-j(2?/4)12 e -j(2?/4)22 e -j(2?/4)32 e
-j(2?/4)03 e -j(2?/4)13 e -j(2?/4)23 e
-j(2?/4)33)
X0 X1 X2 X3
x0 x1 x2 x3
1 1 1 1 1 -j -1 j 1 -1 1
-1 1 j -1 -j
X0 X1 X2 X3
1 1 0 0
2 1 - j 0 1 j
3. Discrete Fourier transform
23DFT (4 of 4)
Example DFT (continued)
e j(2?/4)00 e j(2?/4)10 e j(2?/4)20 e
j(2?/4)30 e j(2?/4)01 e j(2?/4)11 e
j(2?/4)21 e j(2?/4)31 e j(2?/4)02 e
j(2?/4)12 e j(2?/4)22 e j(2?/4)32 e
j(2?/4)03 e j(2?/4)13 e j(2?/4)23 e
j(2?/4)33)
x0 x1 x2 x3
X0 X1 X2 X3
1/4
1 1 1 1 1 j -1 -j 1 -1 1
-1 1 -j -1 j
x0 x1 x2 x3
2 1 - j 0 1 j
1 1 0 0
1/4
3. Discrete Fourier transform
24Aliasing
- The condition in which a continuous-time sinusoid
of higher frequency acquires the identity of a
lower-frequency sinusoid
3. Discrete Fourier transform
25Sampling theorem
- The signal x(t) must be bandlimited such that its
spectrum contains no frequencies above fmax. - The sampling rate fs must be chosen to be ? 2
fmax - 2 fmax is the Nyquist rate
- fs/2 is the Nyquist frequency or folding
frequency
3. Discrete Fourier transform
26Frequency, resolution, length (1 of 4)
Equations
?f 1/To fs/N 1/(NT) 1/To ?f frequency
resolution fs sampling frequency To record
length T sampling interval N number of
samples
3. Discrete Fourier transform
27Frequency, resolution, length (2 of 4)
Example
- Relationship of record length
- An analog signal having a 0.2 second record
length is sampled at a frequency of 2.5 kHz - Maximum frequency that can be present in this
sample if there is no aliasing - fmax Nyquist frequency fs/2 1250 Hz
- Frequency resolution of a DFT for this signal
- ?f 1/To 1/0.2 5 Hz
3. Discrete Fourier transform
28Frequency, resolution, length (3 of 4)
Example (continued)
- Record length
- N To/T 0.2/(1/2500) 500 samples
- Frequencies present
- f 0, 5, 10, , 1250, -1245, -1240, , -5
3. Discrete Fourier transform
29Frequency, resolution, length (4 of 4)
Effect of changing numbers
N T To ?f fmax N 2T 2 To 0.5 ?f 0.5
fmax 2N 0.5 T To ?f 2 fmax 2N T 2 To
0.5 ?f fmax
3. Discrete Fourier transform
30Linear convolution (1 of 7)
Determining yn from xn and hn
- yn are determined by convolving xn and hn
hn
xn
yn
3. Discrete Fourier transform
31Linear convolution (2 of 7)
Convolution by multiplication
hn 1 2 -1 1 xn 1 1 2 1 2
2 1 1 yn 1 3 3 5 3 7 4 3
3 0 1
1148-1
1 1 2 1 2 2 1 1 1 2 -1 1 1
1 2 1 2 2 1 1 2 2 4 2 4
4 2 2 -1 -1 -2 -1 -2 -2 -1 -1
1 1 2 1 2 2 1 1 1
3 3 5 3 7 4 3 3 0 1
Introduction to Signal Processing Sophacles J.
Orfanidis page 147
3. Discrete Fourier transform
32Linear convolution (3 of 7)
Convolution by filtering in time
time
1 2 -1 1
1 1 2 2 1 2 1 1
1 3 3 5 3 7 4 3 3 0 1
1 1 2 2 1 2 1 1
1 1 2 2 1 2 1 1
1 1 2 2 1 2 1 1
1 1 2 2 1 2 1 1
1 1 2 2 1 2 1 1
1 1 2 2 1 2 1 1
1 1 2 2 1 2 1 1
1 1 2 2 1 2 1 1
1 1 2 2 1 2 1 1
1 1 2 2 1 2 1 1
3. Discrete Fourier transform
33Linear convolution (4 of 7)
Convolution by sliding filter
filter slide
1 1 2 1 2 2 1 1
1 -1 2 1
1 3 3 5 3 7 4 3 3 0 1
1 -1 2 1
1 -1 2 1
1 -1 2 1
1 -1 2 1
1 -1 2 1
1 -1 2 1
1 -1 2 1
1 -1 2 1
1 -1 2 1
1 -1 2 1
3. Discrete Fourier transform
34Linear convolution (5 of 7)
Convolution by DFT
- hn 1 2 -1 1
- xn 1 1 2 1 2 2 1 1
- Need to have sequences of same length, and
length needs to be ? 4 8 -1 11 to avoid
circular convolution - hn 1 2 -1 1 0 0 0 0 0 0
0 0 0 0 0 0 - xn 1 1 2 1 2 2 1 1 0 0
0 0 0 0 0 0
3. Discrete Fourier transform
35Linear convolution (6 of 7)
Xk 11 1.3244 - 7.6583j -1.7071 - 0.2929j
1.2168 - 0.8210j - j -0.6310 -
0.5784j -0.2929 1.7071j 2.0898 0.5843j 1
2.0898 - 0.5843j -0.2929 - 1.7071j -0.6310
0.5784j j 1.2168
0.8210j -1.7071 0.2929j 1.3244 7.6583j
Hk 3 2.5233 - 0.9821j 1.7071 - 1.1213j
1.5486 - 0.7580j 2 - j 1.8656 -
2.1722j 0.2929 - 3.1213j -1.9375 -
2.3964j -3 -1.9375 2.3964j 0.2929 3.1213j
1.8656 2.1722j 2 j 1.5486
0.7580j 1.7071 1.1213j 2.5233 0.9821j
YkXk Hk 33 -4.1796 - 20.6253j -3.2426
1.4142j 1.2620 - 2.1937j -1 -
2j -2.4335 0.2916j 5.2426 1.4141j -2.6488 -
6.1400j -3 -2.6488 6.1400j 5.2426 -
1.4141j -2.4335 - 0.2916j -1 2j
1.2620 2.1937j -3.2426 - 1.4142j -4.1796
20.6253j
yn 1 3 3 5 3 7 4 3 3 0 1 0 0 0 0 0
3. Discrete Fourier transform
36Linear convolution (7 of 7)
Convolution by DFT (continued)
MATLAB code for convolution by DFT x
1,1,2,1,2,2,1,1,0,0,0,0,0,0,0,0 h
1,2,-1,1,0,0,0,0,0,0,0,0,0,0,0,0 X fft(x) H
fft(h) Y X.H y ifft(Y)
3. Discrete Fourier transform
37Circular convolution (1 of 4)
Definition and example
N-1
ycn ? xm h ltn-mgtN
m0
xn 1 1 2 0, hn 1 2 -1 1 yc0 1
1 2 0 1 1 -1 2 0 yc1 1 1 2 0 2 1
1 -1 5 yc2 1 1 2 0 -1 2 1 1
3 yc3 1 1 2 0 1 -1 2 1 4
3. Discrete Fourier transform
38Circular convolution (2 of 4)
Matrix format
yc0 yc1 yc2 . . . ycN-1
h0 hN-1 hN-2 h1 h1 h0
hN-1 h2 h2 h1 h0
h3 . . . . .
. . . .
. . . hN-1 hN-2
hN-3 h0
x0 x1 x2 . . . xN-1
3. Discrete Fourier transform
39Circular convolution (3 of 4)
Example
1 1 -1 2 2 1 1 -1 -1 2 1 1
1 -1 2 1
1 1 2 1
2 4 4 5
Linear
1 1 2 1 1 2 -1 1 1 1 2 1 2
2 4 2 -1 -1 -2 -1
1 1 2 1 1 3 3 5 1 1 1
Circular
1 3 3 5 1 1 1 2 4 4 5
40Circular convolution (4 of 4)
Explanation
- Circular convolution is what DFTs compute
naturally when convolving two sequences of length
N using a DFT of length N - The matrix format shows a formal way of computing
circular convolution - A simpler way to compute circular convolution is
to compute the linear convolution and then wrap
the part of the linear convolution that is longer
than N
3. Discrete Fourier transform
41Block filtering (1 of 9)
Reason for block filtering
- In many applications, the data is too long to
handle in one step - In these cases, filtering may be done in blocks
- There are two methods
- Overlap add
- Overlap save
3. Discrete Fourier transform
42Block filtering (2 of 9)
Lengths
- Given
- Signal x is of length L
- Filter h of length M
- Then
- The length of convolution Ly L M - 1
- The size of the DFT N ? Ly to ensure that the
circular convolution gives the same results as
the linear convolution - To use a DFT of length N, we must pad x and h
with zeros to make them of length N also
3. Discrete Fourier transform
43Block filtering (3 of 9)
Overlap add
L
L
L
block xo
block x1
block x2
x
ytemp
ytemp
L
M
ytemp
yo
L
M
y1
L
M
y2
n0
nL
n2L
n3L
3. Discrete Fourier transform
44Block filtering (4 of 9)
Overlap-add (continued)
hn 1 2 -1 1 xn 1 1 2
1 2 2 1 1 yn 1 3 3 5 3 7
4 3 3 0 1
Divide input sequence into 3 parts
x1n 1 1 2, x2n 1 2 2,
x3n 1 1
1 2 -1 1 1 1 2 1 3 3 4 -1 2
1 2 -1 1 1 2 2 1 4 5 3 0 2
1 2 -1 1 1 1 1 3 1 0 1
1 3 3 4 -1 2 1 4 5 3 0 2
1 3 1 0 1 1 3 3 5 3
7 4 3 3 0 1
3. Discrete Fourier transform
45Block filtering (5 of 9)
MATLAB code for convolution by DFT
x 1,1, 2, 0,0,0,0,0 h 1,2,-1,1, 0,0,0,0 X
fft(x) H fft(h) Y X.H y ifft(Y)
yn 1 3 3 4 -1 2 0 0
3. Discrete Fourier transform
46Block filtering (6 of 9)
Overlap save
block xo
block x1
block x2
block x3
M
M
M
x
N-M
M
yo
N-M
M
y1
N-M
M
y2
N-M
M
y3
n0
nN
n2N
n3N
3. Discrete Fourier transform
47Block filtering (7 of 9)
Overlap save (continued)
hn 1 -1 -1 1 xn 1,1,1,1,3,3,3,3,1,1
,1,2,2,2,2,1,1,1,1 yn 1,0,-1,0,2,0,-2,0,-2,0
,2,1,0,-1,0,-1,0,1,0,-1,0,1
- Divide input sequence into sequences of length 8
- that overlap by 3
- But first, attach 8-3 5 zeros to front of
sequence - xn 0,0,0,0,0,1,1,1,1,3,3,3,3,1,1,1,2,2,2,2,1
,1,1,1
3. Discrete Fourier transform
48Block filtering (8 of 9)
Overlap save (continued)
Form sequences 0,0,0,0,0,1,1,1 1,1,1,1,3,3,3,3
3,3,3,1,1,1,2,2 1,2,2,2,2,1,1,1 1,1,1,1,0,0,
0,0
Form circular convolutions X,X,X,0,0,1,0,-1 X,X
,X,0,2,0,-2,0 X,X,X,-2,0,2,1,0 X,X,X,-1,0,-1,0
,1 X,X,X,0,-1,0,1,0
yn 1,0,-1,0,2,0,-2,0,-2,0,2,1,0,-1,0,-1,0,1,0
,-1,0,1
3. Discrete Fourier transform
49Block filtering (9 of 9)
Cost
- Cost
- Linear convolution (M1) (N-M)
- DFT N (log2 N 1)
- Ratio log2 N /M for NgtgtMgtgt1
- Overlap-add and overlap-save have about the same
cost
3. Discrete Fourier transform
50Filtering (1 of 11)
Definition
- Filter -- A filter is an algorithm that converts
in input sequence into an output sequence - Linear, constant-coefficient difference equation
(LCCDE)
q
p
yn ? bk xn-k - ? ak yn-k
k0
k1
3. Discrete Fourier transform
51Filtering (2 of 11)
Impulse response
- Impulse response, hn -- hn is found by
solving the LCDDE for xn ?n
3. Discrete Fourier transform
52Filtering (3 of 11)
IIR
- Infinite impulse response (IIR) filter -- An IIR
is a filter in which the length of hn is
infinite. It corresponds to an LCCDE in which
not all the values of an-k are zero - yn -0.5 yn-1 0.5 xn
- IIR advantages
- Useful for implementing analog filters in digital
format - Sometimes has fewer coefficients
3. Discrete Fourier transform
53Filtering (4 of 11)
FIR
- Finite impulse response (FIR) filter -- A FIR is
a filter in which the length of hn is finite.
It corresponds to an LCCDE in which all the
values of an-k are zero - yn 0.25 xn 0.50 xn-1 0.25 xn-2
- FIR advantages
- Simple
- Always stable
- Linear phase
3. Discrete Fourier transform
54Filtering (5 of 11)
Types of filters
- Filters may be of many types
- Low-pass
- High-pass
- All-pass
- Band-pass
3. Discrete Fourier transform
55Filtering (6 of 11)
Ideal filter
- Ideal filter
- Magnitude -- constant across pass-band
- Phase -- linear across pass-band
- Reason for ideal filter
- The envelope of a signal will not be distorted
when passing through a filter with linear phase
3. Discrete Fourier transform
56Filtering (7 of 11)
M
ideal low-pass filter
constant magnitude
?
?c
?
-?
-?c
stop-band
stop-band
pass-band
P
linear phase
?
?c
?
-?
-?c
3. Discrete Fourier transform
57Filtering (8 of 11)
Four types of FIRs with linear phase
- Four types of FIRs with linear phase
- Type 1 -- Nodd, real and symmetric
- Type 2 -- Neven, real and symmetric
- Type 3 -- Nodd, real and antisymmetric
- Type 4 -- Neven, real and antisymmetric
3. Discrete Fourier transform
58Filtering (9 of 11)
Linear phase
- Linear phase -- An LTI system has linear phase if
- H(e j? ) H (e j? ) e -j??
- Generalized linear phase -- An LTI has
generalized linear phase if - H(e j? ) H (e j? ) e -j (?? - ? )
3. Discrete Fourier transform
59Filtering (10 of 11)
Types (continued)
type 1
type 2
type 3
type 4
3. Discrete Fourier transform
60Filtering (11 of 11)
Design
- The design of an FIR involves finding the
coefficients of hn that result in a frequency
response that satisfies a set of filter design
specifications
3. Discrete Fourier transform
61Windowing (1 of 4)
Definitions
- Windowing -- The process of reducing the length
of the original signal because we can take DFTs
of unlimited size - Purpose
- Reduces the frequency resolution
- Introduces spurious frequency components into the
spectrum -- called frequency leakage - Equation
- xL n xn wn
3. Discrete Fourier transform
62Windowing (2 of 4)
Rectangular window
3. Discrete Fourier transform
63Windowing (3 of 4)
Hanning window
3. Discrete Fourier transform
64Windowing (4 of 4)
Comparison of effect of rectangular Hamming
windows
Rectangular window with sidelobe at -13 dB
Hamming window with sidelobe at -40 dB
3. Discrete Fourier transform
654. Power spectral density
- Power spectrum (PS)
- Power spectral density (PSD)
- Experiment
- Use of PSD
- Effect of linear system on PSD
4. Power spectral density
66Power spectrum (PS)
- The mean square value of a periodic time
function is the sum of the mean square value of
the individual harmonic components present
?
x2 ? 1/2 Cn Cn
n1
- The power spectrum G(fn) 1/2 Cn Cn is the
contribution to the mean square error in the
frequency interval ?f
?
x2 ? G(fn)
n1
67Power spectral density (PSD)
- The power spectral density S(fn) is the power
spectrum divided by the frequency interval ?f
S(fn) G(fn) / ?f
?
x2 ? S(fn) ?f
n1
4. Power spectral density
68Experiment
shaker
accelerometer
amplifier
filter
RMS meter
f 420-580 Hz 480-520 Hz 495-505 Hz
?f 160 Hz 40 Hz 10 Hz
meter 8g 4g 2g
G(fn) 64g2 16g2 4g2
S(fn)/ ?f 0.40g2/Hz 0.40g2/Hz 0.40g2/Hz
Theory of Vibration with Applications, William T.
Thompson
4. Power spectral density
69Use of PSD
PSD (g2/Hz)
G12
G22
G32
f
Grms SQRT(G12 G22 G32 )
4. Power spectral density
70Effect of linear system on PSD
H(j?)
x
y
Syy(?) H(j?) H(j?) Sxx (?) H(j?)2 Sxx
(?) Where Sxx (?) power spectrum of input Syy
(?) power spectrum of output H(j?) transfer
function with s j?
4. Power spectral density