clc;
clear all;
close all;
Ap=input('Enter the passband ripple in db:\n');
As=input('Enter the stopband attenuation in db:\n');
Wp=input('Enter the pass band edge frequency in rad:\n');
Ws=input('Enter the stop band edge frequency in rad:\n');
Fs=input('Enter sampling frequency in Hz:\n');
Omgp=2*Fs*tan(Wp/2);
Omgs=2*Fs*tan(Ws/2);
[N,W]=buttord(Omgp,Omgs,Ap,As,'s');
[num,den]=butter(N,Ap,W,'low','s');
[B,A]=bilinear(num,den,Fs);
w=0:0.01:pi;
[h,ph]=freqz(B,A,w);
m=20*log(abs(h));
an=angle(h);
subplot(211);
plot(ph/pi,m);
grid;
xlabel('Frequency in Hz');
ylabel('Gain in db');
title('Frequency response of the Chebyshev filter');
subplot(212);
plot(ph/pi,an);
grid;
ylabel('Phase in rad');
xlabel('Frequency in Hz');