does the GUI read scripts?

9 views (last 30 days)
MAHMOUD ALZIOUD
MAHMOUD ALZIOUD on 5 Nov 2017
Edited: Stephen23 on 6 Nov 2017
Hello Guys, I have a question please. I started to watch tutorials on YouTube about the Graphical user interface on matlab, because I wrote many codes and I need to visualize them. my question is: my codes are written on scripts, I didn't make then as function, Can the Graphical user interface deal with scripts? or should I have them as functions? another question , how can I learn more about this. thank you guys.
  1 Comment
Stephen23
Stephen23 on 6 Nov 2017
Edited: Stephen23 on 6 Nov 2017
Even if it did, you should not be using scripts. Scripts might be fun for playing around in the command window, but if you want to write code that is efficient, repeatable, and debuggable then you need to be writing functions or classes.
Rule of thumb: if your code is going to be used for more than one day, turn it into a function. Test it, document it, write clear input and output specifications.

Sign in to comment.

Accepted Answer

per isakson
per isakson on 5 Nov 2017
Edited: per isakson on 5 Nov 2017
  • "I am a PhD student and working on some traffic counting cards, the card has around 2900 rows ..." (excerpt from one of your questions a month ago) May I assume that you plan to work with real world data over a longer period of time? If so, I assume it would pay off to develop some good programming habits.
  • "I started to watch tutorials on YouTube about the Graphical user interface ..." Do I hear a bit of rejection of the documentation made by The MathWorks? See Videos and Webinars
  • "Can the Graphical user interface deal with scripts?" Yes, but don't do it! Read https://se.mathworks.com/matlabcentral/answers/228557-experts-of-matlab-how-did-you-learn-any-advice-for-beginner-intermediate-users#answer_185153 and convert them to function. Remember that you must be able to understand and trust the code in two years from now.
"how can I learn more about this"
There are three different ways to make graphical interfaces in Matlab:
  1. App Designer (Matlab the new drag-and-drop tool)
  2. GUIDE (the old tool. IMO: don't touch it! )
  3. Create Apps Programmatically (see 41 Complete GUI Examples by Loginatorist and GUI Examples using Nested Functions by Steven Lord for a good approach)
  4 Comments
per isakson
per isakson on 6 Nov 2017
Edited: per isakson on 6 Nov 2017
Yes, that's correct. Neither have I done any serious work with the the new App Designer.
The MathWorks doesn't provide us with a road-map regarding "making graphical interfaces", but I find it hard to believe that App Designer and GUIDE will be developed in parallel. I believe GUIDE will eventually be dropped and it isn't worth start to use it now. See https://se.mathworks.com/matlabcentral/answers/296406-app-designer-or-guide#answer_229177.
I'm very much in favor of the programmatic way. For small programs with a GUI I think the "nested approach" of Steven Lord is good. I've used it many times.
MAHMOUD ALZIOUD
MAHMOUD ALZIOUD on 6 Nov 2017
Mr Walter, I just started with this thing and I think it is something very useful but hard at the same time.

Sign in to comment.

More Answers (0)

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!