我应该将输入的字符串或选择的值分配给回调函数中的结构。我有类似下面的内容,但我无法将其嵌入到功能中。在命令窗口中,matlab返回一些数值而不是响应
%subject.name = NameAns %subject.gender = GenderAns
function b
d = dialog('Position',[300 300 300 300],'Name','My Dialog');
NameAns = uicontrol('Parent', d,...
'Style', 'edit',...
'String','Type Your Name',...
'position', [70 260 100 20] )
GenderAns = uicontrol('Parent', d,...
'Style', 'popup', 'String', {'female','male', 'other'},...
'Position', [70 230 90 20 ])
uicontrol('Parent', d, 'Style', 'pushbutton',...
'String', 'OK',...
'Position', [90, 90, 110, 30],...
'FontSize',18,'Callback',@OKCallBack);
function ConfCallBack(source,eventdata)
disp(get(source,'Value'));
subject.name = NameAns
subject.gender = GenderAns
uiwait (d)
end
function OKCallBack(source,eventdata)
close(d)
end
end