Experiment 7[1]

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

Experiment 8(A)

Write a matlab program to implement 4 different filter:


Low pass filter:
clc

clear all

close all

rp=input('enter passband ripple=');%0.23

rs=input('enter stop band ripple=');%47

wp=input('enter passband frequency=');%1300

ws=input('enter stopband frequency =');%1550

fs=input('enter the sampling frequency=');%7800

w1=2*wp/fs;

w2=2*ws/fs;

[n,wn]=cheb1ord(w1,w2,rp,rs);

[b,a]=cheby1(n,rp,wn);

w=0:0.01:pi;

[h,om]=freqz(b,a,w);

m=20*log10(abs(h));

an=angle(h);

subplot(2,1,1);

plot(om/pi,m);

title('magnitude response');
xlabel('normalisd frequency............>');

ylabel('gain in db...............>');

grid on;

subplot(2,1,2);

plot(om/pi,an);

title('phase response');

xlabel('normalised frequency .........>');

ylabel('phase in radians..........>');

grid on;
Experiment -8(d): Bandstop filter:
clc

clear all

close all

rp=input('enter passband ripple=');%0.15

rs=input('enter stop band ripple=');%30

wp=input('enter passband frequency=');%2000


ws=input('enter stopband frequency =');%2400

fs=input('enter the sampling frequency=');%7000

w1=2*wp/fs;

w2=2*ws/fs;

[n]=cheb1ord(w1,w2,rp,rs);

wn=[w1 w2];

[b,a]=cheby1(n,rp,wn,'stop');

w=0:0.01:pi;

[h,om]=freqz(b,a,w);

m=20*log10(abs(h));

an=angle(h);

subplot(2,1,1);

plot(om/pi,m);

title('magnitude response');

xlabel('normalisd frequency............>');

ylabel('gain in db...............>');

grid on;

subplot(2,1,2);

plot(om/pi,an);

title('phase response');

xlabel('normalised frequency .........>');

ylabel('phase in radians..........>');

grid on;

You might also like