Digital Signal Processing Reference
In-Depth Information
of the desired bandstop filter are
f
l
=
f
1
−∆
f/
2 (lower cutoff frequency) and
f
u
=
f
1
+∆
f/
2 (upper cutoff frequency).
•
Obtain the desired
Nth
order FIR digital filter coefficients
h
(
n
), 0
≤
n
N
using MATLAB. The various MATLAB commands for FIR
digital filter design are given in Section 5.3.2 of this topic. Examples
of these commands are
fir1
,
fir2
, and
Remez
, in which the appropri-
ate windowing function should also be specified. A sample program
using the
fir1
command is given below.
≤
% MATLAB Program to calculate the FIR bandstop filter
coefficients
N = 50; specifies the filter order (50)
fs = 8000; specifies the sampling frequency (8 KHz)
f = [
f
l
f
h
]; specifies the analog filter cutoff frequency
vector in Hz.
wn = 2*pi*f/fs; transforms the analog cutoff frequency
vector,
f
Hz, to digital cutoff frequency vector,
w
n
, rad.
wn = wn/pi; normalizes the digital cutoff frequency vector
(MATLAB) requirement)
h = fir1(N, wn, 'stop'); calculates the bandstop FIR
filter coefficients
Note:
If no window function is specified, as in the program above, then
MATLAB uses the Hamming window.
Once the required filter coefficients,
h
(
n
), 0
≤
n
≤
N
, are obtained, a coeffi-
cient file,
bandstop.cof
is created as shown below.
/*bandstop.cof FIR bandstop filter coefficients file*/
#define N 51 /*length of filter*/
short hbs[N]=
{ h(0),h(1),………………………h(10),
h(11),h(12),………………………h(20),
h(21), h(22), ………………………h(30),
h(31), h(32), ………………………h(40),
h(41), h(32), ………………………h(50)
};