Is it possible to make an app after you have written a large program?
1 view (last 30 days)
Show older comments
Muazma Ali on 21 Feb 2023
Hi! I have made a program in matlab and just started to make the app in matlab app designer but I am wondering whether I have done it in the right way by making a program at first and then making the app..
dpb on 21 Feb 2023
To amplify on the comment above -- the bulk of the code in the .mlapp file is stuff for housekeeping and the top-level callback functions.
The niceties of having the app keep its memory of where user left controls states and input file locations, etc., etc., ... is a lot of the typical "housekeeping" code that belongs there.
Then the callbacks don't need to do much of the work; just make sure the inputs are verified before calling the actual working code routines and then return the results needed to be available for other functions.
The biggest difference here is that you may need to share the various pieces of data computed by your app in global structure variables so the other callback functions can have access to those results if everything isn't done all in one function or one main function that calls all the workers sequentially before it returns to the UI.
Rik on 21 Feb 2023
In my personal opinion, a GUI should only be an interface to your function (that is after what the I stands for). That means it should only provide a convenient way to collect inputs and settings from your user and present progress/results to the user.
WIth that in mind it makes perfect sense to write your function first as a command line interface (CLI), and then create a wrapper around it that provides a graphical user interface (GUI).
If you want practical advice about how to approach creating a GUI in Matlab, you might want to have a look at this thread. I personally don't use AppDesigner, but most advice is interchangeable if you follow the design filosophy that Jan and dpb also already mentioned.
Find more on Develop Apps Using App Designer 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!