Anda di halaman 1dari 9

ALGORITHM AND PROGRAMMING

Project

BY :

R. Rizky Zamhir Musthofa (4173121042)

BILLINGUAL PHYSICS EDUCATION’17

PHYSICS DEPARTMENT
FACULTY OF MATHEMATICS AND NATURAL SCIENCE
STATE UNIVERSITY OF MEDAN
2019
Based on the following sample program, each student chooses one physics topic and develops it
as a project assignment.
1. Algorithm Program

Start

Data

Perhitungan Panjang Gelombang


(Lambda)
𝜆 = 𝑣. 𝑇

Graph

Stop
Koding Non GUI
% Program pembelajaran project gelombang
clc;
pilih=0;
while pilih ~=2
disp('MENU GELOMBANG ');
disp('1. GELOMBANG TRANSVERSAL ');
disp('2. Keluar ');
pilih =input('Pilihan = ');
clc;
switch pilih
case 1
pil1=0;
while pil1~=4;
disp(' ');
disp('SUB MENU GELOMBANG TRANSVERSAL ');
disp('1. Teori GELOMBANG TRANSVERSAL ');
disp('2. Rumus GELOMBANG TRANSVERSAL ');
disp('3. Grafik GELOMBANG TRANSVERSAL ');
disp('4. Ke Menu ');
pil1=input('Pilihan = ');
clc;
switch pil1
case 1
disp('Uraian teori Gelombang Transversal ');
disp('Gelombang Transversal adalah gelombang yang arah
rambatannya tegak lurus dengan arah getarannya');
disp('a. Contoh Gelombang Transversal');
disp('1. Gelombang yang ada pada sebuah air yang dapat
terjadi apabila diberi gangguan');
disp('2. Gelombang pada ombak laut maupun gelombang yang
terjadi didalam danau');
disp('3. Gelombang yang terjadi pada sebuah tali yang
dimainkan');
disp('b. Karakteristik Gelombang Transversal');
disp('1. Arah rambatan gelombang transversal tegak lurus
terhadap arah getarannya');
disp('2. Bentuk dari gelombang transversal yaitu berbentuk
bukti dan lembah ');
disp('c. Komponen pada gelombang Transversal');
disp('1. .Simpangan 2. Puncak gelombang 3. Dasar gelombang 4.
Bukit gelombang 5. Lembah gelombang 6. Amplitude 7. Panjang gelombang 8.
Periode gelombang 9. Frekuensi gelombang 10. Cepat rambat gelombang ');
disp(' ');
jb=input('Tekan enter untuk lanjut','s');
case 2
disp(' Kalkulasi Gelombang ');
disp(' Hitung Panjang Gelombang');
v=input('Besar kecepatan rambat = ');
t=input('Periode = ');
lambda=v*t;
disp(['Jarak tempuh = ',num2str(lambda),' meter']);
disp(' ');
disp('Hitung besar kecepatan rambat ');
lambda=input('Panjang Gelombang = ');
t=input('Periode = ');
v=lambda/t;
disp(['Besar kecepatan rambat = ',num2str(v),' m/s']);
disp(' ');
jb=input('Tekan enter untuk lanjut','s');
case 3
disp(' Grafik Lambda vs T ');
v=15;
T=0:0.1:10;
Lambda=v*T;
plot(T,Lambda);
grid on;
xlabel('Periode');
ylabel('Lambda');
disp(' ');
jb=input('Tekan enter untuk lanjut ','s');
end
end
end
end

Koding GUI

function varargout = guimungkinfixyangini(varargin)


% GUIMUNGKINFIXYANGINI MATLAB code for guimungkinfixyangini.fig
% GUIMUNGKINFIXYANGINI, by itself, creates a new GUIMUNGKINFIXYANGINI or
raises the existing
% singleton*.
%
% H = GUIMUNGKINFIXYANGINI returns the handle to a new
GUIMUNGKINFIXYANGINI or the handle to
% the existing singleton*.
%
% GUIMUNGKINFIXYANGINI('CALLBACK',hObject,eventData,handles,...) calls
the local
% function named CALLBACK in GUIMUNGKINFIXYANGINI.M with the given input
arguments.
%
% GUIMUNGKINFIXYANGINI('Property','Value',...) creates a new
GUIMUNGKINFIXYANGINI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before guimungkinfixyangini_OpeningFcn gets called.
An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to guimungkinfixyangini_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 guimungkinfixyangini

% Last Modified by GUIDE v2.5 29-Nov-2019 20:22:24


% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @guimungkinfixyangini_OpeningFcn, ...
'gui_OutputFcn', @guimungkinfixyangini_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 guimungkinfixyangini is made visible.


function guimungkinfixyangini_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 guimungkinfixyangini (see VARARGIN)

% Choose default command line output for guimungkinfixyangini


handles.output = hObject;

% Update handles structure


guidata(hObject, handles);

% UIWAIT makes guimungkinfixyangini wait for user response (see UIRESUME)


% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = guimungkinfixyangini_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)
indeks=handles.indeks
if indeks==1
v=str2num(get(handles.edit1,'string'));
T=str2num(get(handles.edit2,'string'));
Lambda=v*T;
set(handles.edit3,'string');
axes(handles.axes1);
x=[0 v];
y=[0 Lambda];
plot(x,y);
title('Grafik v vs Lambda');
xlabel('cepat rambat gelombang');
ylabel('panjang gelombang');
grid on
else
end

% --- 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)
indeks=handles.indeks
if indeks==1
set(handles.edit1,'string','');
set(handles.edit2,'string','');
set(handles.edit3,'string','');
axes(handles.axes1);
plot(0);
else
end

% --- Executes on selection change in popupmenu1.


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

% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1


contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
indeks=get(handles.popupmenu1,'value')
handles.indeks=indeks
guidata(hObject,handles)
if indeks==1
set(handles,uipanel1,'visible','on');
set(handles,uipanel2,'visible','on');
set(handles,uipanel3,'visible','on');
set(handles,edit1,'visible','on');
set(handles,edit2,'visible','on');
set(handles,edit3,'visible','on');
set(handles,pushbutton1,'visible','on');
set(handles,pushbutton2,'visible','on');
set(handles,axes1,'visible','on');
else
end

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


function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: popupmenu 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 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 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
SCREEN CAPTURE

Anda mungkin juga menyukai