Perbandingan Algoritma Bidirectional Associative Memory dan Learning Vector Quantization Dalam Menentukan Obat Penyakit Saluran Cerna Lambung-Usus
84
LAMPIRAN LISTING PROGRAM
Beranda.m
function varargout = Beranda(varargin)
% BERANDA M-file for Beranda.fig
gui_Singleton = 1;
gui_State = struct('gui_Name',
mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Beranda_OpeningFcn, ...
'gui_OutputFcn', @Beranda_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback',
[]);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before Beranda is made visible.
function Beranda_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
handles.citra=imread('logousu.jpg');
guidata(hObject,handles);
axes(handles.axes1);
imshow(handles.citra);
% Choose default command line output for Beranda
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes Beranda wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = Beranda_OutputFcn(hObject, eventdata, handles)
% Get default command line output from handles structure
varargout{1} = handles.output;
% ------------------------------------------------------------------function beranda_Callback(hObject, eventdata, handles)
Beranda
delete(handles.figure1)
% ------------------------------------------------------------------function menupelatihan_Callback(hObject, eventdata, handles)
% ------------------------------------------------------------------function menupengujian_Callback(hObject, eventdata, handles)
% ------------------------------------------------------------------function bantuan_Callback(hObject, eventdata, handles)
Bantuan
delete(handles.figure1)
Universitas Sumatera Utara
85
% ------------------------------------------------------------------function keluar_Callback(hObject, eventdata, handles)
choice= questdlg ('Apakah Anda Ingin Keluar?','Konfirmasi',...
'Ya','Tidak','Tidak');
switch choice
case 'Ya'
close all;
end
% ------------------------------------------------------------------function ujibam_Callback(hObject, eventdata, handles)
UjiBAM
delete(handles.figure1)
% ------------------------------------------------------------------function ujilvq_Callback(hObject, eventdata, handles)
UjiLVQ
delete(handles.figure1)
% ------------------------------------------------------------------function latihbam_Callback(hObject, eventdata, handles)
LatihBAM
delete(handles.figure1)
% ------------------------------------------------------------------function latihlvq_Callback(hObject, eventdata, handles)
LatihLVQ
delete(handles.figure1)
LatihBAM.m
function varargout = LatihBAM(varargin)
% LATIHBAM M-file for LatihBAM.fig
gui_Singleton = 1;
gui_State = struct('gui_Name',
mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @LatihBAM_OpeningFcn, ...
'gui_OutputFcn', @LatihBAM_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback',
[]);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before LatihBAM is made visible.
function LatihBAM_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% --- Executes on button press in Kel.
function Kel_Callback(hObject, eventdata, handles)
% --- Executes on button press in Keh.
function Keh_Callback(hObject, eventdata, handles)
Universitas Sumatera Utara
86
% --- Executes on button press in Sak.
function Sak_Callback(hObject, eventdata, handles)
% --- Executes on button press in tombollatih.
function tombollatih_Callback(hObject, eventdata, handles)
tStart = tic; %untuk waktu
%1x16
target1
target2
target3
target4
=
=
=
=
[1 1 1
[-1 -1
[-1 -1
[-1 -1
1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 1 1 1 1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 1 1 1 1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1
-1 -1];
-1 -1];
-1 -1];
1 1 1];
input1 = xlsread('bam.xlsx', 'nilai', 'B1:U1'); %1x20
input2 = xlsread('bam.xlsx', 'nilai', 'B2:U2');
input3 = xlsread('bam.xlsx', 'nilai', 'B3:U3');
input4 = xlsread('bam.xlsx', 'nilai', 'B4:U4');
input5 = xlsread('bam.xlsx', 'nilai', 'B5:U5'); %1x20
input6 = xlsread('bam.xlsx', 'nilai', 'B6:U6');
input7 = xlsread('bam.xlsx', 'nilai', 'B7:U7');
input8 = xlsread('bam.xlsx', 'nilai', 'B8:U8');
input9 = xlsread('bam.xlsx', 'nilai', 'B9:U9'); %1x20
input10 = xlsread('bam.xlsx', 'nilai', 'B10:U10');
input11 = xlsread('bam.xlsx', 'nilai', 'B11:U11');
input12 = xlsread('bam.xlsx', 'nilai', 'B12:U12');
input13 = xlsread('bam.xlsx', 'nilai', 'B13:U13'); %1x20
input14 = xlsread('bam.xlsx', 'nilai', 'B14:U14');
input15 = xlsread('bam.xlsx', 'nilai', 'B15:U15');
input16 = xlsread('bam.xlsx', 'nilai', 'B16:U16');
input17 = xlsread('bam.xlsx', 'nilai', 'B17:U17'); %1x20
input18 = xlsread('bam.xlsx', 'nilai', 'B18:U18');
input19 = xlsread('bam.xlsx', 'nilai', 'B19:U19');
input20 = xlsread('bam.xlsx', 'nilai', 'B20:U20');
w1 = input1'* target1; %20x16
w2 = input2'* target1;
w3 = input3'* target1;
w4 = input4'* target1;
w5 = input5'* target1;
w6 = input6'* target2;
w7 = input7'* target2;
w8 = input8'* target2;
w9 = input9'* target2;
w10 = input10'* target2;
w11 = input11'* target3;
w12 = input12'* target3;
w13 = input13'* target3;
w14 = input14'* target3;
w15 = input15'* target3;
w16 = input16'* target4;
w17 = input17'* target4;
w18 = input18'* target4;
w19 = input19'* target4;
w20 = input20'* target4;
%20x16
w = w1 + w2 + w3 + w4 + w5 + w6 + w7 + w8 + w9 + w10 + w11 + w12 +
w13 + w14 + w15 + w16 + w17 + w18 + w19 + w20;
Universitas Sumatera Utara
87
xlswrite('bam.xlsx',w, 'bobot', 'A1:P20');
y_in1 = input1 *
y_in2 = input2 *
y_in3 = input3 *
y_in4 = input4 *
y_in5 = input5 *
y_in6 = input6 *
y_in7 = input7 *
y_in8 = input8 *
y_in9 = input9 *
y_in10 = input10
y_in11 = input11
y_in12 = input12
y_in13 = input13
y_in14 = input14
y_in15 = input15
y_in16 = input16
y_in17 = input17
y_in18 = input18
y_in19 = input19
y_in20 = input20
w; %1x16
w;
w;
w;
w;
w;
w;
w;
w;
* w;
* w;
* w;
* w;
* w;
* w;
* w;
* w;
* w;
* w;
* w;
for indeks = 1 : 5
if (y_in1(indeks) < 0)
y_in1(indeks) = -1;
else
y_in1(indeks) = 1;
end
if (y_in2(indeks) < 0)
y_in2(indeks) = -1;
else
y_in2(indeks) = 1;
end
if (y_in3(indeks) < 0)
y_in3(indeks) = -1;
else
y_in3(indeks) = 1;
end
if (y_in4(indeks) < 0)
y_in4(indeks) = -1;
else
y_in4(indeks) = 1;
end
if (y_in5(indeks) < 0)
y_in5(indeks) = -1;
else
y_in5(indeks) = 1;
end
if (y_in6(indeks) < 0)
y_in6(indeks) = -1;
else
y_in6(indeks) = 1;
end
Universitas Sumatera Utara
88
if (y_in7(indeks) < 0)
y_in7(indeks) = -1;
else
y_in7(indeks) = 1;
end
if (y_in8(indeks) < 0)
y_in8(indeks) = -1;
else
y_in8(indeks) = 1;
end
if (y_in9(indeks) < 0)
y_in9(indeks) = -1;
else
y_in9(indeks) = 1;
end
if (y_in10(indeks) < 0)
y_in10(indeks) = -1;
else
y_in10(indeks) = 1;
end
if (y_in11(indeks) < 0)
y_in11(indeks) = -1;
else
y_in11(indeks) = 1;
end
if (y_in12(indeks) < 0)
y_in12(indeks) = -1;
else
y_in12(indeks) = 1;
end
if (y_in13(indeks) < 0)
y_in13(indeks) = -1;
else
y_in13(indeks) = 1;
end
if (y_in14(indeks) < 0)
y_in14(indeks) = -1;
else
y_in14(indeks) = 1;
end
if (y_in15(indeks) < 0)
y_in15(indeks) = -1;
else
y_in15(indeks) = 1;
end
if (y_in16(indeks) < 0)
y_in16(indeks) = -1;
else
Universitas Sumatera Utara
89
y_in16(indeks) = 1;
end
if (y_in17(indeks) < 0)
y_in17(indeks) = -1;
else
y_in17(indeks) = 1;
end
if (y_in18(indeks) < 0)
y_in18(indeks) = -1;
else
y_in18(indeks) = 1;
end
if (y_in19(indeks) < 0)
y_in19(indeks) = -1;
else
y_in19(indeks) = 1;
end
if (y_in20(indeks) < 0)
y_in20(indeks) = -1;
else
y_in20(indeks) = 1;
end
end
waktupengujian = toc(tStart);
set(handles.waktulatih,'string',waktupengujian);
h = msgbox('Data telah dilatih', 'Berhasil');
function namapenyakit_Callback(hObject, eventdata, handles)
function namapenyakit_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function waktulatih_Callback(hObject, eventdata, handles)
function waktulatih_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in tombolsimpan.
function tombolsimpan_Callback(hObject, eventdata, handles)
a = get(handles.Sul,'Value');
b = get(handles.Per,'Value');
c = get(handles.Bat,'Value');
d = get(handles.Mua,'Value');
e = get(handles.Sua,'Value');
f = get(handles.Nye,'Value');
Universitas Sumatera Utara
90
g
h
i
j
=
=
=
=
get(handles.Mun,'Value');
get(handles.Ada,'Value');
get(handles.Lam,'Value');
get(handles.Atp,'Value');
k
l
m
n
o
=
=
=
=
=
get(handles.Sen,'Value');
get(handles.Kem,'Value');
get(handles.Ane,'Value');
get(handles.Ras,'Value');
get(handles.Pen,'Value');
p
q
r
s
t
=
=
=
=
=
get(handles.Tm,'Value');
get(handles.Md,'Value');
get(handles.Kel,'Value');
get(handles.Keh,'Value');
get(handles.Sak,'Value');
penyakit= [a b c d e f g h i j k l m n o p q r s t];
for indeks = 1 : 20
if (penyakit(indeks) == 0)
penyakit(indeks) = -1;
else
penyakit(indeks) = 1;
end
end
nm = get(handles.namapenyakit,'String');
if (strcmp(nm , 'Radang Kerongkongan 1'))
xlswrite('bam.xlsx',penyakit,'Nilai','B1:U1');
elseif (strcmp(nm , 'Radang Kerongkongan 2'))
xlswrite('bam.xlsx',penyakit,'Nilai','B2:U2');
elseif (strcmp(nm , 'Radang Kerongkongan 3'))
xlswrite('bam.xlsx',penyakit,'Nilai','B3:U3');
elseif (strcmp(nm , 'Radang Kerongkongan 4'))
xlswrite('bam.xlsx',penyakit,'Nilai','B4:U4');
elseif (strcmp(nm , 'Radang Kerongkongan 5'))
xlswrite('bam.xlsx',penyakit,'Nilai','B5:U5');
elseif (strcmp(nm , 'Radang Lambung 1'))
xlswrite('bam.xlsx',penyakit,'Nilai','B6:U6');
elseif (strcmp(nm , 'Radang Lambung 2'))
xlswrite('bam.xlsx',penyakit,'Nilai','B7:U7');
elseif (strcmp(nm , 'Radang Lambung 3'))
xlswrite('bam.xlsx',penyakit,'Nilai','B8:U8');
elseif (strcmp(nm , 'Radang Lambung 4'))
xlswrite('bam.xlsx',penyakit,'Nilai','B9:U9');
elseif (strcmp(nm , 'Radang Lambung 5'))
xlswrite('bam.xlsx',penyakit,'Nilai','B10:U10');
elseif (strcmp(nm , 'Tukak Lambung 1'))
xlswrite('bam.xlsx',penyakit,'Nilai','B11:U11');
elseif (strcmp(nm , 'Tukak Lambung 2'))
xlswrite('bam.xlsx',penyakit,'Nilai','B12:U12');
elseif (strcmp(nm , 'Tukak Lambung 3'))
xlswrite('bam.xlsx',penyakit,'Nilai','B13:U13');
elseif (strcmp(nm , 'Tukak Lambung 4'))
Universitas Sumatera Utara
91
xlswrite('bam.xlsx',penyakit,'Nilai','B14:U14');
elseif (strcmp(nm , 'Tukak Lambung 5'))
xlswrite('bam.xlsx',penyakit,'Nilai','B15:U15');
elseif (strcmp(nm , 'Kanker Lambung 1'))
xlswrite('bam.xlsx',penyakit,'Nilai','B16:U16');
elseif (strcmp(nm , 'Kanker Lambung 2'))
xlswrite('bam.xlsx',penyakit,'Nilai','B17:U17');
elseif (strcmp(nm , 'Kanker Lambung 3'))
xlswrite('bam.xlsx',penyakit,'Nilai','B18:U18');
elseif (strcmp(nm , 'Kanker Lambung 4'))
xlswrite('bam.xlsx',penyakit,'Nilai','B19:U19');
elseif (strcmp(nm , 'Kanker Lambung 5'))
xlswrite('bam.xlsx',penyakit,'Nilai','B20:U20');
end
penyakit = [];
pesan = msgbox('Data telah disimpan', 'Berhasil');
% --- Executes on button press in tombolreset.
function tombolreset_Callback(hObject, eventdata, handles)
set(handles.namapenyakit,'String','','Enable','on');
set(handles.waktulatih,'String','','Enable','on');
set(handles.Sul,'Value',0);
set(handles.Per,'Value',0);
set(handles.Bat,'Value',0);
set(handles.Mua,'Value',0);
set(handles.Sua,'Value',0);
set(handles.Nye,'Value',0);
set(handles.Mun,'Value',0);
set(handles.Ada,'Value',0);
set(handles.Lam,'Value',0);
set(handles.Atp,'Value',0);
set(handles.Sen,'Value',0);
set(handles.Kem,'Value',0);
set(handles.Ane,'Value',0);
set(handles.Ras,'Value',0);
set(handles.Pen,'Value',0);
set(handles.Tm,'Value',0);
set(handles.Md,'Value',0);
set(handles.Kel,'Value',0);
set(handles.Keh,'Value',0);
set(handles.Sak,'Value',0);
% ------------------------------------------------------------------function beranda_Callback(hObject, eventdata, handles)
Beranda
delete(handles.figure1)
% ------------------------------------------------------------------function menubam_Callback(hObject, eventdata, handles)
% ------------------------------------------------------------------function menulvq_Callback(hObject, eventdata, handles)
% ------------------------------------------------------------------function bantuan_Callback(hObject, eventdata, handles)
UjiBAM.m
function varargout = UjiBAM(varargin)
% UJIBAM M-file for UjiBAM.fig
gui_Singleton = 1;
gui_State = struct('gui_Name',
mfilename, ...
Universitas Sumatera Utara
92
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @UjiBAM_OpeningFcn, ...
'gui_OutputFcn', @UjiBAM_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback',
[]);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before UjiBAM is made visible.
function UjiBAM_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% --- Outputs from this function are returned to the command line.
function varargout = UjiBAM_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
% --- Executes on button press in tombolreset.
function tombolreset_Callback(hObject, eventdata, handles)
xlswrite('databam.xlsx', '0','nilai','B2:U2');
set(handles.namapenyakit,'String','','Enable','on');
set(handles.jenisobat,'String','','Enable','on');
set(handles.waktuuji,'String','','Enable','on');
set(handles.Sul,'Value',0);
set(handles.Per,'Value',0);
set(handles.Bat,'Value',0);
set(handles.Mua,'Value',0);
set(handles.Sua,'Value',0);
set(handles.Nye,'Value',0);
set(handles.Mun,'Value',0);
set(handles.Ada,'Value',0);
set(handles.Lam,'Value',0);
set(handles.Atp,'Value',0);
set(handles.Sen,'Value',0);
set(handles.Kem,'Value',0);
set(handles.Ane,'Value',0);
set(handles.Ras,'Value',0);
set(handles.Pen,'Value',0);
set(handles.Tm,'Value',0);
set(handles.Md,'Value',0);
set(handles.Kel,'Value',0);
set(handles.Keh,'Value',0);
set(handles.Sak,'Value',0);
% --- Executes on button press in tombolhasil.
function tombolhasil_Callback(hObject, eventdata, handles)
tStart=tic;
a = get(handles.Sul,'Value');
b = get(handles.Per,'Value');
Universitas Sumatera Utara
93
c = get(handles.Bat,'Value');
d = get(handles.Mua,'Value');
e = get(handles.Sua,'Value');
f
g
h
i
j
=
=
=
=
=
get(handles.Nye,'Value');
get(handles.Mun,'Value');
get(handles.Ada,'Value');
get(handles.Lam,'Value');
get(handles.Atp,'Value');
k
l
m
n
o
=
=
=
=
=
get(handles.Sen,'Value');
get(handles.Kem,'Value');
get(handles.Ane,'Value');
get(handles.Ras,'Value');
get(handles.Pen,'Value');
p
q
r
s
t
=
=
=
=
=
get(handles.Tm,'Value');
get(handles.Md,'Value');
get(handles.Kel,'Value');
get(handles.Keh,'Value');
get(handles.Sak,'Value');
data_uji = [a b c d e f g h i j k l m n o p q r s t];
for indeks = 1 : 20
if (data_uji(indeks) == 0)
data_uji(indeks) = -1;
else
data_uji(indeks) = 1;
end
end
w = xlsread('bam.xlsx','bobot','A1:P20'); %20x16
output_uji = data_uji * w; %1x16
for indeks = 1 : 16
if (output_uji(indeks) < 0)
output_uji(indeks) = -1;
else
output_uji(indeks) = 1;
end
end
output_uji
target1 = [1 1 1
target2 = [-1 -1
target3 = [-1 -1
target4 = [-1 -1
1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 1 1 1 1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 1 1 1 1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1
-1 -1];
-1 -1];
-1 -1];
1 1 1];
if
isequal (output_uji,target1)
set(handles.namapenyakit,'String','Radang Kerongkongan (reflux
oesophagitis)');
set(handles.jenisobat,'String','Ranitidin , Omeprazole ,
Domperidone , Antasida , Sukralfat');
elseif isequal (output_uji,target2)
set(handles.namapenyakit,'String','Radang lambung (gastritis)');
Universitas Sumatera Utara
94
set(handles.jenisobat,'String','Omeprazole , Antasida , Bismuth ,
Amoxixilin , Claritromixin)');
elseif isequal (output_uji,target3)
set(handles.namapenyakit,'String','Tukak Lambung-Usus (ulcus
pepticum)');
set(handles.jenisobat,'String','Antasida , Bismuth , Sukralfat ,
Ranitidin , Omeprazole');
elseif isequal (output_uji,target4)
set(handles.namapenyakit,'String','Kanker Lambung');
set(handles.jenisobat,'String','Kemoterapi , Radiasi , Operasi');
else
set(handles.namapenyakit,'String','Tidak Dikenali');
end
waktupengujian = toc(tStart);
set(handles.waktuuji,'string',waktupengujian);
% --- Executes on button press in Sul.
function Sul_Callback(hObject, eventdata, handles)
% --- Executes on button press in Per.
function Per_Callback(hObject, eventdata, handles)
% --- Executes on button press in Bat.
function Bat_Callback(hObject, eventdata, handles)
% --- Executes on button press in Mua.
function Mua_Callback(hObject, eventdata, handles)
% --- Executes on button press in Sua.
function Sua_Callback(hObject, eventdata, handles)
% --- Executes on button press in Nye.
function Nye_Callback(hObject, eventdata, handles)
% --- Executes on button press in Mun.
function Mun_Callback(hObject, eventdata, handles)
% --- Executes on button press in Ada.
function Ada_Callback(hObject, eventdata, handles)
% --- Executes on button press in Lam.
function Lam_Callback(hObject, eventdata, handles)
% --- Executes on button press in Atp.
function Atp_Callback(hObject, eventdata, handles)
% --- Executes on button press in Sen.
function Sen_Callback(hObject, eventdata, handles)
% --- Executes on button press in Kem.
LatihLVQ.m
function varargout = LatihLVQ(varargin)
% LATIHLVQ M-file for LatihLVQ.fig
gui_Singleton = 1;
gui_State = struct('gui_Name',
mfilename, ...
'gui_Singleton', gui_Singleton, ...
Universitas Sumatera Utara
95
'gui_OpeningFcn', @LatihLVQ_OpeningFcn, ...
'gui_OutputFcn', @LatihLVQ_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback',
[]);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes on button press in Sak.
function Sak_Callback(hObject, eventdata, handles)
% --- Executes on button press in tombolreset.
function tombolreset_Callback(hObject, eventdata, handles)
xlswrite('datalvq.xlsx', '0','nilai','B2:U2');
set(handles.namapenyakit,'String','','Enable','on');
set(handles.waktu,'String','','Enable','on');
set(handles.Sul,'Value',0);
set(handles.Per,'Value',0);
set(handles.Bat,'Value',0);
set(handles.Mua,'Value',0);
set(handles.Sua,'Value',0);
set(handles.Nye,'Value',0);
set(handles.Mun,'Value',0);
set(handles.Ada,'Value',0);
set(handles.Lam,'Value',0);
set(handles.Atp,'Value',0);
set(handles.Sen,'Value',0);
set(handles.Kem,'Value',0);
set(handles.Ane,'Value',0);
set(handles.Ras,'Value',0);
set(handles.Pen,'Value',0);
set(handles.Tm,'Value',0);
set(handles.Md,'Value',0);
set(handles.Kel,'Value',0);
set(handles.Keh,'Value',0);
set(handles.Sak,'Value',0);
function namapenyakit_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function namapenyakit_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in tombolsimpan.
function tombolsimpan_Callback(hObject, eventdata, handles)
a = get(handles.Sul,'Value');
b = get(handles.Per,'Value');
c = get(handles.Bat,'Value');
Universitas Sumatera Utara
96
d = get(handles.Mua,'Value');
e = get(handles.Sua,'Value');
f
g
h
i
j
=
=
=
=
=
get(handles.Nye,'Value');
get(handles.Mun,'Value');
get(handles.Ada,'Value');
get(handles.Lam,'Value');
get(handles.Atp,'Value');
k
l
m
n
o
=
=
=
=
=
get(handles.Sen,'Value');
get(handles.Kem,'Value');
get(handles.Ane,'Value');
get(handles.Ras,'Value');
get(handles.Pen,'Value');
p
q
r
s
t
=
=
=
=
=
get(handles.Tm,'Value');
get(handles.Md,'Value');
get(handles.Kel,'Value');
get(handles.Keh,'Value');
get(handles.Sak,'Value');
penyakit= [a b c d e f g h i j k l m n o p q r s t];
for indeks = 1 : 20
if (penyakit(indeks) == 0)
penyakit(indeks) = -1;
else
penyakit(indeks) = 1;
end
end
nm = get(handles.namapenyakit,'String');
if (strcmp(nm , 'Radang Kerongkongan 1'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B1:U1');
elseif (strcmp(nm , 'Radang Kerongkongan 2'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B2:U2');
elseif (strcmp(nm , 'Radang Kerongkongan 3'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B3:U3');
elseif (strcmp(nm , 'Radang Kerongkongan 4'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B4:U4');
elseif (strcmp(nm , 'Radang Kerongkongan 5'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B5:U5');
elseif (strcmp(nm , 'Radang Lambung 1'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B6:U6');
elseif (strcmp(nm , 'Radang Lambung 2'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B7:U7');
elseif (strcmp(nm , 'Radang Lambung 3'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B8:U8');
elseif (strcmp(nm , 'Radang Lambung 4'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B9:U9');
elseif (strcmp(nm , 'Radang Lambung 5'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B10:U10');
elseif (strcmp(nm , 'Tukak Lambung 1'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B11:U11');
Universitas Sumatera Utara
97
elseif (strcmp(nm , 'Tukak Lambung 2'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B12:U12');
elseif (strcmp(nm , 'Tukak Lambung 3'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B13:U13');
elseif (strcmp(nm , 'Tukak Lambung 4'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B14:U14');
elseif (strcmp(nm , 'Tukak Lambung 5'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B15:U15');
elseif (strcmp(nm , 'Kanker Lambung 1'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B16:U16');
elseif (strcmp(nm , 'Kanker Lambung 2'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B17:U17');
elseif (strcmp(nm , 'Kanker Lambung 3'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B18:U18');
elseif (strcmp(nm , 'Kanker Lambung 4'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B19:U19');
elseif (strcmp(nm , 'Kanker Lambung 5'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B20:U20');
end
penyakit = [];
pesan = msgbox('Data telah disimpan', 'Berhasil');
function waktu_Callback(hObject, eventdata, handles)
% hObject
handle to waktu (see GCBO)
% --- Executes during object creation, after setting all properties.
function waktu_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in tombollatih.
function tombollatih_Callback(hObject, eventdata, handles)
tStart = tic; %untuk waktu
%target 1 x 20
w1_awal = [1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
1]; %kelas 1
w2_awal = [-1 -1 -1 -1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
1]; %kelas 2
w3_awal = [-1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1 1 -1 -1 -1 -1 -1 -1
1]; %kelas 3
w4_awal = [-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1
1]; %kelas 4
-1 -1 -1 1 1
input1 = xlsread('lvq.xlsx', 'nilai', 'B1:U1'); %1x20
input2 = xlsread('lvq.xlsx', 'nilai', 'B2:U2');
input3 = xlsread('lvq.xlsx', 'nilai', 'B3:U3');
input4 = xlsread('lvq.xlsx', 'nilai', 'B4:U4');
input5 = xlsread('lvq.xlsx', 'nilai', 'B5:U5'); %1x20
input6 = xlsread('lvq.xlsx', 'nilai', 'B6:U6');
input7 = xlsread('lvq.xlsx', 'nilai', 'B7:U7');
input8 = xlsread('lvq.xlsx', 'nilai', 'B8:U8');
input9 = xlsread('lvq.xlsx', 'nilai', 'B9:U9'); %1x20
input10 = xlsread('lvq.xlsx', 'nilai', 'B10:U10');
input11 = xlsread('lvq.xlsx', 'nilai', 'B11:U11');
input12 = xlsread('lvq.xlsx', 'nilai', 'B12:U12');
Universitas Sumatera Utara
98
input13
input14
input15
input16
input17
input18
input19
input20
=
=
=
=
=
=
=
=
xlsread('lvq.xlsx',
xlsread('lvq.xlsx',
xlsread('lvq.xlsx',
xlsread('lvq.xlsx',
xlsread('lvq.xlsx',
xlsread('lvq.xlsx',
xlsread('lvq.xlsx',
xlsread('lvq.xlsx',
'nilai',
'nilai',
'nilai',
'nilai',
'nilai',
'nilai',
'nilai',
'nilai',
'B13:U13'); %1x20
'B14:U14');
'B15:U15');
'B16:U16');
'B17:U17'); %1x20
'B18:U18');
'B19:U19');
'B20:U20');
pola = [input1 ; input2 ; input3 ; input4; input5 ;
input6 ; input7 ; input8 ; input9 ; input10;
input11; input12; input13 ; input14 ; input15 ;
input16 ; input17; input18; input19; input20];
kelas = [1 ; 2 ; 3 ; 4];
a = 0.05;
max_epoch = 100000;
epoch
w11 =
w22 =
w33 =
w44 =
= 0;
0;
0;
0;
0;
while epoch
LAMPIRAN LISTING PROGRAM
Beranda.m
function varargout = Beranda(varargin)
% BERANDA M-file for Beranda.fig
gui_Singleton = 1;
gui_State = struct('gui_Name',
mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Beranda_OpeningFcn, ...
'gui_OutputFcn', @Beranda_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback',
[]);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before Beranda is made visible.
function Beranda_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
handles.citra=imread('logousu.jpg');
guidata(hObject,handles);
axes(handles.axes1);
imshow(handles.citra);
% Choose default command line output for Beranda
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes Beranda wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = Beranda_OutputFcn(hObject, eventdata, handles)
% Get default command line output from handles structure
varargout{1} = handles.output;
% ------------------------------------------------------------------function beranda_Callback(hObject, eventdata, handles)
Beranda
delete(handles.figure1)
% ------------------------------------------------------------------function menupelatihan_Callback(hObject, eventdata, handles)
% ------------------------------------------------------------------function menupengujian_Callback(hObject, eventdata, handles)
% ------------------------------------------------------------------function bantuan_Callback(hObject, eventdata, handles)
Bantuan
delete(handles.figure1)
Universitas Sumatera Utara
85
% ------------------------------------------------------------------function keluar_Callback(hObject, eventdata, handles)
choice= questdlg ('Apakah Anda Ingin Keluar?','Konfirmasi',...
'Ya','Tidak','Tidak');
switch choice
case 'Ya'
close all;
end
% ------------------------------------------------------------------function ujibam_Callback(hObject, eventdata, handles)
UjiBAM
delete(handles.figure1)
% ------------------------------------------------------------------function ujilvq_Callback(hObject, eventdata, handles)
UjiLVQ
delete(handles.figure1)
% ------------------------------------------------------------------function latihbam_Callback(hObject, eventdata, handles)
LatihBAM
delete(handles.figure1)
% ------------------------------------------------------------------function latihlvq_Callback(hObject, eventdata, handles)
LatihLVQ
delete(handles.figure1)
LatihBAM.m
function varargout = LatihBAM(varargin)
% LATIHBAM M-file for LatihBAM.fig
gui_Singleton = 1;
gui_State = struct('gui_Name',
mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @LatihBAM_OpeningFcn, ...
'gui_OutputFcn', @LatihBAM_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback',
[]);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before LatihBAM is made visible.
function LatihBAM_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% --- Executes on button press in Kel.
function Kel_Callback(hObject, eventdata, handles)
% --- Executes on button press in Keh.
function Keh_Callback(hObject, eventdata, handles)
Universitas Sumatera Utara
86
% --- Executes on button press in Sak.
function Sak_Callback(hObject, eventdata, handles)
% --- Executes on button press in tombollatih.
function tombollatih_Callback(hObject, eventdata, handles)
tStart = tic; %untuk waktu
%1x16
target1
target2
target3
target4
=
=
=
=
[1 1 1
[-1 -1
[-1 -1
[-1 -1
1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 1 1 1 1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 1 1 1 1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1
-1 -1];
-1 -1];
-1 -1];
1 1 1];
input1 = xlsread('bam.xlsx', 'nilai', 'B1:U1'); %1x20
input2 = xlsread('bam.xlsx', 'nilai', 'B2:U2');
input3 = xlsread('bam.xlsx', 'nilai', 'B3:U3');
input4 = xlsread('bam.xlsx', 'nilai', 'B4:U4');
input5 = xlsread('bam.xlsx', 'nilai', 'B5:U5'); %1x20
input6 = xlsread('bam.xlsx', 'nilai', 'B6:U6');
input7 = xlsread('bam.xlsx', 'nilai', 'B7:U7');
input8 = xlsread('bam.xlsx', 'nilai', 'B8:U8');
input9 = xlsread('bam.xlsx', 'nilai', 'B9:U9'); %1x20
input10 = xlsread('bam.xlsx', 'nilai', 'B10:U10');
input11 = xlsread('bam.xlsx', 'nilai', 'B11:U11');
input12 = xlsread('bam.xlsx', 'nilai', 'B12:U12');
input13 = xlsread('bam.xlsx', 'nilai', 'B13:U13'); %1x20
input14 = xlsread('bam.xlsx', 'nilai', 'B14:U14');
input15 = xlsread('bam.xlsx', 'nilai', 'B15:U15');
input16 = xlsread('bam.xlsx', 'nilai', 'B16:U16');
input17 = xlsread('bam.xlsx', 'nilai', 'B17:U17'); %1x20
input18 = xlsread('bam.xlsx', 'nilai', 'B18:U18');
input19 = xlsread('bam.xlsx', 'nilai', 'B19:U19');
input20 = xlsread('bam.xlsx', 'nilai', 'B20:U20');
w1 = input1'* target1; %20x16
w2 = input2'* target1;
w3 = input3'* target1;
w4 = input4'* target1;
w5 = input5'* target1;
w6 = input6'* target2;
w7 = input7'* target2;
w8 = input8'* target2;
w9 = input9'* target2;
w10 = input10'* target2;
w11 = input11'* target3;
w12 = input12'* target3;
w13 = input13'* target3;
w14 = input14'* target3;
w15 = input15'* target3;
w16 = input16'* target4;
w17 = input17'* target4;
w18 = input18'* target4;
w19 = input19'* target4;
w20 = input20'* target4;
%20x16
w = w1 + w2 + w3 + w4 + w5 + w6 + w7 + w8 + w9 + w10 + w11 + w12 +
w13 + w14 + w15 + w16 + w17 + w18 + w19 + w20;
Universitas Sumatera Utara
87
xlswrite('bam.xlsx',w, 'bobot', 'A1:P20');
y_in1 = input1 *
y_in2 = input2 *
y_in3 = input3 *
y_in4 = input4 *
y_in5 = input5 *
y_in6 = input6 *
y_in7 = input7 *
y_in8 = input8 *
y_in9 = input9 *
y_in10 = input10
y_in11 = input11
y_in12 = input12
y_in13 = input13
y_in14 = input14
y_in15 = input15
y_in16 = input16
y_in17 = input17
y_in18 = input18
y_in19 = input19
y_in20 = input20
w; %1x16
w;
w;
w;
w;
w;
w;
w;
w;
* w;
* w;
* w;
* w;
* w;
* w;
* w;
* w;
* w;
* w;
* w;
for indeks = 1 : 5
if (y_in1(indeks) < 0)
y_in1(indeks) = -1;
else
y_in1(indeks) = 1;
end
if (y_in2(indeks) < 0)
y_in2(indeks) = -1;
else
y_in2(indeks) = 1;
end
if (y_in3(indeks) < 0)
y_in3(indeks) = -1;
else
y_in3(indeks) = 1;
end
if (y_in4(indeks) < 0)
y_in4(indeks) = -1;
else
y_in4(indeks) = 1;
end
if (y_in5(indeks) < 0)
y_in5(indeks) = -1;
else
y_in5(indeks) = 1;
end
if (y_in6(indeks) < 0)
y_in6(indeks) = -1;
else
y_in6(indeks) = 1;
end
Universitas Sumatera Utara
88
if (y_in7(indeks) < 0)
y_in7(indeks) = -1;
else
y_in7(indeks) = 1;
end
if (y_in8(indeks) < 0)
y_in8(indeks) = -1;
else
y_in8(indeks) = 1;
end
if (y_in9(indeks) < 0)
y_in9(indeks) = -1;
else
y_in9(indeks) = 1;
end
if (y_in10(indeks) < 0)
y_in10(indeks) = -1;
else
y_in10(indeks) = 1;
end
if (y_in11(indeks) < 0)
y_in11(indeks) = -1;
else
y_in11(indeks) = 1;
end
if (y_in12(indeks) < 0)
y_in12(indeks) = -1;
else
y_in12(indeks) = 1;
end
if (y_in13(indeks) < 0)
y_in13(indeks) = -1;
else
y_in13(indeks) = 1;
end
if (y_in14(indeks) < 0)
y_in14(indeks) = -1;
else
y_in14(indeks) = 1;
end
if (y_in15(indeks) < 0)
y_in15(indeks) = -1;
else
y_in15(indeks) = 1;
end
if (y_in16(indeks) < 0)
y_in16(indeks) = -1;
else
Universitas Sumatera Utara
89
y_in16(indeks) = 1;
end
if (y_in17(indeks) < 0)
y_in17(indeks) = -1;
else
y_in17(indeks) = 1;
end
if (y_in18(indeks) < 0)
y_in18(indeks) = -1;
else
y_in18(indeks) = 1;
end
if (y_in19(indeks) < 0)
y_in19(indeks) = -1;
else
y_in19(indeks) = 1;
end
if (y_in20(indeks) < 0)
y_in20(indeks) = -1;
else
y_in20(indeks) = 1;
end
end
waktupengujian = toc(tStart);
set(handles.waktulatih,'string',waktupengujian);
h = msgbox('Data telah dilatih', 'Berhasil');
function namapenyakit_Callback(hObject, eventdata, handles)
function namapenyakit_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function waktulatih_Callback(hObject, eventdata, handles)
function waktulatih_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in tombolsimpan.
function tombolsimpan_Callback(hObject, eventdata, handles)
a = get(handles.Sul,'Value');
b = get(handles.Per,'Value');
c = get(handles.Bat,'Value');
d = get(handles.Mua,'Value');
e = get(handles.Sua,'Value');
f = get(handles.Nye,'Value');
Universitas Sumatera Utara
90
g
h
i
j
=
=
=
=
get(handles.Mun,'Value');
get(handles.Ada,'Value');
get(handles.Lam,'Value');
get(handles.Atp,'Value');
k
l
m
n
o
=
=
=
=
=
get(handles.Sen,'Value');
get(handles.Kem,'Value');
get(handles.Ane,'Value');
get(handles.Ras,'Value');
get(handles.Pen,'Value');
p
q
r
s
t
=
=
=
=
=
get(handles.Tm,'Value');
get(handles.Md,'Value');
get(handles.Kel,'Value');
get(handles.Keh,'Value');
get(handles.Sak,'Value');
penyakit= [a b c d e f g h i j k l m n o p q r s t];
for indeks = 1 : 20
if (penyakit(indeks) == 0)
penyakit(indeks) = -1;
else
penyakit(indeks) = 1;
end
end
nm = get(handles.namapenyakit,'String');
if (strcmp(nm , 'Radang Kerongkongan 1'))
xlswrite('bam.xlsx',penyakit,'Nilai','B1:U1');
elseif (strcmp(nm , 'Radang Kerongkongan 2'))
xlswrite('bam.xlsx',penyakit,'Nilai','B2:U2');
elseif (strcmp(nm , 'Radang Kerongkongan 3'))
xlswrite('bam.xlsx',penyakit,'Nilai','B3:U3');
elseif (strcmp(nm , 'Radang Kerongkongan 4'))
xlswrite('bam.xlsx',penyakit,'Nilai','B4:U4');
elseif (strcmp(nm , 'Radang Kerongkongan 5'))
xlswrite('bam.xlsx',penyakit,'Nilai','B5:U5');
elseif (strcmp(nm , 'Radang Lambung 1'))
xlswrite('bam.xlsx',penyakit,'Nilai','B6:U6');
elseif (strcmp(nm , 'Radang Lambung 2'))
xlswrite('bam.xlsx',penyakit,'Nilai','B7:U7');
elseif (strcmp(nm , 'Radang Lambung 3'))
xlswrite('bam.xlsx',penyakit,'Nilai','B8:U8');
elseif (strcmp(nm , 'Radang Lambung 4'))
xlswrite('bam.xlsx',penyakit,'Nilai','B9:U9');
elseif (strcmp(nm , 'Radang Lambung 5'))
xlswrite('bam.xlsx',penyakit,'Nilai','B10:U10');
elseif (strcmp(nm , 'Tukak Lambung 1'))
xlswrite('bam.xlsx',penyakit,'Nilai','B11:U11');
elseif (strcmp(nm , 'Tukak Lambung 2'))
xlswrite('bam.xlsx',penyakit,'Nilai','B12:U12');
elseif (strcmp(nm , 'Tukak Lambung 3'))
xlswrite('bam.xlsx',penyakit,'Nilai','B13:U13');
elseif (strcmp(nm , 'Tukak Lambung 4'))
Universitas Sumatera Utara
91
xlswrite('bam.xlsx',penyakit,'Nilai','B14:U14');
elseif (strcmp(nm , 'Tukak Lambung 5'))
xlswrite('bam.xlsx',penyakit,'Nilai','B15:U15');
elseif (strcmp(nm , 'Kanker Lambung 1'))
xlswrite('bam.xlsx',penyakit,'Nilai','B16:U16');
elseif (strcmp(nm , 'Kanker Lambung 2'))
xlswrite('bam.xlsx',penyakit,'Nilai','B17:U17');
elseif (strcmp(nm , 'Kanker Lambung 3'))
xlswrite('bam.xlsx',penyakit,'Nilai','B18:U18');
elseif (strcmp(nm , 'Kanker Lambung 4'))
xlswrite('bam.xlsx',penyakit,'Nilai','B19:U19');
elseif (strcmp(nm , 'Kanker Lambung 5'))
xlswrite('bam.xlsx',penyakit,'Nilai','B20:U20');
end
penyakit = [];
pesan = msgbox('Data telah disimpan', 'Berhasil');
% --- Executes on button press in tombolreset.
function tombolreset_Callback(hObject, eventdata, handles)
set(handles.namapenyakit,'String','','Enable','on');
set(handles.waktulatih,'String','','Enable','on');
set(handles.Sul,'Value',0);
set(handles.Per,'Value',0);
set(handles.Bat,'Value',0);
set(handles.Mua,'Value',0);
set(handles.Sua,'Value',0);
set(handles.Nye,'Value',0);
set(handles.Mun,'Value',0);
set(handles.Ada,'Value',0);
set(handles.Lam,'Value',0);
set(handles.Atp,'Value',0);
set(handles.Sen,'Value',0);
set(handles.Kem,'Value',0);
set(handles.Ane,'Value',0);
set(handles.Ras,'Value',0);
set(handles.Pen,'Value',0);
set(handles.Tm,'Value',0);
set(handles.Md,'Value',0);
set(handles.Kel,'Value',0);
set(handles.Keh,'Value',0);
set(handles.Sak,'Value',0);
% ------------------------------------------------------------------function beranda_Callback(hObject, eventdata, handles)
Beranda
delete(handles.figure1)
% ------------------------------------------------------------------function menubam_Callback(hObject, eventdata, handles)
% ------------------------------------------------------------------function menulvq_Callback(hObject, eventdata, handles)
% ------------------------------------------------------------------function bantuan_Callback(hObject, eventdata, handles)
UjiBAM.m
function varargout = UjiBAM(varargin)
% UJIBAM M-file for UjiBAM.fig
gui_Singleton = 1;
gui_State = struct('gui_Name',
mfilename, ...
Universitas Sumatera Utara
92
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @UjiBAM_OpeningFcn, ...
'gui_OutputFcn', @UjiBAM_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback',
[]);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before UjiBAM is made visible.
function UjiBAM_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% --- Outputs from this function are returned to the command line.
function varargout = UjiBAM_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
% --- Executes on button press in tombolreset.
function tombolreset_Callback(hObject, eventdata, handles)
xlswrite('databam.xlsx', '0','nilai','B2:U2');
set(handles.namapenyakit,'String','','Enable','on');
set(handles.jenisobat,'String','','Enable','on');
set(handles.waktuuji,'String','','Enable','on');
set(handles.Sul,'Value',0);
set(handles.Per,'Value',0);
set(handles.Bat,'Value',0);
set(handles.Mua,'Value',0);
set(handles.Sua,'Value',0);
set(handles.Nye,'Value',0);
set(handles.Mun,'Value',0);
set(handles.Ada,'Value',0);
set(handles.Lam,'Value',0);
set(handles.Atp,'Value',0);
set(handles.Sen,'Value',0);
set(handles.Kem,'Value',0);
set(handles.Ane,'Value',0);
set(handles.Ras,'Value',0);
set(handles.Pen,'Value',0);
set(handles.Tm,'Value',0);
set(handles.Md,'Value',0);
set(handles.Kel,'Value',0);
set(handles.Keh,'Value',0);
set(handles.Sak,'Value',0);
% --- Executes on button press in tombolhasil.
function tombolhasil_Callback(hObject, eventdata, handles)
tStart=tic;
a = get(handles.Sul,'Value');
b = get(handles.Per,'Value');
Universitas Sumatera Utara
93
c = get(handles.Bat,'Value');
d = get(handles.Mua,'Value');
e = get(handles.Sua,'Value');
f
g
h
i
j
=
=
=
=
=
get(handles.Nye,'Value');
get(handles.Mun,'Value');
get(handles.Ada,'Value');
get(handles.Lam,'Value');
get(handles.Atp,'Value');
k
l
m
n
o
=
=
=
=
=
get(handles.Sen,'Value');
get(handles.Kem,'Value');
get(handles.Ane,'Value');
get(handles.Ras,'Value');
get(handles.Pen,'Value');
p
q
r
s
t
=
=
=
=
=
get(handles.Tm,'Value');
get(handles.Md,'Value');
get(handles.Kel,'Value');
get(handles.Keh,'Value');
get(handles.Sak,'Value');
data_uji = [a b c d e f g h i j k l m n o p q r s t];
for indeks = 1 : 20
if (data_uji(indeks) == 0)
data_uji(indeks) = -1;
else
data_uji(indeks) = 1;
end
end
w = xlsread('bam.xlsx','bobot','A1:P20'); %20x16
output_uji = data_uji * w; %1x16
for indeks = 1 : 16
if (output_uji(indeks) < 0)
output_uji(indeks) = -1;
else
output_uji(indeks) = 1;
end
end
output_uji
target1 = [1 1 1
target2 = [-1 -1
target3 = [-1 -1
target4 = [-1 -1
1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 1 1 1 1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 1 1 1 1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1
-1 -1];
-1 -1];
-1 -1];
1 1 1];
if
isequal (output_uji,target1)
set(handles.namapenyakit,'String','Radang Kerongkongan (reflux
oesophagitis)');
set(handles.jenisobat,'String','Ranitidin , Omeprazole ,
Domperidone , Antasida , Sukralfat');
elseif isequal (output_uji,target2)
set(handles.namapenyakit,'String','Radang lambung (gastritis)');
Universitas Sumatera Utara
94
set(handles.jenisobat,'String','Omeprazole , Antasida , Bismuth ,
Amoxixilin , Claritromixin)');
elseif isequal (output_uji,target3)
set(handles.namapenyakit,'String','Tukak Lambung-Usus (ulcus
pepticum)');
set(handles.jenisobat,'String','Antasida , Bismuth , Sukralfat ,
Ranitidin , Omeprazole');
elseif isequal (output_uji,target4)
set(handles.namapenyakit,'String','Kanker Lambung');
set(handles.jenisobat,'String','Kemoterapi , Radiasi , Operasi');
else
set(handles.namapenyakit,'String','Tidak Dikenali');
end
waktupengujian = toc(tStart);
set(handles.waktuuji,'string',waktupengujian);
% --- Executes on button press in Sul.
function Sul_Callback(hObject, eventdata, handles)
% --- Executes on button press in Per.
function Per_Callback(hObject, eventdata, handles)
% --- Executes on button press in Bat.
function Bat_Callback(hObject, eventdata, handles)
% --- Executes on button press in Mua.
function Mua_Callback(hObject, eventdata, handles)
% --- Executes on button press in Sua.
function Sua_Callback(hObject, eventdata, handles)
% --- Executes on button press in Nye.
function Nye_Callback(hObject, eventdata, handles)
% --- Executes on button press in Mun.
function Mun_Callback(hObject, eventdata, handles)
% --- Executes on button press in Ada.
function Ada_Callback(hObject, eventdata, handles)
% --- Executes on button press in Lam.
function Lam_Callback(hObject, eventdata, handles)
% --- Executes on button press in Atp.
function Atp_Callback(hObject, eventdata, handles)
% --- Executes on button press in Sen.
function Sen_Callback(hObject, eventdata, handles)
% --- Executes on button press in Kem.
LatihLVQ.m
function varargout = LatihLVQ(varargin)
% LATIHLVQ M-file for LatihLVQ.fig
gui_Singleton = 1;
gui_State = struct('gui_Name',
mfilename, ...
'gui_Singleton', gui_Singleton, ...
Universitas Sumatera Utara
95
'gui_OpeningFcn', @LatihLVQ_OpeningFcn, ...
'gui_OutputFcn', @LatihLVQ_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback',
[]);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes on button press in Sak.
function Sak_Callback(hObject, eventdata, handles)
% --- Executes on button press in tombolreset.
function tombolreset_Callback(hObject, eventdata, handles)
xlswrite('datalvq.xlsx', '0','nilai','B2:U2');
set(handles.namapenyakit,'String','','Enable','on');
set(handles.waktu,'String','','Enable','on');
set(handles.Sul,'Value',0);
set(handles.Per,'Value',0);
set(handles.Bat,'Value',0);
set(handles.Mua,'Value',0);
set(handles.Sua,'Value',0);
set(handles.Nye,'Value',0);
set(handles.Mun,'Value',0);
set(handles.Ada,'Value',0);
set(handles.Lam,'Value',0);
set(handles.Atp,'Value',0);
set(handles.Sen,'Value',0);
set(handles.Kem,'Value',0);
set(handles.Ane,'Value',0);
set(handles.Ras,'Value',0);
set(handles.Pen,'Value',0);
set(handles.Tm,'Value',0);
set(handles.Md,'Value',0);
set(handles.Kel,'Value',0);
set(handles.Keh,'Value',0);
set(handles.Sak,'Value',0);
function namapenyakit_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function namapenyakit_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in tombolsimpan.
function tombolsimpan_Callback(hObject, eventdata, handles)
a = get(handles.Sul,'Value');
b = get(handles.Per,'Value');
c = get(handles.Bat,'Value');
Universitas Sumatera Utara
96
d = get(handles.Mua,'Value');
e = get(handles.Sua,'Value');
f
g
h
i
j
=
=
=
=
=
get(handles.Nye,'Value');
get(handles.Mun,'Value');
get(handles.Ada,'Value');
get(handles.Lam,'Value');
get(handles.Atp,'Value');
k
l
m
n
o
=
=
=
=
=
get(handles.Sen,'Value');
get(handles.Kem,'Value');
get(handles.Ane,'Value');
get(handles.Ras,'Value');
get(handles.Pen,'Value');
p
q
r
s
t
=
=
=
=
=
get(handles.Tm,'Value');
get(handles.Md,'Value');
get(handles.Kel,'Value');
get(handles.Keh,'Value');
get(handles.Sak,'Value');
penyakit= [a b c d e f g h i j k l m n o p q r s t];
for indeks = 1 : 20
if (penyakit(indeks) == 0)
penyakit(indeks) = -1;
else
penyakit(indeks) = 1;
end
end
nm = get(handles.namapenyakit,'String');
if (strcmp(nm , 'Radang Kerongkongan 1'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B1:U1');
elseif (strcmp(nm , 'Radang Kerongkongan 2'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B2:U2');
elseif (strcmp(nm , 'Radang Kerongkongan 3'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B3:U3');
elseif (strcmp(nm , 'Radang Kerongkongan 4'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B4:U4');
elseif (strcmp(nm , 'Radang Kerongkongan 5'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B5:U5');
elseif (strcmp(nm , 'Radang Lambung 1'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B6:U6');
elseif (strcmp(nm , 'Radang Lambung 2'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B7:U7');
elseif (strcmp(nm , 'Radang Lambung 3'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B8:U8');
elseif (strcmp(nm , 'Radang Lambung 4'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B9:U9');
elseif (strcmp(nm , 'Radang Lambung 5'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B10:U10');
elseif (strcmp(nm , 'Tukak Lambung 1'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B11:U11');
Universitas Sumatera Utara
97
elseif (strcmp(nm , 'Tukak Lambung 2'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B12:U12');
elseif (strcmp(nm , 'Tukak Lambung 3'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B13:U13');
elseif (strcmp(nm , 'Tukak Lambung 4'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B14:U14');
elseif (strcmp(nm , 'Tukak Lambung 5'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B15:U15');
elseif (strcmp(nm , 'Kanker Lambung 1'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B16:U16');
elseif (strcmp(nm , 'Kanker Lambung 2'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B17:U17');
elseif (strcmp(nm , 'Kanker Lambung 3'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B18:U18');
elseif (strcmp(nm , 'Kanker Lambung 4'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B19:U19');
elseif (strcmp(nm , 'Kanker Lambung 5'))
xlswrite('lvq.xlsx',penyakit,'Nilai','B20:U20');
end
penyakit = [];
pesan = msgbox('Data telah disimpan', 'Berhasil');
function waktu_Callback(hObject, eventdata, handles)
% hObject
handle to waktu (see GCBO)
% --- Executes during object creation, after setting all properties.
function waktu_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in tombollatih.
function tombollatih_Callback(hObject, eventdata, handles)
tStart = tic; %untuk waktu
%target 1 x 20
w1_awal = [1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
1]; %kelas 1
w2_awal = [-1 -1 -1 -1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
1]; %kelas 2
w3_awal = [-1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1 1 -1 -1 -1 -1 -1 -1
1]; %kelas 3
w4_awal = [-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1
1]; %kelas 4
-1 -1 -1 1 1
input1 = xlsread('lvq.xlsx', 'nilai', 'B1:U1'); %1x20
input2 = xlsread('lvq.xlsx', 'nilai', 'B2:U2');
input3 = xlsread('lvq.xlsx', 'nilai', 'B3:U3');
input4 = xlsread('lvq.xlsx', 'nilai', 'B4:U4');
input5 = xlsread('lvq.xlsx', 'nilai', 'B5:U5'); %1x20
input6 = xlsread('lvq.xlsx', 'nilai', 'B6:U6');
input7 = xlsread('lvq.xlsx', 'nilai', 'B7:U7');
input8 = xlsread('lvq.xlsx', 'nilai', 'B8:U8');
input9 = xlsread('lvq.xlsx', 'nilai', 'B9:U9'); %1x20
input10 = xlsread('lvq.xlsx', 'nilai', 'B10:U10');
input11 = xlsread('lvq.xlsx', 'nilai', 'B11:U11');
input12 = xlsread('lvq.xlsx', 'nilai', 'B12:U12');
Universitas Sumatera Utara
98
input13
input14
input15
input16
input17
input18
input19
input20
=
=
=
=
=
=
=
=
xlsread('lvq.xlsx',
xlsread('lvq.xlsx',
xlsread('lvq.xlsx',
xlsread('lvq.xlsx',
xlsread('lvq.xlsx',
xlsread('lvq.xlsx',
xlsread('lvq.xlsx',
xlsread('lvq.xlsx',
'nilai',
'nilai',
'nilai',
'nilai',
'nilai',
'nilai',
'nilai',
'nilai',
'B13:U13'); %1x20
'B14:U14');
'B15:U15');
'B16:U16');
'B17:U17'); %1x20
'B18:U18');
'B19:U19');
'B20:U20');
pola = [input1 ; input2 ; input3 ; input4; input5 ;
input6 ; input7 ; input8 ; input9 ; input10;
input11; input12; input13 ; input14 ; input15 ;
input16 ; input17; input18; input19; input20];
kelas = [1 ; 2 ; 3 ; 4];
a = 0.05;
max_epoch = 100000;
epoch
w11 =
w22 =
w33 =
w44 =
= 0;
0;
0;
0;
0;
while epoch