Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Matlab GUI newbye

Subject: Matlab GUI newbye

From: Frank

Date: 30 Nov, 2008 23:48:01

Message: 1 of 8

Hi again!

So many questions for you experts these days. I'd like to know if there is a simple and fast way to create a GUI interface with data input boxes for parameters, other simple controls, like labels or textboxes to give output information (like the time elapsed) and buttons that start the calculation of a PDE solution (I wrote the code for that) with a figure window in which to display the "video" or frames of the time varying solution?

Thank you

Subject: Matlab GUI newbye

From: ImageAnalyst

Date: 1 Dec, 2008 00:17:31

Message: 2 of 8

On Nov 30, 6:48=A0pm, "Frank" <francesco.mann...@fastwebnet.it> wrote:
> Hi again!
>
> So many questions for you experts these days. I'd like to know if there i=
s a simple and fast way to create a GUI interface with data input boxes for=
 parameters, other simple controls, like labels or textboxes to give output=
 information (like the time elapsed) and buttons that start the calculation=
 of a PDE solution (I wrote the code for that) with a figure window in whic=
h to display the "video" or frames of the time varying solution?
>
> Thank you

---------------------------------------------------------------------------=
-----------
Frank:
Yes. I suggegst you use GUIDE. It's included in MATLAB and allows
you to put various kinds of controls on the GUI (static text, edit
fields, button, pictures/plots, scroll bars, radio button, check
boxes, grids/tables, etc.) and you can set various properties for them
(size, color, location, font, caption, etc.).
Regards,
ImageAnalyst

Subject: Matlab GUI newbye

From: Frank

Date: 1 Dec, 2008 13:11:02

Message: 3 of 8

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <c2fd2c68-5120-49ca-8cd0-06ca543eb7be@20g2000yqt.googlegroups.com>...
> On Nov 30, 6:48=A0pm, "Frank" <francesco.mann...@fastwebnet.it> wrote:
> > Hi again!
> >
> > So many questions for you experts these days. I'd like to know if there i=
> s a simple and fast way to create a GUI interface with data input boxes for=
> parameters, other simple controls, like labels or textboxes to give output=
> information (like the time elapsed) and buttons that start the calculation=
> of a PDE solution (I wrote the code for that) with a figure window in whic=
> h to display the "video" or frames of the time varying solution?
> >
> > Thank you
>
> ---------------------------------------------------------------------------=
> -----------
> Frank:
> Yes. I suggegst you use GUIDE. It's included in MATLAB and allows
> you to put various kinds of controls on the GUI (static text, edit
> fields, button, pictures/plots, scroll bars, radio button, check
> boxes, grids/tables, etc.) and you can set various properties for them
> (size, color, location, font, caption, etc.).
> Regards,
> ImageAnalyst

Thank you very much! Now I'm trying to understand how it works, seems like a visual programming language... It's really what I was looking for. I have a question for you. If I use a template I have some code already written and ready to use, but if I choose a blank Gui project, is there a way to get function names and parameters automatically? (In visual B or C you just clicked on the button for example and the code window opened with the functions declared)

Thanks

Frank

Subject: Matlab GUI newbye

From: Husam Aldahiyat

Date: 1 Dec, 2008 13:55:06

Message: 4 of 8

GUIDE on default creates an m-file for your GUI with callback functions for each of the uicontrols that you put (edit, text, slider, etc.). So after you make the GUI and save it, scroll down to one of the functions and put your code there (you can check control's callback but doiuble clicking on it).

Subject: Matlab GUI newbye

From: ImageAnalyst

Date: 1 Dec, 2008 15:17:51

Message: 5 of 8

On Dec 1, 8:55=A0am, "Husam Aldahiyat" <numand...@gmail.com> wrote:
> GUIDE on default creates an m-file for your GUI with callback functions f=
or each of the uicontrols that you put (edit, text, slider, etc.). So after=
 you make the GUI and save it, scroll down to one of the functions and put =
your code there (you can check control's callback but doiuble clicking on i=
t).

---------------------------------------------------------------------------=
--------------
Well, not exactly. These functions are only created in your source
code AFTER you right click on the control then select "View Callbacks"
and pick the callback function that you want. Only AFTER this, does
the callback function actually show up in the source code. (Try it
and you'll see.)

Your best option may be to create the callbacks by right clicking as
described above, then paste your template code (from some other m-
file) into the appropriate function. I just go with the automatically-
created callback function names, but you can change these if you want
by modifying the string in the callback property of the control. This
will give it the name you want instead of the automatically-generated
name. So this could be an option for you if you really like the
function names in your template instead. Just make sure that the
three input arguments match the automatically-generated input
arguments.

I know it's not as nice as Visual Studio and I hear they are working
on a massive upgrade for the lame GUIDE. For example, when you double
click the control, it brings up the properties window instead of the
callback source code (Visual Studio brings up the callback source
code). Plus there's no way to dock the properties window. Why they
chose not to allow docking of that window when they do allow docking
of most other windows, I don't know. I'd prefer a docked properties
window and to go to the control's callback source code when you double
click on the control (i.e. just like it is in Visual Studio). And
control-a selects all controls on the figure EXCEPT those controls
within group boxes. And there's the whole issue with units -
normalized, pixels, etc. How if you're in normalized and then want to
adjust something - well, it's a major pain to get things aligned. I
could go on but they know it's crappy and hopefully the next version
will be a lot better. But for now, it's all we have and it's still
better than creating all the figures and controls on it manually in
your code.
Regards,
ImageAnalyst

Subject: Matlab GUI newbye

From: ImageAnalyst

Date: 1 Dec, 2008 15:26:27

Message: 6 of 8

On Dec 1, 10:17=A0am, ImageAnalyst <imageanal...@mailinator.com> wrote:
> On Dec 1, 8:55=A0am, "Husam Aldahiyat" <numand...@gmail.com> wrote:
>
> > GUIDE on default creates an m-file for your GUI with callback functions=
 for each of the uicontrols that you put (edit, text, slider, etc.). So aft=
er you make the GUI and save it, scroll down to one of the functions and pu=
t your code there (you can check control's callback but doiuble clicking on=
 it).
>
> -------------------------------------------------------------------------=
--=AD--------------
> Well, not exactly. =A0These functions are only created in your source
> code AFTER you right click on the control then select "View Callbacks"
> and pick the callback function that you want. =A0Only AFTER this, does
> the callback function actually show up in the source code. =A0(Try it
> and you'll see.)
>
> Your best option may be to create the callbacks by right clicking as
> described above, then paste your template code (from some other m-
> file) into the appropriate function. =A0I just go with the automatically-
> created callback function names, but you can change these if you want
> by modifying the string in the callback property of the control. =A0This
> will give it the name you want instead of the automatically-generated
> name. =A0So this could be an option for you if you really like the
> function names in your template instead. =A0Just make sure that the
> three input arguments match the automatically-generated input
> arguments.
>
> I know it's not as nice as Visual Studio and I hear they are working
> on a massive upgrade for the lame GUIDE. =A0For example, when you double
> click the control, it brings up the properties window instead of the
> callback source code (Visual Studio brings up the callback source
> code). =A0Plus there's no way to dock the properties window. =A0Why they
> chose not to allow docking of that window when they do allow docking
> of most other windows, I don't know. =A0I'd prefer a docked properties
> window and to go to the control's callback source code when you double
> click on the control (i.e. just like it is in Visual Studio). =A0And
> control-a selects all controls on the figure EXCEPT those controls
> within group boxes. =A0And there's the whole issue with units -
> normalized, pixels, etc. =A0How if you're in normalized and then want to
> adjust something - well, it's a major pain to get things aligned. =A0I
> could go on but they know it's crappy and hopefully the next version
> will be a lot better. =A0But for now, it's all we have and it's still
> better than creating all the figures and controls on it manually in
> your code.
> Regards,
> ImageAnalyst

-------------------------------------------------------
Frank:
Oh yeah, one other thing I forgot to tell you. When you view the
callback, it creates two functions: the callback and an "CreateFcn"
function. You put your code into the callback. But even though the
CreateFcn() function for that control doesn't have any code in it,
don't think that it's safe to delete it. You might think so because
there may be other controls on the figure that you haven't viewed the
callback for (checkboxes, etc.) and they don't have Create functions
for them but yet they do, in fact, get created. So you might think
that they are optional, especially since there's no code inside it,
only comments. However if you delete the CreateFcn() and run your
code, all hell breaks loose. MATLAB crashes with a big dump. So
don't delete any CreateFcn() functions once they are created. It may
even totally corrupt your file and the only option is to get an old
copy from a backup that you've hopefully made (I know from experience
- several times!). I just now (this morning) verfied this crash
again, in R2008b, so it's still not fixed. You've been warned.
Good luck,
ImageAnalyst

Subject: Matlab GUI newbye

From: Frank

Date: 1 Dec, 2008 23:11:01

Message: 7 of 8

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <3bec2bf3-471a-4709-a44c-b9be2364ac0d@k19g2000yqg.googlegroups.com>...
> On Dec 1, 10:17=A0am, ImageAnalyst <imageanal...@mailinator.com> wrote:
> > On Dec 1, 8:55=A0am, "Husam Aldahiyat" <numand...@gmail.com> wrote:
> >
> > > GUIDE on default creates an m-file for your GUI with callback functions=
> for each of the uicontrols that you put (edit, text, slider, etc.). So aft=
> er you make the GUI and save it, scroll down to one of the functions and pu=
> t your code there (you can check control's callback but doiuble clicking on=
> it).
> >
> > -------------------------------------------------------------------------=
> --=AD--------------
> > Well, not exactly. =A0These functions are only created in your source
> > code AFTER you right click on the control then select "View Callbacks"
> > and pick the callback function that you want. =A0Only AFTER this, does
> > the callback function actually show up in the source code. =A0(Try it
> > and you'll see.)
> >
> > Your best option may be to create the callbacks by right clicking as
> > described above, then paste your template code (from some other m-
> > file) into the appropriate function. =A0I just go with the automatically-
> > created callback function names, but you can change these if you want
> > by modifying the string in the callback property of the control. =A0This
> > will give it the name you want instead of the automatically-generated
> > name. =A0So this could be an option for you if you really like the
> > function names in your template instead. =A0Just make sure that the
> > three input arguments match the automatically-generated input
> > arguments.
> >
> > I know it's not as nice as Visual Studio and I hear they are working
> > on a massive upgrade for the lame GUIDE. =A0For example, when you double
> > click the control, it brings up the properties window instead of the
> > callback source code (Visual Studio brings up the callback source
> > code). =A0Plus there's no way to dock the properties window. =A0Why they
> > chose not to allow docking of that window when they do allow docking
> > of most other windows, I don't know. =A0I'd prefer a docked properties
> > window and to go to the control's callback source code when you double
> > click on the control (i.e. just like it is in Visual Studio). =A0And
> > control-a selects all controls on the figure EXCEPT those controls
> > within group boxes. =A0And there's the whole issue with units -
> > normalized, pixels, etc. =A0How if you're in normalized and then want to
> > adjust something - well, it's a major pain to get things aligned. =A0I
> > could go on but they know it's crappy and hopefully the next version
> > will be a lot better. =A0But for now, it's all we have and it's still
> > better than creating all the figures and controls on it manually in
> > your code.
> > Regards,
> > ImageAnalyst
>
> -------------------------------------------------------
> Frank:
> Oh yeah, one other thing I forgot to tell you. When you view the
> callback, it creates two functions: the callback and an "CreateFcn"
> function. You put your code into the callback. But even though the
> CreateFcn() function for that control doesn't have any code in it,
> don't think that it's safe to delete it. You might think so because
> there may be other controls on the figure that you haven't viewed the
> callback for (checkboxes, etc.) and they don't have Create functions
> for them but yet they do, in fact, get created. So you might think
> that they are optional, especially since there's no code inside it,
> only comments. However if you delete the CreateFcn() and run your
> code, all hell breaks loose. MATLAB crashes with a big dump. So
> don't delete any CreateFcn() functions once they are created. It may
> even totally corrupt your file and the only option is to get an old
> copy from a backup that you've hopefully made (I know from experience
> - several times!). I just now (this morning) verfied this crash
> again, in R2008b, so it's still not fixed. You've been warned.
> Good luck,
> ImageAnalyst

I thank you very much! Your answer was very satisfying. I will ask you in future if I need some hint about GUI. Now I start my struggle with GUIDE!

Frank

Subject: Matlab GUI newbye

From: Jiro Doke

Date: 1 Dec, 2008 23:24:02

Message: 8 of 8

"Frank" <francesco.manni01@fastwebnet.it> wrote in message >
> I thank you very much! Your answer was very satisfying. I will ask you in future if I need some hint about GUI. Now I start my struggle with GUIDE!
>
> Frank

Frank,

These videos by Doug may be of interest to you:

http://blogs.mathworks.com/videos/category/gui-or-guide/

You can start off with the first one (last on the page):

http://blogs.mathworks.com/videos/2005/05/05/gui-building-tutorial/
(GUI Building Tutorial)


jiro

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us