GUI operations on matlab objects (non-GUI)
1 回表示 (過去 30 日間)
古いコメントを表示
I am having difficulty updating an object that I am using in a GUI callback. I am sure there must be a good way around it that I am missing because of my own lack of knowledge. If anyone can help me get around the problem (without undue hardship ;) ), I would appreciate it.
1)Say that I have an object 'obj' with internal variables 'varx' and 'vary'.
2)Say that, within a method of obj, I update obj.varx.
In order to keep the update beyond the duration of the method call, I need to return the object. [e.g. obj = obj.method(...);]
If I pass obj to a GUI callback and perform this operation, I cannot update obj in the main GUI function, because callbacks do not return output. (ex. set(h.toggle_exp, 'Callback', {@toggle, obj, othervar}); Using guidata() doesn't update particular variables, either.
Is the only way to update objects in the parent GUI function to define them as globals? (I hope not, ... ughh ...)
Any thoughts on how to a) update parent object within methods, and/or b) update particular variables within parent function would be awesome.
Thanks in advance, Sean
0 件のコメント
採用された回答
Walter Roberson
2011 年 11 月 15 日
You can assignin('caller') but when you are in a GUI callback, the caller is the the base MATLAB workspace. The main GUI function is not a "parent function" to a callback.
You can use nested functions and thus nested variables. This is probably the best way.
0 件のコメント
その他の回答 (1 件)
Sean de Wolski
2011 年 11 月 15 日
And there's always get/setappdata:
doc setappdata
doc getappdata
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Whos についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!