Continue to Site

# Need guide to design FIR bandpass filter using calculation or MATLAB

Status
Not open for further replies.

#### naspek

##### Member level 1
hey there..
I really hope u guys can help me extracting the important element from the question below;

A signal is sampled at the sampling rate of 10kHz. The signal has useful signal content
between 1kHz and 2.4kHz, and distortion of not more than 1dB is required for this range. It
is known that the signal is corrupted with noise above 3.6kHz. This noise needs to be
attenuated by at least 40dB.

i need confirmation from u guys whether i'm in the right direction to solve this problem..

so far, this is what i got..

sampling frequency, ft = 10kHz
fp = 2.4kHz ; αp = 1dB
fs = 3.6kHz ; αs = 40dB

based on the stopband attenuation, i can choose either Hanning, Hamming, Blackmann or Kaiser window right?

i can solve it if the question asking me to do the lowpass filter..
but... for bandpass, i need fp1, fp2, fs1 and fs2.. how am i going to get it?

thank you.

fs1=0.1kHz
fp1=1kHz
fp2=2.4Khz
fs2=3.3khz
These two transition bandwidths must be the same in the window design. Hence Since all frequencies above 3.3 will attenuated by 40dB, You will meet your design requirement.

- - - Updated - - -

Here is the code
Code:
ws1 = 0.01; wp1 = 0.1; wp2 = 0.24; ws2 = 0.33; As = 40;
tr_width = min((wp1-ws1),(ws2-wp2)); M = ceil(11*pi/tr_width) + 1
n=[0:1:M-1]; wc1 = (ws1+wp1)/2; wc2 = (wp2+ws2)/2;
%lowpass2
alpha = (M-1)/2; n = [0:1:(M-1)];
m = n - alpha; fc2 = wc2/pi; hd2 = fc2*sinc(fc2*m);
%lowpass1
fc1 = wc1/pi; hd1 = fc1*sinc(fc1*m);
hd = hd2-hd1;
w_bla = blackman(M)'; h = hd .* w_bla;
[H,w] = freqz(h,[1],1000,'whole');
H = H(1:1:501); w = w(1:1:501);
mag = abs(H); db = 20*log10((mag+eps)/max(mag));
pha = angle(H); grd = grpdelay(h,[1],w);
delta_w = 2*pi/1000;
Rp = -min(db(wp1/delta_w+1:1:wp2/delta_w))
As = -round(max(db(ws2/delta_w+1:1:501)))
subplot(2,2,1); stem(n,hd); title('Ideal Impulse Response')
axis([0 M-1 -0.4 0.5]); xlabel('n'); ylabel('hd(n)')
subplot(2,2,2); stem(n,w_bla);title('Blackman Window')
axis([0 M-1 0 1.1]); xlabel('n'); ylabel('w(n)')
subplot(2,2,3); stem(n,h);title('Actual Impulse Response')
axis([0 M-1 -0.4 0.5]); xlabel('n'); ylabel('h(n)')
subplot(2,2,4);plot(w/pi,db);axis([0 1 -150 10]);
title('Magnitude Response in dB');grid;
xlabel('frequency in pi units'); ylabel('Decibels')

Status
Not open for further replies.