Best way to generate specific GUI

3 views (last 30 days)
Hi all,
I've been a moderately heavy Matlab user for a long time, but I've never tried to make a GUI. Now I want to, and I'm looking for the best method. The App Designer examples and tutorial I have seen don't enforce any particular sequence of events. What I want to do is 1) have user locate a folder. 2) have code find files of a certain type in that folder -- let's say csv -- that have a certain thing in common. 3) User specifies which cells in the csv files (they all have the same structure) Matlab should capture and stuff into an array. I already have m-files to do these things, but the standard Matlab UI (e.g. "inputdlg") is very clunky. 4) Do various things with the results: write them out to an Excel file, maybe get some stats, generate plots (but we won't know how many until we find out how many csv files there are), stuff like that.
I don't even know where to begin. Will App Designer allow a sequential kind of thing like that? Do I have to use GUIDE? Can I call my existing matlab functions from AD or GUIDE? I tried researching this, but for whatever reason I couldn't get this thing off the ground.
Thanks all. Aram
  1 Comment
Aram Schiffman
Aram Schiffman on 22 May 2017
Thanks to both of you. I'll give App Designer a try when I get some free time (eye roll) and see how it goes. Thanks for the help! -Aram

Sign in to comment.

Accepted Answer

Gaurav Ahuja
Gaurav Ahuja on 19 May 2017
Well to get this off the grounds for you, I'll try to be very specific and try to answer your different queries to the point.
Well, both App Designer and GUIDE will enable you "to do sequential kind of things like you mentioned". How do you do it? The answer is callbacks. You can write different callbacks that apart from doing your jobs make a change to a global property say increment a 'count' variable that signifies a step number in your workflow. So before you do anything in a callback, you read this variable to see from which step you are coming. Well essentially its just a hack to serialize some independent processes. In addition in some cases with some tweaks, you can disable some other GUIs so that only your intended GUI is active. So yes, you can serialize.
So which one to start with? I'll say AppDesigner, just because of its new. But you can decide for yourself by reading a comparison between the two in the following link. However, essentially for your use case, both should give you equally good results. Both of them give you drag and drop capabilities to build an app. I find App Designer a bit easier to use and intuitive to work with. But it's your call.
https://www.mathworks.com/help/matlab/creating_guis/differences-between-app-designer-and-guide.html
"1) have user locate a folder." ==> use functions like 'uigetfile', 'uigetdir', 'uiopen', 'uiputfile' in callbacks, say of a button.
"2) have code find files of a certain type in that folder -- let's say csv -- that have a certain thing in common." ==> let you MATLAB code do the job, write that in a callback. You can also invoke any MATLAB function that you have already separately written from a callback, finish the job and resume back from where you left in the callback.
"3) User specifies which cells in the csv files (they all have the same structure) Matlab should capture and stuff into an array. I already have m-files to do these things" ==> you have a code, you are good to go. Using the 'Tables' feature would help you in this.
"4) Do various things with the results:" ==> well as long as MATLAB can do it, your app can do it.
"Can I call my existing matlab functions from AD or GUIDE?" ==> Yes, as I have already said. You can call them from the callbacks.
I really hope this helps you find answers to the queries you were looking for. Have a nice experience building apps. Good luck for your work.
  1 Comment
Walter Roberson
Walter Roberson on 19 May 2017
"In addition in some cases with some tweaks, you can disable some other GUIs so that only your intended GUI is active."
That is a somewhat common approach: build all of the possible figures and frames ahead of time, and make them visible or invisible and enabled or disabled at need.
Another approach is to build the items on the fly and destroy them when their immediate use is past. This approach does not require that you keep around a bunch of graphics objects just because the might be used; on the other hand, if you have a graphics object that is used a fair bit, then it is typically much more efficient to update its properties than to create a new version of it.
Creating graphics objects on the fly is also used a fair bit when the layout is not entirely fixed. For example if you allow your user to pick up to 9 images to display at the same time, and you want to maximize their display within an overall fixed frame, then you could create configurations ahead of time for the 1-image case, the 2-image case, the 3-image case, and so on, but it gets to be a nuisance to manage all of those objects, and it can be much easier to just compute the desired layout at run-time and show it.

Sign in to comment.

More Answers (0)

Categories

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

Products

Community Treasure Hunt

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

Start Hunting!