Вы находитесь на странице: 1из 8

Perancangan interface program menghitung luas dan keliling lingkaran

Program yang digunakan:


function varargout = KELILING_LUAS(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @KELILING_LUAS_OpeningFcn,
...
'gui_OutputFcn', @KELILING_LUAS_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

function KELILING_LUAS_OpeningFcn(hObject, eventdata, handles,


varargin)
handles.output = hObject;
guidata(hObject, handles);

function varargout = KELILING_LUAS_OutputFcn(hObject, eventdata,


handles)
varargout{1} = handles.output;

function btn_hitung_luas_Callback(hObject, eventdata, handles)


jari=handles.txt_jari;
luas=pi*jari*jari;
set(handles.txt_luas, 'string', jari);

function btn_hitung_keliling_Callback(hObject, eventdata, handles)


jari=handles.txt_jari;
luas=pi*jari*jari;
set(handles.txt_luas, 'string', jari);

function txt_jari_Callback(hObject, eventdata, handles)


jari=str2num(get(handles.txt_jari, 'String'));
handles.jari=jari;
guidata(hObject, handles)

function txt_jari_CreateFcn(hObject, eventdata, handles)


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

function edit2_Callback(hObject, eventdata, handles)

function edit2_CreateFcn(hObject, eventdata, handles)


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

function edit3_Callback(hObject, eventdata, handles)

function edit3_CreateFcn(hObject, eventdata, handles)


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

function keluar_Callback(hObject, eventdata, handles)


close;

Eksekusi program dengan contoh pemasukan nilai jari-jari:


Perancangan interface program menghitung panambahan, pengurangan,
perkalian dan pembagian

Program yang digunakan:


function varargout = Hitungan(varargin)

% Begin initialization code - DO NOT EDIT


gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Hitungan_OpeningFcn, ...
'gui_OutputFcn', @Hitungan_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

% --- Executes just before Hitungan is made visible.


function Hitungan_OpeningFcn(hObject, eventdata, handles,
varargin)
handles.output = hObject;
guidata(hObject, handles);

% --- Outputs from this function are returned to the command line.
function varargout = Hitungan_OutputFcn(hObject, eventdata,
handles)
varargout{1} = handles.output;

% --- Executes on button press in btn_keluar.


function btn_keluar_Callback(hObject, eventdata, handles)
close;

% --- Executes on button press in btn_kurang.


function btn_kurang_Callback(hObject, eventdata, handles)
bil_1=handles.bil_1;
bil_2=handles.bil_2;
bil_3=handles.bil_3;
hasil=bil_1-bil_2-bil_3;
set(handles.hasil_kurang, 'string', hasil);

% --- Executes on button press in btn_tambah.


function btn_tambah_Callback(hObject, eventdata, handles)
bil_1=handles.bil_1;
bil_2=handles.bil_2;
bil_3=handles.bil_3;
hasil=bil_1+bil_2+bil_3;
set(handles.hasil_tambah, 'string', hasil);

function edit1_Callback(hObject, eventdata, handles)


% --- Executes during object creation, after setting all
properties.
function edit1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit2_Callback(hObject, eventdata, handles)


% --- Executes during object creation, after setting all
properties.
function edit2_CreateFcn(hObject, eventdata, handles)

% See ISPC and COMPUTER.


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

function edit3_Callback(hObject, eventdata, handles)


% --- Executes during object creation, after setting all
properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function bilangan1_Callback(hObject, eventdata, handles)


bil_1=str2num(get(handles.bilangan1, 'String'));
handles.bil_1=bil_1;
guidata(hObject, handles)

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


properties.
function bilangan1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function bilangan2_Callback(hObject, eventdata, handles)


bil_2=str2num(get(handles.bilangan2, 'String'));
handles.bil_2=bil_2;
guidata(hObject, handles)

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


properties.
function bilangan2_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function bilangan3_Callback(hObject, eventdata, handles)


bil_3=str2num(get(handles.bilangan3, 'String'));
handles.bil_3=bil_3;
guidata(hObject, handles)

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


properties.
function bilangan3_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

% --- Executes on button press in btn_bagi.


function btn_bagi_Callback(hObject, eventdata, handles)
bil_1=handles.bil_1;
bil_2=handles.bil_2;
bil_3=handles.bil_3;
hasil=bil_1/bil_2/bil_3;
set(handles.hasil_bagi, 'string', hasil);

% --- Executes on button press in btn_kali.


function btn_kali_Callback(hObject, eventdata, handles)
bil_1=handles.bil_1;
bil_2=handles.bil_2;
bil_3=handles.bil_3;
hasil=bil_1*bil_2*bil_3;
set(handles.hasil_kali, 'string', hasil);

Eksekusi program dengan contoh pemasukan nilai tiga biangan:


Perancangan interface program pembangkitan sinyal

Program yang digunakan:


function varargout = PEMBANGKITAN_SINYAL(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn',
@PEMBANGKITAN_SINYAL_OpeningFcn, ...
'gui_OutputFcn',
@PEMBANGKITAN_SINYAL_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

function PEMBANGKITAN_SINYAL_OpeningFcn(hObject, eventdata,


handles, varargin)
handles.output = hObject;
guidata(hObject, handles);

function varargout = PEMBANGKITAN_SINYAL_OutputFcn(hObject,


eventdata, handles)
varargout{1} = handles.output;

function Sinyal_Kotak_Callback(hObject, eventdata, handles)


x=[0 2 2 2 0 0 0];
subplot(2,2,2);stairs(x,'LineWidth',2);
axis([0 10 0 3.5]);
title('SINYAL KOTAK');
grid on

function btn_keluar_Callback(hObject, eventdata, handles)


close;

function Sinyal_Sinus_Callback(hObject, eventdata, handles)


x = 0:0.1:1;
y = sin(x*1*pi*2)*2;
subplot(2,2,2);plot(x,y,'LineWidth',2)
title('SINYAL SINUS');
grid on;

function Sinyal_Segi_tiga_Callback(hObject, eventdata, handles)


x = 0:1:4;
y=[0 3 0 3 0];
subplot(2,2,2);plot(x,y,'LineWidth',2);
grid on
title('SINYAL SEGITIGA');

Eksekusi program dengan contoh pemasukan nilai tiga biangan: