DSPRelated.com
Forums

Helping disigning a bandpass filter in matlab

Started by rebel November 24, 2009
I'm really new to filter design and need some major help on building a
bandpass filter in matlab. I have the specs but i don't know where to
start. 
These are the specs:
wp1 = 0.45*pi
wp2 = 0.65*pi
ws1 = 0.3*pi
ws2 = 0.8*pi
op = 0.01
os1 = 0.008
os2 = 0.05

I can't use the fir1 function. 

What is my first step?
What other methods can i use to create a filter?

Any help is appreciated.
Thanks.
>I'm really new to filter design and need some major help on building a >bandpass filter in matlab. I have the specs but i don't know where to >start.
Start by installing Matlab, Signal Processing Toolbox and then go to help, search for 'filters'
> >Any help is appreciated. >Thanks. >
On Nov 24, 1:06&#4294967295;am, "rebel" <rebelins...@gmail.com> wrote:
> I'm really new to filter design and need some major help on building a > bandpass filter in matlab. I have the specs but i don't know where to > start. > These are the specs: > wp1 = 0.45*pi > wp2 = 0.65*pi > ws1 = 0.3*pi > ws2 = 0.8*pi > op = 0.01 > os1 = 0.008 > os2 = 0.05 > > I can't use the fir1 function. > > What is my first step? > What other methods can i use to create a filter? > > Any help is appreciated. > Thanks.
What happens when you type "fdatool" at the matlab command prompt? There are other ways of designing a filter with matlab but fdatool provides a GUI that's really easy to use. Darol Klawetter
Cool i got the filter with fdatool, but i need to do it manually. Without
using the fir1 function, what other functions do i use to get a bandpass
filter? 


>On Nov 24, 1:06=A0am, "rebel" <rebelins...@gmail.com> wrote: >> I'm really new to filter design and need some major help on building a >> bandpass filter in matlab. I have the specs but i don't know where to >> start. >> These are the specs: >> wp1 =3D 0.45*pi >> wp2 =3D 0.65*pi >> ws1 =3D 0.3*pi >> ws2 =3D 0.8*pi >> op =3D 0.01 >> os1 =3D 0.008 >> os2 =3D 0.05 >> >> I can't use the fir1 function. >> >> What is my first step? >> What other methods can i use to create a filter? >> >> Any help is appreciated. >> Thanks. > >What happens when you type "fdatool" at the matlab command prompt? >There are other ways of designing a filter with matlab but fdatool >provides a GUI that's really easy to use. > >Darol Klawetter >
I found the export to m file but the export includes fir1. 

>Cool i got the filter with fdatool, but i need to do it manually.
Without
>using the fir1 function, what other functions do i use to get a bandpass >filter? > > >>On Nov 24, 1:06=A0am, "rebel" <rebelins...@gmail.com> wrote: >>> I'm really new to filter design and need some major help on building
a
>>> bandpass filter in matlab. I have the specs but i don't know where to >>> start. >>> These are the specs: >>> wp1 =3D 0.45*pi >>> wp2 =3D 0.65*pi >>> ws1 =3D 0.3*pi >>> ws2 =3D 0.8*pi >>> op =3D 0.01 >>> os1 =3D 0.008 >>> os2 =3D 0.05 >>> >>> I can't use the fir1 function. >>> >>> What is my first step? >>> What other methods can i use to create a filter? >>> >>> Any help is appreciated. >>> Thanks. >> >>What happens when you type "fdatool" at the matlab command prompt? >>There are other ways of designing a filter with matlab but fdatool >>provides a GUI that's really easy to use. >> >>Darol Klawetter >> >
On Nov 24, 4:14&#4294967295;pm, "rebel" <rebelins...@gmail.com> wrote:
> I found the export to m file but the export includes fir1. > > > > >Cool i got the filter with fdatool, but i need to do it manually. > Without > >using the fir1 function, what other functions do i use to get a bandpass > >filter? > > >>On Nov 24, 1:06=A0am, "rebel" <rebelins...@gmail.com> wrote: > >>> I'm really new to filter design and need some major help on building > a > >>> bandpass filter in matlab. I have the specs but i don't know where to > >>> start. > >>> These are the specs: > >>> wp1 =3D 0.45*pi > >>> wp2 =3D 0.65*pi > >>> ws1 =3D 0.3*pi > >>> ws2 =3D 0.8*pi > >>> op =3D 0.01 > >>> os1 =3D 0.008 > >>> os2 =3D 0.05 > > >>> I can't use the fir1 function. > > >>> What is my first step? > >>> What other methods can i use to create a filter? > > >>> Any help is appreciated. > >>> Thanks. > > >>What happens when you type "fdatool" at the matlab command prompt? > >>There are other ways of designing a filter with matlab but fdatool > >>provides a GUI that's really easy to use. > > >>Darol Klawetter
In my opinion the simplest FIR design technique to use is the so- called 'window method'. This technique, although suboptimal, is easy to implement. Start with a lowpass filter and convert to bandpass by modulating the coefficients up to the BPF center. Look for it on your favorite search engine in a book. John
On Nov 24, 3:14&#4294967295;pm, "rebel" <rebelins...@gmail.com> wrote:
> I found the export to m file but the export includes fir1. >
You can also export the FIR coefficients to a variable. You could then do a convolution of the coefficients with your data using the "conv" function. You write that you can't use the fir1 function so it appears that you're doing homework, right? If so, maybe the professor wants you to understand the convolution operation. Darol Klawetter
I think i need to multiply with an appropriate window function. This is an
example of a low pass filter:
wp=0.2*pi;ws=0.3*pi;tr_width=ws-wp;
M=ceil((6.6*pi/tr_width-1)/2)
wc=(ws+wp)/2; %Ideal LPF cutoff frequency;
n=-M:M;
h_LP=sinc(n*wc/pi)*wc/pi; w=hamming(2*M+1); h=h_LP.*w';
[H,w]=freqz(h,[1]); mag=abs(H);pha=angle(H);
mag_db=20*log10((mag+eps)/max(mag));

I'm suppose to use this example to create my bandpass, but how to i get
the transition bandwidth?


>On Nov 24, 3:14=A0pm, "rebel" <rebelins...@gmail.com> wrote: >> I found the export to m file but the export includes fir1. >> > >You can also export the FIR coefficients to a variable. You could then >do a convolution of the coefficients with your data using the "conv" >function. You write that you can't use the fir1 function so it appears >that you're doing homework, right? If so, maybe the professor wants >you to understand the convolution operation. > >Darol Klawetter >
On Nov 24, 2:06&#4294967295;am, "rebel" <rebelins...@gmail.com> wrote:
> I'm really new to filter design and need some major help on building a > bandpass filter in matlab. I have the specs but i don't know where to > start. > These are the specs: > wp1 = 0.45*pi > wp2 = 0.65*pi > ws1 = 0.3*pi > ws2 = 0.8*pi > op = 0.01 > os1 = 0.008 > os2 = 0.05 > > I can't use the fir1 function. > > What is my first step? > What other methods can i use to create a filter? > > Any help is appreciated. > Thanks.
This skips the MatLab step and the price is right (free). This is an application I wrote a long time ago, feel free to use it. http://www.claysturner.com/dsp/fir.zip IHTH, Clay