% Simple script that illustrates response of various filters

% Written 11/30/01 - rms

% Fixed params:

N = 10; 	% filter order
R1 = .5; 	% Passband ripple
R2 = 20;	% Stopband ripple
Wc = 50; 	% Continuous-time cutoff frequency

% zplane0 calls turned into zplane

% Butterworth filter
[b1,a1] = butter(N,Wc,'s');
[h1,w1] = freqs(b1,a1);
freqs(b1,a1);
pause
subplot(1,1,1)
zplane(b1,a1)
%axis square
pause

% Cheb1 filter
[b2,a2] = cheby1(N,R1,Wc,'s');
[h2,w2] = freqs(b2,a2);
freqs(b2,a2);
pause
subplot(1,1,1)
zplane(b2,a2)
%axis square
pause

% Cheb2 filter
[b3,a3] = cheby2(N,R2,Wc,'s');
[h3,w3] = freqs(b3,a3);
freqs(b3,a3);
pause
subplot(1,1,1)
zplane(b3,a3)
%axis square
pause

% Elliptical filter
[b4,a4] = ellip(N,R1,R2,Wc,'s');
[h4,w4] = freqs(b4,a4);
freqs(b4,a4);
pause
subplot(1,1,1)
zplane(b4,a4)
pause

% The four together in linear plots
subplot(4,1,1),plot(w1,abs(h1))
title('Butterworth filter','fontsize',14)
axis([0,100,0,1.5])
subplot(4,1,2),plot(w2,abs(h2))
title('Chebyschev1 filter','fontsize',14)
axis([0,100,0,1.5])
subplot(4,1,3),plot(w3,abs(h3))
title('Chebyschev2 filter','fontsize',14)
axis([0,100,0,1.5])
subplot(4,1,4),plot(w4,abs(h4))
title('Elliptical filter','fontsize',14)
axis([0,100,0,1.5])
pause

% The four together in log plots

subplot(4,1,1),plot(log10(w1),20*log10(abs(h1)))
title('Butterworth filter','fontsize',14)
axis([0,3,-60,20])
subplot(4,1,2),plot(log10(w2),20*log10(abs(h2)))
title('Chebyschev1 filter','fontsize',14)
axis([0,3,-60,20])
subplot(4,1,3),plot(log10(w3),20*log10(abs(h3)))
title('Chebyschev2 filter','fontsize',14)
axis([0,3,-60,20])
subplot(4,1,4),plot(log10(w4),20*log10(abs(h4)))
title('Elliptical filter','fontsize',14)
axis([0,3,-60,20])
pause

