ECE 408 Computer Assignment #5 Parks-Mcclellan Algorithm

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

ECE 408

COMPUTER ASSIGNMENT #5

PARKS-McCLELLAN ALGORITHM MATLAB function: firpm.m firpm designs a linear-phase FIR filter using the Parks-McClellan algorithm [1]. The Parks-McClellan algorithm uses the Remez exchange algorithm and Chebyshev approximation theory to design filters with an optimal fit between the desired and actual frequency responses. The filters are optimal in the sense that the maximum error between the desired frequency response and the actual frequency response is minimized. Filters designed this way exhibit an equiripple behavior in their frequency responses and are sometimes called equiripple filters. firpm exhibits discontinuities at the head and tail of its impulse response due to this equiripple nature. [1] Programs for Digital Signal Processing, IEEE Press, New York, 1979, Algorithm 5.1. 1. Read a short wav file into MATLAB and pass it through an equalizer using firpm with specifications Number of taps: 51 (order is 50) f=[0,0.1,0.2,1]; m=[1,1,0,0]; (a) Play the sound before and after the equalizer. (b) Plot the waveforms in the time domain before and after the equalizer. (c) Plot the spectrums (fft magnitude) before and after the equalizer. (d) Plot the impulse response, magnitude response, phase response, pole-zero diagram of the equalizer. Hint: %File Name: equal1.m %Written by Dr. James S. Kang, ECE Department, Cal Poly Pomona. [x,fs,bits]=wavread('windwing.wav'); %fs=sampling rate disp('sampling rate = '); disp(fs); wavplay(x); %or soundsc(x,fs) pause(5); fs2=fs/2; N=51; f=[0,0.1,0.2,1]; m=[1,1,0,0]; h=firpm(N-1,f,m); a=[1];

[H,w]=freqz(h,a,100); n=1:N; figure stem(n-1,h); grid; title('Impulse Response'); y=filter(h,a,x); soundsc(y,fs); plot(w/pi,abs(H)); grid; title('Magnitude Response'); figure plot(w/pi,20*log10(abs(H))); grid; title('Magnitude Response in dB'); figure plot(w/pi,angle(H)/pi); grid; title('Phase Response'); figure zplane(h,a); grid; title('Pole-Zero Diagram'); figure Y=fft(y); plot(abs(Y)); grid; title('Spectrum of the Output Signal'); 2. Repeat Problem #1 with f=[0,0.3,0.4,1]; m=[0,0,1,1]; 3. Repeat Problem #1 with f=[0,0.15,0.2,0.25,0.3,1]; m=[0,0,1,1,0,0]; 4. Repeat Problem #1 with f=[0,0.1,0.12,0.3,0.32,1]; m=[1,1,0,0,1,1]; 5. Repeat Problem #1 with your own choice of f and m. Use 10 different frequencies for f. 6. Read a short wav file into MATLAB and pass it through a 51-tap digital differentiator using firpm.m. (a) Play the sound before and after the differentiator. (b) Plot the waveforms in the time domain before and after the differentiator. (c) Plot the spectrums (fft magnitude) before and after the differentiator. (d) Plot the impulse response, magnitude response, phase response, pole-zero diagram of the differentiator. 7. Read a short wav file into MATLAB and pass it through a 51-tap digital Hilbert transformer using firpm.m.

(a) Play the sound before and after the Hilbert transformer. (b) Plot the waveforms in the time domain before and after the Hilbert transformer. (c) Plot the spectrums (fft magnitude) before and after the Hilbert transformer. (d) Plot the impulse response, magnitude response, phase response, pole-zero diagram of the Hilbert transformer.

Turn in maximum 4 pages of plots.

You might also like