%LOW PASS
clc;clear;close all;
order=10;
Wc=0.5;
N=order+1;
win=ones(N,1);
b=fir1(order,Wc,'low',win);
disp(b);
[H,W]=freqz(b,1);
plot(W/pi,mag2db(abs(H)));
grid on;
title('Low pass filter with cut off frequency 0.5pi and order 12')
xlabel('Normalized frequency (x pi rad)');
ylabel('Magnitude in db');
%HIGH PASS
clc; clear; close all;
order = 10;
Wc = 0.5;
N=order+1;
win = [0.5;ones(N-2, 1);0.5];
b = fir1(order,Wc,'high',win);
disp(b);
[H,W] = freqz(b,1);
plot(W/pi,mag2db(abs(H)));
grid on;
title('High pass filter with cut off frequency 0.5pi an order 12);
xlabel('Normalize Frequency');
ylabel('Magnitude in db');
%BAND PASS
clc; clear; close all;
order = 10;
Wc1 = 0.35;
Wc2 = 0.65;
N=order+1;
n = 0:1:N-1;
win = 0.5-0.5*cos(2*pi*n/(N-1));
b = fir1(order,[Wc1 Wc2],'bandpass',win);
disp(b);
[H,W] = freqz(b,1);
plot(W/pi,mag2db(abs(H)));
grid on;
title('High pass filter with cut off frequency 0.35pi, 0.65pi an order 12');
xlabel('Normalize Frequency');
ylabel('Magnitude in db');
%BAND STOP
clc; clear; close all;
order = 10;
Wc1 = 0.35;
Wc2 = 0.65;
N=order+1;
n = 0:1:N-1;
win = 0.5-0.5*cos(2*pi*n/(N-1));
b = fir1(order,[Wc1 Wc2],'stop',win);
disp(b);
[H,W] = freqz(b,1);
plot(W/pi,mag2db(abs(H)));
grid on;
title('Band stop filter with cut off frequency 0.35pi, 0.65pi an order 12');
xlabel('Normalize Frequency');
ylabel('Magnitude in db');