【发布时间】:2015-05-27 16:09:16
【问题描述】:
我正在尝试修改此 gui http://www.mathworks.com/matlabcentral/fileexchange/20604-3d-slice-viewer,因为我想添加一个功能。这个新功能是评估疾病,我的意思是如果当前查看器上的切片有疾病,用户单击是,否则单击否。每个病人应该做几次。出于学习目的,我使用了 matlab 中的 mri 数据。
问题是我使用指南添加了一个带有两个单选按钮的新框(按钮组)。但我无法从 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
标签: matlab user-interface matlab-guide