Vous êtes sur la page 1sur 10

TUGAS 3

FIA AMALIAH
60400114026
FISIKA B

Buat program GUI hitung trigonometri(log,exp, ln, akar, tan,


sin, cos, dan sebagainya !
Jawab:
Hasil eksekusi:

Program di M-File dengan GUI:


function varargout = nomor_1_Tugas_3(varargin)
% NOMOR_1_TUGAS_3 M-file for nomor_1_Tugas_3.fig
%
NOMOR_1_TUGAS_3, by itself, creates a new NOMOR_1_TUGAS_3 or raises the existing
%
singleton*.
%
%
H = NOMOR_1_TUGAS_3 returns the handle to a new NOMOR_1_TUGAS_3 or the handle to
%
the existing singleton*.
%
%
NOMOR_1_TUGAS_3('CALLBACK',hObject,eventData,handles,...) calls the local
%
function named CALLBACK in NOMOR_1_TUGAS_3.M with the given input arguments.
%
%
NOMOR_1_TUGAS_3('Property','Value',...) creates a new NOMOR_1_TUGAS_3 or raises
the
%
existing singleton*. Starting from the left, property value pairs are
%
applied to the GUI before nomor_1_Tugas_3_OpeningFcn gets called. An
%
unrecognized property name or invalid value makes property application

%
stop. All inputs are passed to nomor_1_Tugas_3_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 nomor_1_Tugas_3
% Last Modified by GUIDE v2.5 20-Apr-2016 21:57:36
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',
mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @nomor_1_Tugas_3_OpeningFcn, ...
'gui_OutputFcn', @nomor_1_Tugas_3_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 nomor_1_Tugas_3 is made visible.


function nomor_1_Tugas_3_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 nomor_1_Tugas_3 (see VARARGIN)
% Choose default command line output for nomor_1_Tugas_3
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes nomor_1_Tugas_3 wait for user response (see UIRESUME)
% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = nomor_1_Tugas_3_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 hasil_Callback(hObject, eventdata, handles)


% hObject
handle to hasil (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 hasil as text


%
str2double(get(hObject,'String')) returns contents of hasil as a double

% --- Executes during object creation, after setting all properties.


function hasil_CreateFcn(hObject, eventdata, handles)
% hObject
handle to hasil (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

% --- Executes on button press in pushbutton9.


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

% --- Executes on button press in graf.


function graf_Callback(hObject, eventdata, handles)
axes(handles.axes1);
a=get(handles.hasil,'string');
hold on
ezplot(a)
hold on
% hObject
handle to graf (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in tangen.


function tangen_Callback(hObject, eventdata, handles)
a=str2num(get(handles.hasil,'string'));
b=tan(pi/180*a)
set(handles.hasil,'string',num2str(b));
% hObject
handle to tangen (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in cosinus.


function cosinus_Callback(hObject, eventdata, handles)
a=str2num(get(handles.hasil,'string'));
b=cos(pi/180*a)
set(handles.hasil,'string',num2str(b));
% hObject
handle to cosinus (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in sinus.


function sinus_Callback(hObject, eventdata, handles)
a=str2num(get(handles.hasil,'string'));
b=sin(pi/180*a)
set(handles.hasil,'string',num2str(b));
% hObject
handle to sinus (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in logaritma.


function logaritma_Callback(hObject, eventdata, handles)
a=str2num(get(handles.hasil,'string'));
b=log10(a)
set(handles.hasil,'string',num2str(b));
% hObject
handle to logaritma (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in lognatural.


function lognatural_Callback(hObject, eventdata, handles)
a=str2num(get(handles.hasil,'string'));
b=log(a)
set(handles.hasil,'string',num2str(b));
% hObject
handle to lognatural (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in pangkat3.


function pangkat3_Callback(hObject, eventdata, handles)
a=str2num(get(handles.hasil,'string'));
b=a^3
set(handles.hasil,'string',num2str(b));
% hObject
handle to pangkat3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in pangkat2.


function pangkat2_Callback(hObject, eventdata, handles)
a=str2num(get(handles.hasil,'string'));
b=a^2
set(handles.hasil,'string',num2str(b));
% hObject
handle to pangkat2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in eksponensial.


function eksponensial_Callback(hObject, eventdata, handles)
a=str2num(get(handles.hasil,'string'));
b=exp(a)
set(handles.hasil,'string',num2str(b));
% hObject
handle to eksponensial (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in pangkatx.


function pangkatx_Callback(hObject, eventdata, handles)
a=get(handles.hasil,'string');
a=strcat(a,'^')

set(handles.hasil,'string',a);
% hObject
handle to pangkatx (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in akarpangkat2.


function akarpangkat2_Callback(hObject, eventdata, handles)
a=str2num(get(handles.hasil,'string'));
b=sqrt(a)
set(handles.hasil,'string',num2str(b));
% hObject
handle to akarpangkat2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in pi.


function pi_Callback(hObject, eventdata, handles)
a=get(handles.hasil,'string');
a=strcat(a,'22/7')
set(handles.hasil,'string',a);
% hObject
handle to pi (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in akarpangkatx.


function akarpangkatx_Callback(hObject, eventdata, handles)
a=get(handles.hasil,'string');
a=strcat('nthroot(',a,',',a,')')
set(handles.hasil,'string',a);
% hObject
handle to akarpangkatx (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in akarpangkat3.


function akarpangkat3_Callback(hObject, eventdata, handles)
a=str2num(get(handles.hasil,'string'));
b=nthroot(a,3)
set(handles.hasil,'string',num2str(b));
% hObject
handle to akarpangkat3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in invsin.


function invsin_Callback(hObject, eventdata, handles)
a=str2num(get(handles.hasil,'string'));
b=asind(a)
set(handles.hasil,'string',num2str(b));
% hObject
handle to invsin (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in invcos.


function invcos_Callback(hObject, eventdata, handles)
a=str2num(get(handles.hasil,'string'));
b=acosd(a)
set(handles.hasil,'string',num2str(b));
% hObject
handle to invcos (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in coshiper.


function coshiper_Callback(hObject, eventdata, handles)
a=str2num(get(handles.hasil,'string'));
b=cosh(a)
set(handles.hasil,'string',num2str(b));
% hObject
handle to coshiper (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in sinhiper.


function sinhiper_Callback(hObject, eventdata, handles)
a=str2num(get(handles.hasil,'string'));
b=sinh(a)
set(handles.hasil,'string',num2str(b));
% hObject
handle to sinhiper (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in invtan.


function invtan_Callback(hObject, eventdata, handles)
a=str2num(get(handles.hasil,'string'));
b=atand(a)
set(handles.hasil,'string',num2str(b));
% hObject
handle to invtan (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in tanhiper.


a=str2num(get(handles.hasil,'string'));
b=tanh(a)
set(handles.hasil,'string',num2str(b));
% hObject
handle to tanhiper (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in delapan.


function delapan_Callback(hObject, eventdata, handles)
a=get(handles.hasil,'string');
a=strcat(a,'8')
set(handles.hasil,'string',a);
% hObject
handle to delapan (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in sembilan.


function sembilan_Callback(hObject, eventdata, handles)
a=get(handles.hasil,'string');
a=strcat(a,'9')
set(handles.hasil,'string',a);
% hObject
handle to sembilan (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in penjumlahan.


function penjumlahan_Callback(hObject, eventdata, handles)
a=get(handles.hasil,'string');
a=strcat(a,'+')
set(handles.hasil,'string',a);
% hObject
handle to penjumlahan (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB

% handles

structure with handles and user data (see GUIDATA)

% --- Executes on button press in clear.


function clear_Callback(hObject, eventdata, handles)
a=char(' ');
set(handles.hasil,'string',a);
% hObject
handle to clear (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in exit.


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

% --- Executes on button press in lima.


function lima_Callback(hObject, eventdata, handles)
a=get(handles.hasil,'string');
a=strcat(a,'5')
set(handles.hasil,'string',a);
% hObject
handle to lima (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in enam.


function enam_Callback(hObject, eventdata, handles)
a=get(handles.hasil,'string');
a=strcat(a,'6')
set(handles.hasil,'string',a);
% hObject
handle to enam (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in Pengurangan.


function Pengurangan_Callback(hObject, eventdata, handles)
a=get(handles.hasil,'string');
a=strcat(a,'-')
set(handles.hasil,'string',a);
% hObject
handle to Pengurangan (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in perkalian.


function perkalian_Callback(hObject, eventdata, handles)
a=get(handles.hasil,'string');
a=strcat(a,'*')
set(handles.hasil,'string',a);
% hObject
handle to perkalian (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in empat.


function empat_Callback(hObject, eventdata, handles)
a=get(handles.hasil,'string');
a=strcat(a,'4')
set(handles.hasil,'string',a);
% hObject
handle to empat (see GCBO)

% eventdata
% handles

reserved - to be defined in a future version of MATLAB


structure with handles and user data (see GUIDATA)

% --- Executes on button press in dua.


function dua_Callback(hObject, eventdata, handles)
a=get(handles.hasil,'string');
a=strcat(a,'2')
set(handles.hasil,'string',a);
% hObject
handle to dua (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in tiga.


function tiga_Callback(hObject, eventdata, handles)
a=get(handles.hasil,'string');
a=strcat(a,'3')
set(handles.hasil,'string',a);
% hObject
handle to tiga (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in pembagian.


function pembagian_Callback(hObject, eventdata, handles)
a=get(handles.hasil,'string');
a=strcat(a,'/')
set(handles.hasil,'string',a);
% hObject
handle to pembagian (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in samadengan.


function samadengan_Callback(hObject, eventdata, handles)
a=get(handles.hasil,'string');
a=eval(a)
set(handles.hasil,'string',a);
% hObject
handle to samadengan (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in satu.


function satu_Callback(hObject, eventdata, handles)
a=get(handles.hasil,'string');
a=strcat(a,'1')
set(handles.hasil,'string',a);
% hObject
handle to satu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in nol.


function nol_Callback(hObject, eventdata, handles)
a=get(handles.hasil,'string');
a=strcat(a,'0')
set(handles.hasil,'string',a);
% hObject
handle to nol (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in koma.


function koma_Callback(hObject, eventdata, handles)

a=get(handles.hasil,'string');
a=strcat(a,'.')
set(handles.hasil,'string',a);
% hObject
handle to koma (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in tujuh.


function tujuh_Callback(hObject, eventdata, handles)
a=get(handles.hasil,'string');
a=strcat(a,'7')
set(handles.hasil,'string',a);
% hObject
handle to tujuh (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in bukakurung.


function bukakurung_Callback(hObject, eventdata, handles)
a=get(handles.hasil,'string');
a=strcat(a,'(')
set(handles.hasil,'string',a);
% hObject
handle to bukakurung (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in tutupkurung.


function tutupkurung_Callback(hObject, eventdata, handles)
a=get(handles.hasil,'string');
a=strcat(a,')')
set(handles.hasil,'string',a);
% hObject
handle to tutupkurung (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes on button press in pushbutton80.


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

% --- Executes on button press in pushbutton81.


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

% --- Executes on button press in pushbutton82.


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

% --- Executes on button press in pushbutton83.


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

% --- Executes on button press in pushbutton84.


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

% --- Executes on button press in radiobutton2.


function radiobutton2_Callback(hObject, eventdata, handles)
axes(handles.axes1);
valor=get(handles.hasil,'string');
hold on
ezplot(valor)
grid on
hold on
% 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

% --- Executes on button press in persen.


function persen_Callback(hObject, eventdata, handles)
a=str2num(get(handles.hasil,'string'));
b=1/100*(a)
set(handles.hasil,'string',num2str(b));
% hObject
handle to persen (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)

% --- Executes during object deletion, before destroying properties.


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