Docsity

Chapter 6 MATLAB GUI, Study notes of Matlab skills

Partial preview of the text

Download Chapter 6 MATLAB GUI and more Study notes Matlab skills in PDF only on Docsity!

Chapter 6Chapter

MATLAB GUI

MATLAB GUI (G

hi

l U

I t

f^

) T t

i l f

B^

i

MATLAB GUI (Graphical User Interface) Tutorial for Beginners

By J.S. Park

University of Incheon

Preprocessing Data

p

g

Why use a GUI in MATLAB?It makes things simple for the end-users of the program.The command line interface Vs. GUIThe command line interface Vs. GUI

Initializing GUIDE (GUI Creator)

  1. You should now see the following screen.

Initializing GUIDE (GUI Creator)

  1. Before adding components blindly, it is good to have a rough idea about how you

want the graphical part of the GUI to look like.

Creating the Visual Aspect of the GUI: Part 1

  1. Edit the properties of these components.

Double click one of the

Static Text components. You should see the

property Inspector.

p

p^

p^

y^

p

Creating the Visual Aspect of the GUI: Part 1

  1. Do the same for the next

Static Text component, but instead of changing the

String pa

rameter to +, change it to =, and another it to MyAdderGUI.4. For

Static Text component 0, modify the

Tag parameter to answer_staticText.

  1. You should have something that looks like

the following:

Creating the Visual Aspect of the GUI: Part 2

3.^

Modify the

pushbutton component.

Change the

String parameter to Add!

Change the

Tag parameter to add pushbutton.

Change the

Tag parameter to add_pushbutton.

Creating the Visual Aspect of the GUI: Part 2

  1. You should have something like this:

You should have something like this:

  1. Save your GUI under any file name you please. I chose to name mine myAdder.5. Save your GUI under any file name you please. I chose to name mine myAdder.

When you save this file, MATLAB automatically generates two files:

myAdder.fig and

myAdder.m.

The .fig file contains the graphics of your interface.The .m file contains all the code for the GUI.The .m file contains all the code for the GUI.

Writing the Code for the GUI Callbacks

  1. The cursor should take you to the following code block: 4. Add the following code to the bottom of that code block: 5. Add the same block of code to

input2_editText_Callback.

Writing the Code for the GUI Callbacks

  1. Now we need to edit the

add_pushbutton_Callback.

Here is the code that we will add to this callback:

Launching the GUI

  1. The GUI should start running immediately:

MATLAB GUI Tutorial - Slider

In this Matlab GUI tutorial, you will learn how to create and use the slider component.Sliders are useful controls for choosing a value in a range of values.Common uses are volume controls, seekers for movie and sound files as well as color picCommon uses are volume controls, seekers for movie and sound files as well as color pickers.An example of a slider is shown below.

Create the Visual Aspect of the GUI

  1. You should now see the following screen.

Creating the Visual Aspect of the GUI: Part 1 1.^ For the adder GUI, we will need the following components

Add

Edit T

t^

t t

th

GUI fi

Add an

Edit Text component to the GUI figure.

Add a

Slider component onto the GUI figure.