Pedoman untuk Pemrograman GUI Matlab
Perhatikan ! Yang berwarna kuning adalah pedoman pemrogramannya
1. Mendefinisikan masukan edit text
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
A=str2num(get(handles.edit1,'string'));
handles.A=A;
guidata(hObject, handles);
2. Perintah di Push Button
RUN
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)
A=handles.A;
B=handles.B;
C=handles.C;
D=A+B+C;
set(handles.edit4,'String',D);
RESET
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','');
plot(0); %Jika ada axes
3. Untuk menampilkan gambar dengan axes (harus .jpg) dan gambar harus 1 folder dengan program
function coba1_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 coba1 (see VARARGIN)
% Choose default command line output for coba1
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes coba1 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
handles.data1=imread('image049.jpg');
axes(handles.axes1)
imshow(handles.data1);
4. Untuk loading program lain (Misalnya : COVER.fig)
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
COVER;
5. Untuk menggambar grafik fungsi dengan axes
% --- 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)
T(1) = handles.T(1);
T(2) = handles.T(2);
T(3) = handles.T(3);
T(4) = handles.T(4);
T(5) = handles.T(5);
T(6) = handles.T(6);
T(7) = handles.T(7);
T(8) = handles.T(8);
T(9) = handles.T(9);
T(10) = handles.T(10);
% interval = handles.interval;
% Fk=handles.Fk;
% x=handles.x;
% t=handles.t;
T(1)
T(2)
T(3)
T(4)
T(5)
T(6)
T(7)
T(8)
T(9)
T(10)
% L={'0-10 detik' '11-20 detik' '21-30 detik' '31-40 detik' '41-50 detik' '51-60 detik' '61-70 detik' '71-80 detik' '81-90 detik' '91-100 detik'};
% disp(' silakan masukkan jumlah kapal berdasar interval waktu tunggu tertentu dibawah ini')
% for i=1:10
% % disp(L(i));
% % T(i)=input('silakan masukkan jumlah kapalnya =');
% end
%menghitung frekuensi relatif (Fr) dang menghitung frekuensi komulatif (Fk)
for j=1:10
Fr(j)=T(j)/200;
if j==1
Fk(j)=Fr(j);
else
Fk(j)=Fr(j)+Fk(j-1);
end
end
% T;
Fr
Fk
%membangkitkan waktu tunggu kapal dengan bilangan random
interval=[10 20 30 40 50 60 70 80 90 100];
% interval
% disp('anda ingin membangkitkan waktu tunggu kapal? (Y?N)');
% disp('tekan 1 untuk Yes dan 0 untuk No');
% W=input(' masukkan pilihan anda = ');
% while W==1
% x adalah bilangan random yang dibangkitkan oleh komputer
x=rand;
for k=1:10
if (x
break;
end
continue;
end
% k adalah index pendekatan Frekeunsi komulatif
% k;
t=interval(k-1)+((interval(k)-interval(k-1))/(Fk(k)-Fk(k-1)))*(x-Fk(k-1));
% disp('anda ingin membangkitkan waktu tunggu kapal lagi? (Y?N)');
% disp('tekan 1 untuk Yes dan 0 untuk No');
% W=input(' masukkan pilihan anda = ');
p = plot(interval,Fk);
xlabel ('Interval Waktu');
ylabel ('Frekuensi Kumulatif');
title ('Plot Grafik Waktu Tunggu Kapal');
axes(handles.axes1,p);
1 Response to "Pedoman untuk Pemrograman GUI Matlab"
Posting Komentar