Pembuatan Database menggunakan Matlab dan Ms. Excel


Dalam pembuatan basis data (database), Matlab dapat diintegrasikan dengan beberapa software lain contohnya adalah Microsoft Office Excel 2007. Berikut ini merupakan contoh pemrograman matlab untuk membuat database mahasiswa menggunakan GUI Matlab R2015b.

Sistem basis data yang dirancang terdiri dari 4 buah tampilan GUI yaitu:
1. Tampilan menu Utama (Home)
Pada menu ini disajikan 4 buah tombol untuk masuk ke dalam tampilan submenu yang lain. Submenu yang lain antara lain yaitu Menu Registrasi Mahasiswa, Menu Status Mahasiswa, Menu Database Mahasiswa, dan Menu Keluar.

2. Tampilan menu Registrasi Mahasiswa
Pada menu ini disajikan form untuk mengisi data mahasiswa. Data yang dapat diisikan antara lain adalah Nomor Induk Mahasiswa (NIM), Nama, Jenis Kelamin, Tempat dan Tanggal Lahir (TTL), Alamat, Tahun Masuk, dan Bidang Minat.

3. Tampilan menu Status Mahasiswa
Pada menu ini disajikan kolom untuk mengisi Nomor Induk Mahasiswa yang ingin dicari statusnya. Data status mahasiswa sesuai dengan data yang diisikan pada menu Registrasi Mahasiswa.

4. Tampilan menu Database Mahasiswa
Pada menu ini disajikan tabel yang berisi data dari seluruh mahasiswa yang didaftarkan pada menu Registrasi Mahasiswa.

Langkah-langkah pengisian data dalam sistem database yang dirancang adalah sebagai berikut:
1. Membuka tampilan menu utama. Kemudian memilih menu Registrasi Mahasiswa

sehingga akan muncul tampilan seperti pada gambar berikut

2. Mengisi data mahasiswa pada form yang telah disediakan

Jika data sudah terisi, maka langkah berikutnya adalah menekan tombol Daftar sehingga akan diperoleh tampilan seperti pada gambar berikut

3. Mengecek status mahasiswa yang sudah didaftarkan. Proses ini dilakukan pada tampilan menu Status Mahasiswa

Mengisikan NIM dari mahasiswa yang ingin dicari statusnya

Jika NIM sudah terisi, langkah selanjutnya adalah menekan tombol Cari NIM, sehingga akan muncul tampilan sebagai berikut

Data yang ditampilkan pada menu Status Mahasiswa tersebut sesuai dengan data mahasiswa yang telah diisikan sebelumnya pada menu Registrasi Mahasiswa

4. Data dari seluruh mahasiswa yang telah didaftarkan pada menu Registrasi Mahasiswa dapat dilihat pada tampilan menu Database Mahasiswa

Database seluruh mahasiswa terintegrasi dengan software Microsoft Office Excel 2007 seperti ditunjukkan pada gambar berikut:

Source code masing-masing tampilan menu GUI adalah sebagai berikut:
1. Menu Utama (Home)

function varargout = Database_Mahasiswa_Fisika(varargin)
% DATABASE_MAHASISWA_FISIKA MATLAB code for Database_Mahasiswa_Fisika.fig
%      DATABASE_MAHASISWA_FISIKA, by itself, creates a new DATABASE_MAHASISWA_FISIKA or raises the existing
%      singleton*.
%
%      H = DATABASE_MAHASISWA_FISIKA returns the handle to a new DATABASE_MAHASISWA_FISIKA or the handle to
%      the existing singleton*.
%
%      DATABASE_MAHASISWA_FISIKA('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in DATABASE_MAHASISWA_FISIKA.M with the given input arguments.
%
%      DATABASE_MAHASISWA_FISIKA('Property','Value',...) creates a new DATABASE_MAHASISWA_FISIKA or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Database_Mahasiswa_Fisika_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Database_Mahasiswa_Fisika_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help Database_Mahasiswa_Fisika

% Last Modified by GUIDE v2.5 16-Nov-2016 17:24:16

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
    'gui_Singleton',  gui_Singleton, ...
    'gui_OpeningFcn', @Database_Mahasiswa_Fisika_OpeningFcn, ...
    'gui_OutputFcn',  @Database_Mahasiswa_Fisika_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 Database_Mahasiswa_Fisika is made visible.
function Database_Mahasiswa_Fisika_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to Database_Mahasiswa_Fisika (see VARARGIN)

% Choose default command line output for Database_Mahasiswa_Fisika
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);
movegui(hObject,'center');

% UIWAIT makes Database_Mahasiswa_Fisika wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = Database_Mahasiswa_Fisika_OutputFcn(hObject, eventdata, handles)
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
close;
guidata(Registrasi);

% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
close;
guidata(Status);

% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
close;
guidata(Database);

% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
close;

2. Menu Registrasi Mahasiswa

function varargout = Registrasi(varargin)
% REGISTRASI MATLAB code for Registrasi.fig
%      REGISTRASI, by itself, creates a new REGISTRASI or raises the existing
%      singleton*.
%
%      H = REGISTRASI returns the handle to a new REGISTRASI or the handle to
%      the existing singleton*.
%
%      REGISTRASI('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in REGISTRASI.M with the given input arguments.
%
%      REGISTRASI('Property','Value',...) creates a new REGISTRASI or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Registrasi_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Registrasi_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help Registrasi

% Last Modified by GUIDE v2.5 16-Nov-2016 18:36:46

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
    'gui_Singleton',  gui_Singleton, ...
    'gui_OpeningFcn', @Registrasi_OpeningFcn, ...
    'gui_OutputFcn',  @Registrasi_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 Registrasi is made visible.
function Registrasi_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to Registrasi (see VARARGIN)

% Choose default command line output for Registrasi
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);
movegui(hObject,'center');

% UIWAIT makes Registrasi wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = Registrasi_OutputFcn(hObject, eventdata, handles)
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;



function edit1_Callback(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit1 as text
%        str2double(get(hObject,'String')) returns contents of edit1 as a double


% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit2_Callback(hObject, eventdata, handles)
% hObject    handle to edit2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit2 as text
%        str2double(get(hObject,'String')) returns contents of edit2 as a double


% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit3_Callback(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit3 as text
%        str2double(get(hObject,'String')) returns contents of edit3 as a double


% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit4_Callback(hObject, eventdata, handles)
% hObject    handle to edit4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit4 as text
%        str2double(get(hObject,'String')) returns contents of edit4 as a double


% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit5_Callback(hObject, eventdata, handles)
% hObject    handle to edit5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit5 as text
%        str2double(get(hObject,'String')) returns contents of edit5 as a double


% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in radiobutton1.
function radiobutton1_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton1
set(hObject,'Value',1)
set(handles.radiobutton2,'Value',0)

% --- Executes on button press in radiobutton2.
function radiobutton2_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton2
set(hObject,'Value',1)
set(handles.radiobutton1,'Value',0)


% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu1


% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in pushbutton3.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
filename = 'Database Mahasiswa Fisika.xlsx';
no = xlsread(filename,'B:B');

nim = get(handles.edit1,'String');
nama = get(handles.edit2,'String');
laki2 = get(handles.radiobutton1,'Value');
perempuan = get(handles.radiobutton2,'Value');
if laki2 == 1
    jenis_kel = 'Laki-laki';
elseif perempuan == 1
    jenis_kel = 'Perempuan';
end
ttl = get(handles.edit3,'String');
alamat = get(handles.edit4,'String');
tahun_masuk = get(handles.edit5,'String');
minat = get(handles.popupmenu1,'Value');
if minat == 1
    bidang_min = 'Elektronika dan Instrumentasi';
elseif minat == 2
    bidang_min = 'Geofisika';
elseif minat == 3
    bidang_min = 'Fisika Material';
elseif minat == 4
    bidang_min = 'Fisika Radiasi';
elseif minat == 5
    bidang_min = 'Fisika Medik';
end

if numel(no) == 0
    no = 1;
    range = 'B5';
else
    no = numel(no)+1;
    range = strcat(['B',num2str(no+4)]);
end

if isempty(nim)
    warndlg('NIM tidak boleh kosong','Warning');
elseif isempty(nama)
    warndlg('Nama tidak boleh kosong','Warning');
else
    data = table(cell({no,nim,nama,jenis_kel,ttl,alamat,tahun_masuk,bidang_min}));
    writetable(data,filename,'Sheet',1,'Range',range,'WriteVariableNames',false)
    msgbox(strcat(['Data Mahasiswa No. ',num2str(no),' berhasil disimpan']),'Message')
end

% --- Executes on button press in pushbutton3.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
set(handles.edit1,'String','')
set(handles.edit2,'String','')
set(handles.edit3,'String','')
set(handles.edit4,'String','')
set(handles.edit5,'String','')

set(handles.radiobutton1,'Value',1)
set(handles.radiobutton2,'Value',0)

set(handles.popupmenu1,'Value',1)

% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
close;
guidata(Database_Mahasiswa_Fisika);

3. Menu Status Mahasiswa

function varargout = Status(varargin)
% STATUS MATLAB code for Status.fig
%      STATUS, by itself, creates a new STATUS or raises the existing
%      singleton*.
%
%      H = STATUS returns the handle to a new STATUS or the handle to
%      the existing singleton*.
%
%      STATUS('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in STATUS.M with the given input arguments.
%
%      STATUS('Property','Value',...) creates a new STATUS or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Status_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Status_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help Status

% Last Modified by GUIDE v2.5 16-Nov-2016 20:00:18

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
    'gui_Singleton',  gui_Singleton, ...
    'gui_OpeningFcn', @Status_OpeningFcn, ...
    'gui_OutputFcn',  @Status_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 Status is made visible.
function Status_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to Status (see VARARGIN)

% Choose default command line output for Status
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);
movegui(hObject,'center');

% UIWAIT makes Status wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = Status_OutputFcn(hObject, eventdata, handles)
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;



function edit1_Callback(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit1 as text
%        str2double(get(hObject,'String')) returns contents of edit1 as a double


% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
try
    filename = 'Database Mahasiswa Fisika.xlsx';
    [~,~,data] = xlsread(filename);
    no_base = (data(:,2));
    
    k = 1;
    while k<=numel(no_base)
        no_base{k} = num2str(no_base{k});
        k = k+1;
    end
    
    no_search = get(handles.edit1,'String');
    no_res = strcmpi(no_base,no_search);
    
    [a,~] = find(no_res);
    nama = data{a,3};
    jenis_kel = data{a,4};
    ttl = data{a,5};
    alamat = data{a,6};
    tahun_masuk = data{a,7};
    bidang_min = data{a,8};
    
    set(handles.edit2,'String',nama)
    set(handles.edit2,'Enable','inactive')
    set(handles.edit3,'String',jenis_kel)
    set(handles.edit3,'Enable','inactive')
    set(handles.edit4,'String',ttl)
    set(handles.edit4,'Enable','inactive')
    set(handles.edit5,'String',alamat)
    set(handles.edit5,'Enable','inactive')
    set(handles.edit6,'String',tahun_masuk)
    set(handles.edit6,'Enable','inactive')
    set(handles.edit7,'String',bidang_min)
    set(handles.edit7,'Enable','inactive')
    
catch
    warndlg('NIM Mahasiswa Tidak Ditemukan','Warning');
    set(handles.edit2,'String','')
    set(handles.edit2,'Enable','off')
    set(handles.edit3,'String','')
    set(handles.edit3,'Enable','off')
    set(handles.edit4,'String','')
    set(handles.edit4,'Enable','off')
    set(handles.edit5,'String','')
    set(handles.edit5,'Enable','off')
    set(handles.edit6,'String','')
    set(handles.edit6,'Enable','off')
    set(handles.edit7,'String','')
    set(handles.edit7,'Enable','off')
end

% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
set(handles.edit1,'String','')
set(handles.edit2,'String','')
set(handles.edit3,'String','')
set(handles.edit4,'String','')
set(handles.edit5,'String','')
set(handles.edit6,'String','')
set(handles.edit7,'String','')

% --- Executes on button press in pushbutton2.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
close;
guidata(Database_Mahasiswa_Fisika);


function edit2_Callback(hObject, eventdata, handles)
% hObject    handle to edit2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit2 as text
%        str2double(get(hObject,'String')) returns contents of edit2 as a double


% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit3_Callback(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit3 as text
%        str2double(get(hObject,'String')) returns contents of edit3 as a double


% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit4_Callback(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit3 as text
%        str2double(get(hObject,'String')) returns contents of edit3 as a double


% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit5_Callback(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit3 as text
%        str2double(get(hObject,'String')) returns contents of edit3 as a double


% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit6_Callback(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit3 as text
%        str2double(get(hObject,'String')) returns contents of edit3 as a double


% --- Executes during object creation, after setting all properties.
function edit6_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit7_Callback(hObject, eventdata, handles)
% hObject    handle to edit7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit7 as text
%        str2double(get(hObject,'String')) returns contents of edit7 as a double


% --- Executes during object creation, after setting all properties.
function edit7_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

4. Menu Database Mahasiswa

function varargout = Database(varargin)
% DATABASE MATLAB code for Database.fig
%      DATABASE, by itself, creates a new DATABASE or raises the existing
%      singleton*.
%
%      H = DATABASE returns the handle to a new DATABASE or the handle to
%      the existing singleton*.
%
%      DATABASE('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in DATABASE.M with the given input arguments.
%
%      DATABASE('Property','Value',...) creates a new DATABASE or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Database_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Database_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help Database

% Last Modified by GUIDE v2.5 16-Nov-2016 20:46:13

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
    'gui_Singleton',  gui_Singleton, ...
    'gui_OpeningFcn', @Database_OpeningFcn, ...
    'gui_OutputFcn',  @Database_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 Database is made visible.
function Database_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to Database (see VARARGIN)

% Choose default command line output for Database
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);
movegui(hObject,'center');

% UIWAIT makes Database wait for user response (see UIRESUME)
% uiwait(handles.figure1);
filename = 'Database Mahasiswa Fisika.xlsx';
[~,~,data] = xlsread(filename);
no_base = (data(:,2));
k = 4;

while k<=numel(no_base)
    nim = data{k,2};
    nama = data{k,3};
    jenis_kel = data{k,4};
    ttl = data{k,5};
    if isnan(ttl)
        ttl = '';
    end
    alamat = data{k,6};
    if isnan(alamat)
        alamat = '';
    end
    tahun_masuk = data{k,7};
    if isnan(tahun_masuk)
        tahun_masuk = '';
    end
    bidang_min = data{k,8};
    data2(k-3,:) = {nim,nama,jenis_kel,ttl,alamat,tahun_masuk,bidang_min};
    k = k+1;
end
set(handles.uitable1,'Data',data2,'ForegroundColor',[0 0 0])

% --- Outputs from this function are returned to the command line.
function varargout = Database_OutputFcn(hObject, eventdata, handles)
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
close;
guidata(Database_Mahasiswa_Fisika);

Source code pada pemrograman matlab di atas dapat diunduh melalui laman berikut ini: Source Code

Posted on November 16, 2016, in Data mining, Pengenalan Matlab and tagged , , , , , , , , , , . Bookmark the permalink. 5 Comments.

  1. kalo sourcecode buat pidah dari satu gui ke gui lain gmana yah?

  2. materi yang sebelah mana yah?atau judulnya apa?

  3. ka boleh minta kontak linenya, saya mau bertanya tentang koneksi antara source code yang satu dengan lainnya

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: