1

我的 MATLAB GUI 中有两个按钮。我试图在 button1 的回调函数中识别一个按钮,并对按下哪个按钮做一些事情。我尝试使用按钮组并将所有按钮都放在该组中。单击任何这些按钮时,似乎没有代码。为什么?

这是我的代码:

function uibuttongroup1_SelectionChangeFcn(hObject,eventdata)  
    switch get(eventdata.NewValue,'Tag') % Get Tag of selected object.  
    case 'notSimul'   
          disp('notSimul clicked')   
    case 'simul'  
        % Code for when radiobutton2 is selected.  
    case 'stopTest'  
        % Code for when togglebutton1 is selected.  
    case 'start'  
        % Code for when togglebutton2 is selected.  
    % Continue with more cases as necessary.  
    otherwise  
        % Code for when there is no match.  
end
4

1 回答 1

0

如果我正确理解您在按钮组中放置了一个按钮的问题,答案是它不起作用,因为按钮组应该只由切换按钮和单选按钮组成。正如您所描述的,当我尝试将按钮放入按钮组时,什么都不会发生。

于 2014-08-14T03:37:21.257 回答