In: Electrical Engineering
1. Design a bandpass filter to meet the following specificatoins: lower stopband edge = 0.3π upper stopband edge = 0.6π lower passband edge = 0.4π upper passband edge = 0.5π Rp = 0.5 dB, As = 50 dB Use a sampling frequency of 1000 Hz. You may use MATLAB and the fir1 commmand to implement. It is advisable to check the MathWorks site for help on using these commands. It is advisable to check if the commands use the ripple in dB or in absolute units and you may use MATLAB commands to convert if needed. Note, since you must title and label axes, the default plot from freqz is not sufficient but you may use freqz to generate the frequency response and plot that data using the plot command ( and a few others to convert to dB ). a. Use one of the fixed windows that meets specification. Plot the magnitude ( in dB ) and phase response. Note: the order of the filter can be computed according to the formulas on page 20 of file ADSP-10 and the example on page 23, for example for the Hamming window : 4w = 6.6π/L where L = filter order and 4w is the transition band width. ( 1 point ) b. Use a Kaiser window to meet the same specification. Plot the magnitude ( in dB ) and phase response. You may use MATLAB commands to estimate the order of the filter and implement using the fir1 command. ( 1 point ) c. Verify that both part a. and part b. meet the Rp and As specifications.
PLEASE SLOVE USING MATLAB
solution::
a) and b)
Script:
clc;close all;clear all;
%Filter specifications
fs1=0.3*pi;fs2=0.6*pi;Rp=0.5;As=50;
fp1=0.4*pi; fp2=0.5*pi;Fsamp=1000;
fc1=(fp1+fs1)/2;fc2=(fp2+fs2)/2;
fc=[fc1/pi fc2/pi];
%Transition width
delw=min(fp1-fs1,fs2-fp2);
% Hamming window
L=(6.6*pi/delw)
hh=fir1(L,fc,'bandpass');%Default window used with fir1 is hamming window
w=0:pi/2000:pi;
H=freqz(hh,1,w);
figure;
subplot(221)
plot(w/pi,20*log10(abs(H)),'b');grid;
xlabel('w Xpi');ylabel('|H(exp(jw)| in db');
title(' LPF using Hamming window-Magnitude in db ')
subplot(222)
plot(w/pi,angle(H),'g');grid;
xlabel('w Xpi');ylabel('<H(exp(jw)>');
title('Phase response')
%kaiser window
fcut =[fs1 fp1 fp2 fs2];
fcc=Fsamp*fcut/(2*pi);
Mag = [0 1 0];
rp=1-(10^(-Rp/20)-1);
rs=10^(-As/20);
att= [rs rp rs];
[L,Wc,beta,ftype] = kaiserord(fcc,Mag,att,Fsamp);
L = L + rem(L,2)
%Kaiser window
hk = fir1(L,fc,ftype,kaiser(L+1,beta),'noscale');
%plots
H=freqz(hk,1,w);
subplot(223)
plot(w/pi,20*log10(abs(H)),'m');grid;
xlabel('w Xpi');ylabel('|H(exp(jw)| in db');
title('LPF using kaiser window-Magnitude in db ')
subplot(224)
plot(w/pi,angle(H),'g');grid;
xlabel('w Xpi');ylabel('<H(exp(jw)> in db');
title('Phase response')
c)
To implement the same specifications, N=67 is required for Hamming window. But this is achieved at the order of N=61 when kaiser window is used.
please give a thumb...thank you...