28
GUIDE Praktikum Pemrosesan Bahasa Alami

GUIDE - TOTO HARYANTOtotoharyanto.staff.ipb.ac.id/files/2014/03/Materi-Praktikum-GUIDE.pdf · GUIDE Praktikum Pemrosesan Bahasa Alami . GUIDE? •MATLAB implements GUIs as figure

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: GUIDE - TOTO HARYANTOtotoharyanto.staff.ipb.ac.id/files/2014/03/Materi-Praktikum-GUIDE.pdf · GUIDE Praktikum Pemrosesan Bahasa Alami . GUIDE? •MATLAB implements GUIs as figure

GUIDE

Praktikum Pemrosesan Bahasa Alami

Page 2: GUIDE - TOTO HARYANTOtotoharyanto.staff.ipb.ac.id/files/2014/03/Materi-Praktikum-GUIDE.pdf · GUIDE Praktikum Pemrosesan Bahasa Alami . GUIDE? •MATLAB implements GUIs as figure

GUIDE?

• MATLAB implements GUIs as figure windows containing various uicontrol objects.

• You must program each object to perform the action you intend it to do when a user activates the component.

• In addition, you must be able to save and run your GUI.

• All of these tasks are simplified by GUIDE, the MATLAB graphical user interface development environment.

Page 3: GUIDE - TOTO HARYANTOtotoharyanto.staff.ipb.ac.id/files/2014/03/Materi-Praktikum-GUIDE.pdf · GUIDE Praktikum Pemrosesan Bahasa Alami . GUIDE? •MATLAB implements GUIs as figure

GUI Development Environment

• Creating a GUI involves two basic tasks:

– Laying out the GUI components

– Programming the GUI components

Page 4: GUIDE - TOTO HARYANTOtotoharyanto.staff.ipb.ac.id/files/2014/03/Materi-Praktikum-GUIDE.pdf · GUIDE Praktikum Pemrosesan Bahasa Alami . GUIDE? •MATLAB implements GUIs as figure

Layout Editor

Page 5: GUIDE - TOTO HARYANTOtotoharyanto.staff.ipb.ac.id/files/2014/03/Materi-Praktikum-GUIDE.pdf · GUIDE Praktikum Pemrosesan Bahasa Alami . GUIDE? •MATLAB implements GUIs as figure

• GUIDE also generates an M-file that contains code to handle the initialization and launching of the GUI.

• This M-file provides a framework for the implementation of the callbacks -- the functions that execute when users activate components in the GUI

Page 6: GUIDE - TOTO HARYANTOtotoharyanto.staff.ipb.ac.id/files/2014/03/Materi-Praktikum-GUIDE.pdf · GUIDE Praktikum Pemrosesan Bahasa Alami . GUIDE? •MATLAB implements GUIs as figure

GUIDE Generated Files

• A FIG-file -- a file with a .fig file name extension, which contains a complete description of the GUI figure and all of its children (uicontrols and axes), as well as the values of all object properties. You make changes to the FIG-file by editing the GUI in the Layout Editor.

• An M-file -- a file with a .m file name extension, which contains the functions that run and control the GUI and the callbacks. This file is referred to as the GUI M-file. Note that the M-file does not contain the code that lays out the uicontrols; this information is saved in the FIG-file.

Page 7: GUIDE - TOTO HARYANTOtotoharyanto.staff.ipb.ac.id/files/2014/03/Materi-Praktikum-GUIDE.pdf · GUIDE Praktikum Pemrosesan Bahasa Alami . GUIDE? •MATLAB implements GUIs as figure

Example 1: Merekam Suara dan Mendengarkan

Page 8: GUIDE - TOTO HARYANTOtotoharyanto.staff.ipb.ac.id/files/2014/03/Materi-Praktikum-GUIDE.pdf · GUIDE Praktikum Pemrosesan Bahasa Alami . GUIDE? •MATLAB implements GUIs as figure

Rancangan GUI

Page 9: GUIDE - TOTO HARYANTOtotoharyanto.staff.ipb.ac.id/files/2014/03/Materi-Praktikum-GUIDE.pdf · GUIDE Praktikum Pemrosesan Bahasa Alami . GUIDE? •MATLAB implements GUIs as figure

M-File

Page 10: GUIDE - TOTO HARYANTOtotoharyanto.staff.ipb.ac.id/files/2014/03/Materi-Praktikum-GUIDE.pdf · GUIDE Praktikum Pemrosesan Bahasa Alami . GUIDE? •MATLAB implements GUIs as figure

Example 2

• We want to build GUI like this picture

Page 11: GUIDE - TOTO HARYANTOtotoharyanto.staff.ipb.ac.id/files/2014/03/Materi-Praktikum-GUIDE.pdf · GUIDE Praktikum Pemrosesan Bahasa Alami . GUIDE? •MATLAB implements GUIs as figure

Open GUIDE • Write guide at command window, then push

ENTER button at your keyboard

Page 12: GUIDE - TOTO HARYANTOtotoharyanto.staff.ipb.ac.id/files/2014/03/Materi-Praktikum-GUIDE.pdf · GUIDE Praktikum Pemrosesan Bahasa Alami . GUIDE? •MATLAB implements GUIs as figure

Choose Blank GUI

• At GUIDE quick start window, choose Blank GUI (Default).

• Then push OK.

Page 13: GUIDE - TOTO HARYANTOtotoharyanto.staff.ipb.ac.id/files/2014/03/Materi-Praktikum-GUIDE.pdf · GUIDE Praktikum Pemrosesan Bahasa Alami . GUIDE? •MATLAB implements GUIs as figure

Blank GUI

Page 14: GUIDE - TOTO HARYANTOtotoharyanto.staff.ipb.ac.id/files/2014/03/Materi-Praktikum-GUIDE.pdf · GUIDE Praktikum Pemrosesan Bahasa Alami . GUIDE? •MATLAB implements GUIs as figure

Using Static Text and Edit Text

• Put three Static Text and three edit text the Figure

Static text

Edit text

Push button

Page 15: GUIDE - TOTO HARYANTOtotoharyanto.staff.ipb.ac.id/files/2014/03/Materi-Praktikum-GUIDE.pdf · GUIDE Praktikum Pemrosesan Bahasa Alami . GUIDE? •MATLAB implements GUIs as figure

Change Static Text Property • Double click at first Static Text (text1)

• The Property Inspector will be opened

Page 16: GUIDE - TOTO HARYANTOtotoharyanto.staff.ipb.ac.id/files/2014/03/Materi-Praktikum-GUIDE.pdf · GUIDE Praktikum Pemrosesan Bahasa Alami . GUIDE? •MATLAB implements GUIs as figure

Change Static Text Property (2)

• Click the button at String property

• Then change the string to “ Enter First Number”

Page 17: GUIDE - TOTO HARYANTOtotoharyanto.staff.ipb.ac.id/files/2014/03/Materi-Praktikum-GUIDE.pdf · GUIDE Praktikum Pemrosesan Bahasa Alami . GUIDE? •MATLAB implements GUIs as figure

Change Static Text Property (3)

• Change the String property at second Static Text (text2) into “Enter Second Number”

Page 18: GUIDE - TOTO HARYANTOtotoharyanto.staff.ipb.ac.id/files/2014/03/Materi-Praktikum-GUIDE.pdf · GUIDE Praktikum Pemrosesan Bahasa Alami . GUIDE? •MATLAB implements GUIs as figure

Change Edit Text Property

• Double click at first Edit Text (edit1)

• Then change the String property to blank string

Page 19: GUIDE - TOTO HARYANTOtotoharyanto.staff.ipb.ac.id/files/2014/03/Materi-Praktikum-GUIDE.pdf · GUIDE Praktikum Pemrosesan Bahasa Alami . GUIDE? •MATLAB implements GUIs as figure

Change Edit Text Property (2)

• Change the String property ata second Edit Text (edit2) to blank string

Page 20: GUIDE - TOTO HARYANTOtotoharyanto.staff.ipb.ac.id/files/2014/03/Materi-Praktikum-GUIDE.pdf · GUIDE Praktikum Pemrosesan Bahasa Alami . GUIDE? •MATLAB implements GUIs as figure

Change Push Button Property

• Double click at the Push Button (pushbutton1)

• Then change the String property to “process”

Page 21: GUIDE - TOTO HARYANTOtotoharyanto.staff.ipb.ac.id/files/2014/03/Materi-Praktikum-GUIDE.pdf · GUIDE Praktikum Pemrosesan Bahasa Alami . GUIDE? •MATLAB implements GUIs as figure

Add another Static Text

• Add one Static Text under the Push Button

• Then change the String property into “Result”

Page 22: GUIDE - TOTO HARYANTOtotoharyanto.staff.ipb.ac.id/files/2014/03/Materi-Praktikum-GUIDE.pdf · GUIDE Praktikum Pemrosesan Bahasa Alami . GUIDE? •MATLAB implements GUIs as figure

Save the figure

• Choose File > Save at the menu bar

Page 23: GUIDE - TOTO HARYANTOtotoharyanto.staff.ipb.ac.id/files/2014/03/Materi-Praktikum-GUIDE.pdf · GUIDE Praktikum Pemrosesan Bahasa Alami . GUIDE? •MATLAB implements GUIs as figure

myfirstgui

• The file name is myfirstgui

Page 24: GUIDE - TOTO HARYANTOtotoharyanto.staff.ipb.ac.id/files/2014/03/Materi-Praktikum-GUIDE.pdf · GUIDE Praktikum Pemrosesan Bahasa Alami . GUIDE? •MATLAB implements GUIs as figure

The M-File • After myfirstgui.fig saved, the myfirstgui.m will be built and

opened

Page 25: GUIDE - TOTO HARYANTOtotoharyanto.staff.ipb.ac.id/files/2014/03/Materi-Praktikum-GUIDE.pdf · GUIDE Praktikum Pemrosesan Bahasa Alami . GUIDE? •MATLAB implements GUIs as figure

Write the code

• Find the btnProcess_Callback function, then write this codes under that function

a=get(handles.txtFirstNumber,'String');

a = str2num(a);

b=get(handles.txtSecondNumber,'String');

b = str2num(b);

c=a+b;

c=num2str(c);

set(handles.txtResult,'String',c);

Page 26: GUIDE - TOTO HARYANTOtotoharyanto.staff.ipb.ac.id/files/2014/03/Materi-Praktikum-GUIDE.pdf · GUIDE Praktikum Pemrosesan Bahasa Alami . GUIDE? •MATLAB implements GUIs as figure

• get is the function to get property value. In this example, is to get the String property value that entered by the user

• set is the function to set the property value

• str2num is the function to convert string data to number data

• num2str is the function to convert number data to string data

Page 27: GUIDE - TOTO HARYANTOtotoharyanto.staff.ipb.ac.id/files/2014/03/Materi-Praktikum-GUIDE.pdf · GUIDE Praktikum Pemrosesan Bahasa Alami . GUIDE? •MATLAB implements GUIs as figure

Run the gui

Page 28: GUIDE - TOTO HARYANTOtotoharyanto.staff.ipb.ac.id/files/2014/03/Materi-Praktikum-GUIDE.pdf · GUIDE Praktikum Pemrosesan Bahasa Alami . GUIDE? •MATLAB implements GUIs as figure

The result