从按钮组中的单选按钮检索值并导出到工作区
retrieve values and export to workspace from a radiobutton in a buttongroup
我正在尝试修改此 gui http://www.mathworks.com/matlabcentral/fileexchange/20604-3d-slice-viewer 因为我想添加一项功能。这个新功能是评估疾病,我的意思是如果当前在查看器上的切片有疾病,用户点击是,否则点击否。每个病人应该做几次。出于此学习目的,我使用来自 matlab 的 mri 数据。
问题是我使用指南添加了一个带有两个单选按钮的新框(按钮组)。但我无法从 gui 中获得任何价值。当我只使用 get(eventdata.NewValue, 'Tag') 时,每次单击按钮时,我都可以在命令中看到 window 按钮的值,但我不知道如何保存这些点击。我尝试了以下但没有成功:
% --- 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)
- look here for more info 更新句柄对象。之后您应该可以访问该值。
您的问题还提到导出到工作区 - 您可以使用 assignin('base', 'variable', value)
- see here
我正在尝试修改此 gui http://www.mathworks.com/matlabcentral/fileexchange/20604-3d-slice-viewer 因为我想添加一项功能。这个新功能是评估疾病,我的意思是如果当前在查看器上的切片有疾病,用户点击是,否则点击否。每个病人应该做几次。出于此学习目的,我使用来自 matlab 的 mri 数据。
问题是我使用指南添加了一个带有两个单选按钮的新框(按钮组)。但我无法从 gui 中获得任何价值。当我只使用 get(eventdata.NewValue, 'Tag') 时,每次单击按钮时,我都可以在命令中看到 window 按钮的值,但我不知道如何保存这些点击。我尝试了以下但没有成功:
% --- 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)
- look here for more info 更新句柄对象。之后您应该可以访问该值。
您的问题还提到导出到工作区 - 您可以使用 assignin('base', 'variable', value)
- see here