Sie sind auf Seite 1von 25

TUGAS 6

PIRANTI LUNAK TELEKOMUNIKASI LANJUT

OLEH :

KELOMPOK 1

I MADE INDRA WIGUNA 1404405047

PUTU FEBY PRADIPTA 1404405056

I MADE SURYA KUMARA 1404405061

RAHMAT RUDIANTONO 1404405072

PROGRAM STUDI TEKNIK ELEKTRO


FAKULTAS TEK NIK
UNIVERSITAS UDAYANA
2017
A. Membuat Grafik Sinus
1. Buatlah GUI untuk grafik sinus pada Matlab seperti gambar berikut :

2. Kemudian buat script pada new script seperti berikut :


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

% Last Modified by GUIDE v2.5 12-Apr-2017 12:25:52

% Begin initialization code - DO NOT EDIT


gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @grafik_OpeningFcn, ...
'gui_OutputFcn', @grafik_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 grafik is made visible.


function grafik_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 grafik (see VARARGIN)

% Choose default command line output for grafik


handles.output = hObject;

% Update handles structure


guidata(hObject, handles);

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


% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command


line.
function varargout = grafik_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 efungsi_Callback(hObject, eventdata, handles)


% hObject handle to efungsi (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 efungsi as


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

proyek=guidata(gcbo);
f=get(proyek.efungsi,'String');
axes(proyek.axes1)
ezplot(f)
set(proyek.axes1,'XMinorTick','on')
grid on

% --- Executes on button press in tkluar.


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

close
function exmin_Callback(hObject, eventdata, handles)
% hObject handle to exmin (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 exmin as


text
% str2double(get(hObject,'String')) returns contents
of exmin as a double

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


properties.
function exmin_CreateFcn(hObject, eventdata, handles)
% hObject handle to exmin (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 exmax_Callback(hObject, eventdata, handles)


% hObject handle to exmax (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 exmax as


text
% str2double(get(hObject,'String')) returns contents
of exmax as a double

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


properties.
function exmax_CreateFcn(hObject, eventdata, handles)
% hObject handle to exmax (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

3. Setelah itu klik RUN pada script dan GUI, lalu masukkan fungsi sin(x) maka
akan muncul tampila GUI sesuai yang diinginkan seperti berikut :
B. Membuat Grafik Sinus dengan Interval
1. Buatlah GUI untuk grafik sinus dengan interval pada Matlab seperti gambar
berikut :
2. Kemudian buat script pada new script seperti berikut :
function varargout = grafik2(varargin)
% GRAFIK2 MATLAB code for grafik2.fig
% GRAFIK2, by itself, creates a new GRAFIK2 or raises
the existing
% singleton*.
%
% H = GRAFIK2 returns the handle to a new GRAFIK2 or the
handle to
% the existing singleton*.
%
% GRAFIK2('CALLBACK',hObject,eventData,handles,...)
calls the local
% function named CALLBACK in GRAFIK2.M with the given
input arguments.
%
% GRAFIK2('Property','Value',...) creates a new GRAFIK2
or raises the
% existing singleton*. Starting from the left, property
value pairs are
% applied to the GUI before grafik2_OpeningFcn gets
called. An
% unrecognized property name or invalid value makes
property application
% stop. All inputs are passed to grafik2_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 grafik2

% Last Modified by GUIDE v2.5 12-Apr-2017 12:27:47

% Begin initialization code - DO NOT EDIT


gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @grafik2_OpeningFcn, ...
'gui_OutputFcn', @grafik2_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 grafik2 is made visible.


function grafik2_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 grafik2 (see VARARGIN)

% Choose default command line output for grafik2


handles.output = hObject;

% Update handles structure


guidata(hObject, handles);

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


% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command


line.
function varargout = grafik2_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 efungsi_Callback(hObject, eventdata, handles)


% hObject handle to efungsi (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 efungsi as


text
% str2double(get(hObject,'String')) returns contents
of efungsi as a double

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


properties.
function efungsi_CreateFcn(hObject, eventdata, handles)
% hObject handle to efungsi (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)
% 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)

proyek=guidata(gcbo);
f=get(proyek.efungsi,'String');
x1=str2num(get(proyek.exmin,'String'));
x2=str2num(get(proyek.exmax,'String'));
set(proyek.axes1,'xLim',[x1 x2])
ezplot(f,[x1 x2])
grid on

%proyek=guidata(gcbo);
%f=get(proyek.efungsi,'String');
%axes(proyek.axes1)
%ezplot(f)
%set(proyek.axes1,'XMinorTick','on')
%grid on

% --- Executes on button press in tkluar.


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

function exmin_Callback(hObject, eventdata, handles)


% hObject handle to exmin (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 exmin as


text
% str2double(get(hObject,'String')) returns contents
of exmin as a double

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


properties.
function exmin_CreateFcn(hObject, eventdata, handles)
% hObject handle to exmin (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 exmax_Callback(hObject, eventdata, handles)


% hObject handle to exmax (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 exmax as


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

3. Setelah itu klik RUN pada script dan GUI, lalu masukkan fungsi sin(x) dan
berikan nilai untuk x maximum dan minimum. Maka akan muncul tampilan
GUI sesuai yang diinginkan seperti berikut :
C. Membuat Tampilan Depan dan Menu
1. Buatlah GUI untuk tampilan depan dan menu pada Matlab seperti gambar
berikut :
2. Kemudian buat script pada new script seperti berikut :
function varargout = Depan(varargin)
% DEPAN MATLAB code for Depan.fig
% DEPAN, by itself, creates a new DEPAN or raises the
existing
% singleton*.
%
% H = DEPAN returns the handle to a new DEPAN or the
handle to
% the existing singleton*.
%
% DEPAN('CALLBACK',hObject,eventData,handles,...) calls
the local
% function named CALLBACK in DEPAN.M with the given
input arguments.
%
% DEPAN('Property','Value',...) creates a new DEPAN or
raises the
% existing singleton*. Starting from the left, property
value pairs are
% applied to the GUI before Depan_OpeningFcn gets
called. An
% unrecognized property name or invalid value makes
property application
% stop. All inputs are passed to Depan_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 Depan

% Last Modified by GUIDE v2.5 12-Apr-2017 13:03:05

% Begin initialization code - DO NOT EDIT


gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Depan_OpeningFcn, ...
'gui_OutputFcn', @Depan_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 Depan is made visible.


function Depan_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 Depan (see VARARGIN)

% Choose default command line output for Depan


handles.output = hObject;

% Update handles structure


guidata(hObject, handles);

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


% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command


line.
function varargout = Depan_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 Untitled_1_Callback(hObject, eventdata, handles)
% hObject handle to out (see GCBO)
% eventdata reserved - to be defined in a future version of
MATLAB
% handles structure with handles and user data (see
GUIDATA)

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

bantuan

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

respon=keluar('Title', 'Konfirmasi Keluar');


switch lower(respon)
case'tidak'
case'ya'
close
end
%
-------------------------------------------------------------
-------
function ez_Callback(hObject, eventdata, handles)
% hObject handle to ez (see GCBO)
% eventdata reserved - to be defined in a future version of
MATLAB
% handles structure with handles and user data (see
GUIDATA)

grafik

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

grafik2
3. Setelah itu klik RUN pada script dan GUI, maka akan muncul tampilan GUI
sesuai yang diinginkan seperti berikut :

D. Tampilan Depan dan Menu Secara Keseluruhan :

Das könnte Ihnen auch gefallen