Saving the responses as struct from the GUI
Afficher commentaires plus anciens
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
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Characters and Strings dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!