FIR Bandpass Filter with Hamming

5 views (last 30 days)
Liam Nielson
Liam Nielson on 5 Mar 2021
Answered: William Rose on 2 Apr 2021
Hi,
How would you solve the following question of the bandpass filter with the hamming window - with w1=0.2*pi rad/sample and w2=0.4*pi rad/sample. With the order of the filter being 100. Whilst plotting the fequency and phase responses too.
This isn't homework.

Answers (1)

William Rose
William Rose on 2 Apr 2021
See code below.
%LiamsFilter Liam Nielsen & W.Rose
%Requested filter order was 100, but I will use 101 for symmetry
n=-50:50;
w1=0.2*pi;
w2=0.4*pi;
h1=(w2/pi)*sin(n*w2)./(n*w2)-(w1/pi)*sin(n*w1)./(n*w1);
h1(51)=w2/pi-w1/pi;
h2=h1.*hamming(101)'; %apply Hamming window to h1
plot(n,h1,'rx-',n,h2,'bo-'); %plot impulse responses
xlabel('n'); ylabel('Impulse Response'); legend('h','hamm(h)');
fvtool(h1,'magnitude');
fvtool(h2,'magnitude');
fvtool(h1,'phase');
fvtool(h2,'phase');
Code above makes 5 plots:
  • impulse response of h and hamming(h)
  • magn(h)
  • magn(hamm(h))
  • phase(h)
  • phase(hamm(h))
Plots 1 and 3 from list above are shown below.

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!