Professional Documents
Culture Documents
6
MHH606312 Digital Signal Processing
4
5
7
Digital filters with finite-duration impulse reponse (referred to as FIR filters)
have both
8
advantages and disadvantages when compared to infinite-duration impulse
response (IIR)
9
filters. (Note: You will need sg01 for some of the functions in this Lab.).
10
11
FIR filters have the following primary advantages:
12
They can have exactly linear phase.
They are always stable, even when quantized.
The design methods are generally linear.
They can be realized effciently in hardware.
The filter startup transients have finite duration.
13
14
The primary disadvantage of FIR filters is that they often require a much
higher filter order
15
than IIR filters to achieve a given level of performance. Correspondingly, the
delay of these
16
filters is often much greater than for an equal performance IIR filter.
17
18
19
FIR Methods
20
The Signal Processing Toolbox supports a variety of methods for the design of
FIR filters.
21
22
Question: Using an appropriate search list the methods available in
Matlab for designing FIR filters.
23
24
25
Impulse Response
26
y ( n )= x ( m ) h (nm)
28
m=0
(1)
29
8
G Morison
page 1
30
where the filtered signal y(n) is just a linear combination of current and
previous values of
31
the input signal x(n). The coeffcients b (b(m)) are the numerator coeffcients
of the transfer
32
function. The denominator of the transfer function will always be a = 1. The
order of the
33
filter is n = length(b) -1.
34
35
Question: Explain how to calculate the impulse response of the
above filter.
36
37
38
(1).
39
40
41
42
Try this in Matlab. Let b represent the coeffcients of the x's in equation
44
43
45
46
A filter whose impulse response is symmetric or antisymmetriac about its
midpoint is called
47
a (generalized) linear phase filter. That is,
48
49
h ( n ) H ( e jn )= H ( e jn ) e j()
(2)
50
with
51
( ) =K
(3)
52
The phase shift of the altered signal ( ) will vary linearly with frequency
. (This translates
53
into the fact that the output signal of such a filter has a pure time delay
with respect to the
54
input signal. There is no phase distortion).
The phase delay ( ) / and the group delay d ( ) /d will be equal
and constant
55
56
Except for cfirpm, all the FIR filter design functions in the Signal
Processing Toolbox design linear phase filters only.
57
58
Try this is Matlab
59
60
61
62
a = 1;
b = fir1(5,0.5);
fvtool(b,a)
63
64
This is the classic method of windowed FIR linear-phase filter design. Look at
the phase delay and the group delay in fvtool.
10
G Morison
page 2
65
66
67
68
Question: For this (5th order) 6-point filter, confirm that the phase
( ) 2.4868 as
69
seen in the phase plot of fvtool.
70
71
72
73
The symmetric impulse response of a linear phase filter can have an odd or
an even number
74
of points,and can have an odd or even symmetry about the midpoint, leading
to four filter
75
types:
76
Type I: Odd length, even symmetry
Type II: Even length, even symmetry
Type III: Odd length, odd symmetry
Type IV: Even length, odd symmetry
77
78
Question: Describe any restrictions that can occur when using each
of the above types of FIR filter.
G Morison
page 3
79
80
81
Under FIR Methods above, Windowing is the first filter design method. It is the
common,
82
classic design method for FIR filters.
83
84
Recall that the frequency response H ( e jn ) is periodic. Hence it can be
written as a Fourier series.
85
That is ,
86
H (e jn )=
87
h[n]e jn
n=
(4)
88
h[n] are the Fourier coefficients that are determined using the inverse
89
DTFT. In general, the
90
impulse response cannot be implemented as a digital filter because it is
infinite and non91
causal.
92
93
Question: Show using the Inverse DTFT that the ideal frequency
response of a low pass filter, cannot be implemented, and explain why this
is the case.
94
95
So, h[n] is symmetrically truncated (multiplied by a finite, symmetric
window) and shifted
96
to make it causal, to create an implementation that gives a linear phase finite
impulse response.
97
98
(Recall that from Fourier series properties, if the function is even, the Fourier
coefficients
99
are even and if the function is odd, Fourier coefficients are odd. Hence for
jn
H (e ) even, like
100 for a low pass filter, h[n] will be even, i.e. symmetric.)
101
102 The truncated Fourier series can be shown to be an approximation to the ideal
filter, which
103 is best" in a mean square sense, compared to other approximations of the
same length.
104 However, the abrupt truncation leads to overshoot (Gibb's phenomenon) and
ripples in the
105 spectrum. The undesirable effects of truncation can be reduced or eliminated
by the use of
106 tapered windows.
107
108 Question: Describe what is meant by the Gibbs phenomenon.
109
110 The Windowing method does not allow you to design a filter, with explicit
amplitude response
G Morison
page 4
111
used
112
113
114
115
116
117
118
119
120
121
122
123
124 Question: How does the filter frequency response change with
increasing the size of
125 the filter?
126
127 Question: Even as you increase the number of filter
coefficients that you retain, does
128 the largest overshoot in the magnitude frequency response
decrease in size?
129
130 Question: Explain what is happening in the 4 figures that you
see in windemo.
131
134 In windemo you saw the effects (Gibbs phenomena) on the frequency
response of the finite
135 length filter when a (default) rectangular window was imposed. Now we see
methods of
136 ridding ourselves of Gibbs phenomena - at a price.
137
138 The Signal Processing Toolbox supports a variety of windows commonly used
in FIR filter
139 design. (We will see this in class.) Typing
140
141
142
help window
G Morison
page 5
150
151
alpha=0.25
w = gausswin(64,alpha)
152
153
154
and
155
w = window(@gausswin,64,alpha)
156
157 both return a Gaussian window of length 64 with standard deviation equal to
1/alpha.
158
159 Question: Pick two of the available windows and discuss and
demonstrate their properties.
160
170
171
172
173 edit windft
174 windft
175
176 You see a truncated signal (5 hz sine wave) and its DFT (Recall the
Fourier transform of a sine wave? Do you see how the DFT is different?) Then,
the truncated sine wave is multiplied by a Gaussian window and the DFT is
taken of the truncated windowed signal.
177
178 Question: Detail and explain the output of the above function.
179
180 Question: For a continuous-time sine wave, its Fourier transform are
a couple of delta functions. For a discrete-time truncated sine wave, how
is its spectrum (DFT) different to the idealized delta function spectrum of a
(continuous-time) sine wave?
181
182 Question: How does windowing the truncated sine wave "improve"
the DFT spectrum.
183
184 Note: You have a 5 hertz sine wave.
185
2
G Morison
page 6
186
If you edit windft you see that you are just looking at it for 1 second. So you
see 5 cycles of it in 1 second. Hence you are taking a sine wave, infinitely long, and
putting a 1 second rectangular window on it. In the analog domain you have,
187
x w ( t )=sin ( 2 5 t ) . w R (t)
188
(5)
189
190 where w R (t ) is a 1 second rectangular window.
191
192 Question: Calculate the Fourier transform of the signal x w ( t ) .
193
194 Question: Compare the results of the Fourier transform with the
Matlab output from the DFT of the signal.
195
206
wvtool(windowname(n))
214
215
216
wvtool(hamming(64),hann(64),gausswin(64),rectwin(64))
wvtool(hamming(32),kaiser(32,2.5),flattopwin(32))
wvtool(kaiser(32,1),kaiser(32,5),kaiser(32,10))
207
208 opens WVTool with time and frequency domain plots of the n-length window
specified in
209 windowname, which can be any window in the Signal Processing Toolbox.
Several windows
210 can be given as input arguments for comparative display.
211
212 Try the following in Matlab
213
217
218 Question: Comment on the differences - main lobe width and ripples
- between the
219 same size rectangular window and the Hamming window.
220
2
G Morison
page 7
234
wintool
235 Question:
Experiment with different windows (minimum 3) and
detail what you find.
236
237
238
G Morison
page 8
246
G Morison
page 9