In: Computer Science
Using Matlab functions ‘fdesign’ and ‘design’, create the
following filters (do not forget to create an m file to write a
script that should be printed in your report). [0.5] a-c each
(a) Low pass Hamming and low pass Hann filters, with cut off
frequency Fc=300 Hz, sampling frequency Fs=2000 Hz, filter order
N=100. Plot both filters on the same graph and use legend in the
figure to mark each filter. Comment on the figure.
(b) Low pass Hamming filter and high pass Hamming filter with same
specifications as in (a). Create a new figure and plot both filters
on the same figure. Comment on the figure.
(c) Band pass Hamming with cut off frequencies Fc1=200 Hz, Fc2=400,
N=100, sampling
frequency Fs=2KHz; Band pass Hamming with cut off frequencies
Fc1=200 Hz, Fc2=400, N=50, sampling frequency Fs=2KHz. Create a
figure with both filters. Comment on the figure.
a)Script:
clc;close all;clear all;
Fc=300;
Fs=2000;
wc=2*Fc/Fs;
N=100;
wH1=hamming(N+1)';
wH2=hann(N+1)';
hd=fir1(N,wc);
h1=hd.*wH1;
h2=hd.*wH2;
figure;[H1 f]=freqz(h1,1,1024,Fs);
[H2 f]=freqz(h2,1,1024,Fs);
subplot(211);plot(f,20*log10(abs(H1)));grid;
hold on;plot(f,20*log10(abs(H2)));
xlabel('f(Hz)');ylabel('|H|')
title('Magnitude response')
legend('Hamming','Hanning')
subplot(212);plot(f,angle(H1));grid;
hold on;
plot(f,angle(H2));
xlabel('f(Hz)');ylabel('<H>')
title('Phase response')
legend('Hamming','Hanning')
b)Script:
clc;close all;clear all;
Fc=300;Fs=2000;
wc=2*Fc/Fs;N=100;
wH=hamming(N+1)';
hd1=fir1(N,wc);
hd2=fir1(N,wc,'high');
h1=hd1.*wH;
h2=hd2.*wH;
figure;[H1 f]=freqz(h1,1,1024,Fs);
[H2 f]=freqz(h2,1,1024,Fs);
subplot(211);plot(f,20*log10(abs(H1)));grid;
hold on;plot(f,20*log10(abs(H2)));
xlabel('f(Hz)');ylabel('|H|')
title('Magnitude response')
legend('Low pass Hamming','High pass Hamming')
subplot(212);plot(f,angle(H1));grid;
hold on;
plot(f,angle(H2));
xlabel('f(Hz)');ylabel('<H>')
title('Phase response')
legend('Low pass Hamming','High pass Hamming')
C)Script:
clc;close all;clear all;
Fc1=200;Fc2=400;Fs=2000;
wc=2*[Fc1 Fc2]./Fs;N=100;
N=100;
wH=hamming(N+1)';
hd1=fir1(N,wc,'bandpass');
h1=hd1.*wH;
N=50;
wH=hamming(N+1)';
hd2=fir1(N,wc,'bandpass');
h2=hd2.*wH;
figure;[H1 f]=freqz(h1,1,1024,Fs);
[H2 f]=freqz(h2,1,1024,Fs);
subplot(211);plot(f,20*log10(abs(H1)));grid;
hold on;plot(f,20*log10(abs(H2)));
xlabel('f(Hz)');ylabel('|H|')
title('Magnitude response')
legend('Bandpass Hamming for N=100','Band pass Hamming for N=50')
subplot(212);plot(f,angle(H1));grid;
hold on;
plot(f,angle(H2));
xlabel('f(Hz)');ylabel('<H>')
title('Phase response')
legend('Bandpass Hamming for N=100','Band pass Hamming for N=50')