%============================================================
%===== Two Filters Desinged According To The Equations: =====
%=====          h1(n)=2cos(2pi n fo/fs)h(n)LP           =====
%=====                      And                         ===== 
%=====          h1(n)=2sin(2pi n fo/fs)h(n)LP           =====
%=====                  Where Wo=Ws/4                   =====
%============================================================

fs=400;
wn=[0.25];
[b,a]=fir1(199,wn,hamming(200));
[H,w]=freqz(b,a,512);

figure(1);
plot(w*fs/(2*pi),abs(H));
n=(1:1:200);
ws=2*pi*fs;
wo=ws/4;
fo=wo/(2*pi);
x=(2*cos(2*pi*n*fo/fs));
y=b.*x;
[H,w]=freqz(y,a,512);
title('LOW PASS Filter Frequency Response');
xlabel('Freqency (Hz)');
ylabel('Magnitude of Frequency Response');
grid on

figure(2);
plot(w*fs/(2*pi),abs(H));
title('BAND PASS Filter Frequency Response');
xlabel('Freqency (Hz)');
ylabel('Magnitude of Frequency Response');
grid on

alpha=unwrap(angle(H));

figure(3);
plot((w*fs/2*pi),(alpha/pi)*180);
title('Filters Phase Response');
xlabel('Frequency (Hz)');
ylabel('Phase (Degrees)');
grid on