Sabtu, 10 November 2018
POPUP MENU MATLAB
How Get VALUE POPUP MENU
function pilAgama_Callback(hObject, eventdata, handles)
ar= get(handles.pilAgama, 'String');
v = get(handles.pilAgama, 'value');
hasil=cell2mat(ar(v));
set(handles.pilAgama, 'Userdata',hasil);
How SET VALUE POPUP MENU:
v=1;
if(strcmp(agama,'Islam')>0)
v=1;
elseif(strcmp(agama,'Kristen')>0)
v=2;
elseif(strcmp(agama,'Hindu')>0)
v=3;
elseif(strcmp(agama,'Budha')>0)
v=4;
end
set(handles.pilAgama, 'Value', v);
How SET STRING POPUP MENU:
a='you';b='are';c='crazy'
s=char(a,b,c); %s 3x5 30 char
set(handles.pilNIK,'string',s);
How SET STRING POPUP MENU FROM DATABASE:
[arkode,arnama] = aremployee( 'tb_employe' );
set(handles.pilNIK,'string',arkode);
function [kode,nama] = aremployee( tabel )
[con]=koneksivalue();
setdbprefs('NullNumberWrite', 'NaN');
SQL=['SELECT nik,name FROM ' tabel ' order by nik asc' ];
curs = exec(con,SQL);
curs = fetch(curs);
mydata=curs.Data;
baris=size(mydata,1);
kode=mydata(:,1);
nama=mydata(:,2);
end
function [con] = koneksivalue()
url = 'jdbc:mysql://localhost:3306/';
con = database('db_matlab', 'root', '', 'com.mysql.jdbc.Driver', url);
end
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar