File Exchange Pick of the Week

August 3rd, 2007

Dynamic GUIs with GUIDE

I recently got a question via e-mail from a reader of this blog. This MATLAB user wanted to know:

If you are thinking about another tutorial, can you show if it is possible to build a dynamic GUI, i.e., instead of actions opening other GUI’s, the parent GUI layout itself changes to offer user more content within the same GUI?

I do read and respond to all of my e-mails, so as requested here is a video about reconfiguring a GUI as it is running.

The files are all here on the File Exchange.

12 Responses to “Dynamic GUIs with GUIDE”

  1. Jette replied on :

    Doug,
    nice video - but this is a quite simple dynamic GUI. What if you don’t know how many elements of something you need because it depends on a users choice? And/or if you need to change the size of a GUI during runtime? That are things I still have no idea how to do it with GUIDE.

    Jette

  2. Doug replied on :

    Jette,

    Excellent idea for a new movie. The dynamic resizing should not be a problem, ‘position’ is a property of the GUI that you can change with set and get as shown here with visibility.

    However, adding N buttons to a GUI based on user input, that might be done in a couple of ways. You could just have the maximum number of buttons and hide, unhide them. The other thing you might want to do is create them as needed. That is a little more complicated and will take a short movie to explain.

    Thanks for the input,
    Doug

  3. Ruben replied on :

    Hi Doug,
    I had the same question as Jette. This is my code

    ——————————————————–

    i = 2;
    x = get(handles.NFilter,’String’)
    % display x;
    j = str2num(x);
    k = 24;
    while(i

  4. Ruben replied on :

    Since my last question is cut half,
    How can i create dynamic callbacks?

  5. Mohammad Sarfaraz replied on :

    too much excellent;
    I was wondering if you could possibly make a GUI which simulate “impact” of 2 particles with the given velocity.This subject comes from the Dynamic Lessons.

    Mohammad Sarfaraz
    Mohammad.Sarfaraz@gmail.com

  6. Doug replied on :

    Thank you for the kind words. I can only really make demos that are of general interest so I would not be able to do this. You may want to try finding collaborators on the Newsgroup.

    Doug

  7. Craig Mewis replied on :

    Hey Doug, thanks for all the great videos!
    I’m really learning alot here.
    In particular I’m looking for a movie along the lines of what Jette has asked. I’d like to create a certain number of boxes as I need them, I’d rather not do the hiding/unhiding as I think that may create problems later on (trying to think ahead)
    A video on this subject would be excellent.
    Thanks,
    Craig

  8. Muzaffar replied on :

    hi dear Doug,

    this is always nice to see your videos. it would be nice of you if you please take care of the move pointer/cursor position in your presentations.
    It would be nice if you please present a simple example how to load data into matlab (say from xls file) after making some process saving back to the file or to xls.

  9. Doug replied on :

    Muzaffar,

    Thank you for the comments. This is actually one of my earlier movies, I think you will find I have gotten better about parking the cursor as I go.

    That is a great idea to write out an Excel file when I am done. I will make one of those soon!

    Doug

  10. Santiago replied on :

    I really would like to know how to make dynamic callbacks. I have created a GUI where the user input determines the layout and produces a variable (aka dynamic) number of pushbuttons. HOWEVER, I am not sure how to assign to them different Callbacks (e.g. ‘Callback’, {@dyn0_Callback, hFigure} for the first, ‘Callback’, {@dyn1_Callback, hFigure} for the second, and so on until it creates the Nth pushbutton and assigns it ‘Callback’, {@dynN_Callback, hFigure}). The challenge really is not to assign different callbacks but to create the functions that correspond to the callbacks. Subsequently, I need to know how to create or emulate dynamic callbacks/functions.

  11. Doug replied on :

    I think that anonymous functions will serve you well here:

    http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_prog/f4-70115.html

    You will want to make these anonymous functions inside of another function. It is sort of like an anonymous function is the output of a different function.

    If I understand your question, this should be what you are looking for.

    Doug

  12. Rajat replied on :

    I am just starting to learn GUIs in Matlab. This is a great tutorial sites…demos always help and saves a lot of time. I appreciate your efforts Doug.

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.

  • Zach: Hi Doug and Les, I didn’t have a lot of time to mess with this, but I did find a work-around. I plotted...
  • hamed: k
  • Les: @Zach This isn’t exactly what you are looking for but at least it puts all three parameters on the same...
  • Zach: Thanks for your suggestions Doug. I’ll give that a shot and see what happens. I’ve seen many of...
  • Doug: @Zach, I would say to use plotYYY, because that is close to what you want, but using depth as Y makes sense....
  • Doug: @Teja, I think this will work: http://www.mathworks .com/access/helpdesk /help/techdoc/ref...
  • Gify: merry christmas :) nice christmas tree! Regards, Janet Gify
  • Teja: Dear Doug Is there anyway to plot a surface from nonuniform data without meshgrid and griddata? Basically i...
  • Zach: I’m working with geophysical data, so I’d like to produce a depth profile. The y-axis would be...
  • Doug: @Ashok First, please do not use variable names that are MATLAB commands (std and mean). Second, p(j) should be...

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