(GUI variable saving) guidata vs appdata
4 ビュー (過去 30 日間)
古いコメントを表示
Dear all
I need your opinion on the matter. In order to allow the user to enter various parameters, my program has a GUI figure. The problem is that the user by interacting with my program, creates a big amount of data, which have to be stored and processed every time. My problem is that when the user hovers his mouse on my figure, I need to go trough a lot of these data.
So, saving where, these data, will ensure the maximum speed for my program? Should I go with the appdata, or with the guidata (saving the variable directly into the guihandle)?
Thanks in advance
0 件のコメント
採用された回答
Sean de Wolski
2013 年 2 月 4 日
編集済み: Sean de Wolski
2013 年 2 月 4 日
guidata() Just uses setappdata() internally. That being said: setappdata() will be faster since you don't have the overhead of what's inside guidata().
3 件のコメント
Sean de Wolski
2013 年 2 月 4 日
What appdata are you using when you use setappdata; and how are you timing it?
Sean de Wolski
2013 年 2 月 4 日
Also, if you're really worried about timing and control, (which it sounds like you are!), ditch GUIDE and write the GUI programatically. GUIDE uses an older framework that is not necessarily speed or control optimized.
Using nested functions will get you this.
These examples will help you getting started:
その他の回答 (1 件)
Jan
2013 年 2 月 4 日
GUIs live in the frequency domain of 10 Hz: Mouse clicks by the user, animated effects, waiting for update of the screen - GUIs are slow and that's ok, because they are useful for the slow visual reception by human.
When calculations should happen with a high speed, they should be decoupled from the GUI, such that the decision between guidata and setappdata does not matter at all. Processing a lot of data whenever the mouse is moved is prone to problems caused by the latency. Unfortunately such an uncoupling is not easy in Matlab, because Matlab runs a single thread only.
You do not have to search for the spatial objects dynamically. The areas belonging to certain objects change only when you move the 3D or 2D scene and when new objects are added.
Finally I'm convinced that getappdata is faster than guidata for the reasons Sean has posted already. But the small overhead of both functions should not matter, when you avoid to call them thousands of times for one processing step. Calling them once should be sufficient, when the data are stored in a useful structure.
4 件のコメント
Sean de Wolski
2013 年 2 月 5 日
http://blogs.mathworks.com/videos/2011/03/29/graphics-challenge-for-new-users/ And the solutions in the next two posts.
参考
カテゴリ
Help Center および File Exchange で Graphics Object Properties についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!