
R_stop=20;
R_pass=6;
w_stop=3;
w_pass=2;

[n_butter, w_c_butter] = buttord(w_pass, w_stop, R_pass, R_stop,'s');
[A_butter, B_butter] = butter(n_butter, w_c_butter, 's');
[H_butter,w_butter]=freqs(A_butter,B_butter);

[n_cheby1, w_c_cheby1] = cheb1ord(w_pass, w_stop, R_pass, R_stop,'s');
[A_cheby1, B_cheby1] = cheby1(n_cheby1, R_pass, w_c_cheby1, 's');
[H_cheby1,w_cheby1]=freqs(A_cheby1,B_cheby1);

[n_cheby2, w_c_cheby2] = cheb2ord(w_pass, w_stop, R_pass, R_stop,'s');
[A_cheby2, B_cheby2] = cheby2(n_cheby2, R_stop,  w_c_cheby2, 's');
[H_cheby2,w_cheby2]=freqs(A_cheby2,B_cheby2);

[n_ellip, w_c_ellip] = ellipord(w_pass, w_stop, R_pass, R_stop,'s');
[A_ellip, B_ellip] = ellip(n_ellip,R_pass,R_stop,w_c_ellip, 's');
[H_ellip,w_ellip]=freqs(A_ellip,B_ellip);

figure;hold on
plot(w_butter,20*log10(abs(H_butter)))
plot(w_cheby1,20*log10(abs(H_cheby1)))
plot(w_cheby2,20*log10(abs(H_cheby2)))
plot(w_ellip,20*log10(abs(H_ellip)))

[z_bessel, p_bessel, k_bessel] = besselap(n_butter);
[A_bessel,B_bessel]=zp2tf(z_bessel,p_bessel,k_bessel);
[H_bessel,w_bessel]=freqs(A_bessel,B_bessel);

figure
plot(w_butter,20*log10(abs(H_butter)))
hold on
plot(w_bessel,20*log10(abs(H_bessel)))


