0
$\begingroup$

I am trying to design a digital butterworth filter for the given specifications.. code is posted below..

rp=3;
rs=15;
FS=1;
wp=0.5*pi;
ws=0.75*pi;
pwp=2*FS*tan(wp/2);
pws=2*FS*tan(ws/2);
[n,wn]=buttord(pwp,pws,rp,rs,'s')
[b,a]=butter(n,wn,'s');
[bn,an]=bilinear(b,a,FS);%error
freqz(bn,an,512,FS);

My question is ,if i design a filter manually i am getting different values for 'bn' and 'an'.. but matlab gives different answer.. can anybody help me...?

$\endgroup$
  • $\begingroup$ Do you get the same filter order? Are both filters meeting the specification? $\endgroup$ – Oscar Jan 22 '15 at 14:51
1
$\begingroup$

I cannot run your code because I have not matlab on this pc, but I can try to give you some advice.

The first thing I will check is the way you defined the cut-off frequencies. The Matlab function uses normalized frequencies (look at the examples here http://it.mathworks.com/help/signal/ref/buttord.html), which means you have to define it in this way: lets assume you want to cut your signal at 5 Hz and your sampling frequency is $Fs$

cut_freq = 5;
Wn = cut_freq/(Fs/2);

Of course if you have a band-pass filter you have to define 2 cut-off frequencies and therefore $Wn$ will be a vector of 2 elements.

Hope this helps. As soon as I get my laptop I will try to run your code and see what happens.

$\endgroup$
  • $\begingroup$ thanks for your advice.I checked the examples.. But there ,they are directly designing digital filter...But what i am trying to do here is given the analog specifications of a butterworth filter, designing digital butterworth filter using Binilear Tranformation teqniq..For more clarity i will post original Q. below $\endgroup$ – spectre Nov 22 '14 at 15:29
  • $\begingroup$ Design a digital filter,given the equavalent analog filter with following specifications Passband ripple=3.01 db Passband edge=500 hz Stopband attenuation =15 db Stopband edge=750 hz Sample rate=2000 hz, and design using Bilinear Tranformation. $\endgroup$ – spectre Nov 22 '14 at 15:34
  • $\begingroup$ Sorry I did not specify, my answer was related to the first part of your code where you used the 'buttord()' function. There I do not understand the way you are defining the frequencies 'pwp=2*FStan(wp/2); pws=2*FStan(ws/2); [n,wn]=buttord(pwp,pws,rp,rs,'s')' $\endgroup$ – Rhei Nov 22 '14 at 15:35
  • 1
    $\begingroup$ To be more clear, $pwp$ and $pws$ are not normalized frequencies, but buttord() asks for normalized values of frequencies. So I think the problem could be in the way you are using the buttord() function $\endgroup$ – Rhei Nov 22 '14 at 15:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.