callback function handle syntax inside objects?
1 次查看(过去 30 天)
显示 更早的评论
I have an object that generates a gui and controls some external equipment. I am trying to set things up so that a particular button press on the gui sends a particular command to the external equipment (without success). The command is sent using one of the object methods.
Example:
cg=CCUCGUI('10.0.1.1');
cg.navi('up');
The above code works, but my numerous attempts to create a callback inside the object contructor have failed miserably.
I have tried the following and more, but my understanding of callback function handle syntax is clearly insufficient to the task.
set(obj.guiobj.buttonup,'Callback','obj.navi(''up'');');
%Note the above executes, but 'obj' does not exist in main MATLAB workspace
set(obj.guiobj.buttonup,'Callback',@() obj.navi('up'));
set(obj.guiobj.buttonup,'Callback',{@() obj.navi('up')});
set(obj.guiobj.buttonup,'Callback',{@('up') obj.navi});
set(obj.guiobj.buttonup,'Callback'{@obj.navi,'up'});
tmp='up';set(obj.guiobj.buttonup,'Callback',@(tmp) obj.navi);
tmp='up';set(obj.guiobj.buttonup,'Callback',{@(tmp), obj.navi});
Any help would be appreciated, Thanks, Sean
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!