Is it more efficient to pass data between functions by global variables than handles structure in Matlab GUI?
Thanks, Myrick
Is it more efficient to pass data between functions by global variables than handles structure in Matlab GUI?
Thanks, Myrick
Just to complement Pariah's and Lucius' answers, if you intend to deploy your GUI as a standalone application you will likely discover that it's a bad idea to use global/persistent variables.
There are of course some workarounds you can use but as Pariah mentioned, it's good practice to limit your use of global variables although they highly simplify code development.
Depends mainly on what you want to do.
I mean normally i do global variables for prototyping, (and it is poor practice to set all variables to global for security and for performance reasons).
But then again when passing variables via handlers, is a good practice that you really should get into because it not only gives you a better insight into the data you are passing but forces you into good coding practices to aid in debugging and future work that you may extend on your current work.
(This is more of a suggestion but also if you set global variables it can create nightmares when debugging code).
depending on how big is your data, you could see differences in terms of speed.
the main reason is (correct me, if I'm wrong):
but of course, maintaining a code with many global variables can get more complicated. If someone got the time: create a simple performance-test, that compares both variants with different sizes of data passed :)