EE473 Homework #7



Reading : Chapter 7

  1. MATLAB has a butter function which can be used to design lowpass filters. This function uses the bilinear transformation method to convert an analog Butterworth filter to a digital one. In this week's homework assignment you are asked to implement a similar function, but uses impulse invariance method for the conversion. You may find the following MATLAB functions useful: ceil, log10, buttap, poly, residue, freqz, and filter.

    1. Write a MATLAB function newbutter with the following usage:

      [b, a] = newbutter(Wp, Ws, Rp, Rs)

      Wp and Ws are passband and stopband cutoff frequencies of the filter respectively. Rp is the attenuation in dB (a positive number) at the passband cutoff frequency and Rs is the minimum attenuation in dB in the stopband. The function should return b and a vectors which determine the digital transfer function H(z). Here b correspond to numerator polynomial and a correspond to denominator polynomial coefficients. All frequencies are normalized, so Wp and Ws have values between 0 and 1. The steps involved in the design of the filter are as follows:

      1. Convert the digital filter specifications to analog filter specs. (Ignore aliasing. Also, it does not matter what value of T is chosen, because you will eventually convert the analog system to a digital one and all of the T's will cancel. For convenience let T=1.

      2. Determine the filter order, N, and the 3dB (half-power) frequency, Wc, of the analog Butterworth filter that meets the specifications.

      3. Find the system function, Ha(s), of the analog Butterworth filter with filter order and half-power frequency determined in the previous step. (MATLAB's buttap function will find the system function of a normalized (half-power frequency equal to one) analog Butterworth filter of the specified order. Make an appropriate substitution to transform this filter to one which has its half-power point at Wc.)

      4. buttap returns the analog system function in pole-zero form. Convert this to rational form so that the function's partial fraction expansion can be found in the next step. Use the poly function to accomplish this.

      5. Find the partial fraction expansion of Ha(s). The residue function will do this for you.

      6. Apply the impulse invariance transformation to each term in the partial fraction expansion to convert the analog system to a discrete one. You now have a partial fraction expansion for H(z).

      7. Combine the terms in the partial fraction of H(z) to get a rational function. residue function will also do this for you. The coefficients of the numerator are the elements of the b vector, while the coefficients of the denominator are the elements of the a vector.

    2. Use MATLAB's freqz function to plot the magnitude and phase response of the newbutter filter which has the following parameters: Wp=0.25, Ws=0.375, Rp=1, and Rs=10. Does your filter have approximately linear phase in the passband? What is the approximate group delay in the passband? (The group delay should be positive!)

    3. Download the speech signal in file speech.wav . You can port the signal in the WAV speech file by the command s=wavread('speech.wav');  Use the filter that you designed in part b) to filter this speech signal using the filter function in MATLAB. Plot the spectrogram of the original and filtered speech signals by specgram function in MATLAB. Explain what you see in the spectrogram. You can use help specgram to get more help on the spectrogram definition. Listen to both the input and output signals using soundsc functions in MATLAB (i.e.,  soundsc(y,16000)). Describe what you hear.