Designing a lowpass filter in matlab

Hello,
I want to implement the analog LP filter having a cutoff frequency of 2.4Hz and gain of 101 as shown http://img42.imageshack.us/img42/4320/qe74.jpg in the matlab. How to implement this LPfilter having a cutoff frequency and gain in matlab. Can help me out with this.

 採用された回答

Youssef  Khmou
Youssef Khmou 2013 年 12 月 2 日

0 投票

there is a filter design functions , you can start with the simplest function as follows :
% given you sampling frequency, lets say 20
fs=20;
fc=2/10;
b=fir(N,fc);
freqz(b);

6 件のコメント

Stefan
Stefan 2013 年 12 月 2 日
Thanks but what about gain.
Youssef  Khmou
Youssef Khmou 2013 年 12 月 2 日
i think "fir1" scales the filer to a gain of 0dB , try this and let me now :
fs=20;
N=200;
fc=2/(fs/2);
b=101*fir1(N,fc);
freqz(b);
[gain,f]=freqz(b);
figure, plot(f,abs(gain))
Stefan
Stefan 2013 年 12 月 2 日
Yes,it is having a cutoff frequency of 0.2 but what is this b=101*fir1(N,fc); How to increase the gain to 101. And I have doubt that thisthread has LP filter, what will be the difference of using the both and which one should I follow. thanks.
Youssef  Khmou
Youssef Khmou 2013 年 12 月 3 日
編集済み: Youssef Khmou 2013 年 12 月 3 日
i do not have experience with the other method (filterdesign), howeve i wrote an example for testing : filtering white noise
N=200;
Fs=80;
fc=2.4/(Fs/2);
b=fir1(N,fc);
x=randn(200,1); % AWGN
y=filter(b,1,x);
NFFT=800;
Fx=fft(x,NFFT);
Fx=abs(Fx(1:end/2));
Fy=fft(y,NFFT);
Fy=abs(Fy(1:end/2));
frequency=(0:NFFT-1)*Fs/NFFT;
frequency=frequency(1:floor(end/2));
figure, plot(frequency,Fx,frequency,Fy,'r'), legend(' AWGN','filtered')
Stefan
Stefan 2013 年 12 月 18 日
Hi Youssef KHMOU,
Can I know what is 'N' here and why you are using fc=2/(fs/2); is it mandatory to use this or can we directly use the required fc in the b=fir1(N,3) if fc=3Hz. How to design FIR lowpass filter having a cutoff frequency of 2.8Hz and with a sample rate of 300Hz .
Youssef  Khmou
Youssef Khmou 2013 年 12 月 18 日
N is the number of coefficients in the filter. The build in function fir1 requires the cut off frequency to be 0<fc<1, that is why you compute the new cut frequency as a function of Fs : Fc2=fc/(0.5*Fs).

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

製品

質問済み:

2013 年 12 月 2 日

コメント済み:

2013 年 12 月 18 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by