post-lab3
DESCRIPTION
ee370 post lab 3kfupmTRANSCRIPT
EE-370-51 LAB#3: Report & Post-Lab
ANWER AL-SOMAILY (200841680) ABDULLAH AL-KARAIRI (200923910)
123
Post-Lab#3:-Matlab_CODE-
%% sampling time and frequencyf=1000;fs=100*f;ts=1/fs;t=-0.1:ts:0.1;
L=length(t);faxis=(-L/2:((L/2)-1))/(L*ts);% generating an implusex=L.*rectpuls(t,ts);
%% High pass filter% the cutoff freq. of the High.Pass.Filter.cutoff_HPF=1000;
[a1,b1]=butter(1,2*cutoff_HPF*ts,'high');[a2,b2]=butter(3,2*cutoff_HPF*ts,'high');[a3,b3]=butter(5,2*cutoff_HPF*ts,'high');
z_1_HPF=filter(a1,b1,x);z_2_HPF=filter(a2,b2,x);z_3_HPF=filter(a3,b3,x);
%HPF Transfere FunctionH_1_HPF=abs(fftshift(fft(z_1_HPF)));H_2_HPF=abs(fftshift(fft(z_2_HPF)));H_3_HPF=abs(fftshift(fft(z_3_HPF)));
%% High pass filter% the cutoff freq. of the High.Pass.Filtercutoff_HPF=1000;
[a1,b1]=butter(1,2*cutoff_HPF*ts,'high');[a2,b2]=butter(3,2*cutoff_HPF*ts,'high');[a3,b3]=butter(5,2*cutoff_HPF*ts,'high');
z_1_HPF=filter(a1,b1,x);z_2_HPF=filter(a2,b2,x);z_3_HPF=filter(a3,b3,x);
%HPF Transfere FunctionH_1_HPF=abs(fftshift(fft(z_1_HPF)));H_2_HPF=abs(fftshift(fft(z_2_HPF)));H_3_HPF=abs(fftshift(fft(z_3_HPF)));
%% Band. Pass. Filter.% the cutoff freq. of the B.P.Fcutoff_BPF=[5000 8000];
[c1,d1]=butter(1,2*cutoff_BPF*ts,'bandpass');[c2,d2]=butter(3,2*cutoff_BPF*ts,'bandpass');[c3,d3]=butter(5,2*cutoff_BPF*ts,'bandpass');
z_1_BPF=filter(c1,d1,x);z_2_BPF=filter(c2,d2,x);z_3_BPF=filter(c3,d3,x);
%BPF Transfere FunctionH_1_BPF=abs(fftshift(fft(z_1_BPF)));H_2_BPF=abs(fftshift(fft(z_2_BPF)));H_3_BPF=abs(fftshift(fft(z_3_BPF)));
%% plotting%Impulse function.figure(1)plot(t,x,'LineWidth',1.5);grid on;title('Unite impluse');xlabel('time (sec)');ylabel('amplitude');axis ([-0.05 0.05 -10 25000]);
%HPFfigure(2)plot(faxis,H_1_HPF,'k-',faxis,H_2_HPF,':',faxis,H_3_HPF,'r--','LineWidth',1.5);grid on;title('High Pass Filter');xlabel('f (Hz)');ylabel('amplitude');legend('1st-order','3rd-order','5th-order');axis ([-2000 2000 -500 28000]);
%BPFfigure(3)plot(faxis,H_1_BPF,'k-',faxis,H_2_BPF,':',faxis,H_3_BPF,'r--','LineWidth',1.5);grid on;title('Band Pass Filter');xlabel('f (Hz)');ylabel('amplitude');legend('1st-order','3rd-order','5th-order');axis ([-20000 20000 -500 21000]);
-FIGURES/PLOTS-
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
x 104
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
2
x 104 Band Pass Filter
f (Hz)
ampl
itude
1st-order
3rd-order5th-order
-2000 -1500 -1000 -500 0 500 1000 1500 20000
0.5
1
1.5
2
2.5
x 104 High Pass Filter
f (Hz)
ampl
itude
1st-order
3rd-order5th-order
-0.05 -0.04 -0.03 -0.02 -0.01 0 0.01 0.02 0.03 0.04 0.050
0.5
1
1.5
2
2.5x 10
4 Unite impluse
time (sec)
ampl
itude
-COMMENTS-
The plots in the previous page show Dirac delta function (impulse) and the
transfer functions of the HPF figure(2) & BPF figure(3).
1) In the High Pass Filter: frequencies higher than 10 kHz will only be passed.
And as the order of the filter increases the selectivity increases as well. In
the plot figure(2) the HPF with the 5th order is more closer to the shape of
the ideal HPF that the lower orders.
2) In BPF the frequencies between 5 kHz & 8 kHz will only be passed. 5th
order BPF is more selective than the lower filters.
However, increasing the order of the filter will increase the selectivity but also
the cost of the filter will be higher that more active/non-active elements will be
needed to implement the circuits of higher filters.