Saving the responses as struct from the GUI
显示 更早的评论
I supposed to assign the entered strings or chosen values to a struct in the callback functions. I have something like below but I cannot embed it into function. In command window, matlab returns me some numerical values rather than responses
function b
d = dialog('Position',[300 300 300 300],'Name','My Dialog');
Name = uicontrol('Parent',d,...
'Style','text',...
'Position',[20 180 50 100 ],...
'String','Name');
NameAns = uicontrol('Parent', d,...
'Style', 'edit',...
'String','Type Your Name',...
'position', [70 260 100 20] )
Gender = uicontrol('Parent',d,...
'Style','text',...
'Position',[20 150 50 100 ],...
'String','Gender');
GenderAns = uicontrol('Parent', d,...
'Style', 'popup', 'String', {'female','male', 'other'},...
'Position', [70 230 90 20 ])
Color = uicontrol('Parent',d,...
'Style','text',...
'Position',[20 120 50 100 ],...
'String','Favorite Color');
ColorAns = uicontrol('Parent', d,...
'Style', 'popup', 'String', {'Blue','Red', 'Orange'},...
'Position', [70 200 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
subject.color = ColorAns
uiwait (d)
end
function OKCallBack(source,eventdata)
close(d)
end
end
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!