MATLAB Code for Study of FIR filter design using window method: Low Pass, High Pass Filter

Shubham Gupta

--

Follow for more such content

clc;

clear all;

n=40 %Order

fp=250 %Pass Frequency

fs=700 %Stop Frequency

f=1000

wp=2*(fp/f) %Convert to Radian

ws=2*(fs/f) %Convert to Radian

window=boxcar(n+1) %Rectangular Window

wn=2*(fp/f)

b1=fir1(n,wn,window) %Low Pass

b2=fir1(n,wn,’high’,window) %High Pass

[H w]=freqz(b1,1)

subplot(2,2,1)

plot(w/pi,20*log(abs(H)))

xlabel(‘nf’)

ylabel(‘Magnitude in dB ‘)

title(‘Magnitude Response Low Pass- ‘)

subplot(2,2,2)

plot(w/pi,angle(H))

xlabel(‘nf’)

ylabel(‘Angle’)

title(‘Phase Response Low Pass — ‘)

[H w]=freqz(b2,1)

subplot(2,2,3)

plot(w/pi,20*log(abs(H)))

xlabel(‘nf’)

ylabel(‘Magnitude in dB ‘)

title(‘Magnitude Response High Pass- ‘)

subplot(2,2,4)

plot(w/pi,angle(H))

xlabel(‘nf’)

ylabel(‘Angle’)

title(‘Phase Response High Pass — ‘)

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Shubham Gupta
Shubham Gupta

Written by Shubham Gupta

Software Engineer and Content Writer at Lovebird Lingerie

No responses yet

Write a response