setappdata Question
1 次查看(过去 30 天)
显示 更早的评论
Within a GUI if I want to create a variable in one function and use it in another is "setappdata" a good stratagy to use? I am trying to get away from any use of global variables
0 个评论
采纳的回答
Jan
2011-9-30
Yes. SETAPPDATA is fine.
The function GUIDATA is convenient also, and internally it calls SETAPPDATA also.
Another idea is "set(FigHandle, 'UserData', data)", but this is no real difference. Just for conventions I'm using the UserData for values which change dynamically during using the GUI, and the ApplicationData for fixed values as handles etc. But these two methods can be swapped also, or joined whithout drawbacks.
0 个评论
更多回答(1 个)
Daniel Shub
2011-9-30
Yes, setappdata is a reasonable strategy and much better than a global variable. The FAQ provides some other alternatives.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 PID Controller Tuning 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!