how to get an output from this dialog box?

2 views (last 30 days)
michael woodcock
michael woodcock on 23 Feb 2020
Answered: Vimal Rathod on 26 Feb 2020
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

Answers (1)

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

Categories

Find more on Graphics in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!