4

I have inherited a pile of Matlab scripts that manually build a GUI using calls to uicontrol, uimenu, etc. Over the years we have needed to remove and add elements to the GUI and since all the positions are specified manually in the scripts, the layout hasn't really changed to accommodate the missing elements so it is really starting to look like a pile of trash.

Is there a way to automatically convert my matlab scripted gui into something I can use with guide? I would rather not have to start over...

2 Answers 2

6

GUIs generated with GUIDE are not much better than manually scripted ones (if not worse in my opinion in terms of maintainability).

The sad truth is that there are no builtin layout managers in MATLAB (there are user-contributed ones on FEX like border layout, gridbag layout and others). If you are refactoring the code, please consider using some sort of GUI layout manager.

To answer your question, afaik there is no automatic tool for such a conversion.


To be exact, MATLAB has some undocumented layout managers: uiflowcontainer and uigridcontainer. See this article by Yair Altman

2
  • Can I ask why you dislike GUIDE?
    – mjr
    Apr 24, 2013 at 12:05
  • 1
    @mjr: I don't dislike it, it certainly has its uses. It's just that based on your description, I had the impression that your project is starting to grow beyond a simple GUI, in which managing it with drag-drop style in GUIDE is not much better than hard-coding the ui-control elements position manually in the code. A better solution is to let a layout manager worry about "layout" :) For example take a look at GUI Layout Toolbox on FEX (it has excellent documentation as well)
    – Amro
    Apr 24, 2013 at 12:14
2

Well, there is no automatic conversion utility but you dont need to create everything from scratch with GUIDE.

Execute your GUI so that it shows up and save the figure window as a fig file. This file then can be edited with guide. However this needs manual adjustments in your code. Especially if you need access to handles and I am also not sure about the callback functions.

However, as Amro already pointed out, GUIDE is not a perfect solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.