This document provides a 4 step guide to creating a GUI in Matlab using GUIDE. Step 1 explains how to open GUIDE and select a template. Step 2 discusses saving the GUI file. Step 3 covers working with object tags and callbacks. Step 4 discusses creating callback and input functions to get and assign values in the GUI. The document uses an example of a GUI calculating mass from user-entered density and volume values.
Next-generation AAM aircraft unveiled by Supernal, S-A2
Create GUI Matlab Guide
1. Creating a GUI in Matlab
USING GUIDE
By Sahil Potnis, VIT, Mumbai
2. STEP 1:
Open Matlab and type „guide‟ in command window .
Guide stands for GUI Development Environment.
OR
You can select File-> new-> GUI.
It is one and the same thing......
By Sahil Potnis, VIT, Mumbai
4. STEP 2:
Select a standard template from the list:
Say for example : GUI with uicontrols
Save the GUI with a certain name –abc
This generates a abc.m file with the GUI code.
Now , you can play with the code.
Do not alter the initialization code up to line no:74
By Sahil Potnis, VIT, Mumbai
5. STEP 3:
All objects present within the GUI have their own
tags.
Double click on an object to display it „s properties
Tag property will show you the existing tag of that
object.
Callback and Create function of these are associated
with this tag
By Sahil Potnis, VIT, Mumbai
6. If you change the tag, and save the file automatically
abc.m will be updated
(note-Do not alter the .m file to change the tag, make
changes in .fig file and save it).
Ta of your selected object is displayed at the right
hand bottom corner of your .fig window.
By Sahil Potnis, VIT, Mumbai
7. Now I will explain rest of basics using reference to the
“Density * volume =Mass example”
Density, Volume are the Edit text boxes in which user
can enter the values
Mass is the static text box in which answer is displayed.
Calculate and Reset are the two Pushbuttons while Units
consists of two radio buttons
By Sahil Potnis, VIT, Mumbai
8. STEP 4 :
Mutual Exclusivity of these radio buttons is preserved as
they are embedded within a “button group‟‟ container.
A create function is essential when a value is to be
obtained from the User
A callback function is essential when a value is to be
assigned to a certain tag (static text) Or a certain object
has to perform a specific task (pushbutton)
By Sahil Potnis, VIT, Mumbai
9. Functions related to specific Objects can be viewed
by using : View Callback
By Sahil Potnis, VIT, Mumbai
10. You can further change the „calculate callback‟
function as per your usage:
Even a function can be created within „calculate‟ as
follows:
Mass=fxname(handles.metricdata.density,handles.metricdat.volume)
Save a fxname.m file within the same folder and
write the function within that file.
By Sahil Potnis, VIT, Mumbai
12. EXPECTED OUTCOME :
You can now create a simple User Interface with User
Input and perform certain operations on those input
values....
Keep on trying new things.....Its the best way to learn.!!
Watch out this space for tutorials on Matlab....
By Sahil Potnis, VIT, Mumbai
13. Thank You
For further advanced Matlab programming visit :
http://sahilpotnis.blogspot.in/
Or drop me a mail at :
sahil.potnis@vit.edu.in
By Sahil Potnis, VIT, Mumbai