variable: global or in guidata
2 ビュー (過去 30 日間)
その他の回答 (2 件)
Alex 2011 年 11 月 17 日
Global variables are often a bad choice when programming.
Another option for sharing data through a gui is basing the gui in a class. This is my preferred method.
Jan 2011 年 11 月 17 日
In case of problems it is hard to find the code, which is responsible for the last changes in the global variables. In addition the uasge of globals lead to problems, if you want to open multiple instances of the GUI.
Therefore I prefer guidata - which calls setappdata internally, so you can call it directly also. Using the figure's UserData is equivalent. For conventional reasons I use the UserData for static values as handles and the application data for dynamic values like the current choice of variables etc. But this is a question of taste.