Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/15.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

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
Matlab 从按钮组中的radiobutton检索值并导出到工作区_Matlab_User Interface_Matlab Guide - Fatal编程技术网

Matlab 从按钮组中的radiobutton检索值并导出到工作区

Matlab 从按钮组中的radiobutton检索值并导出到工作区,matlab,user-interface,matlab-guide,Matlab,User Interface,Matlab Guide,我试图修改这个gui,因为我想添加一个功能。这个新功能用于评估疾病,我的意思是,如果当前在查看器上的切片有疾病,则用户单击“是”,否则单击“否”。每个患者应该执行几次。为了便于学习,我使用了matlab中的mri数据 问题是,我使用guide添加了一个新的框(buttongroup),其中包含两个单选按钮。但我无法从gui中获得任何价值。当我只使用get(eventdata.NewValue,'Tag')时,每次单击按钮时,我都可以在命令窗口中看到按钮的值,但我不知道如何保存这些单击。我尝试了以

我试图修改这个gui,因为我想添加一个功能。这个新功能用于评估疾病,我的意思是,如果当前在查看器上的切片有疾病,则用户单击“是”,否则单击“否”。每个患者应该执行几次。为了便于学习,我使用了matlab中的mri数据

问题是,我使用guide添加了一个新的框(buttongroup),其中包含两个单选按钮。但我无法从gui中获得任何价值。当我只使用get(eventdata.NewValue,'Tag')时,每次单击按钮时,我都可以在命令窗口中看到按钮的值,但我不知道如何保存这些单击。我尝试了以下方法,但没有成功:

% --- Executes when selected object is changed in Assess.
function Assess_SelectionChangeFcn(hObject, eventdata, handles)
% hObject    handle to the selected object in EmphyAssess 
% eventdata  structure with the following fields (see UIBUTTONGROUP)
%   EventName: string 'SelectionChanged' (read only)
%   OldValue: handle of the previously selected object or empty if none was selected
%   NewValue: handle of the currently selected object
% handles    structure with handles and user data (see GUIDATA)

switch get(eventdata.NewValue,'Tag')   % Get Tag of selected object
    case '1'
        value = 1; 
        Setappdata(hObject,'result', value); 

      case '2'
          value= 0; 
          Setappdata(hObject,'result', value); 

end

% --- Outputs from this function are returned to the command line.
function varargout = SliceBrowserIsa_OutputFcn(hObject, eventdata, handles)
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure

   varargout{1} = getappdata(hObject,'result');

您可以使用
guidata(hObject,handles)
-更新handles对象。之后,您应该能够访问该值


您的问题还提到导出到工作区-您可以使用
assignin('base','variable',value)
-

在figure对象中存储值。使用guidataHi@cwissy,我已经按照您在第一个示例中的建议,使用guidata(hObject,handles)修改了我的代码,但仍然无法在GUI之外获取值。我试过了,但什么也没发生。还有其他想法吗?也许问题是我没有很好地使用它,你能为我树立一个榜样吗?谢谢如果您将
assignin('base','result',value)
放入工作区中,您应该有一个
result
变量。你试过调试吗?