Title: Filtering of signals
1Filtering of signals
Adawy
2What is meant by a filter!
The DTFT is remembered again
Xn is expressed as a summation of sinusoids
with scaled amplitude. Using a system with a
frequency selective to these inputs, then it is
possible to pass some frequencies and attenuate
the others. Such a system is called a Filter.
Adawy
3The function of a filter is to remove unwanted
parts of the signal, such as random noise, or to
extract useful parts of the signal, such as the
components lying within a certain frequency
range.
Unfiltered signal or raw signal
Filtered signal
Adawy
4Example
Choose frequency response of a system such that
1, for wwc
0, for wcwp
If xn Acos(w1n) Bcos(w2n), 0ltw1ltwcltw2lt p
y(n)AH(ejw1)cos(w1n?(w1)) AH(ejw2)cos(w2n?
(w2))
Almost 0
y(n)AH(ejw)cos(w1n?(w1))
Which indicating the LPF effect of the LTI system
Adawy
5Design a HP digital filter that passes the
0.4rad/sec, and stops the 0.1 rad/sec frequency.
hn a b a
?(w)-w
Solving for the two equations gives a-6.76195,
b13.456335
ynhnxn
ynh0xnh1xn-1h2xn-2axnbxn-1
axn-2
Adawy
6yn-6.76195(xnxn-2)13.456335xn-1
If Xncos(0.1n)cos(0.4n)u(n)
X1X2
Output is almost equal to x2, the high frequency
Output of the filter
Transient
x1
Adawy
7Classification of filters as analog or digital
Analog filters
Digital filters
An analog filter uses analog electronic circuits
made up from components such as resistors,
capacitors and op amps to produce the required
filtering effect. Such filter circuits are widely
used in such applications as noise reduction,
video signal enhancement, graphic equalizers in
hi-fi systems, and many other areas.
A digital filter uses a digital processor to
perform numerical calculations on sampled values
of the signal. The processor may be a
general-purpose computer such as a PC, or a
specialized DSP (Digital Signal Processor) chip.
Adawy
8Design of analog filters
- We need to discuss some of the famous techniques
for analog filter design due to two main reasons - We need them as a prefilter or antialiasing
filter before the A/D conversion, - Some techniques for digital filter design are
based on the transformation of some analog
techniques.
Characteristics of a LPF
Ha(j?)
1dp
1-dp
Transition band
Pass band
Stop band
ripples
ds
?
0
?p
?s
Adawy
91-dp Ha(j?) 1dp 0 ? ?p
Pass band
Ha(j?) ds ?s ? 8
Stop band
Transition ratio, or selectivity parameter, it is
larger than unity
ap-20log10(1-dp) dB
Peak pass band ripple
as-20log10(ds) dB
Minimum stop band attenuation
Such filter is completely characterized by ?c,
the 3dB point, ?s, ?p, dp, and ds.
Adawy
10?c is the cut off frequency or the -3db cut ff
frequency
Butterworth Approximation
N2
N4
N10
It has a maximally flat magnitude at zero
frequency. This clear from (2N-1) differentiation
of its function gives zeros.
Adawy
11MATLAB Butterworth functions
num,den BUTTER(N,Wn) designs an Nth order
lowpass digital Butterworth filter and returns
the filter coefficients in length N1 vectors
(numerator) and (denominator). The coefficients
are listed in descending powers of z. See MATLAB
help for more Butterworth functions
design of butterworth filter num,denbutter(4,1
,'s') w00.15 hfreqs(num,den,w) gain20log1
0(abs(h)) subplot(2,1,1) plot(w,gain) grid xla
bel('Normalized frequency') ylabel('Gain in dB')
Adawy
12Type 1 Chebyshev Approximation
Type 1 Chebyshev filter. It is equiripple in the
pass band and monotonically decreasing in the
stop band
TN(?) cos(Ncos-1?) ? 1
cosh(Ncosh-1?) ? gt 1
?2 represent the ripples in the pas band
CHEBY1 Chebyshev type I digital and analog filter
design. num,den CHEBY1(N,R,Wn) designs an
Nth order lowpass digital Chebyshev filter with R
decibels of ripple in the pass band. CHEBY1
returns the filter coefficients in length N1
vectors (numerator) and (denominator).
Adawy
13N3, Rp1 dB, fp1000Hz, wp2pifp
design of type1 chebyshev filter num,dencheby1
(3,1,2000pi,'s') w020012000pi hfreqs(num,d
en,w) gain20log10(abs(h)) subplot(2,1,1) plot
(w/(2pi),gain) grid ylabel('Gain in
dB') w02002400pi hfreqs(num,den,w) gain20
log10(abs(h)) subplot(2,1,2) plot(w/(2pi),gain
) grid xlabel('Frequency in Hz') ylabel('Gain
in dB')
Adawy
14Type 2 Chebyshev filter. It is equiripple in the
stop band and monotonically decreasing in the
pass band
Type 2 Chebyshev Approximation
CHEBY2 Chebyshev type II digital and analog
filter design. B,A CHEBY2(N,R,Wn) designs
an Nth order lowpass digital Chebyshev filter
with the stop band ripple R decibels down and
stop band edge frequency Wn. CHEBY2 returns the
filter coefficients in length N1 vectors B
(numerator) and A (denominator).
Adawy
15N11, R30 dB, fs1000Hz, ws2pifs
Type2 Chebyshev filter
design of type2 chebyshev filter num,dencheby2
(11,30,2000pi,'s') w020012000pi hfreqs(num
,den,w) gain20log10(abs(h)) subplot(2,1,1) pl
ot(w/(2pi),gain) grid ylabel('Gain in dB')
Adawy
16Elliptic filter. It is equiripple in the stop
band and in the pass band
Elliptic Approximation
RN(?) is a rational function satisfies the
property RN(1/?)1/RN(?)
ELLIP Elliptic or Cauer digital and analog filter
design. B,A ELLIP(N,Rp,Rs,Wn) designs an
Nth order lowpass digital elliptic filter
with Rp decibels of ripple in the passband and a
stopband Rs decibels down. ELLIP returns the
filter coefficients in length N1 vectors B
(numerator) and A (denominator).
Adawy
17N7, pass band ripples 1 dB, Minimum stop band
attenuation 30db cut off frequency 1000Hz
design of elliptic filter num,denellip(7,1,30,
2000pi,'s') w020012000pi hfreqs(num,den,w)
gain20log10(abs(h)) subplot(2,1,1) plot(w/(2
pi),gain) grid ylabel('Gain in
dB') w02002000pi hfreqs(num,den,w) gain20
log10(abs(h)) subplot(2,1,2) plot(w/(2pi),gain
) grid xlabel('Frequency in Hz') ylabel('Gain
in dB')
Adawy
18Classification of filters According to frequency
response
H(ejw)
LPF
w
wc
p
0
HPF
H(ejw)
w
wc
p
0
BPF
H(ejw)
p
w
wc1
wc2
0
H(ejw)
BSF
p
w
wc1
0
wc2
Adawy
19Pass band 0 w wc Stop band wc w p
LPF
Stop band 0 w wc Pass band wc w p
HPF
Pass band wc1 w wc2 Stop band 0 w wc1,
wc2 w p
BPF
Stop band wc1 w wc2 Pass band 0 w wc1,
wc2 w p
BSF
Wc, wc1, and wc2 are called the cut off
frequencies.
Adawy
20Design Of Digital Filters
21Advantages of using digital filters
1. A digital filter is programmable, i.e. its
operation is determined by a program stored in
the processor's memory. This means the digital
filter can easily be changed without affecting
the circuitry (hardware). An analog filter can
only be changed by redesigning the filter
circuit. 2. Digital filters are easily designed,
tested and implemented on a general-purpose
computer or workstation. 3. The characteristics
of analog filter circuits (particularly those
containing active components) are subject to
drift and are dependent on temperature. Digital
filters do not suffer from these problems, and so
are extremely stable with respect to both time
and temperature.
Adawy
224. Unlike their analog counterparts, digital
filters can handle low frequency signals
accurately. As the speed of DSP technology
continues to increase, digital filters are being
applied to high frequency signals in the RF
(radio frequency) domain, which in the past was
the exclusive preserve of analog technology. 5.
Digital filters are very much more versatile in
their ability to process signals in a variety of
ways this includes the ability of some types of
digital filter to adapt to changes in the
characteristics of the signal. 6. Fast DSP
processors can handle complex combinations of
filters in parallel or cascade (series), making
the hardware requirements relatively simple and
compact in comparison with the equivalent analog
circuitry.
Adawy
231- Filter Characteristics Specification
Pass band
wwp
1-dpH(ejw)1dp
dp Pass band deviation
wp Pass band edge frequency
Stop band
wsw p
H(ejw)ds
ds Stop band deviation
ws Stop band edge frequency
Adawy
24Normalized LPF specs
k?p/?s
k, and k1 will be used to estimate the degree of
IIR filter
1/A
Adawy
25Classification of filters according to impulse
response length
Finite Impulse Response, FIR filters
Infinite Impulse Response, IIR filters
Adawy
262- Selection of filter type
FIR or IIR
1. FIR can have an exactly linear phase
response. 2. FIR realized nonrecursively is
always stable. 3. Quantization effects are less
severe in FIR than in IIR. 4. FIR requires more
coefficients for sharp cutoff than IIR. 5. Analog
filters can be transformed into IIR. 6. FIR is
easier to synthesize if CAD support is available.
An FIR system is always stable, But an IIR system
may be stable or not, and it must be designed
properly.
Adawy
27An originally stable IIR filter with precession
coefficients may become unstable after
implementation due to unavoidable quantization
error in its coefficients. !!!
Stable IIR filter
After quantization unstable IIR filter
Adawy
28Demonistration for the effect of quantization of
filter coefficients L100 L is the length of
the impulse response hn num1 den1 -1.845
0.850586 den21 -1.85 0.85 h1
timpz(num,den,L) subplot(2,1,1) stem(h1) ylab
el('Amplitude') xlabel('Time index n') h2
timpz(num,den2,L) subplot(2,1,2) stem(h2) yla
bel('Amplitude') xlabel('Time index n')
This program draws the previous impulse response
that shows the effect of quantization on the
system stability.
Adawy
29Filter degree
Butterworth filter
Chebyshev filter
1- IIR filter
Elliptic filter
2- FIR filter
There are another approximation for very narrow
pass band and very wide pass band
Adawy
30Example
LPF with 1dB at wp1kHz, and 40dB at ws5kHz
g20.25895
A210000
N3.2814
1- Butterworth filter
N2.60593
2- Chebyshev filter
3- FIR filter
N7
Adawy
31IIR Filter Design
Design using Analog Filters
1) Impulse Invariant Method (IIM)
2) Bilinear z-Transform (BZT) Method
Adawy
321) Impulse Invariant Method (IIM)
In this method we require that the unit sample
response hn of the desired causal digital
transfer function H(z) be equal to the sampled
version ha(t) sampled at uniform intervals of T
seconds. hnha(nT)
We have seen before that the freq. response
H(ejw) of a sampled sequence ha(nT) is given by
Adawy
33In the last equation put zejw, sj?, and ?w/T
will be s(1/T)lin(z), so we can write this
equation as follows
Z transform of the sequence
Laplace transform of the continuous impulse
response
Take a look at this transformation
S(1/T)lin(z) or zeST
Ssj?
zresT
ZeSTesT ej?T
Points on the j? axis means s0 in the s plane
Points on the unit circle r1 in the z plane
For s negative, left half of the s plane
rlt1 inside the unit circle of the z plane
Adawy
34j?
Im z
S Plane
Z Plane
3p/T
p/T
s
1
-1
Re z
-p/T
-3p/T
Infinity of strips of width 2p/T in the s plane
maps to the unit circle in the z plane. Left half
of each strip maps inside the unit circle
Adawy
35The resultant frequency response is given by the
sum of the frequency responses of the original
analog function and its shifted versions at
2pk/T with the over all sum scaled by 1/T. So if
Ha is band limited, there will be no aliasing,
and if it is not band limited there will be
aliasing as it was seen before.
So in Impulse Invariant method IIM
Stable analog filter maps to stable digital filter
Frequency response of the digital filter is a
multiple versions of the analog filter response
centered at 2pk/T, (sampling frequency).
Adawy
362) Bilinear Transformation Method
Disadvantage of the previous method is the
aliasing, and the many to one mapping where many
strips in the s plane each of them maps to the
entire z plane.
Bilinear Transformation Method
Adawy
37Put T2 to make things simple in the expression
of S and Z
Put ssj?
S Plane
j?
Im z
- For slt0 LHP, Zlt1 inside unit circle.
Z Plane
s
- For sgt0 RHP, Zgt1 outside unit circle.
Re z
Adawy
38w
p
W2tan-1(?T/2)
?
0
-p
ve ? maps into upper half of the unit circle, 0
to p
-ve ? maps into lower half of the unit circle, 0
to -p
The relation is highly nonlinear
Adawy
39w
W2tan-1(?T/2)
w
p
?
H(ejw)
0
-p
1- Given the digital filter specs, wp and ws,
find there corresponding in the analog filter,
use the relation between w and ?
Ha(j?)
?
2- Design an analog filter that meets these
specs. Find Ha(s)
3- Use bilinear transformation to find H(z) from
Ha(s).
Adawy
40Example
Design a digital LPF using bilinear
transformation to satisfy the following 1-
Monotonic stop band and pass band, 2- -3.01dB
cutoff frequency at 0.5p, and 15dB at w0.75p
1- Monotonically decreasing magnitude means
Butterworth filter
2- Calculation of corresponding analog
frequencies considering T1 ?p(2/T)tan(wp/2)
2tan(0.5p/2)2 ?s(2/T)tan(ws/2)2tan(0.75p/2)4.8
28
3- Calculation of
N2
Adawy
41From tables of analog Butterworth filter
Apply bilinear transformation
Adawy
42IIR digital filter design using MATLAB
1- BUTTER Butterworth digital and analog filter
design. B,A BUTTER(N,Wn) designs an Nth
order low pass digital Butterworth filter and
returns the filter coefficients in length N1
vectors B (numerator) and A (denominator). The
coefficients are listed in descending powers of
z. The cutoff frequency Wn must be 0.0 lt Wn lt
1.0, with 1.0 corresponding to half the sample
rate. If Wn is a two-element vector, Wn W1
W2, BUTTER returns an order 2N band pass filter
with pass band W1 lt W lt W2. B,A
BUTTER(N,Wn,'high') designs a high pass filter.
B,A BUTTER(N,Wn,'stop') is a band stop filter
if Wn W1 W2. When used with three left-hand
arguments, as in Z,P,K BUTTER(...), the zeros
and poles are returned in length N column vectors
Z and P, and the gain in scalar K.
BUTTER(N,Wn,'s'), BUTTER(N,Wn,'high','s') and
BUTTER(N,Wn,'stop','s') design analog Butterworth
filters. In this case, Wn can be bigger than 1.0.
Adawy
43B,Abutter(N,wn) B,Acheby1(N,Rp,wn) B,Ache
by2(N,Rs,wn) B,Aellip(N,Rp,Rs,wn)
z,p,kbutter(N,wn) z,p,kcheby1(N,Rp,wn) z,p,
kcheby2(N,Rs,wn) z,p,kellip(N,Rp,Rs,wn)
Rp, ripples in the pass band, Rs, ripples in the
stop band
The function freqz(B,A,w) can be used to plot the
frequency response.
Adawy
44BUTTORD Butterworth filter order selection.
N, Wn BUTTORD(Wp, Ws, Rp, Rs) returns the
order N of the lowest order digital Butterworth
filter that loses no more than Rp dB in the pass
band and has at least Rs dB of attenuation in the
stop band. Wp and Ws are the pass band and stop
band edge frequencies, normalized from 0 to 1
(where 1 corresponds to pi radians/sample). For
example, Low pass Wp .1, Ws
.2 High pass Wp .2, Ws .1
Band pass Wp .2 .7, Ws .1 .8
Band stop Wp .1 .8, Ws .2 .7
BUTTORD also returns Wn, the Butterworth natural
frequency (or, the "3 dB frequency") to use with
BUTTER to achieve the specifications. N, Wn
BUTTORD(Wp, Ws, Rp, Rs, 's') does the
computation for an analog filter, in which case
Wp and Ws are in radians/second. When Rp is
chosen as 3 dB, the Wn in BUTTER is equal to Wp
in BUTTORD.
N, Wn buttord(Wp, Ws, Rp, Rs) N, Wn
cheby1ord(Wp, Ws, Rp, Rs) N, Wn cheby2ord(Wp,
Ws, Rp, Rs) N, Wn ellipord(Wp, Ws, Rp, Rs)
Adawy
45Example
Determine the transfer function and plot the gain
response of a 5th order elliptic IIR filter with
a pass band edge at wp0.4, pass band ripples
Rp0.5dB, and minimum stop band attenuation
Rs40dB.
elliptic IIR LP digital filter
design N5 Rp0.5 Rs40 wn0.4 b,aellip(5,0
.5,40,0.4) disp('Numerator polynomial') disp(b)
disp('denominator polynomial') disp(a) w00.01
/pipi hfreqz(b,a,w) gain20log10(abs(h)) plo
t(w/pi,gain) grid xlabel('normalized
frequency') ylabel('gain in dB')
Numerator polynomial 0.0528 0.0797
0.1295 0.1295 0.0797 0.0528 denominator
polynomial 1.0000 -1.8107 2.4947
-1.8801 0.9537 -0.2336
Adawy
46Numerator polynomial 0.0528 0.0797
0.1295 0.1295 0.0797 0.0528 denominator
polynomial 1.0000 -1.8107 2.4947
-1.8801 0.9537 -0.2336
Gain response of the previous filter
Adawy
47Pole zero representation of the previous filter
elliptic IIR LP digital filter design (poles and
zeros) N5 Rp0.5 Rs40 wn0.4 b,aellip(5,0
.5,40,0.4) z,p,ktf2zp(b,a) disp('Zeros
are') disp(z) disp('Poles are') disp(p) disp
('Gain constant is') disp(k) zplane(b,a)
Stable !!
Poles are 0.2787 0.8973i 0.2787 -
0.8973i 0.3812 0.6274i 0.3812 - 0.6274i
0.4909
Zeros are -1.0000 -0.3020
0.9533i -0.3020 - 0.9533i 0.0474 0.9989i
0.0474 - 0.9989i
Gain constant is 0.0528
Adawy
48Example
Determine the transfer function and plot the gain
response of an 8th order Butterworth band pass
digital filter with pass band edges 0.4 and 0.7.
butterworth IIR BP digital filter
N8 MN/2 w10.4 w20.7 wnw1
w2 b,abutter(M,wn) disp('numerator
polynomial')disp(b) disp('denominator
polynomial')disp(a) w0.2pi0.01/pi0.85pi h
freqz(b,a,w) gain20log10(abs(h)) plot(w/pi,gai
n) grid xlabel('normalized frequency') ylabel('
gain in dB')
0.0186 0 -0.0743 0 0.1114
0 -0.0743 0 0.0186
Num pol.
Denom pol.
Adawy
1.0000 0.9780 1.9399 1.3386 1.6271
0.7349 0.5826 0.1386 0.0762
49Pole zero representation of the previous filter
butterworth IIR BP digital filter design (poles
and zeros) N8 w10.4 w20.7 wnw1
w2 b,abutter(N/2,wn) z,p,ktf2zp(b,a) dis
p('Zeros are')disp(z) disp('Poles
are')disp(p) disp('Gain constant
is')disp(k) zplane(b,a)
Poles are -0.4963 0.7058i -0.4963 -
0.7058i 0.2419 0.8060i 0.2419 - 0.8060i
-0.2651 0.5715i -0.2651 - 0.5715i 0.0305
0.6027i 0.0305 - 0.6027i
Zeros are 1.0001 1.0000
0.0001i 1.0000 - 0.0001i 0.9999
-1.0001 -1.0000 0.0001i -1.0000 -
0.0001i -0.9999
Gain constant is 0.0186
Adawy
50Design of FIR filters
FIR filters are characterized by linear phase
IIR filters cannot produce a linear phase
Linear phase is necessary when it is desired to
maintain the shape of the wave
Adawy
51Linear phase15 samples
phase
Xsin(pi/30)n
X1sin(pi/30)(n-15)
w
ysin(pi/10)n
y1sin(pi/10)(n-15)
The result is the same wave shifted by 15 samples
Adawy
52Nonlinear phase
phase
Xsin(pi/30)n
X1sin(pi/30)(n-15)
w
ysin(pi/10)n
y1sin(pi/10)(n-2)
The wave shape is not conserved because delay is
not linear
Adawy
53Realization of linear phase FIR filter
It is always possible to design an FIR transfer
function with an exact linear phase, but nearly
impossible to design an IIR linear phase one.
1- Design of linear phase FIR filter using odd
length symmetric impulse response
hnhN-n, 0nN
For N8
H(z)h8h7z-1h6z-2h5z-3h4z-4h3z-5
h2z-6 h1z-7h0z-8
Adawy
54The impulse response is symmetric around the h4
sample, so h0h8, h1h7, h2h6,
h3h5. So we can write
H(z)h0(1z-8)h1(z-1z-7)h2(z-2z-6)h3(
z-3z-5) h4z-4
H(z)h0z-4(z4z-4)h1z-4(z3z-3)
h2Z-4(z2z-2) h3z-4(z1z-1) h4z-4
H(z)z-4h0(z4z-4)h1(z3z-3) h2(z2z-2)
h3(z1z-1) h4
H(ejw)e-jw42h0cos(4w)2h1cos(3w)2h2cos(2w
) 2h3cos(w)h4
?(w)-4w, which is linear, GD4 which is
constant
Where a0hN/2, an2hN/2 n,
1nN/2
Adawy
552- Design of linear phase FIR filter using even
length symmetric impulse response
For N7
h0h7, h1h6, h2h5, h3h4.
H(z)h0(1z-7)h1(z-1z-6)h2(z-2z-5)h3(
z-3z-4)
H(z)z-7/2h0(z7/2z-72)h1(z5/2z-5/2)
h2(z3/2z-3/2) h3(z1/2z-1/2)
H(ejw)e-jw7/22h0cos(7w/2)2h1cos(5w/2)
2h2cos(3w/2) 2h3cos(w/2)
?(w)-7w/2, which is linear, GD7/2 which is
constant
Where bn2h(N1)/2 n,
1n(N1)/2
Adawy
56H(z)(1/6)0.5z-1z-2z-3z-4z-50.5z-6
Example
Phase response, it is linear in the pass band
Frequency response
Impulse response
Adawy
573- Design of linear phase FIR filter using odd
length antisymmetric impulse response
For N8
hn-hN-n, 0nN, hN/20
H(z)z-4h0(z4-z-4)h1(z3-z-3) h2(z2-z-2)
h3(z1z-1)
H(ejw)e-j(4w-p/2)2h0sin(4w)2h1sin(3w)2h2
sin(2w) 2h3sin(w)
?(w)-4w-p/2, which is linear, GD4 which is
constant
Where cn2hN/2 n, 1nN/2
Adawy
584- Design of linear phase FIR filter using even
length antisymmetric impulse response
For N7
H(z)z-7/2h0(z7/2-z-72)h1(z5/2-z-5/2)
h2(z3/2-z-3/2) h3(z1/2-z-1/2)
H(ejw)e-(jw7/2-p/2)2h0sin(7w/2)2h1sin(5w/2)
2h2sin(3w/2) 2h3sin(w/2)
?(w)-7w/2 p/2, which is linear, GD7/2 which
is constant
Where dn2h(N1)/2 n,
1n(N1)/2
Adawy
59The four cases of symmetry required for linear
phase realization
Odd antisymmetry
Odd symmetry
even antisymmetry
Even symmetry
Point of symmetry
Adawy
60Design of FIR filters using Windows
Simply truncate the response of an IIR filter to
a desired length.
Impulse response of the IIR filter
Impulse response of the FIR filter
wn
hnhdn.wn
hdn
Adawy
61From the properties of the Fourier transform
F.T
hnhdn.wn
H(ejw)Hd(eiw)W(ejw)
H(ejw)
w
4p/N
This convolution produced a smeared version of
the ideal LPF frequency response. The wider the
main lobe of W, the more spread is H. So, there
is a trade off between large N to minimize
smearing, and small N to get a reasonable
implementation of the filter.
Adawy
62Different window shapes
Much work has been done to adjust wn to satisfy
certain main lobe width and relative side lobes
levels requirements. These windows are
Rectangle, Bartlett, Hanning, Hamming, Blackman,
Kaiser, and more.
Adawy
63Window Function
Rectangle Window
Hanning Window
-M n M
Hamming Window
-M n M
Blackman Window
-M n M
Adawy
64Characteristics of different windows
Transition band width (wp-ws)c/M, where c is a
constant depends on type of window as in the
table. This relation can be used to estimate the
order of the filter.
Adawy
65H(eiw)
Example
1
w
Wcp/2
p
The impulse response of the desired filter is
obtained by calculating the inverse DTFT as
follows
8- n 8
This response will be windowed for -M n M, and
shifting by M samples to make it realizable
(causal).
0 n N-1, N2M1
Freq. response
Adawy
66N51, wc0.25pi, Rectangle window
Adawy
67Design of FIR filters based on frequency response
sampling
Start by the desired frequency response Hd(ejw)
Uniformly sample it at N equally spaced points
wk2pk/N, k0, 1, 2, N-1
These samples represent N point DFT Hk
Take IDFT of these N points to get the impulse
response hn
Adawy
68FIR digital filter using MATLAB
MATLAB includes 5 window functions that can be
used to design FIR filter using the window
method, these windows are
Wblackman(N), Whamming(N), whanning(N),
wchebwin(N,Rs), wkaiser(N,beta). N is the
number of samples, beta, Rs are coefficients
related transition bands.
bfir1(L,wn), generates a length NL1 vector b
that represent the impulse response coefficients
of the LPF FIR filter. Hamming window is
considered if no window is mentioned. Filter type
(low, high, band stop or band stop). Also a type
of the window can be included like this
form bfir1(L,wn, filter type,
window) bfir1(L,wn, stop, kaiser)
Adawy
69Example
Design a LP FIR filter using kaiser, and hanning
windows with the following specifications
wp0.3pi, ws0.4pi, As50dB.
As is the stop band attenuation50, so, ß4.55126
?f(ws-wp)/2pi 0.05
For Asgt21
N61
For Aslt21
Adawy
70wp0.3 kwkaiser(61,4.55126) bfir1(60,0.3,kw)
w0pi/256pi hfreqz(b,1,w) mag20log10(abs(h)
) subplot(2,1,1) plot(w/pi,mag) AXIS(0 1 -80
0) hamhamming(61) b2fir1(60,0.3,ham) w0pi
/256pi h2freqz(b2,1,w) mag220log10(abs(h2))
subplot(2,1,2) plot(w/pi,mag2) AXIS(0 1 -80
0)
Adawy
71design of FIR LPF N61 beta4.55126 wp0.3 kw
kaiser(61,4.55126) bfir1(60,0.3,kw) w0pi/256
pi hfreqz(b,1,w) mag20log10(abs(h)) fiterin
g a sequence of data n01100 bfir1(60,0.3,kw)
x1cos(0.1pin) x2cos(0.4pin) yfilter(b,1,
x1) subplot(3,1,1) plot(n,y,'r',n,x1,'k') yfil
ter(b,1,x2) subplot(3,1,2) plot(n,y,'r',n,x2,'k'
) yfilter(b,1,x1x2) subplot(3,1,3) plot(n,y,'
r',n,x1x2,'k') ylabel('Amplitude') xlabel('Time
index')
Response of previous filter for different inputs
Adawy