Anda di halaman 1dari 19

TUGAS 1 PEMODELAN DAN SIMULASI SIMULASI GERAK LURUS BERATURAN (GLB)

DOSEN : RIANI LUBIS, S.T.,M.T

KELOMPOK :

Irfan Bustomi Armandani. F Guntur Sulaeman Nisa Yunita Yuli Yanti A

10107188 10107189 10107197 10107205 10107218

JURUSAN TEKNIK INFORMATIKA FAKULTAS TEKNIK DAN ILMU KOMPUTER UNIVERSITAS KOMPUTER INDONESIA

Daftar Isi
PENDAHULUAN ..................................................................................................................................................... 1 RUMUS GERAK LURUS BERATURAN ............................................................................................................................. 2 GRAFIK GERAK LURUS BERATURAN (GLB) .................................................................................................................... 2 SIMULASI ............................................................................................................................................................... 4 LANGKAH LANGKAH ........................................................................................................................................... 5 SOURCE CODE GERAK.M ........................................................................................................................................ 7 SCREEN SHOT GERAK.FIG (GUI)............................................................................................................................ 15

Pendahuluan
Konsep Fisika yang sering kita jumpai dalam kehidupan sehari-hari adalah gerak manusia berjalan, planet berputar, pohon tumbang. Seluruh alam semesta bergerak. Setiap gerak didefinisikan sebagai perubahan posisi relatif terhadap titik acuan tertentu. Namun dalam kehidupan sehari-hari kita sering menggunakan bumi (tanah) sebagai titik acuan umum Pengertian Jarak Dan Perpindahan - Jarak didefinisikan sebagai panjang seluruh lintasan yang dialami benda - Perpindahan adalah panjang lintasan lurus antara posisi awal dengan posisi akhir - Jarak hanya memiliki nilai sedangkan perpindahan memiliki nilai dan arah gerak. Untuk memperjelas perbedaan antara jarak dan perpindahan, diilustrasikan suatu benda bergerak 70 meter ke timur kemudian berbalik ke barat sejauh 30 meter. Jarak (distance) yang ditempuh benda di atas adalah 100 meter ditunjukkan oleh garis putus-putus, sedangkan perpindahannya (displacement) 40 meter, ditunjukkan garis sambung, ke arah timur.

Untuk menyelidiki apakah sebuah benda melakukan GLB atau tidak dapat digunakan sebuah alat yang disebut pewaktu ketik atau ticker timer dan hasil percobaannya

Rumus Gerak Lurus Beraturan


Seandainya gerak benda pada Gambar tersebut membutuhkan waktu 20 sekon, kelajuan orang tersebut adalah 5 m/s, sedangkan besar kecepatannya 2 m/s. Bagaimanakah hal ini diperoleh? Jarak (distance) yang ditempuh benda di atas adalah 100 meter ditunjukkan oleh garis putus-putus, jadi kelajuannya = jarak / waktu = 100 m / 20 = 5 m/s. sedangkan perpindahannya (displacement) 40 meter, ditunjukkan garis sambung, ke arah timur, jadi kecepatannya = perpindahan / waktu = 40 m / 20 s = 2 m/s. Dari ilustrasi tersebut, kita dapat merumuskannya :

v=
Dimana : v = Kecepatan(m/s) s = Perpindahan(m) t = Waktu(sekon)

atau

s = v.t

Grafik Gerak Lurus Beraturan (GLB)


Grafik Posisi terhadap Waktu Seorang pemain baseball berlari pada lintasan lurus dengan hasil pengukuran waktu dan posisi seperti tabel berikut :
Waktu 1 2 3 4 5 6 7 Posisi 10 12 14 16 18 20 22

Jika dijadikan diagram adalah sebagai berikut :

Simulasi
Simulasi ini dibuat dengan software Matlab yang diproduksi oleh Mathworks Corp. kami berusaha membuatnya dengan tools-tools yang ada pada matlab, kami menggunakan GUIDE (GUI Builder). Dalam modul ini terdapat beberapa komponen yaitu: 1. Komponen Text 2. Komponen Edit yang jumlahnya 12, diantaranya adalah: a. 2 edit untuk input data, dan b. 10 edit untuk hasil 3. 1 Komponen Panel 4. 2 Komponen Tombol a. Tombol Hitung b. Tombol Grafik 5. 2 Komponen Axes a. Axes untuk Grafik 2 dimensi b. Axes untuk Grafik 3 dimensi

Langkah Langkah
Dalam kasus ini kita membuat suatu simulasi dengan bantuan MATLAB terdapat 3 file yaitu: 1. gerak.m Berisi tentang source code yang digunakan dalam pembuatan simulasi 2. gerak.fig menampilkan interface / GUI (Graphical User Interface) seperti hasil perhitungan dan grafik. 3. gerak.asv Nah, untuk menjalankan simulasi ini ada hal yang harus dilakukan terlebih dahulu yaitu:

1. Buka Matlab Simulink terlebih dahulu 2. Setelah itu, dibagian pojok kiri bawah terdapat tombol Start versi Matlab

3. Lalu pilih MATLAB

4. Lalu akan muncul dialog seperti berikut

5. Bila file belum ada dalam daftar klik tombol Browse dan pilih file yang akan dibuka dengan extension file .fig

Program ini disertakan ke dalam CD bila ingin membukanya double klik file gerak.fig maka akan muncul window Matlab, disebelah kiri terdapat panel Current Directory

Lalu pilih file gerak.fig maka akan muncul Program Simulasi Gerak Lurus Beraturan

Source Code gerak.m


Awal Code
function varargout = gerak(varargin) % GERAK M-file for gerak.fig % GERAK, by itself, creates a new GERAK or raises the existing % singleton*. % % H = GERAK returns the handle to a new GERAK or the handle to % the existing singleton*. % % GERAK('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in GERAK.M with the given input arguments. % % GERAK('Property','Value',...) creates a new GERAK or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before gerak_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to gerak_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 gerak % Last Modified by GUIDE v2.5 27-Oct-2009 09:01:19 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; mfilename, ... gui_State = struct('gui_Name', 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @gerak_OpeningFcn, ... 'gui_OutputFcn', @gerak_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 gerak is made visible. function gerak_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn.

% % % %

hObject eventdata handles varargin

handle to figure reserved - to be defined in a future version of MATLAB structure with handles and user data (see GUIDATA) command line arguments to gerak (see VARARGIN)

% Choose default command line output for gerak handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes gerak wait for user response (see UIRESUME) % uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line. function varargout = gerak_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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end

function edit2_Callback(hObject, eventdata, handles) % hObject handle to edit2 (see GCBO)

% eventdata % handles

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

% double

str2double(get(hObject,'String')) returns contents of edit4 as a

% --- 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 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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); 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

10

% --- 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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end

function EA1_Callback(hObject, eventdata, handles) % hObject handle to EA1 (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 EA1 as text % str2double(get(hObject,'String')) returns contents of EA1 as a double

% --- Executes during object creation, after setting all properties. function EA1_CreateFcn(hObject, eventdata, handles) % hObject handle to EA1 (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 edit8_Callback(hObject, eventdata, handles) % hObject handle to edit8 (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 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 handle to edit8 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB

11

% 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 edit9_Callback(hObject, eventdata, handles) % hObject handle to edit9 (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 edit9 as text % str2double(get(hObject,'String')) returns contents of edit9 as a double

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

% --- Executes during object creation, after setting all properties. function edit10_CreateFcn(hObject, eventdata, handles) % hObject handle to edit10 (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.

12

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end

function edit12_Callback(hObject, eventdata, handles) % hObject handle to edit12 (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 edit12 as text % str2double(get(hObject,'String')) returns contents of edit12 as a double

% --- Executes during object creation, after setting all properties. function edit12_CreateFcn(hObject, eventdata, handles) % hObject handle to edit12 (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 pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) myform = guidata(gcbo); mobila=str2double(get(myform.edit1,'string')); mobilb=str2double(get(myform.edit2,'string')); menita=mobila*0.2; menitb=mobila*0.4; menitc=mobila*0.6; menitd=mobila*0.8; menite=mobila; menitf=mobilb*0.2; menitg=mobilb*0.4; menith=mobilb*0.6; meniti=mobilb*0.8; menitj=mobilb; set(myform.edit3,'string',num2str(menita)); set(myform.edit4,'string',num2str(menitb)); set(myform.edit5,'string',num2str(menitc)); set(myform.edit6,'string',num2str(menitd)); set(myform.EA1,'string',num2str(menite)); set(myform.edit8,'string',num2str(menitf)); set(myform.edit9,'string',num2str(menitg)); set(myform.edit10,'string',num2str(menith)); set(myform.edit11,'string',num2str(meniti));

13

set(myform.edit12,'string',num2str(menitj)); % 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) myform = guidata(gcbo); mobila=str2double(get(myform.edit1,'string')); mobilb=str2double(get(myform.edit2,'string')); menita=mobila*0.2; menitb=mobila*0.4; menitc=mobila*0.6; menitd=mobila*0.8; menite=mobila; menitf=mobilb*0.2; menitg=mobilb*0.4; menith=mobilb*0.6; meniti=mobilb*0.8; menitj=mobilb; interval=menitb-menita; interval2=menitg-menitf; x=menita:interval:menite; y=menitf:interval2:menitj; grafikmobila=[(menita) (menitb) (menitc) (menitd) (menite);(menitf) (menitg) (menith) (meniti) (menitj)]; grafikmobilb=[(menitf) (menitg) (menith) (meniti) (menitj)]; axes(handles.grafik); bar(grafikmobila,'group') axes(handles.grafik2); bar3(grafikmobila,'group')

% hObject % eventdata % handles

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

Akhir Dari Code

14

Screen Shot gerak.fig (GUI)


1. Tampilan dari simulasi

2. Input Data

Input harus angka

15

3. Lalu klik tombol Hitung

4. Maka akan muncul hasilnya

5. Bila ingin melihat grafiknya maka klik tombol Grafik

6. Hasil dari grafik berupa grafik batang

16

7. Hasil keseluruhan

17