clear all;
clc;
%LOW PASS FILTER
disp('low pass filter');
wp=input('enter the pass band edge frequency wp=');
ws=input('enter the stop band edge frequency ws=');
ap=input('enter the pass band attenuation ap=');
as=input('enter the stop band attenuation as=');
[N wn]=CHEB1ORD(wp,ws,ap,as,'s');
[b a]=CHEBY1(N,.5,wn,'s');
h=freqs(b,a);
subplot(2,2,1);
plot(abs(h));
title('low pass filter ');
xlabel('frequency');
ylabel('gain');
axis([0 200 0 2]);
%HIGH PASS FILTER
disp('high pass filter');
wp=input('enter the pass band edge frequency wp=');
ws=input('enter the stop band edge frequency ws=');
ap=input('enter the pass band attenuation ap=');
as=input('enter the stop band attenuation as=');
[N wn]=CHEB1ORD(wp,ws,ap,as,'s');
[b a]=CHEBY1(N,.5,wn,'high','s');
h=freqs(b,a);
subplot(2,2,2);
plot(abs(h));
title('high pass filter ');
xlabel('frequency');
ylabel('gain');
axis([0 200 0 2]);
%BAND PASS FILTER
disp('band pass filter');
wp=input('enter the pass band edge frequency wp=');
ws=input('enter the stop band edge frequency ws=');
ap=input('enter the pass band attenuation ap=');
as=input('enter the stop band attenuation as=');
[N wn]=CHEB1ORD(wp,ws,ap,as,'s');
[b a]=CHEBY1(N,.5,wn,'s');
h=freqs(b,a);
subplot(2,2,3);
plot(abs(h));
title('band pass filter ');
xlabel('frequency');
ylabel('gain');
axis([0 200 0 2]);
%BAND STOP FILTER
disp(' band stop filter');
wp=input('enter the pass band edge frequency wp=');
ws=input('enter the stop band edge frequency ws=');
ap=input('enter the pass band attenuation ap=');
as=input('enter the stop band attenuation as=');
[N wn]=CHEB1ORD(wp,ws,ap,as,'s');
[b a]=CHEBY1(N,.5,wn,'stop','s');
h=freqs(b,a);
subplot(2,2,4);
plot(abs(h));
title('BAND STOP filter ');
xlabel('frequency');
ylabel('gain');
axis([0 200 0 2]);
ex7.4
clear all;
clc;
%LOW PASS FILTER
disp('low pass filter');
wp=input('enter the pass band edge frequency wp=');
ws=input('enter the stop band edge frequency ws=');
ap=input('enter the pass band attenuation ap=');
as=input('enter the stop band attenuation as=');
[N wn]=CHEB1ORD(wp,ws,ap,as);
[b a]=CHEBY1(N,.5,wn);
disp('THE ORDER OF THE FILTER N=');
disp(N);
disp('the cutoff frequency of the filter wn=');
disp(wn);
[h f]=freqz(b,a);
H=20*log10(abs(h));
subplot(2,2,1);
plot(f/pi,H);