how to get an output from this dialog box?

3 次查看(过去 30 天)
I am sure I am making just a plain old dumb mistake but how in the world do I gan an answer/output from this? It pops up, respones, but when it's gone I don't have any value from the box at all :(
function correctdialoguefontsize
d = dialog('Position',[700 500 250 150],'Name','');
%coordinates are x,y,length,height
txt = uicontrol('Parent',d,...
'Style','text',...
'Position',[20 90 210 40],...
'String','Which emotion do you recognize?');
txt.FontSize = 12;
btn = uicontrol('Parent',d,...
'Position',[40 70 70 25],...
'String','Angry',...
'Callback','delete(gcf)');
btn.FontSize = 12;
btn = uicontrol('Parent',d,...
'Position',[120 70 70 25],...
'String','Fearful',...
'Callback','delete(gcf)');
btn = uicontrol('Parent',d,...
'Position',[40 30 70 25],...
'String','Happy',...
'Callback','delete(gcf)');
btn = uicontrol('Parent',d,...
'Position',[120 30 70 25],...
'String','Sad',...
'Callback','ans=sad');
end

回答(1 个)

Vimal Rathod
Vimal Rathod 2020-2-26
You could use a Global variable, assign that variable in the callback function and you could retrieve the variable in your program.

类别

Help CenterFile Exchange 中查找有关 Graphics 的更多信息

产品


版本

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by