I just thought I would send the Butterworth algorithm to make sure you get it correct. Note that the scaling at the end will be explained on Friday. ------------------------------------------------------------------------------ INPUT: N (filter order), omega_c (cutoff frequency) OUTPUT: b = [b(0) b(1) ... b(N)], a = [a(0) a(1) ... a(N)] where H(z) = B(z)/A(z) where B(z),A(z) are z transforms of b,a respectivly. ALGORITHM: ------------------------------------------------------------------------------ % Prewarp OMEGA_C = tan(omega_c/2) % Compute b coefficients b = 1 for n = 1 to N b = convolve(b, [OMEGA_C OMEGA_C]) end % Compute a coefficients if (N is odd) a = [(1+OMEGA_C) (-1+OMEGA_C)] else a = 1 end; for n = 1 to floor(N/2) a = convolve(a, [(1 - 2*OMEGA_C*cos((Pi/2)*(1 + (2*n - 1)/N)) + OMEGA_C^2) (-2 + 2*(OMEGA_C^2)) (1 + 2*OMEGA_C*cos((Pi/2)*(1 + (2*n - 1)/N)) + OMEGA_C^2)]) end % Scale H(z) so a(0) = 1 for n = 0 to N b(n) = b(n) / a(0) a(n) = a(n) / a(0) end ----------------------------------------------------------------------------- Q: From taking a look at your Chebyshev algorithm and the book's algorithm, they seem to be different. Is there any way to check the program from the table in the book like the Butterworth tool? A: I was unaware the book had an algorithm for digital Chebyshev LP filter design. Can you provide me with a page number? The easy way to verify your tool is working is to look at the cutoff and the ripple amount and check against your input parameters. Sometimes the cutoff may not be exact if you require small ripple but do not give enough poles. Anyhow, here are results from two filters I designed using my chebyshev routine. Verify your filter with these coefficients. Ex. [b,a] = chebyshev(10,0.3,pi/4) b = 1.0e-03 * 0.0004 0.0040 0.0179 0.0478 0.0837 0.1004 0.0837 0.0478 0.0179 0.0040 0.0004 a = 1.0000 -7.6076 27.2543 -60.3043 91.0218 -97.7535 75.5649 -41.4922 15.4868 -3.5495 0.3797 Ex. [b,a] = chebyshev(11,0.3,3*pi/4) b = 0.0187 0.2054 1.0268 3.0805 1.0268 3.0805 6.1610 8.6255 8.6255 6.1610 3.0805 1.0268 0.2054 0.0187 a = 1.0000 3.4396 6.9904 8.9453 8.4762 5.6626 2.9428 0.9168 0.1595 -0.1527 -0.0894 -0.0555 ----------------------------------------------------------------------------- FILTER The algorithm has some typos on the limits of both summations: 1) the first summation (feed-forward terms) should be from k = 0 to N - 1 2) the second summation (feed-back terms) should go from k = 1 to M - 1 MAGNITUDE_RESPONSE The for loop should go from: for omega_0 = 0 to (2Pi - 2Pi/P) step 2Pi/P so that this tool returns exactly P data points. PHASE_RESPONSE (same as above) MAGNITUDE_RESPONSE The input will have either 2 arguments (b,a) or 4 arguments (b,a,fs,plot_type). If 2 arguments are specified, assume fs = 2Pi and plot_type = 0. EE495: For this and all future projects, if you wish to do the EE545 problems they will be considered bonuses. Please state for my grader that the problem you are doing is a bonus. -----------------------------------------------------------------------------