# Why bandpass code not working

Status
Not open for further replies.

#### bcha

##### Newbie level 3
fs=4000; %half the sampling freq qhich is used for normalising
wp=[3150 3700]/fs
wp=wp*2*pi
ws=[3140 3710]/fs %mychosen values
ws=ws*2*pi
[n16 wn16]=buttord(wp,ws,0.1,40);%my chosen rp and rs
[z16,p16,k16]=butter(n16,wn16,'bandpass')

i know its coz wp and ws are not between 0 and 1 but how do i choose an appropriate fs inorder to achieve that.

#### albbg

As you said, wp and ws are the frequencies normalized to half sampling rate frequency, then 1 means half sampling frequency.

Thus if fs=4000, [3150 3700] and [3140 3710] are in homogeneous measurement units, I mean all of them "Hz" or all of them "rad/sec" then you have to simply divide:

wp=[3150 3700]/fs --> [0.7875 0.925]
ws=[3140 3710]/fs --> [0.785 0.9275]

you don't have to multiply by 2*pi.

Status
Not open for further replies.