GUI with existing function

15 views (last 30 days)
Faith McColl
Faith McColl on 17 Jul 2015
Commented: Walter Roberson on 17 Jul 2015
How do you put an existing Matlab function- or more than one function- into a GUI? When I look up tutorials for how to make GUIs, all I see is how to make one from scratch. How can I make a GUI from existing functions and/or data? I have MATLAB_R2015a.
  2 Comments
Muthu Annamalai
Muthu Annamalai on 17 Jul 2015
Fatih, what the answer from Walter recommends is to keep the GUI parts and computation parts separate.
Walter Roberson
Walter Roberson on 17 Jul 2015
Heh. My answer did not recommend that, but it is a good point.
My experience is that when my GUI programs grow large enough, my users start to want automation, such as to be able to process a series of files the same way.
Automation can be achieved by writing a routine that activates the GUI step-by-step, including faking clicks, but that approach tends to be very fragile, sometimes failing on minor changes such as the user selecting a different font size.
The other main way to achieve automation is by building in a command language that can be represented as text (so files of commands can be created and edited), and then have the GUI invoke those commands. This approach is more initial work, requiring that a command parser be designed and written, but it is much easier than trying to retrofit automation into a project created as a pure GUI. It is the approach I recommend -- keeping the GUI and the computation separate.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 17 Jul 2015
Create the GUI from scratch. Edit the code for the appropriate callback functions so that they have calls to your existing routines.
  1 Comment
Faith McColl
Faith McColl on 17 Jul 2015
Thank you! I will refine my research and figure out how to do that.

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 17 Jul 2015
You can try MAGIC. http://www.mathworks.com/matlabcentral/fileexchange/24224-magic-matlab-generic-imaging-component. Just plug your code into the AnalyzeSingleImage function. It's a good framework to start out using GUIs.
Description This GUI will help the novice user get up to speed very quickly on using GUI-based applications. Everything is laid out in a very simple Step 1, Step 2, Step 3, etc. layout. It is a very good starting point for a typical image analysis application. This application uses GUIDE to do the user interface design, and has most of the basic controls such as buttons, listboxes, checkboxes, radio buttons, scrollbars, etc. It allows the user to select a folder of images, select one or more images and display them, to select a series of options, and to individually or batch process one or more images. The user can optionally....
  2 Comments
Faith McColl
Faith McColl on 17 Jul 2015
Thank you, but I would rather not download anything outside the Matlab program I currently have.
Image Analyst
Image Analyst on 17 Jul 2015
Faith:
Then you can recreate a generic user interface - one with all the custom controls, whatever you want - if you follow the guidelines in this tutorial: http://blogs.mathworks.com/videos/2013/02/06/introduction-to-gui-building-with-guide-in-matlab/?s_tid=Blog_Videos_Category. Of course it will take time to build in some of the convenient features that MAGIC already has , but maybe you want to do it yourself.

Sign in to comment.

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!