Title: Lab 9 Improved FIR filter
1Lab 9 Improved FIR filter
2Improved FIR filter
- Lab objective
- Use SystemView to simulate/analyze an improved
window based filter. This is similar to the
filter we analyzed in Lab 8, but is improved by
using a Hamming window. - I hope well be able to do a realtime
implementation of this filter using the Analog
Devices EZ-Kits next week. If not, well
implement it using Matlab.
3Improved FIR filter
First, well use Matlab to generate a Hamming
window, and apply it to the truncated and shifted
impulse response we used in Lab 8. The formula
for the Hamming window is given in Cartinhour,
eq. 9-7. Use this formula, in Matlab, to
generate a Hamming window with N 29. Import the
filter coefficients we used in lab 8, which are
in the file coeffs.txt. Use the Matlab fopen,
fscanf, and fclose functions.
4Improved FIR filter
Save the coeffs.txt file in your Matlab Work
directory, or in a directory in the search path
if using Octave. Open it for reading fid
fopen(coeffs.txt, r) create a vector to hold
the raw impulse response, then read in the
coefficients using fscanf hi zeros(1, 29) hi
fscanf(fid, 9f) Close the file. fclose(fid)
5Improved FIR filter
Transpose the vector you just read hi
hi Plot the raw impulse response Plot the
Hamming window you generated Now, multiply the
Hamming window point-by-point with the raw
impulse response. If your Hamming window vector
is called w, h w . hi Plot the result, note
the differences. Now, write the windowed impulse
response to a new file.
6Improved FIR filter
Create a new file hcoeffs.txt, and open it for
writing fid fopen(hcoeffs.txt,
w) fprintf(fid, 9.6f\r\n,
h) fclose(fid) Turn in your Matlab code, and
your hcoeffs.txt file Now, repeat Lab 8. Use
your hcoeffs.txt file in place of the coeffs.txt
file you used in Lab 8. Notice the IMPROVED
results.