AllExperts > Experts 
Search      

CAD

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More CAD Answers
Question Library

Ask a question about CAD
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About George Moustris
Expertise
I have extensive experience in MATLAB which is a CAD for engineers.I can answer many questions on the programming script as well as the use of many toolboxes Matlab uses.However DO NOT ask me about the underlying theory of your projects.I will only answer questions regarding the USE of Matlab.

Experience
I have written many scripts in Matlab utilizing many toolboxes and libraries such as Fuzzy Logic toolbox,Neural Nets,Image processing,Wavelets,Signal processing etc.

Organizations
Aristotle University of Thessaloniki

 
   

You are here:  Experts > Computing/Technology > Computer-Aided Design > CAD > GUIs

Topic: CAD



Expert: George Moustris
Date: 12/27/2007
Subject: GUIs

Question
Hi George,
Can you tell me the best way to learn to program GUIs in matlab. I find it confusing particularly in the handle graphics of the m-file when I have completed using guide to create the GUI layout.

Answer
Hi Jim,
handle graphics is rather simple if you get the idea, so i'm gonna explain to you in brief how it works. From there, if you read the Matlab manual you will get it on real quickly.   

First of all, every element in a GUI has its properties. You can define them either at program time or at run time (which is what you probably want). You can read or set a property by using the "get", "set" commands. Either way you need the handle of the gui element you want to operate on. The handle is a unique number that identifies each element. When you run a gui, each element is assigned a random number as its handle. Thus, you can't know before hand the handle of an element. The only way to get it at run time is by using its "TAG" property (well, not just the only way but the most common way). The tag is a word you assign to an element in order to distinguish it. Its a string you write when you create the gui in the GUIDE. So, say you have a button with a tag "myButton1". You can get its handle by using the "get" command, handle1=get("Tag","myButton1"). This will return the handle of the button. Now, you can change its property by using the set command, e.g. set(handle1,"SomeProperty","PropertyValue"). This is the way you can access and change handle graphics properties.

The automated m-file Matlab produces when you save a gui in GUIDE, is rather too messy for me. I don't use it. I write my scripts from scratch. I run a GUI using the "fig" command if a remember correctly. This creates the gui figure and assigns handles to all elements. Then i use the method described above to access them. Another important chapter on gui design is the callback functions. These are the functions an element calls when its state changes, e.g. when you press a button. Since the discussion on callbacks is rather lengthy, i suggest you read through the manual. It describes them very well. If you have any more questions feel free to contact me.

Best
G.

Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.