File Exchange Pick of the Week

April 17th, 2008

Advanced MATLAB: Handles and other inputs to GUIDE callbacks

There are three inputs to every automatically generated callback from GUIDE:

function edit1_Callback(hObject, eventdata, handles)

A common question that I am asked is “What is the handles structure?” This four minute video will show a simple GUI where you edit some text, and press a button that will copy that text into a third uicontrol. This is all done using the handles structure. The other two inputs: hObject and eventdata will be briefly discussed also.


Video Content

iconFiles.jpgiconPod.jpg

15 Responses to “Advanced MATLAB: Handles and other inputs to GUIDE callbacks”

  1. Quan replied on :

    Nice video as usual. You need a nickname of some sorts . . . I was thinking “The MATLAB Evangelist” might a good one.

    But seriously, good videos. I want to start linking them from blinkdagger because I think the tutorials supplement each other very well.

  2. naor replied on :

    Doug,
    Can you explain about guidata(hObject,handles)? I thought this was necessary after any change to handles.
    Thanks

  3. Doug replied on :

    Quan,

    We actually had “MATLAB Evangelist” as a title for while when Scott was looking for people. Looks like we took that out of the title, but there are plenty of jobs like that for MATLAB geeks.

    http://www.mathworks.com/company/jobs/opportunities/ApplicationEngineering.html

    Send me a resume, we will see what we can do.

    Doug

  4. Doug replied on :

    Naor,

    About GUIDATA: That is a a different way of interacting with handles. I prefer handles to be more of a read-only type of structure. If I want to store data, then I advocate SETAPPDATA. See my video on this:

    http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=8616&objectType=FILE

    Doug

  5. jiro replied on :

    Quan,

    There’s actually 6 of us at The MathWorks with an internal title of “LTC Evangelist” (LTC = Language of Technical Computing = MATLAB). I am one of them, and Doug used to be in this group as well.

  6. amiryousuf replied on :

    Hello, Can we output data entered by user in dialogbox to command window?
    thanks in advance.

  7. Administrator replied on :

    Amir,

    You would simply modify the callback to use the DISP command to display any data you want.

    Doug

  8. amiryousuf replied on :

    thanks for the idea. it is working.

  9. Tayfun replied on :

    ıt is very good video. I learn a lot of new things about gui

  10. Zach replied on :

    Doug,
    I have a GUI that I put a timer in so that it will check if any serial data has come in every second. I am having trouble getting the Timer to pass the handles structure to my function that is plopped into the M-file that guide made. On compile it says that the “handles” is undefined. I tried to pass the hadles from the Timer funtion by saying {@myfunction, handles} to pass the handles to the myfunction but I get another compile problem. any help would be great.

  11. Doug replied on :

    Zach,

    I think that the GETAPPDATA, SETAPPDATA techniques shown here:

    http://blogs.mathworks.com/pick/2005/10/03/guide-video-part-two/

    Might be an easy solution for you.

    Doug

  12. Zach replied on :

    Doug,
    I cant get the file to play from link or by going to list??

  13. Doug replied on :

    I have tested, it is working now.

    Doug

  14. nico replied on :

    thank you!! i’ve been looking for something like this

  15. Ferdy replied on :

    Thanks a lot!! Been at it for some time now

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


Bob, Brett & Jiro share their favorite user-contributed submissions from the File Exchange.

  • oleg: The author has implemented skewness, kurtosis and checks answering appropriately to the critic.
  • Ashok: how to store 10 or more random number in a loop a loop for i = 1:n mean(i) = input(’enter the mean value...
  • Ben: Doug, Thanks for the very helpful videos! Uitables seem like a convenient way to make a customized property...
  • oleg: Allstats has no checks, no comments and could also be improved (talking about prctile implementatio). Not to...
  • Todd: Additional information and a link to download free MATLAB and Simulink LEGO MINDSTORMS NXT code can be found at...
  • Doug: @Leo, Here is the “English version” of that code. “vec = []” makes an empty variable...
  • leo: Dear Doug I have a question in your code ‘October 9th, 2009 at 13:53′ vec = []; vec = [vec val]; I...
  • Shanker Keshavdas: You sir, are a gentleman and a scholar… No really, helped me out a lot. As to what is...
  • Quan Zheng: how can I get a copy of stepspecs.m?
  • Doug: @Lucy I think this is what you seek to move a line with the mouse in MATLAB. http://blogs.math...

These postings are the author's and don't necessarily represent the opinions of The MathWorks.