Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
需要按两次按钮才能更新MatlabGUI中的变量_Matlab_User Interface_Matlab Guide_Handles - Fatal编程技术网

需要按两次按钮才能更新MatlabGUI中的变量

需要按两次按钮才能更新MatlabGUI中的变量,matlab,user-interface,matlab-guide,handles,Matlab,User Interface,Matlab Guide,Handles,我有以下代码作为MATLAB GUI代码的一部分: k = waitforbuttonpress; if k==0 if strcmp(get(handles.YESNO,'String'),'Y') hint = 1; else hint = 0; end else hint = 0; end 我等待用户按下两个“是”或“否”按钮中的一个。在每个回调中,我将变量han

我有以下代码作为MATLAB GUI代码的一部分:

k = waitforbuttonpress;
if k==0               
   if strcmp(get(handles.YESNO,'String'),'Y')

        hint = 1;
    else
        hint = 0;
    end                
else
    hint = 0;
end
我等待用户按下两个“是”或“否”按钮中的一个。在每个回调中,我将变量handles.YESNO更新为sethandles.YESNO、'String'、'Y';或者sethandles.YESNO,'String','N';分别


当我执行我的MatlabGUI时,我必须按两次YES按钮才能使值生效。有什么克服这个问题的提示吗?

我相信WaitForButton按钮会屏蔽您的回调。
相反,请使用uiwait阻止您的执行,它将等待您的图形关闭或通过按钮回调调用uiresume。

这是我在“是”回调中的内容。。函数YES\u CallbackhObject,eventdata,handles sethandles.YESNO,'String','Y';guidatahObject,handles。我不完全理解你的意思,但是当我使用调试器并放置断点时,它工作得很好。但它在实际运行时并不存在。可能掩盖你的回拨是发生了什么,如果这是一件事。所以调用uiwait来等待用户输入,而uiresume应该放在回调中?