Vivi Oktaviani Simulasi Peluru

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

NAMA : VIVI OKTAVIANI

NIM : 1804111638
JURUSAN : ILMU KELAUTAN
JADWAL PRAKTIKUM : SELASA/ SESI 2/ KELOMPOK 3
ASISTEN LAB : RIZKI AFANDI
function
varargout = VIVIOKTAVIANISIMULASIPELURU(varargin)
% VIVIOKTAVIANISIMULASIPELURU M-file for
VIVIOKTAVIANISIMULASIPELURU.fig
% VIVIOKTAVIANISIMULASIPELURU, by itself, creates a new
VIVIOKTAVIANISIMULASIPELURU or raises the existing
% singleton*.
%
% H = VIVIOKTAVIANISIMULASIPELURU returns the handle to a new
VIVIOKTAVIANISIMULASIPELURU or the handle to
% the existing singleton*.
%
%
VIVIOKTAVIANISIMULASIPELURU('CALLBACK',hObject,eventData,handles,.
..) calls the local
% function named CALLBACK in VIVIOKTAVIANISIMULASIPELURU.M
with the given input arguments.
%
% VIVIOKTAVIANISIMULASIPELURU('Property','Value',...) creates
a new VIVIOKTAVIANISIMULASIPELURU or raises the
% existing singleton*. Starting from the left, property
value pairs are
% applied to the GUI before
VIVIOKTAVIANISIMULASIPELURU_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property
application
% stop. All inputs are passed to
VIVIOKTAVIANISIMULASIPELURU_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


VIVIOKTAVIANISIMULASIPELURU

% Last Modified by GUIDE v2.5 05-May-2019 23:27:19

% Begin initialization code - DO NOT EDIT


gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn',
@VIVIOKTAVIANISIMULASIPELURU_OpeningFcn, ...
'gui_OutputFcn',
@VIVIOKTAVIANISIMULASIPELURU_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 VIVIOKTAVIANISIMULASIPELURU is made


visible.
function VIVIOKTAVIANISIMULASIPELURU_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 VIVIOKTAVIANISIMULASIPELURU
(see VARARGIN)
% Choose default command line output for
VIVIOKTAVIANISIMULASIPELURU
handles.output = hObject;

% Update handles structure


guidata(hObject, handles);

% UIWAIT makes VIVIOKTAVIANISIMULASIPELURU wait for user response


(see UIRESUME)
% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout =
VIVIOKTAVIANISIMULASIPELURU_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)
g=9.8;
Kecepatan=str2double(get(handles.edit1,'string'));
pilih=handles.pilih;
switch handles.pilih
case 1
vx=Kecepatan*cos((15)*pi()./180);
tmaks=vx./g;
ts=2*tmaks;
hmaks=((Kecepatan^2)*(sin((15)*pi()./180)).^2)./(2*g);
vy=Kecepatan*sin((15)*pi()./180);
s=vy*ts;
case 2
vx=Kecepatan*cos((30)*pi()./180);
tmaks=vx./g;
ts=2*tmaks;
hmaks=((Kecepatan^2)*(sin((30)*pi()./180)).^2)./(2*g);
vy=Kecepatan*sin((30)*pi()./180);
s=vy*ts;
case 3
vx=Kecepatan*cos((45)*pi()./180);
tmaks=vx./g;
ts=2*tmaks;
hmaks=((Kecepatan^2)*(sin((45)*pi()./180)).^2)./(2*g);
vy=Kecepatan*sin((45)*pi()./180);
s=vy*ts;
case 4
vx=Kecepatan*cos((60)*pi()./180);
tmaks=vx./g;
ts=2*tmaks;
hmaks=((Kecepatan^2)*(sin((60)*pi()./180)).^2)./(2*g);
vy=Kecepatan*sin((60)*pi()./180);
s=vy*ts;
end
set(handles.edit2,'string',hmaks);
set(handles.edit3,'string',s);
set(handles.edit4,'string',ts);

% --- 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)
g=9.8;
Kecepatan=str2double(get(handles.edit1,'string'));
pilih=handles.pilih;
switch handles.pilih
case 1
vx=Kecepatan*cos((15)*pi()./180);
tmaks=vx./g;
ts=2*tmaks;
hmaks=((Kecepatan^2)*(sin((15)*pi()./180)).^2)./(2*g);
vy=Kecepatan*sin((15)*pi()./180);
s=vy*ts;
tx=0:01:ts;
h=vx*tx-0.5*g*tx.^2;
axes(handles.axes1);
plot(tx,h);

case 2
vx=Kecepatan*cos((30)*pi()./180);
tmaks=vx./g;
ts=2*tmaks;
hmaks=((Kecepatan^2)*(sin((30)*pi()./180)).^2)./(2*g);
vy=Kecepatan*sin((30)*pi()./180);
s=vy*ts;
tx=0:01:ts;
h=vx*tx-0.5*g*tx.^2;
axes(handles.axes1);
plot(tx,h);
case 3
vx=Kecepatan*cos((45)*pi()./180);
tmaks=vx./g;
ts=2*tmaks;
hmaks=((Kecepatan^2)*(sin((45)*pi()./180)).^2)./(2*g);
vy=Kecepatan*sin((45)*pi()./180);
s=vy*ts;
case 4
vx=Kecepatan*cos((60)*pi()./180);
tmaks=vx./g;
ts=2*tmaks;
hmaks=((Kecepatan^2)*(sin((60)*pi()./180)).^2)./(2*g);
vy=Kecepatan*sin((60)*pi()./180);
s=vy*ts;
tx=0:01:ts;
h=vx*tx-0.5*g*tx.^2;
axes(handles.axes1);
plot(tx,h);
end
xlabel('waktu (s)');ylabel('tinggi (m)');
legend('SIMULASI PELURU OLEH VIVI OKTAVIANI');
grid on
set(handles.edit2,'string',hmaks);
set(handles.edit3,'string',s);
set(handles.edit4,'string',ts);

% --- 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)
set(handles.edit2,'string',0);
set(handles.edit3,'string',0);
set(handles.edit4,'string',0);
set(handles.checkbox1,'value',0);
set(handles.radiobutton1,'value',0);
set(handles.radiobutton2,'value',0);
set(handles.radiobutton3,'value',0);
set(handles.radiobutton4,'value',0);
axes(handles.axes1);
plot(0,0);

% --- 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

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 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 checkbox1.


function checkbox1_Callback(hObject, eventdata, handles)
% hObject handle to checkbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of
MATLAB
% handles structure with handles and user data (see GUIDATA)
nilai=get(handles.checkbox1,'value');
if nilai==1
grid on;
else
grid off;
end
% Hint: get(hObject,'Value') returns toggle state of checkbox1

% --- 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)
set(handles.radiobutton2,'value',0);
set(handles.radiobutton3,'value',0);
set(handles.radiobutton4,'value',0);
pilih=1;
handles.pilih=pilih;
guidata(hObject,handles);

% Hint: get(hObject,'Value') returns toggle state of radiobutton1

% --- 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)
set(handles.radiobutton1,'value',0);
set(handles.radiobutton3,'value',0);
set(handles.radiobutton4,'value',0);
pilih=2;
handles.pilih=pilih;
guidata(hObject,handles);
% Hint: get(hObject,'Value') returns toggle state of radiobutton2

% --- Executes on button press in radiobutton3.


function radiobutton3_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of
MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.radiobutton1,'value',0);
set(handles.radiobutton2,'value',0);
set(handles.radiobutton4,'value',0);
pilih=3;
handles.pilih=pilih;
guidata(hObject,handles);
% Hint: get(hObject,'Value') returns toggle state of radiobutton3

% --- Executes on button press in radiobutton4.


function radiobutton4_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of
MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.radiobutton1,'value',0);
set(handles.radiobutton2,'value',0);
set(handles.radiobutton3,'value',0);
pilih=4;
handles.pilih=pilih;
guidata(hObject,handles);
% Hint: get(hObject,'Value') returns toggle state of radiobutton4

You might also like