Function Varargout

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 18

TUGAS ALGORITMA

DAN
PEMROGRAMAN
VOLUME BANGUN RUANG
DAN
GFARIK FUNGSI TRIGONOMETRI

OLEH

MEILINDA FAISOVI
140210101088

FKIP MTK
UNIVERSITAS JEMBER

VOLUME BANGUN RUANG


function varargout = guidetemplate0(varargin)
% GUIDETEMPLATE0 M-file for guidetemplate0.fig
%
GUIDETEMPLATE0, by itself, creates a new GUIDETEMPLATE0 or
raises the existing
%
singleton*.
%
%
H = GUIDETEMPLATE0 returns the handle to a new GUIDETEMPLATE0
or the handle to
%
the existing singleton*.
%
%
GUIDETEMPLATE0('CALLBACK',hObject,eventData,handles,...) calls
the local
%
function named CALLBACK in GUIDETEMPLATE0.M with the given
input arguments.
%
%
GUIDETEMPLATE0('Property','Value',...) creates a new
GUIDETEMPLATE0 or raises the
%
existing singleton*. Starting from the left, property value
pairs are
%
applied to the GUI before guidetemplate0_OpeningFunction gets
called. An
%
unrecognized property name or invalid value makes property
application
%
stop. All inputs are passed to guidetemplate0_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
% Copyright 2002-2003 The MathWorks, Inc.
% Edit the above text to modify the response to help guidetemplate0
% Last Modified by GUIDE v2.5 29-Mar-2015 11:16:43
% Begin initialization code - DO NOT
gui_Singleton = 1;
gui_State = struct('gui_Name',
'gui_Singleton',
'gui_OpeningFcn',
'gui_OutputFcn',
'gui_LayoutFcn',
'gui_Callback',

EDIT
mfilename, ...
gui_Singleton, ...
@guidetemplate0_OpeningFcn, ...
@guidetemplate0_OutputFcn, ...
[] , ...
[]);

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 guidetemplate0 is made visible.
function guidetemplate0_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 guidetemplate0 (see VARARGIN)
% Choose default command line output for guidetemplate0
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes guidetemplate0 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = guidetemplate0_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
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')
);
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
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')
);
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
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')
);
end

function edit6_Callback(hObject, eventdata, handles)


% hObject
handle to edit6 (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 edit6 as text
%
str2double(get(hObject,'String')) returns contents of edit6
as a double
% --- Executes during object creation, after setting all properties.
function edit6_CreateFcn(hObject, eventdata, handles)
% hObject
handle to edit6 (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

set(hObject,'BackgroundColor','white');

else

set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')
);
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
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')
);
end
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
myform=guidata(gcbo);
pilih=str2double(get(myform.edit1,'String'));
switch pilih
case 1
myform = guidata(gcbo);
s=str2double(get(myform.edit4,'string'));
Volume=s*s*s;
set(myform.edit8,'string',num2str(Volume));
case 2
myform = guidata(gcbo);
P=str2double(get(myform.edit4,'string'));
L=str2double(get(myform.edit5,'string'));

T=str2double(get(myform.edit6,'string'));
Volume=P*L*T;
set(myform.edit8,'string',num2str(Volume));
case 3
myform = guidata(gcbo);
r=str2double(get(myform.edit7,'string'));
t=str2double(get(myform.edit6,'string'));
Volume=pi*r*r*t;
set(myform.edit8,'string',num2str(Volume));
otherwise
set(myform.edit8,'string','FOKUSDONG')

end
% hObject
% eventdata
% handles

handle to pushbutton1 (see GCBO)


reserved - to be defined in a future version of MATLAB
structure with handles and user data (see GUIDATA)

% --- Executes on button press in pushbutton2.


function pushbutton2_Callback(hObject, eventdata, handles)
close;
% 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)
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
set(handles.edit8,'string', ' ' );
set(handles.edit1,'string', ' ' );
set(handles.edit4,'string', ' ' );
set(handles.edit5,'string', ' ' );
set(handles.edit6,'string', ' ' );
set(handles.edit7,'string', ' ' );
% 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)

function edit8_Callback(hObject, eventdata, handles)


% hObject
% eventdata
% handles

handle to edit8 (see GCBO)


reserved - to be defined in a future version of MATLAB
structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit8 as text


%
str2double(get(hObject,'String')) returns contents of edit8
as a double
% --- Executes during object creation, after setting all properties.
function edit8_CreateFcn(hObject, eventdata, handles)

% hObject
% eventdata
% handles
called

handle to edit8 (see GCBO)


reserved - to be defined in a future version of MATLAB
empty - handles not created until after all CreateFcns

% Hint: edit controls usually have a white background on Windows.


%
See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')
);
end

RUNNING

GFARIK FUNGSI TRIGONOMETRI


function varargout = tugasfix2(varargin)
% tugasfix2 M-file for tugasfix2.fig
%
tugasfix2, by itself, creates a new tugasfix2 or raises the
existing
%
singleton*.
%
%
H = tugasfix2 returns the handle to a new tugasfix2 or the
handle to
%
the existing singleton*.
%
%
tugasfix2('CALLBACK',hObject,eventData,handles,...) calls the
local
%
function named CALLBACK in tugasfix2.M with the given input
arguments.
%
%
tugasfix2('Property','Value',...) creates a new tugasfix2 or
raises the
%
existing singleton*. Starting from the left, property value
pairs are
%
applied to the GUI before tugasfix2_OpeningFunction gets
called. An
%
unrecognized property name or invalid value makes property
application
%
stop. All inputs are passed to tugasfix2_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
% Copyright 2002-2003 The MathWorks, Inc.
% Edit the above text to modify the response to help tugasfix2
% Last Modified by GUIDE v2.5 29-Mar-2015 12:44:47
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',
mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @tugasfix2_OpeningFcn, ...
'gui_OutputFcn', @tugasfix2_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 tugasfix2 is made visible.
function tugasfix2_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 tugasfix2 (see VARARGIN)
% Choose default command line output for tugasfix2
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes tugasfix2 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = tugasfix2_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
% handles
called

reserved - to be defined in a future version of MATLAB


empty - handles not created until after all CreateFcns

% Hint: edit controls usually have a white background on Windows.


%
See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')
);
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
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')
);
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
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')
);
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
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')
);
end

% --- Executes on button press in pushbutton1.


function pushbutton1_Callback(hObject, eventdata, handles)
myform=guidata(gcbo);
pilih=str2double(get(myform.edit1,'String'));
switch pilih
case 1
a=str2double(get(myform.edit2,'String'));
b=str2double(get(myform.edit3,'String'));
x=str2double(get(myform.edit4,'String'));
for i=1:361
c(i)=i-1;
y=a*(sin((b*x+c)*pi/180));
end
plot(c,y,'og');
xlabel('Sudut');
ylabel('Nilai');
title('GRAFIK FUNGSI SINUS');
grid on;
case 2
a=str2double(get(myform.edit2,'String'));
b=str2double(get(myform.edit3,'String'));
x=str2double(get(myform.edit4,'String'));
for i=1:361
c(i)=i-1;
y=a*(cos((b*x+c)*pi/180));
end
plot(c,y,'og');
xlabel('Sudut');
ylabel('Nilai');
title('GRAFIK FUNGSI COS');
grid on;
case 3
a=str2double(get(myform.edit2,'String'));
b=str2double(get(myform.edit3,'String'));
x=str2double(get(myform.edit4,'String'));
for i=1:361
c(i)=i-1;
y=a*(tan((b*x+c)*pi/180));
end
plot(c,y,'og');
xlabel('Sudut');
ylabel('Nilai');
title('GRAFIK FUNGSI TAN');
grid on;
otherwise
set(myform.edit1,'string','FOKUSDONG')
end
% 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)

% --- Executes on button press in pushbutton2.


function pushbutton2_Callback(hObject, eventdata, handles)
close;
% 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)

% --- Executes on button press in pushbutton3.


function pushbutton3_Callback(hObject, eventdata, handles)
myform=guidata(gcbo);
set(handles.edit1,'string', ' ' );
set(handles.edit2,'string', ' ' );
set(handles.edit3,'string', ' ' );
set(handles.edit4,'string', ' ' );
axes(handles.axes1);
plot(0);
% 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)

RUNNING

You might also like