You are on page 1of 10

Nama : Khusniatun Aisyah

Nim : 06111181924011
Kelas : Indralaya

1.

2.
3.

4.
5.

6.
7.

8.
9.

10.
Kita dapat membuat tampilan program yang telah kita buat pada tugas pertemuan
sebelumnya yaitu tugas 8 dengan Graphical User Interface (GUI), seperti GUI di bawah
ini :

Listing program nya adalah sebagai berikut:

1 function varargout = mesingui(varargin)


2 % MESINGUI MATLAB code for mesingui.fig
3 %      MESINGUI, by itself, creates a new MESINGUI or raises the existing
4 %      singleton*.
5 %
6 %      H = MESINGUI returns the handle to a new MESINGUI or the handle to
7 %      the existing singleton*.
8 %
9 %      MESINGUI('CALLBACK',hObject,eventData,handles,...) calls the local
10 %      function named CALLBACK in MESINGUI.M with the given input arguments.
11 %
12 %      MESINGUI('Property','Value',...) creates a new MESINGUI or raises the
13 %      existing singleton*.  Starting from the left, property value pairs are
14 %      applied to the GUI before mesingui_OpeningFcn gets called.  An
15 %      unrecognized property name or invalid value makes property application
16 %      stop.  All inputs are passed to mesingui_OpeningFcn via varargin.
17 %
18 %      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
19 %      instance to run (singleton)".
20 %
% See also: GUIDE, GUIDATA, GUIHANDLES
21
22  
% Edit the above text to modify the response to help mesingui
23
24  
% Last Modified by GUIDE v2.5 04-Oct-2013 22:13:32
25
26  
% Begin initialization code - DO NOT EDIT
27
gui_Singleton = 1;
28
gui_State = struct('gui_Name',       mfilename, ...
29
    'gui_Singleton',  gui_Singleton, ...
30
    'gui_OpeningFcn', @mesingui_OpeningFcn, ...
31     'gui_OutputFcn',  @mesingui_OutputFcn, ...
32     'gui_LayoutFcn',  [] , ...
33     'gui_Callback',   []);
34 if nargin && ischar(varargin{1})
35
36     gui_State.gui_Callback = str2func(varargin{1});
37 end
38  
39 if nargout
40     [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
41 else
42     gui_mainfcn(gui_State, varargin{:});
43 end
44 % End initialization code - DO NOT EDIT
45  
46  
47 % --- Executes just before mesingui is made visible.
48 function mesingui_OpeningFcn(hObject, eventdata, handles, varargin)
49 % This function has no output args, see OutputFcn.
50 % hObject    handle to figure
51 % eventdata  reserved - to be defined in a future version of MATLAB
52 % handles    structure with handles and user data (see GUIDATA)
53 % varargin   command line arguments to mesingui (see VARARGIN)
54  
55 % Choose default command line output for mesingui
56 handles.output = hObject;
57  
58 % Update handles structure
59 guidata(hObject, handles);
60 movegui(hObject, 'center');
% UIWAIT makes mesingui wait for user response (see UIRESUME)
61
% uiwait(handles.figure1);
62
63  
64  
% --- Outputs from this function are returned to the command line.
65
function varargout = mesingui_OutputFcn(hObject, eventdata, handles)
66
% varargout  cell array for returning output args (see VARARGOUT);
67
% hObject    handle to figure
68
% eventdata  reserved - to be defined in a future version of MATLAB
69
% handles    structure with handles and user data (see GUIDATA)
70
 
71 % Get default command line output from handles structure
72 varargout{1} = handles.output;
73
 
74
 
75 % --- Executes on slider movement.
76 function slider2_Callback(hObject, eventdata, handles)
77 % hObject    handle to slider2 (see GCBO)
78 % eventdata  reserved - to be defined in a future version of MATLAB
79 % handles    structure with handles and user data (see GUIDATA)
80  
81 % Hints: get(hObject,'Value') returns position of slider
82 %        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
83 slider_suhu = get(hObject,'Value');
84 set(handles.edit2, 'string', strcat(num2str(slider_suhu),' *C'));
85  
86 if slider_suhu <= 10
87     suhu = 'dingin';
88 elseif slider_suhu > 10 && slider_suhu <= 20
89     suhu = 'sejuk';
90 elseif slider_suhu > 20 && slider_suhu <= 27
91     suhu = 'normal';
92 elseif slider_suhu > 27 && slider_suhu <= 35
93     suhu = 'hangat';
94 else
95     suhu = 'panas';
96 end
97  
98 set(handles.text14, 'string', suhu);
99  
100  
101 slider_cahaya = get(handles.slider3,'Value');
102  
103 input = [slider_suhu slider_cahaya];
104 fis = readfis('mesin');
105 out = evalfis(input,fis);
106  
107 if out <= 10
108     kec_mesin = 'lambat';
109 elseif out > 10 && out <= 18
110     kec_mesin = 'sedang';
111 else
112     kec_mesin = 'cepat';
113 end
114  
115 set(handles.edit4,'string',strcat(num2str(out),' m/s'));
116 set(handles.text16, 'string', kec_mesin);
117  
118 % --- Executes during object creation, after setting all properties.
119 function slider2_CreateFcn(hObject, eventdata, handles)
120 % hObject    handle to slider2 (see GCBO)
121 % eventdata  reserved - to be defined in a future version of MATLAB
122 % handles    empty - handles not created until after all CreateFcns called
123  
124 % Hint: slider controls usually have a light gray background.
125 if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor
    set(hObject,'BackgroundColor',[.9 .9 .9]);
126
end
127
128  
129  
% --- Executes on slider movement.
130
function slider3_Callback(hObject, eventdata, handles)
131
% hObject    handle to slider3 (see GCBO)
132
% eventdata  reserved - to be defined in a future version of MATLAB
133
% handles    structure with handles and user data (see GUIDATA)
134
 
135
% Hints: get(hObject,'Value') returns position of slider
136 %        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
137 slider_cahaya = get(hObject,'Value');
138 set(handles.edit3, 'string', strcat(num2str(slider_cahaya),' Cd'));
139
 
140 if slider_cahaya <= 30
141     cahaya = 'gelap';
142 elseif slider_cahaya > 30 && slider_cahaya <= 80
143     cahaya = 'normal';
144 else
145     cahaya = 'terang';
146 end
147  
148 set(handles.text15, 'string', cahaya);
149  
150 slider_suhu = get(handles.slider2,'Value');
151  
152 input = [slider_suhu slider_cahaya];
153 fis = readfis('mesin');
154 out = evalfis(input,fis);
155  
156 if out <= 10
157     kec_mesin = 'lambat';
158 elseif out > 10 && out <= 18
159     kec_mesin = 'sedang';
160 else
161     kec_mesin = 'cepat';
162 end
163  
164 set(handles.edit4,'string',strcat(num2str(out),' m/s'));
165 set(handles.text16, 'string', kec_mesin);
166  
167 % --- Executes during object creation, after setting all properties.
168 function slider3_CreateFcn(hObject, eventdata, handles)
169 % hObject    handle to slider3 (see GCBO)
170 % eventdata  reserved - to be defined in a future version of MATLAB
171 % handles    empty - handles not created until after all CreateFcns called
172  
173 % Hint: slider controls usually have a light gray background.
174 if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor
175     set(hObject,'BackgroundColor',[.9 .9 .9]);
176 end
177  
178  
179 function edit2_Callback(hObject, eventdata, handles)
180 % hObject    handle to edit2 (see GCBO)
181 % eventdata  reserved - to be defined in a future version of MATLAB
182 % handles    structure with handles and user data (see GUIDATA)
183  
184 % Hints: get(hObject,'String') returns contents of edit2 as text
185 %        str2double(get(hObject,'String')) returns contents of edit2 as a double
186  
187  
188 % --- Executes during object creation, after setting all properties.
189 function edit2_CreateFcn(hObject, eventdata, handles)
190 % hObject    handle to edit2 (see GCBO)
191 % eventdata  reserved - to be defined in a future version of MATLAB
192 % handles    empty - handles not created until after all CreateFcns called
193  
% Hint: edit controls usually have a white background on Windows.
194
%       See ISPC and COMPUTER.
195
if ispc && isequal(get(hObject,'BackgroundColor'),
196
get(0,'defaultUicontrolBackgroundColor'))
197
    set(hObject,'BackgroundColor','white');
198
end
199
 
200
 
201
 
202
function edit3_Callback(hObject, eventdata, handles)
203
% hObject    handle to edit3 (see GCBO)
204 % eventdata  reserved - to be defined in a future version of MATLAB
205 % handles    structure with handles and user data (see GUIDATA)
206
 
207 % Hints: get(hObject,'String') returns contents of edit3 as text
208 %        str2double(get(hObject,'String')) returns contents of edit3 as a double
209
 
210
 
211 % --- Executes during object creation, after setting all properties.
212 function edit3_CreateFcn(hObject, eventdata, handles)
213 % hObject    handle to edit3 (see GCBO)
214 % eventdata  reserved - to be defined in a future version of MATLAB
215 % handles    empty - handles not created until after all CreateFcns called
216  
217 % Hint: edit controls usually have a white background on Windows.
218 %       See ISPC and COMPUTER.
219 if ispc && isequal(get(hObject,'BackgroundColor'),
220 get(0,'defaultUicontrolBackgroundColor'))
221     set(hObject,'BackgroundColor','white');
222 end
223  
224  
225  
226 function edit4_Callback(hObject, eventdata, handles)
227 % hObject    handle to edit4 (see GCBO)
228 % eventdata  reserved - to be defined in a future version of MATLAB
229 % handles    structure with handles and user data (see GUIDATA)
230  
231 % Hints: get(hObject,'String') returns contents of edit4 as text
232 %        str2double(get(hObject,'String')) returns contents of edit4 as a double
233  
234  
235 % --- Executes during object creation, after setting all properties.
236 function edit4_CreateFcn(hObject, eventdata, handles)
237 % hObject    handle to edit4 (see GCBO)
238 % eventdata  reserved - to be defined in a future version of MATLAB
239 % handles    empty - handles not created until after all CreateFcns called
240  
241 % Hint: edit controls usually have a white background on Windows.
242 %       See ISPC and COMPUTER.
243 if ispc && isequal(get(hObject,'BackgroundColor'),
244 get(0,'defaultUicontrolBackgroundColor'))
245     set(hObject,'BackgroundColor','white');
246 end

You might also like