Matlab program to design Chebyshev Type 2 Digital Band Stop Filter.
Matlab code
clc; clear all; close all;
rp=input('Enter the Passband ripple (In db) = ');
rs=input('Enter the Stopband attenuation (In db) = ');
fpc=input('Enter the Passband corner frequency (In Hz) = ');
fsc=input('Enter the Stopband corner frequency (In Hz) = ');
fs=input('Enter the Sampling frequency (In Hz) = ');
fn=fs/2;
Wp=fpc/fn; % Normalized passband corner frequency
Ws=fsc/fn; % Normalized stopband corner frequency
n=cheb2ord(Wp,Ws,rp,rs);
Wn=[Wp,Ws];
[b,a]=cheby2(n,rs,Wn,'stop');
L=1024;
[h,w]=freqz(b,a,L);
wi=w/pi; % Normalized angular frequency vector
mag=20*log10(abs(h));
ang=angle(h);
subplot(2,1,1);
plot(wi,mag);
title('Magnitude Response [Chebyshev Type 2 Digital Band Stop Filter]');
ylabel('Gain in dB -->');
xlabel('Normalised Frequency ( x pi rad/sample)-->');
grid on;
subplot(2,1,2);
plot(wi,ang);
title('Phase Response');
xlabel('Normalised Frequency ( x pi rad/sample)-->');
ylabel('Phase in radians -->');
grid on;
Command window
Enter the Passband ripple (In db) = .1
Enter the Stopband attenuation (In db) = 80
Enter the Passband corner frequency (In Hz) = 400
Enter the Stopband corner frequency (In Hz) = 600
Enter the Sampling frequency (In Hz) = 2000
No comments:
Post a Comment