Digital Signal Processing Reference
In-Depth Information
that the a 's and b 's used by MATLAB correspond to the b 's and a 's, respectively,
used in this topic, with the b 's (in this topic) representing the denominator coeffi-
cients of the transfer function.
As with the FIR design, this IIR bandstop filter can be implemented in real time
with a push of a button within RTSPTool [3,4].
D.3 MATLAB FOR FIR FILTER DESIGN USING THE STUDENT VERSION
FIR filters can be designed using the Student Version [2] of the MATLAB software
package [1]. See also Section D.1 for the design of FIR filters using MATLAB's
GUI filter designer SPTOOL.
Example D.3: FIR Filter Design Using MATLAB's Student Version
Figure D.5 shows a listing of a MATLAB program mat33.m to design a 33-
coefficient FIR bandpass filter. The function remez uses the Parks-McClellan algo-
rithm based on the Remez exchange algorithm and Chebyshev's approximation
theory. The desired filter has a center frequency of 1 kHz with a sampling frequency
of 10 kHz. The frequency v represents the normalized frequency variable, defined
as v
f / F N , where F N is the Nyquist frequency. The bandpass filter is represented by
three bands:
=
1. The first band (stopband) has normalized frequencies between 0 and 0.1 (0 to
500 Hz), with a corresponding magnitude of 0.
2. The second band (passband) has normalized frequencies between 0.15 and
0.25 (750 to 1250 Hz), with a corresponding magnitude of 1.
3. The third band (stopband) has normalized frequencies between 0.3 and
the Nyquist frequency of 1 (1500 to 5000 Hz), with a corresponding magnitude
of 0.
Run this program from MATLAB and verify the magnitude response of the ideal
desired filter plotted within MATLAB in Figure D.6. Note that the frequencies 750
%Mat33.m MATLAB program for FIR Bandpass with 33 coefficients Fs=10 kHz
nu= [0 0.1 0.15 0.25 0.3 1]; %normalized frequencies
mag= [0 0 1 1 0 0]; %magnitude at normalized frequencies
c=remez (32,nu,mag); %invoke remez algorithm for 33 coeff
bp33=c'; % coeff values transposed
save matpb33.cof bp33 -ascii; %save in ASCII file with coefficients
[h,w] =freqz (c,1,256); %frequency response with 256 points
plot(5000*nu,mag,w/pi,abs(h)) %plot ideal magnitude response
FIGURE D.5. MATLAB program for FIR filter design ( mat33.m ).
Search WWH ::




Custom Search