Upload
sahil-potnis
View
2.438
Download
1
Embed Size (px)
DESCRIPTION
A small Introduction to GUI designing in Matlab Using GUIDE.
Citation preview
USING GUIDE
By Sahil Potnis, VIT, Mumbai
Creating a GUI in Matlab
TUTORIAL : 1
By Sahil Potnis, VIT, Mumbai
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
Create New GUI
By Sahil Potnis, VIT, Mumbai
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
STEP 2:
STEP 3:
By Sahil Potnis, VIT, Mumbai
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
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
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
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
Functions related to specific Objects can be viewed by using : View Callback
By Sahil Potnis, VIT, Mumbai
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
Function [mass]=fxname(density,volume)%CODE%return
Make sure the parameter names and number of parameters within the function and main file match.
By Sahil Potnis, VIT, Mumbai
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....
Thank You
By Sahil Potnis, VIT, Mumbai
For further advanced Matlab programming visit : http://sahilpotnis.blogspot.in/
Or drop me a mail at : [email protected]