我试图修改此gui http://www.mathworks.com/matlabcentral/fileexchange/20604-3d-slice-viewer,因为我想添加一项功能。这个新功能是评估疾病,我的意思是如果当前观察者的切片有疾病,用户单击是,否则单击否。每位患者应该多次这样做。为了这个学习目的,我使用了来自matlab的mri数据。
问题是我使用指南添加了一个带有两个单选按钮的新框(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');
答案 0 :(得分:0)
您可以使用UnboundLocalError: local variable 'counter' referenced before assignment
- look here for more info更新句柄对象。之后,您应该能够访问该值。
您的问题还提到导出到工作区 - 您可以使用guidata(hObject,handles)
- see here