Berikut adalah kode sumber callback dari
tombol Lowpass:
function Lowpass_Callback(hObject, eventdata,
handles)
% hObject
handle to Lowpass (see GCBO)
% eventdata
reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
global x;
% Membaca semua parameter tapis
omega1s =
str2num(get(handles.omega1s,'String'));
omega2s =
str2num(get(handles.omega2s,'String'));
omega1p =
str2num(get(handles.omega1p,'String'));
omega2p =
str2num(get(handles.omega2p,'String'));
A1s = str2num(get(handles.A1s,'String'));
A2s = str2num(get(handles.A2s,'String'));
R1p = str2num(get(handles.R1p,'String'));
R2p = str2num(get(handles.R2p,'String'));
%Mengalikan dengan pi
omega1s = omega1s * pi;
omega1p = omega1p * pi;
omega2s = omega2s * pi;
omega2p = omega2p * pi;
if(omega1s > omega1p)
%Menghitung frek cut-ff dan lebar pita
tr_lebar=omega1s-omega1p;
M=ceil(11*pi/tr_lebar)+1
n=[0:1:M-1];
wc=(omega1s+omega1p)/2; %frekuensi cut-off ideal
%Tanggapan tapis ideal
hd=lp_ideal(wc,M);
%Tanggapan tapis aktual
w_bla=(blackman(M))';
h=hd.*w_bla;
%Tanggapan frekuensi
[db,mag,pha,grd,w]=freqz_m(h,[1]);
delta_w=2*pi/1000;
%Menghitung riak dan atenuasi
Rp=(min(db(1:1:omega1p/delta_w+1))) % riak passband aktual
As=round(max(db(omega1s/delta_w+1:1:501))) % attenuasi stopband minimum
%Menampilkan tanggapan impuls ideal
axes(handles.axes7);
stem(n,hd,'color','r'); title('Respon impuls
ideal');
axis([0 M-1 -0.1 0.3]);xlabel('n');
ylabel('hd(n)');
set(gca,'color',[0,0,0]);
%Menampilkan jendela Hamming
axes(handles.axes8);
stem(n,w_bla,'color','r'); title('Jendela
Blackman');
axis([0 M-1 0 1.1]);xlabel('n');
ylabel('wn');
set(gca,'color',[0,0,0]);
%Menampilkan tanggapan impuls aktual
axes(handles.axes9);
stem(n,h,'color','r');title('Respon impuls
aktual');
axis([0 M-1 -0.1 0.3]);xlabel('n');
ylabel('h(n)');
set(gca,'color',[0,0,0]);
%Menampilkan tanggapan dalam dB
axes(handles.axes3);
plot(w/pi,db,'color','r', 'LineWidth'
,2);title('Respon magnitudo dalam dB'); grid on;
axis([0 1 -100 10]);xlabel('frekuensi dalam
unit pi'); ylabel('dB');
set(gca,'color',[0,0,0]);
% Menghitung Hasil Penapisan
y = conv(double(x),double(h), 'same');
axes(handles.axes2);
t = 0:length(y)-1; %vektor indeks
stem(t,y,'linewidth',1,'color','y');title('Keluaran
Tapis')
set(gca,'color',[0,0,0]);
else
h =
msgbox('Omega1s Harus Lebih Besar dari Omega1p');
end
%Menyimpan data global
global lowpass
lowpass = h;
Berikut adalah kode sumber callback dari
tombol Bandpass:
function
Bandpass_Callback(hObject, eventdata, handles)
% hObject handle to Bandpass (see GCBO)
% eventdata reserved - to be defined in a future version
of MATLAB
% handles structure with handles and user data (see
GUIDATA)
global x;
% Membaca semua
parameter tapis
omega1s =
str2num(get(handles.omega1s,'String'));
omega2s =
str2num(get(handles.omega2s,'String'));
omega1p =
str2num(get(handles.omega1p,'String'));
omega2p =
str2num(get(handles.omega2p,'String'));
A1s =
str2num(get(handles.A1s,'String'));
A2s =
str2num(get(handles.A2s,'String'));
R1p =
str2num(get(handles.R1p,'String'));
R2p =
str2num(get(handles.R2p,'String'));
%Mengalikan dengan
pi
omega1s = omega1s *
pi;
omega1p = omega1p *
pi;
omega2s = omega2s *
pi;
omega2p = omega2p *
pi;
if((omega1p >
omega1s)&&(omega2s > omega2p))
%Menghitung frek
cut-ff dan lebar pita
tr_lebar=min((omega1p-omega1s),(omega2s-omega2p));
M=ceil(11*pi/tr_lebar)+1
n=[0:1:M-1];
wc1=(omega1s+omega1p)/2;
wc2=(omega2s+omega2p)/2;
%frekuensi cut-off ideal
%Tanggapan tapis
ideal untuk bandpass
hd=lp_ideal(wc2,M)-lp_ideal(wc1,M);
%Tanggapan tapis
aktual
w_bla=(blackman(M))';
h=hd.*w_bla;
%Tanggapan
frekuensi
[db,mag,pha,grd,w]=freqz_m(h,[1]);
delta_w=2*pi/1000;
%Menghitung riak
dan atenuasi
Rp=(min(db(omega1p/delta_w+1:1:omega2p/delta_w)))
% riak passband aktual
As=round(max(db(omega2s/delta_w+1:1:501))) % attenuasi stopband minimum
%Menampilkan
tanggapan impuls ideal
axes(handles.axes7);
stem(n,hd,'color','r');
title('Respon impuls ideal');
axis([0 M-1 -0.1
0.5]);xlabel('n'); ylabel('hd(n)');
set(gca,'color',[0,0,0]);
%Menampilkan
jendela Hamming
axes(handles.axes8);
stem(n,w_bla,'color','r');
title('Jendela Blackman');
axis([0 M-1 0
1.1]);xlabel('n'); ylabel('wn');
set(gca,'color',[0,0,0]);
%Menampilkan
tanggapan impuls aktual
axes(handles.axes9);
stem(n,h,'color','r');title('Respon
impuls aktual');
axis([0 M-1 -0.1
0.5]);xlabel('n'); ylabel('h(n)');
set(gca,'color',[0,0,0]);
%Menampilkan
tanggapan dalam dB
axes(handles.axes3);
plot(w/pi,db,'color','r',
'LineWidth' ,2);title('Respon magnitudo dalam dB'); grid on;
axis([0 1 -100
10]);xlabel('frekuensi dalam unit pi'); ylabel('dB');
set(gca,'color',[0,0,0]);
% Menghitung Hasil
Penapisan
y =
conv(double(x),double(h), 'same');
axes(handles.axes2);
t =
0:length(y)-1; %vektor indeks
stem(t,y,'linewidth',1,'color','y');title('Keluaran
Tapis')
set(gca,'color',[0,0,0]);
else
h = msgbox('Omega1p Harus Lebih Besar dari
Omega1s dan Omega2s Harus Lebih Besar dari Omega2p');
end
%Menyimpan data
global
global bandpass
bandpass = h;
Berikut adalah kode sumber callback dari
tombol Bandstop:
function
Bandstop_Callback(hObject, eventdata, handles)
% hObject handle to Bandstop (see GCBO)
% eventdata reserved - to be defined in a future version
of MATLAB
% handles structure with handles and user data (see
GUIDATA)
global x;
% Membaca semua
parameter tapis
omega1s =
str2num(get(handles.omega1s,'String'));
omega2s =
str2num(get(handles.omega2s,'String'));
omega1p =
str2num(get(handles.omega1p,'String'));
omega2p = str2num(get(handles.omega2p,'String'));
A1s =
str2num(get(handles.A1s,'String'));
A2s =
str2num(get(handles.A2s,'String'));
R1p =
str2num(get(handles.R1p,'String'));
R2p =
str2num(get(handles.R2p,'String'));
%Mengalikan dengan
pi
omega1s = omega1s *
pi;
omega1p = omega1p *
pi;
omega2s = omega2s *
pi;
omega2p = omega2p *
pi;
if((omega1s >
omega1p)&&(omega2p > omega2s))
%Menghitung frek
cut-ff dan lebar pita
tr_lebar=min((omega1s-omega1p),(omega2p-omega2s));
M=ceil(11*pi/tr_lebar)+1
n=[0:1:M-1];
wc1=(omega1s+omega1p)/2;
wc2=(omega2s+omega2p)/2;
%frekuensi cut-off ideal
%Tanggapan tapis
ideal untuk bandstop
hd=lp_ideal(wc1,M)+lp_ideal(pi,M)-lp_ideal(wc2,M);
%Tanggapan tapis
aktual
w_bla=(blackman(M))';
h=hd.*w_bla;
%Tanggapan frekuensi
[db,mag,pha,grd,w]=freqz_m(h,[1]);
delta_w=2*pi/1000;
%Menghitung riak
dan atenuasi
Rp=(min(db(1:1:omega1p/delta_w+1))) % riak passband aktual
As=round(max(db(omega1s/delta_w+1:1:501))) % attenuasi stopband minimum
%Menampilkan
tanggapan impuls ideal
axes(handles.axes7);
stem(n,hd,'color','r');
title('Respon impuls ideal');
axis([0 M-1 -0.1
0.5]);xlabel('n'); ylabel('hd(n)');
set(gca,'color',[0,0,0]);
%Menampilkan
jendela Hamming
axes(handles.axes8);
stem(n,w_bla,'color','r');
title('Jendela Blackman');
axis([0 M-1 0
1.1]);xlabel('n'); ylabel('wn');
set(gca,'color',[0,0,0]);
%Menampilkan
tanggapan impuls aktual
axes(handles.axes9);
stem(n,h,'color','r');title('Respon
impuls aktual');
axis([0 M-1 -0.1
0.5]);xlabel('n'); ylabel('h(n)');
set(gca,'color',[0,0,0]);
%Menampilkan
tanggapan dalam dB
axes(handles.axes3);
plot(w/pi,db,'color','r',
'LineWidth' ,2);title('Respon magnitudo dalam dB'); grid on;
axis([0 1 -100
10]);xlabel('frekuensi dalam unit pi'); ylabel('dB');
set(gca,'color',[0,0,0]);
% Menghitung Hasil
Penapisan
y =
conv(double(x),double(h), 'same');
axes(handles.axes2);
t =
0:length(y)-1; %vektor indeks
stem(t,y,'linewidth',1,'color','y');title('Keluaran
Tapis')
set(gca,'color',[0,0,0]);
else
h = msgbox('Omega1s Harus Lebih Besar dari
Omega1p dan Omega2p Harus Lebih Besar dari Omega2s');
end
%Menyimpan data
global
global bandstop
bandstop = h;
Berikut adalah kode sumber callback dari
tombol Highpass:
function
Highpass_Callback(hObject, eventdata, handles)
% hObject handle to Highpass (see GCBO)
% eventdata reserved - to be defined in a future version
of MATLAB
% handles structure with handles and user data (see
GUIDATA)
global x;
% Membaca semua
parameter tapis
omega1s =
str2num(get(handles.omega1s,'String'));
omega2s =
str2num(get(handles.omega2s,'String'));
omega1p =
str2num(get(handles.omega1p,'String'));
omega2p =
str2num(get(handles.omega2p,'String'));
A1s =
str2num(get(handles.A1s,'String'));
A2s =
str2num(get(handles.A2s,'String'));
R1p =
str2num(get(handles.R1p,'String'));
R2p =
str2num(get(handles.R2p,'String'));
%Mengalikan dengan
pi
omega1s = omega1s *
pi;
omega1p = omega1p *
pi;
omega2s = omega2s *
pi;
omega2p = omega2p *
pi;
if(omega2s >
omega2p)
%Menghitung frek cut-ff dan lebar pita
tr_lebar=omega2s-omega2p;
M=ceil(11*pi/tr_lebar)+1
n=[0:1:M-1];
beta=0.1102*(-A2s-8.7)
wc=(omega2s+omega2p)/2; %frekuensi cut-off ideal
%Tanggapan tapis
ideal
hd=lp_ideal(pi,M)-lp_ideal(wc,M);
%Tanggapan tapis
aktual
w_bla=(blackman(M))';
h=hd.*w_bla;
%Tanggapan
frekuensi
[db,mag,pha,grd,w]=freqz_m(h,[1]);
delta_w=2*pi/1000;
%Menghitung riak
dan atenuasi
Rp=(min(db(1:1:omega2p/delta_w+1))) % riak passband aktual
As=round(max(db(omega2s/delta_w+1:1:501))) % attenuasi stopband minimum
%Menampilkan tanggapan
impuls ideal
axes(handles.axes7);
stem(n,hd,'color','r');
title('Respon impuls ideal');
axis([0 M-1 -0.1
0.3]);xlabel('n'); ylabel('hd(n)');
set(gca,'color',[0,0,0]);
%Menampilkan
jendela Hamming
axes(handles.axes8);
stem(n,w_bla,'color','r');
title('Jendela Blackman');
axis([0 M-1 0
1.1]);xlabel('n'); ylabel('wn');
set(gca,'color',[0,0,0]);
%Menampilkan
tanggapan impuls aktual
axes(handles.axes9);
stem(n,h,'color','r');title('Respon
impuls aktual');
axis([0 M-1 -0.1
0.3]);xlabel('n'); ylabel('h(n)');
set(gca,'color',[0,0,0]);
%Menampilkan
tanggapan dalam dB
axes(handles.axes3);
plot(w/pi,db,'color','r',
'LineWidth' ,2);title('Respon magnitudo dalam dB'); grid on;
axis([0 1 -100
10]);xlabel('frekuensi dalam unit pi'); ylabel('dB');
set(gca,'color',[0,0,0]);
% Menghitung Hasil
Penapisan
y =
conv(double(x),double(h), 'same');
axes(handles.axes2);
t =
0:length(y)-1; %vektor indeks
stem(t,y,'linewidth',1,'color','y');title('Keluaran
Tapis')
set(gca,'color',[0,0,0]);
else
h = msgbox('Omega2s Harus Lebih Besar dari
Omega2p');
end
%Menyimpan data
global
global highpass
highpass = h;
No comments:
Post a Comment