clc;
clear all;
close all;
fc= 200;
fs= 1200;
N=25;
Wc=(2*pi*fc/fs);
%1) LPF
b=fir1(N,Wc/pi, hamming(N+1));
w=0:0.01:pi;
[h,w]= freqz(b,1,w);
%W=angular frequency
m = 20*log10(abs(h));
subplot(2,1,1);
plot(w/pi,m);
xlabel('Normalised frequency response');
ylabel('Gain in dB');
subplot(2,1,2);
plot(w/pi,angle(h))
%2) HPF
clc;
clear;
close all;
% Filter specifications
fs = 1000; % Sampling frequency in Hz
fc = 200; % Cutoff frequency in Hz
n = 50; % Filter order (must be even for Type 1 FIR)
% Normalize cutoff frequency
wn = fc / (fs / 2);
% Design Highpass FIR filter using Hamming window
b = fir1(n, wn, 'high', hamming(n+1));
% Frequency response
[H, w] = freqz(b, 1, 1024, fs);
% Plot frequency response
figure;
plot(w, abs(H));
title('Magnitude Response of FIR Highpass Filter');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
grid on;