You are on page 1of 9

Nama : Muchamad Aldi Ananta

Nim : 201010130311153
Listing Program BPF
%Program Perencanaan dan simulasi Filter BPF IIR
%Oleh
: Fatkur Rohman
clc; clear all; clf;
k1=-3; k2=-10;
fl=1000; fu=2000;
f1=300; f2=5000;
fs=12000; Ts=1/fs;
f=(0:255)/256*(fs/2);
t=0:Ts:0.03; %iterasi untuk sinyal input kontinyu
nn=0:Ts:0.03; %iterasi untuk sinyal input hasil sampling
%Sinyal Input xt
x=sin(2*pi*111.3*t)+sin(2*pi*1192.5*t)+sin(2*pi*5565*t);
%Sinyal Input xn
xnn=sin(2*pi*111.3*t)+sin(2*pi*1192.5*t)+sin(2*pi*5565*nn);
xn=xnn(1:180);
%Listing Program Untuk Menghitung Nilai Orde Filter n
w1=(2*pi*f1)/fs;
w2=(2*pi*f2)/fs;
wl=(2*pi*fl)/fs;
wu=(2*pi*fu)/fs;
omega1=2/Ts*tan(w1/2);
omega2=2/Ts*tan(w2/2);
omegal=2/Ts*tan(wl/2);
omegau=2/Ts*tan(wu/2);
A=(-omega1^2+(omegal*omegau))/(omega1*(omegau-omegal));
B=(-omega2^2+(omegal*omegau))/(omega2*(omegau-omegal));
omegar=min(abs(A),abs(B));
n=(log10((10^(-k1/10)-1)/(10^(-k2/10)-1)))/(2*log10(1/omegar));
%koefisien Filter Dari Hasil Perhitungan Manual
B=[0.1595 0 -0.159]; A=[1 -0.4001 0.6808];
%Listing Program Menghitung Respon Impuls Filter hn Tabelnya
xx=zeros(50,1);
xx(1)=1;
for n=1:50;
if n==1;
y(n)=0.1595*xx(n);
elseif n==2;
y(n)=0.1595*xx(n)+0.4001*y(n-1);
elseif n>=3;
y(n)=0.1595*xx(n)-0.1595*xx(n-2)+0.4001*y(n-1)-0.6808*y(n-2);
end
h(n)=y(n);
end
fprintf('Tabel Respon Impuls h(n)\n');
fprintf('--------------------------\n');
fprintf('
N
h(n)
\n');
fprintf('--------------------------\n');
for i=1:50;
fprintf('%5.0f \b',(i-1));
fprintf('%15.4f \n',h(i));
end
fprintf('--------------------------\n');
%listing program menghitung respon frekuensi filter Hejw
[H,w]=freqz(B,A,100);
%listing program menghitung magnitudo sinyal input x(ejw)

figure(3). %listing program menghitung respon impuls output yn for n=1:180. elseif n==2.%Transformasi Fourier sinyal output y Y=yf(1:256). end end %listing program menghitung magnitudo sinyal output Yejw yf=fft(y.512). %Listing Program Untuk Plot Grafik figure(1). title('Grafik Sinyal Input dalam domain waktu x(t)') xlabel('Waktu t. title('Grafik Response Magnitudo. title('Grafik Respon Impuls Sinyal Input xn') xlabel('Sampling ke-n') ylabel('Respon Impuls sinyal input xn') %axis([1 200 -2 2]).h). x(t)') grid on. figure(7) plot(w/pi. 20log|Hejw|') xlabel('Frekuensi Ternormalisasi. |Hejw|^2 (pi rad)') grid on. hertz') ylabel('Amplitudo. title('Grafik Response MAgnitudo.|X|') grid on. X(f)') grid on. grid on. figure(8) plot(w/pi. figure(6) plot(w/pi. |Hejw|^2') xlabel('Frekuensi Ternormalisasi.abs(X)). y(n)=0.4001*y(n-1)-0. elseif n>=3.6808*y(n-2). 20log|Hejw| (dB)') grid on. W (pi rad)') ylabel('Magnitudo. stem(0:179. y(n)=0. title('Grafik Sinyal Input dalam domain frekuensi X(f)') xlabel('Frekuensi. W (pi rad)') ylabel('Magnitudo.1595*xn(n)+0.1595*xn(n).20*log10(abs(H))). figure(5).512). y(n)=0. W (pi rad)') ylabel('Magnitudo.abs(H)). .4001*y(n-1). title('Grafik Respon Impuls Filter h(n)') xlabel('Sampling ke-n') ylabel('Respon Impuls h(n)') grid on. if n==1. stem(0:49.1595*xn(n)-0. plot(t. hertz=w/(2*pi*Ts). figure(4) plot(f*2*Ts.angle(H)/pi). figure(2) plot(f.%transformasi fourier sinyal x X=xf(1:256). (detik)') ylabel('Amplitudo.x).xf=fft(xn.1595*xn(n-2)+0. title('Frekuensi Ternormalisasi.xn).abs(X)).

W (pi rad)') ylabel('Phase (pi rad)') grid on. y(t))') grid on. ylabel('Magnitudo. plot(f*2*Ts.title('Respon fasa') xlabel('Frekuensi Ternormalisasi.y). |Yejw|') grid on. . figure(9) stem(0:179. title('Grafik Sinyal Output dalam domain frekuensi Y(f)') xlabel('Frekuensi. plot(t(1:180). W (pi rad)') ylabel('Magnitudo. (detik)'). Y(f)') grid on. hertz'). figure(11). title('Grafik Respon Impuls Sinyal Output y(n)') xlabel('Sampling ke-n') ylabel('Respon Impuls y(n)') axis([1 100 -1 1]). grid on.abs(Y)). title('Grafik Respon Magnitudo Sinyal Output dalam domain frekuensi. Yejw') xlabel('Frekuensi Ternormalisasi. plot(f. figure(12).y). abs(Y)). figure(10). ylabel('Magnitudo. title('Grafik Sinyal Output dalam domain waktu y(t)') xlabel('Waktu t.

Gambar Gelombang Figure 1 Figure 2 .

Figure 3 Figure 4 .

Figure 5 Figure 6 .

Figure 7 Figure 8 .

Figure 9 Figure 10 .

Figure 11 Figure 12 .