setappdata Question

1 回表示 (過去 30 日間)
William
William 2011 年 9 月 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

採用された回答

Jan
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.

その他の回答 (1 件)

Daniel Shub
Daniel Shub 2011 年 9 月 30 日
Yes, setappdata is a reasonable strategy and much better than a global variable. The FAQ provides some other alternatives.

カテゴリ

Help Center および File ExchangePID Controller Tuning についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by