TUGAS 5
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 TEKNIK
UNIVERSITAS UDAYANA
2017
1. Buatlah GUI pada Matlab seperti gambar berikut :
2. Kemudian buat script pada new script seperti berikut :
function varargout = trigonometri(varargin)
% TRIGONOMETRI MATLAB code for trigonometri.fig
% TRIGONOMETRI, by itself, creates a new TRIGONOMETRI or
raises the existing
% singleton*.
%
% H = TRIGONOMETRI returns the handle to a new TRIGONOMETRI or
the handle to
% the existing singleton*.
%
% TRIGONOMETRI('CALLBACK',hObject,eventData,handles,...) calls
the local
% function named CALLBACK in TRIGONOMETRI.M with the given
input arguments.
%
% TRIGONOMETRI('Property','Value',...) creates a new
TRIGONOMETRI or raises the
% existing singleton*. Starting from the left, property value
pairs are
% applied to the GUI before trigonometri_OpeningFcn gets
called. An
% unrecognized property name or invalid value makes property
application
% stop. All inputs are passed to trigonometri_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 trigonometri
% Last Modified by GUIDE v2.5 17-Mar-2017 09:24:43
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @trigonometri_OpeningFcn, ...
'gui_OutputFcn', @trigonometri_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 trigonometri is made visible.
function trigonometri_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 trigonometri (see VARARGIN)
% Choose default command line output for trigonometri
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes trigonometri wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = trigonometri_OutputFcn(~, 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 pushbutton1_Callback(hObject, eventdata, handles)
A=str2num(get(handles.edit1, 'string')); %mengambil nilai pada
edit1
r=str2num(get(handles.edit2, 'string')); %mengambil nilai pada
edit2
x=-10:0.1:10; %membangkitkan sumbu x
axes(handles.axes1);
a=0;
indeks=get(handles.popupmenu,'Value'); %mengambil nilai
if indeks == 1 %jika menekan pilihan 1
y=A*sin(1*x+r); %Maka T=1;
else if indeks==2
y=A*cos(1*x+r);
else if indeks==3
y1=A*sin(1*x+r);
y2=A*cos(1*x+r);
plot(x,y1,'r',x,y2, a, x, 'b', x, a, 'b');
grid on
end
end
end
axes(handles.axes1);
a=0; %membuat garis, seperti sumbu x dan sumbu y
plot(x,y,'r', a, x, 'b', x, a, 'b');
grid on
% 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)
set(handles.edit1, 'string', ''); %mengosongkan string pada edit1
set(handles.edit2, 'string', ''); %mengosongkan string pada edit2
axes(handles.axes1);
plot(0); %membersihkan gambar pada axees
%membersihkan gambar pada axees
% 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)
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 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
% --- Executes on selection change in popupmenu.
function popupmenu_Callback(hObject, eventdata, handles)
indeks=get(handles.popupmenu,'Value');
handles.indeks=indeks;
guidata(hObject, handles)
% hObject handle to popupmenu (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
popupmenu contents as cell array
% contents{get(hObject,'Value')} returns selected item from
popupmenu
% --- Executes during object creation, after setting all
properties.
function popupmenu_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu (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
3. Setelah itu klik RUN pada script dan GUI, maka akan muncul tampila GUI
sesuai yang diinginkan. Kemudian atur fungsi trigonometri dengan fungsi sin,
cos, serta sin dan cos. Maka didapat grafik hasil seperti berikut :
A. Fungsi Trigonometri Sin
B. Fungsi Trigonometri Cos
C. Fungsi Trigonometri Sin dan Cos