Yuk Kita Buat GUInya :
Jika nanti dijalankan ahsilnya sbb:
Lalu atur propertis nama TAGnya di setiap itemnya
Lalu pada Button kita kasih Koding
Code ahirnya dalah sbb:
function varargout = myGUI(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @myGUI_OpeningFcn, ...
'gui_OutputFcn', @myGUI_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
function myGUI_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
function btnPilih_Callback(hObject, eventdata, handles)
[handles.namafile,handles.direktori]=uigetfile({'*.xls;*.xlsx','file excel(*.xls,*.xlsx)';'*.*','semua file(*.*)'},'buka file xls master');
I=fullfile(handles.direktori,handles.namafile);
if ~isequal(handles.namafile, 0)
set(handles.edPath,'String',I);
[a,b,c]=xlsread(I);
header= {'Kategori', 'Jam', 'Jenis Ikan', 'bagian', 'R', 'G', 'B'};
ba=size(c,1);
co=size(c,2);
mulaike=2;
mydata=c(mulaike:ba,1:co);
rnames = linspace(1,ba-mulaike+1,ba-mulaike+1);
jml=['Total Data Latih ' num2str(ba-1) ' Item']
set(handles.myTabel1,'data',mydata,'ColumnName',header,'RowName',rnames);
set(handles.myTabel1,'Userdata',mydata);
set(handles.txtTotal,'String',jml);
r1=10;
r2=18;
r3=27;
ar1=cell2mat(c(2:r1,5));
ag1=cell2mat(c(2:r1,6));
ab1=cell2mat(c(2:r1,7));
ar2=cell2mat(c(r1+1:r2,5));
ag2=cell2mat(c(r1+1:r2,6));
ab2=cell2mat(c(r1+1:r2,7));
ar3=cell2mat(c(r2+1:r3,5));
ag3=cell2mat(c(r2+1:r3,6));
ab3=cell2mat(c(r2+1:r3,7));
minr1=min(ar1);
ming1=min(ag1);
minb1=min(ab1);
minr2=min(ar2);
ming2=min(ag2);
minb2=min(ab2);
minr3=min(ar3);
ming3=min(ag3);
minb3=min(ab3);
maxr1=max(ar1);
maxg1=max(ag1);
maxb1=max(ab1);
maxr2=max(ar2);
maxg2=max(ag2);
maxb2=max(ab2);
maxr3=max(ar3);
maxg3=max(ag3);
maxb3=max(ab3);
header= {'Kategori', 'Rmin', 'Rmax', 'Gmin', 'Gmax', 'Bmin', 'Bmax'};
rnames = linspace(1,3,3);
mydata2(1,1)={'Segar'};
mydata2(1,2)={minr1};
mydata2(1,3)={maxr1};
mydata2(1,4)={ming1};
mydata2(1,5)={maxg1};
mydata2(1,6)={minb1};
mydata2(1,7)={maxb1};
mydata2(2,1)={'Cukup Segar'};
mydata2(2,2)={minr2};
mydata2(2,3)={maxr2};
mydata2(2,4)={ming2};
mydata2(2,5)={maxg2};
mydata2(2,6)={minb2};
mydata2(2,7)={maxb2};
mydata2(3,1)={'Tidak Segar'};
mydata2(3,2)={minr3};
mydata2(3,3)={maxr3};
mydata2(3,4)={ming3};
mydata2(3,5)={maxg3};
mydata2(3,6)={minb3};
mydata2(3,7)={maxb3};
set(handles.myTabel2,'data',mydata2,'ColumnName',header,'RowName',rnames);
set(handles.myTabel2,'Userdata',mydata2);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
header= {'Linguistic Term', 'R', 'G', 'B'};
rnames = linspace(1,3,3);
mydata3(1,1)={'Low'};
mydata3(1,2)={'10-91'};
mydata3(1,3)={'11-76'};
mydata3(1,4)={'14-87'};
mydata3(2,1)={'Medium'};
mydata3(2,2)={'14-93'};
mydata3(2,3)={'16-90'};
mydata3(2,4)={'27-88'};
mydata3(3,1)={'High'};
mydata3(3,2)={'44-96'};
mydata3(3,3)={'42-93'};
mydata3(3,4)={'41-97'};
set(handles.myTabel3,'data',mydata3,'ColumnName',header,'RowName',rnames);
set(handles.myTabel3,'Userdata',mydata3);
header= {'Linguistic Term', 'Range'};
rnames = linspace(1,3,3);
mydata4(1,1)={'Segar'};
mydata4(1,2)={'11-76'};
mydata4(2,1)={'Cukup Segar'};
mydata4(2,2)={'27-88'};
mydata4(3,1)={'Tidak Segar'};
mydata4(3,2)={'41-97'};
set(handles.myTabel4,'data',mydata4,'ColumnName',header,'RowName',rnames);
set(handles.myTabel4,'Userdata',mydata4);
end
function btnBersih_Callback(hObject, eventdata, handles)
proyek=guidata(gcbo);
mau=questdlg(['Reset ' get(proyek.figure1,'Name')''],['Anda ingin Reset Aplikasi ini?'],'Ya','Tidak','Ya');
if strcmp(mau,'Tidak')
return;
else
%str=date;
%set(handles.edjoindate,'String',str);
set(handles.myTabel1,'data',[],'ColumnName',[],'RowName',[]);
set(handles.myTabel1,'Userdata',[]);
set(handles.myTabel2,'data',[],'ColumnName',[],'RowName',[]);
set(handles.myTabel2,'Userdata',[]);
set(handles.myTabel3,'data',[],'ColumnName',[],'RowName',[]);
set(handles.myTabel3,'Userdata',[]);
set(handles.myTabel4,'data',[],'ColumnName',[],'RowName',[]);
set(handles.myTabel4,'Userdata',[]);
set(handles.edPath,'String','');
set(handles.edMR,'String','');
set(handles.edMG,'String','');
set(handles.edMB,'String','');
set(handles.edPath2,'String','');
set(handles.edHasil1,'String','');
set(handles.edHasil2,'String','');
set(handles.edProses,'String','');
set(handles.txtTotal,'String','Total DataLatih 0 Item');
cla(handles.axes1,'reset');
cla(handles.axes2,'reset');
cla(handles.axes3,'reset');
cla(handles.axes4,'reset');
cla(handles.axes5,'reset');
end
function btnPilih2_Callback(hObject, eventdata, handles)
[handles.namafile,handles.direktori]=uigetfile({'*.jpg;*.bmp','file Image(*.jpg,*.bmp,*.bmp)';'*.*','semua file(*.*)'},'buka file xls master');
I=fullfile(handles.direktori,handles.namafile);
if ~isequal(handles.namafile, 0)
Matrix=imread(I);
set(handles.figure1,'CurrentAxes',handles.axes1);
imshow(Matrix);
set(handles.axes1,'Userdata',Matrix);
MatrixHSV=rgb2hsv(Matrix);
set(handles.figure1,'CurrentAxes',handles.axes5);
imshow(MatrixHSV);
set(handles.axes5,'Userdata',MatrixHSV);
set(handles.btnRGB,'Enable','on');
set(handles.edPath2,'String',I);
end
function btnRGB_Callback(hObject, eventdata, handles)
Matrix=get(handles.axes1,'Userdata');
R=Matrix(:,:,1);
set(handles.figure1,'CurrentAxes',handles.axes2);
imshow(R);
set(handles.axes2,'Userdata',R);
G=Matrix(:,:,2);
set(handles.figure1,'CurrentAxes',handles.axes3);
imshow(G);
set(handles.axes3,'Userdata',G);
B=Matrix(:,:,3);
set(handles.figure1,'CurrentAxes',handles.axes4);
imshow(B);
set(handles.axes4,'Userdata',B);
MR=mean(mean(R));
MG=mean(mean(G));
MB=mean(mean(B));
set(handles.edMR,'String',num2str(MR));
set(handles.edMG,'String',num2str(MG));
set(handles.edMB,'String',num2str(MB));
set(handles.btnRGB,'Enable','off');
function btnExit_Callback(hObject, eventdata, handles)
close;
Tidak ada komentar:
Posting Komentar