Display calculation of GUI in text box

조회 수: 4 (최근 30일)
Adam Glick
Adam Glick 2015년 10월 20일
댓글: Adam Glick 2015년 10월 20일
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
Walter Roberson
Walter Roberson 2015년 10월 20일
Your exact code works for me when pasted into my command window.

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2015년 10월 20일
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
Adam Glick
Adam Glick 2015년 10월 20일
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?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Genomics and Next Generation Sequencing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by