# Confusion implementing chebyshev type 2 band pass filter in matlab

I want to design a band pass Chebyshev Type II filter using analog prototyping. The order of filter is 20 with a value of 60 dB stop band attenuation and 0.75 dB pass band ripple where, Pass band edge = 800 Hz Stop band edge = 2000 Hz Sampling frequency = 6000

My Matlab code is below

clc;  close all;   clear all;
Rp = 0.75;    Rs = 60;
fp = 800;
fs = 2000;
Fs = 6000;

fn = Fs/2;     % nyquist frequency
wp = fp/fn;     % normalized Pass band corner frequency
ws = fs/fn;     % normalized Stop band corner frequency

[n,Wn] = cheb2ord(wp,ws,Rp,Rs);
[num,den] = cheby2(20,Rs,Wn);
freqz(num,den,512,Fs);


I have also attached snapshot of output which shows that output frequency plot looks like low pass,but i think ,why output plot is not band pass?How can it look band pass?

You're using the function cheb2ord in the wrong way. Assuming that your lower stopband edge is $$800$$ Hz and your upper stopband edge is $$2000$$ Hz (note that a bandpass filter has two stopband edges, as well as two passband edges), and if the sampling frequency is $$6000$$ Hz, then the following command should do what you intended to do:

[b, a] = cheby2(10, 60, [4, 10]/15);

Note that for bandpass and bandstop filters, the resulting filter order is twice the number you use in the call to cheby2.

• it might be nice to explain where the numbers "10", "60", "4", "10", and "15: come from when the relevant parameters are 6000 Hz, 800 Hz, 2000 Hz.. – robert bristow-johnson Jul 12 at 2:49
• @robertbristow-johnson: Maybe a bit too nice, considering that this might be part of some homework project? Also, from the OP's code it appears that computing normalized edge frequencies is not the problem here. Concerning the value for the filter order ($10$), I tried to explain this choice in the last sentence of my answer. – Matt L. Jul 12 at 12:33
• @MattL. Please believe me ,it is not part of any home work, i understood "10" and "60", but still confused why you used [4,10]/15 ?? – engr Jul 12 at 17:24
• @engr: These are exactly the same value you used in your code: fp/fn, fs/fn – Matt L. Jul 12 at 17:55
• ok thanks, you re wrote them in lowest form by cancelling common factor – engr Jul 12 at 18:00

What variables n and Wn holds when returned from cheb2ord and, what you do with these values? I.e. check documentation for: cheb2ord and cheby2.