Search for notes by fellow students, in your own course and all over the country.

Browse our notes for titles which look like what you need, you can preview any of the notes via a sample of the contents. After you're happy these are the notes you're after simply pop them into your shopping cart.

My Basket

You have nothing in your shopping cart yet.

Title: MATLAB instruction for making a GUI
Description: Detailed Explanation on how to make and run a GUI in MATLAB. Explained with examples over 68 pages

Document Preview

Extracts from the notes are below, to see the PDF you'll receive please use the links above


Chapter 6
MATLAB GUI

MATLAB GUI (G hi l User Interface) Tutorial for Beginners
(Graphical U
I t f
)T t i lf B i

By J
...
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
...
GUI

Initializing GUIDE (GUI Creator)
1
...
Go to the command window and type in guide

2
...
You should now see the following screen
...
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
...


For the adder GUI, we will need the following components
Two Edit Text components
T
T t
t
Four Static Text component
One Pushbutton component

Creating the Visual Aspect of the GUI: Part 1

2
...

p
p p y
p
Double click one of the Static Text components
...


Creating the Visual Aspect of the GUI: Part 1
3
...

4
...


5
...


Modify the Edit Text components
...

Set the String parameter to 0
Change the Tag parameter to input1_editText
input1 editText

2
...


Creating the Visual Aspect of the GUI: Part 2
3
...

Change the String parameter to Add!
Change the Tag parameter to add pushbutton
...


Creating the Visual Aspect of the GUI: Part 2
4
...
Save your GUI under any file name you please
...

When you save this file, MATLAB automatically generates two files:
myAdder
...
m
...
fig file contains the graphics of your interface
...
m file contains all the code for the GUI
...


Open up the
...


2
...
m file
...


Writing the Code for the GUI Callbacks
3
...
Add the following code to the bottom of that code block:

5
...


Writing the Code for the GUI Callbacks
6
...


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

Launching the GUI
7
...

The first way: Press the

icon on the GUIDE editor
...

Type in the name of the GUI at the command prompt
...
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
...

Common uses are volume controls, seekers for movie and sound files as well as color pic
kers
...


Create the Visual Aspect of the GUI
1
...
Go to the command window and type in guide

2
...
You should now see the following screen
...


For the adder GUI, we will need the following components
Add an Edit Text component to the GUI figure
...


Creating the Visual Aspect of the GUI: Part 1

2
...

Double click the Edit Text component to bring up the Property Inspector
...


3
...

Sit the Min property to 0, and
the Max property to 100
...

slider1

Creating the Visual Aspect of the GUI: Part 1
4
...


Creating the Visual Aspect of the GUI: Part 1
5
...

Modify their text by double clicking on the component and
changing the String property
...


6
...


Writing the Code for the GUI Callbacks
1
...
m file that was automatically generated when you saved your GUI
...


In the MATLAB editor, click on the
within the
...

Select slider1_Callback
...
Add the following code to the function:

Writing the Code for the GUI Callbacks
4
...

1

From the m-file editor, you can click on the icon
m file editor

to save and run the GUI
...


Alternatively, from the GUIDE editor, you can click on the

Now, try to put in different types of inputs to test the GUI
...


to launch the GUI
...

Pop up
Pop-up menus are used as a control for choosing between a set of options
...

A common use for Pop-up menus is a font size selector (shown below)
...
Open up MATLAB
...
Choose the first option Blank GUI (Default)

Create the Visual Aspect of the GUI
3
...


Creating the Visual Aspect of the GUI: Part 1
1
...

T t
t t th
fi
Add a Pop-up Menu component onto the GUI figure
...
Double click the Static Text component to bring up the Property Inspector
...
Modify the properties of the Pop-up Menu component
...


4
...

Fill in the window as shown below:

Creating the Visual Aspect of the GUI: Part 1
5
...


Creating the Visual Aspect of the GUI: Part 1
6
...

Modify their text by double clicking on the component and
changing the String property
...


Open up the
...


2
...
m file
...


icon, which will bring up a list of the functions

Writing the Code for the GUI Callbacks
3
...

1

From the m-file editor, you can click on the icon
m file editor

2
...


to save and run the GUI
...


MATLAB GUI Tutorial - Plotting Data to Axes
In this Matlab GUI tutorial, you will learn how to create and use the Axes component
...

In this tutorial, we will create two axes on the GUI and plot some simple data onto it
...


Create the Visual Aspect of the GUI
1
...
Go to the command window and type in guide

2
...
You should now see the following screen
...
For the adder GUI, we will need the following components
...


Add two Axes components to the GUI figure
Add three Pushbutton components onto the GUI figure
...
Double click the Axes component to bring up the Property Inspector
...

The other Axes component’s Tag property is named axes2
...
Modify the properties of the Pushbutton components
...

Change the String property to Plot Axes 1, and the Tag property to plotAxes1_pushbutton

4
...

Double click on the final pushbutton and change the String property to Clear Axes
and change the Tag property to clearAxes_pushbutton
...
The figure should look like below after you add the components and modify them
...


Open up the
...


2
...
m file
...


icon, which will bring up a list of the functions

Writing the Code for the GUI Callbacks
3
...
Put the following code into the plot2_pushbutton_Callback:

Writing the Code for the GUI Callbacks
5
...
Add the following line of code to axes_tutorial_OpeningFcn:

This line of code effectively adds the standard toolbar to the GUI, allowing the user to zoom,
pan, query the plot, and more
...


From the m-file editor, you can click on the icon

to save and run the GUI
...


...

au c t e GU
...

These button types are: push button, radio button, check box, and toggle buttons
...


Create the Visual Aspect of the GUI
1
...
Go to the command window and type in guide

2
...
You should now see the following screen
...
For the adder GUI, we will need the following components
...

Add three Pushbutton components onto the GUI f
figure
...
Double click the Static Text component to bring up the
p
g p
Property Inspector
...

Change the Tag property to display_staticText
...


Creating the Visual Aspect of the GUI: Part 1
3
...


Writing the Code for the GUI Callbacks
1
...
m file that was automatically generated when you saved your GUI
...


In the MATLAB editor, click on the
within the
...

Select displayText_pushbutton_Callback
...
Add the following code to the function:

Run and Test the GUI
1
...


2
...


Alternatively, from the GUIDE editor, you can click on the
te at e y, o t e GU
ed to ,
ca c c o t e

to launch the GUI
...


Part Two: The Check Box
1
...

add one Check Box component to the GUI figure
...
Double click the Check Box component to bring up the
p
g p
Property Inspector
...

Change the Tag property to bold_checkbox
...
The figure should look like below after you add the Check Box component and modify it
...
Add the following code to the bold_checkbox_Callback function:

Run and Test the GUI
1
...

Try checking and unchecking the Check Box component to make sure that the text
“Hello World!” is being bolded and unbolded
...
Closed GUIDE, reopen it again
...

Add three radio buttons onto the button group panel
...
Double click on the first Radio Button component to bring up
p
g p
the Property Inspector
...

Change the Tag property to fontsize08_radiobutton
...
Double click on the second Radio Button component, and change the String property to 12
...

Double click on the third Radio Button component, and change the String property to 16
...

Double click on the button group panel and change the Tag property to fontSelect_buttongroup
...

Here’s what your figure should look like after you add the components and modify them
...


Check the hierarchical structure of the GUI figure
...

icon

Writing the Code for the GUI Callbacks
3
...

In this tutorial example, it is named button_tutorial_OpeningFcn function

Writing the Code for the GUI Callbacks
3
...
m file
...

Try clicking on all of the buttons to make sure they perform their function correctly
...



Title: MATLAB instruction for making a GUI
Description: Detailed Explanation on how to make and run a GUI in MATLAB. Explained with examples over 68 pages