how to print output in gui

122 views (last 30 days)
Dimple on 5 Aug 2013
prompt{1}='Enter a value :';
prompt{2}='Enter b value :';
in the above code, how to add and disply the output

Accepted Answer

Evan on 5 Aug 2013
Edited: Evan on 5 Aug 2013
You could create a editbox in a figure and display the value there:
fh = figure;
prompt = {1 3};
eh = uicontrol('Style','edit','String',num2str(prompt{1} + prompt{2}));
For ways of customizing your editbox, including its position, read up on uicontrol properties:
For more sophisticated GUIs, you may want to look into GUIDE:

More Answers (2)

Suman Saha
Suman Saha on 7 Aug 2013
prompt = {4 5 5 1 3};
uicontrol('Style','text','unit','inches','position',[1 1 1 1],'String',sum(cell2mat(prompt)));
uicontrol('Style','text','String','The sum','unit','inches','position',[1 2 1 0.5]);

David Sanchez
David Sanchez on 7 Aug 2013
A more simple approach is the use of set:
In your GUI, every object has a tag (see the property inspector), just change your_text_object_in_GUI by the tag of your text object.


Community Treasure Hunt

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

Start Hunting!