Nim : 60400118035
b. Agar tombol buat grafik dapat berfungsi, klik buat grafik lalu pilih view
callback lalu klik callback dan akan muncul ke script
Muncul ke script dan tambahkan fungsi persamaan di file script pada baris
81,94, 107, 140
Line 81:
set(handles.radiobutton2,'value',0);
pilih=1
handles.pilih=pilih;
guidata(hObject,handles)
Line 94:
set(handles.radiobutton1,'value',0);
pilih=2
handles.pilih=pilih;
guidata(hObject,handles)
Line 107
indeks=get(handles.eksekusi,'value');%mengambil nilai
if indeks==1 %jika menekan 1
T=1; %maka T=1
else if indeks==2 %jika menekan 2
T=2; %maka T=2, dst
else if indeks==3
T=3;
else if indeks==4
T=4;
end
end
end
end
A=str2num(get(handles.edit1,'string'));
r=str2num(get(handles.edit1,'string'));
x=-10:0.1:10; %membangkitkan sumbu-x
pilih=handles.pilih
switch handles.pilih
case 1 %jika radiobutton1 yang ditekan
y=A*sin(T*x*r); %maka menghitung nilai sin
case 2 %jika radiobutton2 yang ditekan
y=A*cos(T*x*r); %maka menghitung nilai cos
end
axes(handles.axes1);
a=0; %membuat garis sumbu_x dan sumbu_y
plot(x,y,'r',a,x,'b',x,a,'b');
grid on
Line 140:
Hasil scriptnya:
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State,
varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
Muncul ke script dan tambahkan fungsi persamaan di file script pada baris
81, 107, 133, 182, dan 190
Line 81:
F=str2num(get(handles.edit1,'String'));
handles.F=F;
guidata(hObject,handles)
Line 107
m=str2num(get(handles.edit2,'String'));
handles.m=m;
guidata(hObject,handles);
Line 133
t=str2num(get(handles.edit3,'String'));
handles.t=t;
guidata(hObject,handles);
Line 159
v=str2num(get(handles.edit4,'String'));
handles.v=v;
guidata(hObject,handles);
Line 231
F=handles.F;
m=handles.m;
v=handles.v;
t=handles.t;
I=F*t;
p=m*v;
set(handles.edit5,'string',I);
set(handles.edit6,'string',p);
Line 245
close
c. Pilih Run. Lalu masukkan nilai Gaya=40, Massa=25, t=15, v=17 lalu klik Hasil
Hasil scriptnya:
function varargout = untitled1(varargin)
% UNTITLED1 M-file for untitled1.fig
% UNTITLED1, by itself, creates a new UNTITLED1 or raises
the existing
% singleton*.
%
% H = UNTITLED1 returns the handle to a new UNTITLED1 or
the handle to
% the existing singleton*.
%
% UNTITLED1('CALLBACK',hObject,eventData,handles,...)
calls the local
% function named CALLBACK in UNTITLED1.M with the given
input arguments.
%
% UNTITLED1('Property','Value',...) creates a new
UNTITLED1 or raises the
% existing singleton*. Starting from the left, property
value pairs are
% applied to the GUI before untitled1_OpeningFcn gets
called. An
% unrecognized property name or invalid value makes
property application
% stop. All inputs are passed to untitled1_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
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State,
varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
Muncul ke script dan tambahkan fungsi persamaan di file script pada baris
81, 107, 133, 182, dan 190
Line 81:
ips1=str2num(get(handles.edit1,'String'));
handles.ips1=ips1;
guidata(hObject,handles)
Line 107:
ips2=str2num(get(handles.edit2,'String'));
handles.ips2=ips2;
guidata(hObject,handles)
Line 133:
ips3=str2num(get(handles.edit3,'String'));
handles.ips3=ips3;
guidata(hObject,handles)
Line 182:
ips1=handles.ips1;
ips2=handles.ips2;
ips3=handles.ips3;
ipk=(ips1+ips2+ips3)/3;
set(handles.edit4,'String',ipk)
Line 190
close
c. Pilih Run. Lalu masukkan nilai IPS 1, IPS 2, dan IPS 3 kemudian Klik Hasilnya
Hasil scriptnya:
function varargout = untitled(varargin)
% UNTITLED M-file for untitled.fig
% UNTITLED, by itself, creates a new UNTITLED or raises
the existing
% singleton*.
%
% H = UNTITLED returns the handle to a new UNTITLED or
the handle to
% the existing singleton*.
%
% UNTITLED('CALLBACK',hObject,eventData,handles,...)
calls the local
% function named CALLBACK in UNTITLED.M with the given
input arguments.
%
% UNTITLED('Property','Value',...) creates a new UNTITLED
or raises the
% existing singleton*. Starting from the left, property
value pairs are
% applied to the GUI before untitled_OpeningFcn gets
called. An
% unrecognized property name or invalid value makes
property application
% stop. All inputs are passed to untitled_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
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State,
varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
Muncul ke script dan tambahkan fungsi persamaan di file script pada baris
81
c. Pilih Run. Lalu masukkan Nilai A=10, t=5, dan T=4
Hasil scriptnya:
function varargout = GELOMBANGBERJALAN(varargin)
% GELOMBANGBERJALAN MATLAB code for GELOMBANGBERJALAN.fig
% GELOMBANGBERJALAN, by itself, creates a new
GELOMBANGBERJALAN or raises the existing
% singleton*.
%
% H = GELOMBANGBERJALAN returns the handle to a new
GELOMBANGBERJALAN or the handle to
% the existing singleton*.
%
%
GELOMBANGBERJALAN('CALLBACK',hObject,eventData,handles,...)
calls the local
% function named CALLBACK in GELOMBANGBERJALAN.M with the
given input arguments.
%
% GELOMBANGBERJALAN('Property','Value',...) creates a new
GELOMBANGBERJALAN or raises the
% existing singleton*. Starting from the left, property
value pairs are
% applied to the GUI before GELOMBANGBERJALAN_OpeningFcn
gets called. An
% unrecognized property name or invalid value makes
property application
% stop. All inputs are passed to
GELOMBANGBERJALAN_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
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State,
varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
Muncul ke script dan tambahkan fungsi persamaan di file script pada baris
81
c. Pilih Run. Lalu masukkan persamaan tan(x) kemudian klik Buat grafik untuk
menampilkan hasil eksekusinya
Hasil Script:
function varargout = NewEzplot(varargin)
% NEWEZPLOT M-file for NewEzplot.fig
% NEWEZPLOT, by itself, creates a new NEWEZPLOT or raises
the existing
% singleton*.
%
% H = NEWEZPLOT returns the handle to a new NEWEZPLOT or
the handle to
% the existing singleton*.
%
% NEWEZPLOT('CALLBACK',hObject,eventData,handles,...)
calls the local
% function named CALLBACK in NEWEZPLOT.M with the given
input arguments.
%
% NEWEZPLOT('Property','Value',...) creates a new
NEWEZPLOT or raises the
% existing singleton*. Starting from the left, property
value pairs are
% applied to the GUI before NewEzplot_OpeningFcn gets
called. An
% unrecognized property name or invalid value makes
property application
% stop. All inputs are passed to NewEzplot_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
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State,
varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State,
varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
fungsi = get(handles.persamaanku,'string');
b. Agar tombol buat grafik dapat berfungsi, klik buat grafik lalu pilih view
callback lalu klik callback dan akan muncul ke script
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State,
varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
fungsi = get(handles.persamaanku,'string');
c. Pilih Run. Lalu masukkan nilai suhu 30 lalu klik C>F dan keluar hasilnya
Hasil scriptnya:
function varargout = konversi(varargin)
% KONVERSI M-file for konversi.fig
% KONVERSI, by itself, creates a new KONVERSI or raises
the existing
% singleton*.
%
% H = KONVERSI returns the handle to a new KONVERSI or
the handle to
% the existing singleton*.
%
% KONVERSI('CALLBACK',hObject,eventData,handles,...)
calls the local
% function named CALLBACK in KONVERSI.M with the given
input arguments.
%
% KONVERSI('Property','Value',...) creates a new
KONVERSI or raises the
% existing singleton*. Starting from the left,
property value pairs are
% applied to the GUI before konversi_OpeningFcn gets
called. An
% unrecognized property name or invalid value makes
property application
% stop. All inputs are passed to konversi_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
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State,
varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT