In: Electrical Engineering
Design a LP FIR filter to meet the following specifications using the window method. Use a Blackman window.
Fs = 25 kHz
Fc = 5.0 kHz (3 dB down)
Attenuation = 80 dB at 7 kHz
Give all the relevant plots (impulse, frequency responses) and the performance of the final filter. Compare this filter to one designed using the optimal method .
Script:
clc;close all;clear all;
Fs=25000;
Fc=5000;wc=2*Fc/Fs;
width=2*pi*4000/Fs;
N=ceil(12*pi/width);
n=0:1:N;
wb=blackman(N+1)';
hh=fir1(N,wc);
%Impulse response
h=hh.*wb;
[H,f]=freqz(h,1,1024,Fs);
figure;
subplot(321)
stem(n,hh);grid;title('Ideal impulse response')
xlabel('n');ylabel('h(n)')
subplot(322)
stem(n,wb);grid;title('Blackman window')
xlabel('n');ylabel('wb(n)')
subplot(323)
stem(n,h);grid;title('desired impulse response')
xlabel('n');ylabel('hd(n)')
subplot(324)
plot(f,abs(H));grid;title('Freqeuncy response-Magntiude')
xlabel('f in Hz');ylabel('|H(f)|')
subplot(325)
plot(f,20*log10(abs(H)));grid;title('Freqeuncy response-Magntiude in db')
xlabel('f in Hz');ylabel('|H(f)|')
subplot(326)
plot(f,angle(H));grid;title('Freqeuncy response-Phase')
xlabel('f in Hz');ylabel('<H(f)>')
figure;% optimal FIR filter design
Rs=80;
[N,fo,ao,w] = firpmord([3000 7000],[1 0],[0.001 10^(-Rs/20)],Fs);
h= firpm(N,fo,ao,w);
freqz(h,1,1024,Fs)
Plots:
using blackman window:
Optimal FIR filter design