how to use varibles in a static text gui
2 ビュー (過去 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!