how to use varibles in a static text gui
조회 수: 5 (최근 30일)
이전 댓글 표시
I want to use a static text box to display some info along with some variables , is there a way to do so ?
Thanks in advance.
댓글 수: 0
채택된 답변
Image Analyst
2015년 4월 29일
I'm a fan of sprintf():
txtInfo = sprintf('Your number = %.3f.\nYour string = %s', yourNumber, yourString);
set(handles.txtInfo, 'String', txtInfo);
Obviously use whatever tag you've assigned for that static text label control. Maybe it's text1, txtResults, or whatever...
댓글 수: 0
추가 답변 (1개)
Joseph Cheng
2015년 4월 29일
편집: Joseph Cheng
2015년 4월 29일
you handle it just like an edit box by setting the handle parameter 'string' to a string. so converting the variable from a double to a string would work.
example
%code in a sample pushbutton
number = randi(10);
set(handles.text1,'string',['random generated number: ' num2str(number)])
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!