Matlab

High pass FIR filter implementation and High pass IIR filter implementation

Steps involved in performing FIR filter operation

Step I: Let’s enter the pass band frequency (fp) and stop band frequency (fq).

Step II: And then get the sampling frequency (fs), length of window (n).

Step III: Next calculate cut off frequency.

Step IV: Use the boxcar, hamming, Blackman Commands for designing window.

Step V: And then design filter by using above parameters.

Step VI: To find frequency response of the filter by using matlab command freqz.

Step VII: Then plot the magnitude response and phase response of the filter.

Program:

clc;

clear all;

close all;

n=20;

fp=300;

fq=200;

fs=1000;

fn=2*fp/fs;

window=blackman(n+1);

b=fir1(n,fn,’high’,window);

[H W]=freqz(b,1,128);

subplot(2,1,1);

plot(W/pi,abs(H));

title(‘mag res of lpf’);

ylabel(‘gain in db——–>’);

xlabel(‘normalized frequency——>’);

subplot(2,1,2);

plot(W/pi,angle(H));

title(‘phase res of lpf’);

ylabel(‘angle——–>’);

xlabel(‘normalized frequency——>’);

Steps involved in performing IIR filter operation

Step I: Now enter the pass band ripple (rp) and stop band ripple (rs).

Step II: while the pass band frequency (wp) and stop band frequency (ws).

Step III: Then Get the sampling frequency (fs).

Step IV: Then calculate the normalized pass band frequency, and normalized stop band frequency w1 and w2 respectively.

Step V : Make using the following function for calculating the Butterworth filter order [n,wn]=buttord(w1,w2,rp,rs ) and Chebyshev filter order [n,wn]=cheb1ord(w1,w2,rp,rs)

 Step VI: Let’s design the nth order digital high pass Chebyshev or Butterworth filter using the following commands. Butterworth filter [b,a]=butter (n, wn,’high’) Chebyshev filter [b,a]=cheby1 (n, 0.5, wn,’high’)

Step VII: In order to find the digital frequency response of the filter by using ‘freqz ( )’ function

Step VIII: Then calculate the magnitude for the frequency response in decibels (dB) mag=20*log10 (abs (H))

Step IX: Then plot the magnitude response [magnitude in dB Vs normalized frequency]

Step X: Next calculate the phase response using angle (H).

Step XI: Then plot the phase response [phase in radians Vs normalized frequency (Hz)].

Program:

clc;

clear all;

close all;

disp(‘enter the IIR filter design specifications’);

rp=input(‘enter the passband ripple’);

rs=input(‘enter the stopband ripple’);

wp=input(‘enter the passband freq’);

ws=input(‘enter the stopband freq’);

fs=input(‘enter the sampling freq’);

w1=2*wp/fs;w2=2*ws/fs;

[n,wn]=buttord(w1,w2,rp,rs,’s’);

disp(‘Frequency response of IIR HPF is:’);

[b,a]=butter(n,wn,’high’,’s’);

w=0:.01:pi;

[h,om]=freqs(b,a,w);

m=20*log10(abs(h));

an=angle(h);

figure, subplot(2,1,1);plot(om/pi,m);

title(‘magnitude response of IIR filter is:’);

xlabel(‘(a) Normalized freq. –>’);

ylabel(‘Gain in dB–>’);

subplot(2,1,2);plot(om/pi,an);

title(‘phase response of IIR filter is:’);

xlabel(‘(b) Normalized freq. –>’);

ylabel(‘Phase in radians–>’);

Rajeshwari Chiluveru

Rajeshwari is a Smart TV and connectivity specialist with over 7 years of hands-on experience in troubleshooting real-world device issues. She has worked extensively on diagnosing problems such as WiFi not working, HDMI ARC/eARC failures, app errors, and connectivity issues across platforms like Samsung, Hisense, and Android TV. At Web Vidyalayam, she focuses on creating verified, step-by-step solutions based on practical testing rather than theory. Her goal is to simplify complex technical problems and help users fix their devices quickly and confidently.

Share
Published by
Rajeshwari Chiluveru

Recent Posts

Hisense Smart TV WiFi Not Working? Easy Fixes That Work (2026 Guide)

Introduction: When your Hisense TV won't connect to WiFi, it is rarely a problem with…

2 days ago

Fix Hisense TV Storage Space Running Out: 2026 OS Logic Hub

Hisense Google TV Storage Space Running Out: Why it Happens and How to Fix It…

3 days ago

Samsung Smart TV HDMI ARC/eARC Not Working? Easy Fixes That Actually Work (2026 Guide)

Introduction: "Setting up a soundbar with your Samsung TV should be simple, but the HDMI…

3 days ago

Samsung TV Red Light Blinking? 4 Fixes (2026 Power Logic Hub)

User Problem Scenario: The Red Light "Panic" You press the power button on your Samsung…

3 weeks ago

Samsung TV Not Connecting to WiFi: 2026 Easy Fix Guide

Introduction: I Know the Feeling "We’ve all been there. You sit down to watch your…

3 weeks ago

Samsung TV Restarting During Diagnosis? Fix the Reboot Loop Fast

User Problem Scenario: The "Diagnosis Loop" Paradox Imagine you notice your apps are slow. You…

3 weeks ago