Displaying output in Static box

9 views (last 30 days)
fary
fary on 26 Feb 2018
Commented: fary on 1 Mar 2018
Good day all, please I am working on a project that counts the blood cell, I want the output of the count to display in a static box when I click on the pushbutton "RBC Count", presently my output been printed on the command window. Please I am looking forward to your help

Accepted Answer

Cam Salzberger
Cam Salzberger on 26 Feb 2018
Hello Fary,
When you create the static text, you should get the handle to the object out of it. Then you can have the callback for the pushbutton modify the 'String' property of the static text. For example:
figure
hText = uicontrol('Style', 'text', 'String', 'Waiting...', ...
'Units', 'normalized', 'Position', [0 0.5 0.5 0.5]);
uicontrol('Style', 'pushbutton', 'Callback', ...
@(src, event) set(hText, 'String', 'whatever'))
Of course, if you're doing a GUIDE GUI, you will usually have all the handles to the uicontrols (and other UI elements) in the handles struct that gets passed around. In that case, just access the handle to the static text in that (named by the 'Tag' property for the text) and modify the text in the pushbutton callback.
handles.text1.String = 'whatever you want';
-Cam
  1 Comment
fary
fary on 1 Mar 2018
Thank you much Mr. salzberger its been very helpful

Sign in to comment.

More Answers (0)

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!