Display calculation of GUI in text box

4 views (last 30 days)
Adam Glick
Adam Glick on 20 Oct 2015
Commented: Adam Glick on 20 Oct 2015
I'm trying to display a calculation my code does into a textbox in my GUI. For example:
htextbox1 = uicontrol('Style','text','String','area','Position',...
[150,220,100,30]);
set(htextbox1,'Visible','Off')
r = 0;
x = 2;
y = 4;
r = x^2 + y^2;
if r ~=0
set(htextbox1,'Visible','On')
set(htextbox1,'String',num2str(r))
end
and I want the textbox to display the value of r. How can I do this? Nothing I've tried works. Thanks.
  1 Comment
Walter Roberson
Walter Roberson on 20 Oct 2015
Your exact code works for me when pasted into my command window.

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 20 Oct 2015
Your exact code works for me when pasted into my command window.
One thing I would recommend is that you use Units when you give the Position parameter.
  1 Comment
Adam Glick
Adam Glick on 20 Oct 2015
I figured out what the issue was. It was a problem with a previous part of the code. How can I add units and have the variable r displayed?

Sign in to comment.

Categories

Find more on Genomics and Next Generation Sequencing 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!