Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

11/13/2015

matlabwhatisthecommandforbutterworthbandpassfilterStackOverflow

signup

login

tour

help

stackoverflowcareers

Signup

StackOverflowisacommunityof4.7millionprogrammers,justlikeyou,helpingeachother.Jointhem,itonlytakesaminute:

whatisthecommandforbutterworthbandpassfilter

Ihavesignaldatatofilterusingbandpassfilterwhichthefrequenciesare1045s,45150sand150600s.howtocreatebandpassfilter
commandinmatlabtofilterthatfrequencies?
matlab

editedJun27'13at10:13

askedJun27'13at10:00

VishnuRenku

baizura

1,480

14

15

36

1 inmatlab andthequestionistaggedas PHP ?HamZaJun27'13at10:03


Sincewhenwasseconds(s)theunitoffrequency?learnvstJun27'13at10:30
Usually,a"showmethecode?"commentwouldappearhere,butIguessthisissomewhatjustifiable.
However,youcouldshowsomethingyouhavetried...icedwaterJun27'13at10:52

1Answer

Assumingyouhavethesignalprocessingtoolbox(forthe butter commandseelowercodeif


butter isunavailable),andifyouknowthesamplingfrequency fs ,youcanmakeasimple
recursiveButterworthfilterusingthelowandhighfrequency(inHz)3dBpoinsusingthe
followingcode.Higher order swillgiveyoubetterofffrequencyrejectionattheexpenseofa
longerimpulseresponseandalittlemorecomputationexpense.
[b,a]=butter(order,[lowFreqhiFreq]/(fs/2),'bandpass');
y=filter(b,a,x)

Theoutputsignal y isobtainedbyfilteringtheinputsignal
usingthe butter command.

usingthecoefficientsgenerated

Ifyouwanttohavetheoutputfromall3bandsatonce,youcansumtheoutputsfrom3separate
filteroperations,oneforeachband.However,youmayliketousethe filtfilt commandover
filter whendoingthisifyouwanttopreservethephaserelationshipbetweenthebands.
Ifyoudonothavethesignalprocessingtoolbox,youcancreate2ndorderbandpassbutterworth
coefficientsusingthecodebelow,where dt=1/fs and fl and fu arelowandhighcutoff
frequencies.
function[b,a]=butterTwoBp(dt,fl,fu)
q=pi*dt*(fufl);
r=pi*dt*(fu+fl);
N=(tan(q)^2)+sqrt(2)*tan(q)+1;
M=(tan(q)^2)/N;%MafterNbecauseitdependsonN
O=cos(r)*(2*sqrt(2)*tan(q)+4)/((cos(q))*N);
P=(2*(tan(q)^2)+(((2*cos(r))/(cos(q)))^2)+2)/N;
Q=cos(r)*(2*sqrt(2)*tan(q)4)/(cos(q)*N);
R=((tan(q)^2)sqrt(2)*tan(q)+1)/N;
b=[M02*M0M];
a=[1OPQR];

editedJun27'13at10:49

answeredJun27'13at10:31
learnvst
6,421

http://stackoverflow.com/questions/17340198/whatisthecommandforbutterworthbandpassfilter

30

65

1/2

11/13/2015

matlabwhatisthecommandforbutterworthbandpassfilterStackOverflow

http://stackoverflow.com/questions/17340198/whatisthecommandforbutterworthbandpassfilter

2/2

You might also like