Menampilkan data .xls dari open / browse ke tabel pada Matlab:
proyek=guidata(gcbo);
[handles.namafile,handles.direktori]=uigetfile({'*.xls;*.xlsx','file excel(*.xls,*.xlsx)';'*.*','semua file(*.*)'},'buka file xls master');
I=fullfile(handles.direktori,handles.namafile);
set(handles.edPath,'String',I);
[A,B,C]=xlsread(I);
header= {'nama','jenis kelamin','usia','BB','TB','IMT','status'};
ba=size(C,1);
co=size(C,2);
rnames = linspace(1,ba,ba);
mydata=C(:,1:co);
set(handles.myTabel1,'data',mydata,'ColumnName',header,'RowName',rnames);
set(handles.myTabel1,'Userdata',mydata);
ps=['Jumlah Data Training ' num2str(ba) ' item'];
set(handles.edJum,'String',ps);
-----------------------------------------------------------------------------------------------------------
Code Mengakses radio button pada Matlab:[yjk =name variabel gui uibuttongroup]
function myjk_SelectionChangeFcn(hObject, eventdata, handles)
switch get(eventdata.NewValue,'Tag')
case 'radP'
set(handles.myjk,'Userdata', 'Laki-laki');
case 'radW'
set(handles.myjk,'Userdata', 'Perempuan');
end
sehingga pada button yang lain cukup panggil:
JK= get(handles.myjk,'Userdata');
-----------------------------------------------------------------------------------------------------------
BTNEXIT
mau=questdlg(['Keluar ' get(handles.figure1,'Name')''],['Keluar ' get(handles.figure1,'Name')''],'Ya','Tidak','Ya');
if strcmp(mau,'Tidak')
return;
end
delete(handles.figure1);%close;
-----------------------------------------------------------------------------------------------------------
BTNBROWSE
[handles.namafile,handles.direktori]=uigetfile({'*.rtf';'*.*'},'Open File .RTF');
path=fullfile(handles.direktori,handles.namafile);
if size(path,2)>1
set(handles.edPathRTF,'string',path);
set(handles.btnReset,'Enable','on');
set(handles.btnTXT,'Enable','on');
set(handles.btnReset,'Enable','on');
set(handles.btnGenerate,'Enable','on');
set(handles.btnSave,'Enable','on');
set(handles.edHasil,'string','');
aa='';
fid = fopen(path);
tline = fgetl(fid);
while ischar(tline)
aa=[aa tline];
tline = fgetl(fid);
end
fclose(fid);
set(handles.edProsses,'string',aa);
myicon(:,:,1) = [0 1; 0 1];
myicon(:,:,2) = [.8 1; 0 .3];
myicon(:,:,3) = [.3 0; .9 .5];
h=msgbox('Operation Load .rtf Completed','Success','custom',myicon);
else
set(handles.edPathRTF,'string','');
set(handles.btnTXT,'Enable','off');
set(handles.btnReset,'Enable','off');
set(handles.btnGenerate,'Enable','off');
set(handles.btnSave,'Enable','off');
myicon(:,:,1) = [0 1; 0 1];
myicon(:,:,2) = [.8 1; 0 .3];
myicon(:,:,3) = [.3 0; .9 .5];
h=msgbox('Operation Load .rtf Failed','Failed','custom',myicon);
end
-----------------------------------------------------------------------------------------------------------
BTNLOAD.TXT
[handles.namafile,handles.direktori]=uigetfile({'*.TXT';'*.*'},'Open File .txt');
path=fullfile(handles.direktori,handles.namafile);
if size(path,2)>1
% fid = fopen(path);
% s = textscan(fid,'%s','Delimiter','\n');
% s = s{1};
% mytxt=cell2mat(s);
aa='';
fid = fopen(path);
tline = fgetl(fid);
while ischar(tline)
aa=[aa tline];
tline = fgetl(fid);
end
fclose(fid);
set(handles.edPathTXT,'string',path);
set(handles.edMessage,'string',aa);
set(handles.edHasil,'string','');
set(handles.btnReset,'Enable','on');
set(handles.btnTXT,'Enable','on');
set(handles.btnReset,'Enable','on');
set(handles.btnGenerate,'Enable','on');
set(handles.btnSave,'Enable','on');
myicon(:,:,1) = [0 1; 0 1];
myicon(:,:,2) = [.8 1; 0 .3];
myicon(:,:,3) = [.3 0; .9 .5];
h=msgbox('Operation Load .txt Completed','Success','custom',myicon);
else
set(handles.edPathTXT,'string','');
myicon(:,:,1) = [0 1; 0 1];
myicon(:,:,2) = [.8 1; 0 .3];
myicon(:,:,3) = [.3 0; .9 .5];
h=msgbox('Operation Load .rtf Canceled','Canceled','custom',myicon);
end
-----------------------------------------------------------------------------------------------------------
BTNSAVE
proyek=guidata(gcbo);
mau=questdlg(['SAVE ' get(proyek.proyekPD,'Name')''],['Anda ingin Save hasil Kriptografi ini?'],'Ya','Tidak','Ya');
if strcmp(mau,'Tidak')
return;
else
[namafile, direktori] = uiputfile({'*.rtf';'*.doc';'*.txt';'*.*'},'Save as')
path=fullfile(direktori,namafile);
isi=char(get(handles.edProsses,'String'));%seharusnya edResult ya
fileID = fopen(path,'w');
fwrite(fileID,isi,'uint8','ieee-be');
fclose(fileID);
msgbox(['Process New File RTF :@ ' direktori '\' namafile ' has Succesfully to Save']);
end
-----------------------------------------------------------------------------------------------------------
BTNCLEAR
proyek=guidata(gcbo);
mau=questdlg(['Reset ' get(proyek.proyekPD,'Name')''],['Anda ingin Reset Aplikasi ini?'],'Ya','Tidak','Ya');
if strcmp(mau,'Tidak')
return;
else
set(handles.edPathRTF,'String','');
set(handles.edPathTXT,'String','');
set(handles.edMessage,'String','');
set(handles.edProsses,'String','');
set(handles.edHasil,'String','');
set(handles.btnTXT,'Enable','off');
set(handles.btnReset,'Enable','off');
set(handles.btnGenerate,'Enable','off');
set(handles.btnSave,'Enable','off');
end
Tidak ada komentar:
Posting Komentar