% M11-butterfilt.diary % Analog filter design: Butterworth filter % Dan Ellis dpwe@ee.columbia.edu % 2007-11-08 % Specifications are -1 dB @ 1 kHz, -40 dB @ 5 kHz % so 20*log10(1/sqrt(1+e^2)) = -1 , hence e^2 = e2 = ((1/(10^(-1/20)))^2)-1 %e2 = % 0.2589 % and 20*log10(1/A) = -40, so A = A = 10^(40/20) %A = % 100 % So order must be at least 0.5*log10((A*A-1)/e2)/log10(5000*2*pi/(1000*2*pi)) %ans = % 3.2811 % Since N must be an integer >= 3.28, take N = 4; % If 10*log10( 1/(1+(W/Wc)^2N) ) = -1 dB at W = 2pi*1 kHz , what is Wc? Wc = 2*pi*1000/((1/(10^(-1/10)) - 1)^(1/(2*N))) %Wc = % 7.4393e+03 % What is that in Hz (instead of rad/s)? Wc/2/pi %ans = % 1.1840e+03 % .. same as we got from the table % So now design the filter [B,A]=butter(N,Wc,'s'); % Plot its response log-log freqs(B,A) % .. or sample at specific linear frequencies from 0 to 10 kHz W = [0:10:10000]*2*pi; [h,w] = freqs(B,A,W); subplot(111) % Plot gain in dB against frequency in Hz plot(W/2/pi, 20*log10(abs(h))) grid % Zooming in confirms that it is exactly -1 dB @ 1 kHz, % well below -40 dB @ 5kHz because order was larger than value % required by design.