You are on page 1of 1

Siddhant pratap singh

21111043
Experiment - 9
1. Write a MATLAB program to design FIR filter using window technique
a. Design a Low pass FIR filter
b. Design a high pass FIR filter
SPECIFICATONS : window – Hamming, Hanning
order N = 20, sampling frequency fs = 8 kHz, Cut off frequency fc = 2kHz f.jpeg
MATLAB CODE :;
N = 20; fs
= 8000; fc
= 2000;
lowpass_filter = fir1(N, fc / (fs / 2), 'low', hamming(N+1));
highpass_filter = fir1(N, fc / (fs / 2), 'high', hamming(N+1));
lowpass_filter1 = fir1(N, fc / (fs / 2), 'low', hann(N+1));
highpass_filter1 = fir1(N, fc / (fs / 2), 'high', hann(N+1)); f =
-fs/2:fs/N:fs/2;
lowpass = fftshift(fft(lowpass_filter, N+1)); highpass
= fftshift(fft(highpass_filter, N+1)); lowpass1 =
fftshift(fft(lowpass_filter1, N+1)); highpass1 =
fftshift(fft(highpass_filter1, N+1)); subplot(2, 2, 1);
plot(f, abs(lowpass)); xlabel('Frequency (Hz)');
ylabel('Magnitude');
title('Low-Pass FIR Filter (Hamming Window)');
subplot(2, 2, 2); plot(f, abs(highpass)); xlabel('Frequency
(Hz)'); ylabel('Magnitude');
title('High-Pass FIR Filter (Hamming Window)');
subplot(2, 2, 3); plot(f, abs(lowpass1)); xlabel('Frequency
(Hz)'); ylabel('Magnitude');
title('Low-Pass FIR Filter (Hanning Window)');
subplot(2, 2, 4); plot(f, abs(highpass1));
xlabel('Frequency (Hz)'); ylabel('Magnitude');
title('High-Pass FIR Filter (Hanning Window)');

You might also like