Alex Rivera | Logout

Is the MATLAB gui creator GUIDE as awful as I think? Is there an alternative?

Asked 2011-10-08T21:09:26.070
18

I've been trying to put together a gui in MATLAB and have had great difficulty. Here is a little background about my program: I want to create a wizard to step users through an image analysis process. The wizard will cue users for their input and then perform an image processing action once a button labeled "Next" has been pressed, and so on. From reading the MATLAB help I believe there are two approaches to gui creation: 1. write a gui with lines of code. 2. use GUIDE.

I figured GUIDE would have the shallowest learning curve. At first the process was straight-forward. I could drag and drop buttons and text boxes and arrange them easily. My plan was to arrange a series of panels, with the buttons and text and etc., that would sequentially become visible as the "Next" button was pressed. And it was here I became stumped.

Once I save a panel with GUIDE, MATLAB creates a .m file and a .fig file. Reading through the .m file I see it has left room for me to write code for the callbacks, but little else. The .fig file is binary and therefore I dare not bother edit it. I am left wondering how I can control the objects, e.g. How to set the visibility of a panel? Furthermore, I had to create each panel of the wizard separately. I was hoping that I could manually combine the .m files into a wizard.m wrapper file, but I do not think this is the right approach (at least for me, because I cannot see how to do it).

In lieu of using GUIDE I've seen examples where guis are created using the "uicontrol" function. This approach seems tedious to me, because I would have to manually code the position and size and defaults of each button. Perhaps this is the best approach, but it intimidates me.

As a result I am unhappy with MATLAB for its seemingly clunky gui tools and I am unhappy with myself for lacking the chops to overcome this hurdle.

I've seen some fancy guis created in MATLAB and having attempted this myself and falling way short I am b

Edit
Report

2 Answers

20

The .fig file is binary and therefore I dare not bother edit it.

FIG file is a MAT file containing list of gui elements with properties you set in GUIDE.

How to set the visibility of a panel?

Assign a Tag to the element, you can access it using handles.mytag like set(handles.mypanel, 'visible', 'off')

Furthermore, I had to create each panel of the wizard separately. I was hoping that I could manually combine the .m files into a wizard.m wrapper file, but I do not think this is the right approach (at least for me, because I cannot see how to do it).

You can not combine these automatically generated m-files into one, why would you want to anyway? Keep a .fig and .m file for each wizard page!

In lieu of using GUIDE I've seen examples where guis are created using the "uicontrol" function. This approach seems tedious to me, because I would have to manually code the position and size and defaults of each button. Perhaps this is the best approach, but it intimidates me.

Using uicontrol directly is not bad if you do not position elements manually but use a layout manager. You can see some here and here. If you want you GUI to be nicely resizable then layout manager is the only way to do it.

Does anyone have advice on this subject? Can anyone please point out where I am going wrong or why I am having such difficulty?

Professional GUI programming is not easy, IMO is even the most difficult part at all.

Besides MATLAB GUI I have used both Java Swing and .NET WPF a lot, IMO MAT

answered 2011-10-09T06:43:50.677
3

The main problem with GUIDE generated GUIs, opposed to programmatically created ones is the fact that the file is not a text. Thus, you cannot use a version control. There is a workaround - you can use the export function to create only .m file. Of course, you will not be able to switch it back to fig and edit it visually.
Personally, I always prefer to write GUIs without GUIDE.

answered 2012-01-29T23:36:19.243

Your Answer