how to use varibles in a static text gui
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ahmed Alnahdi
am 29 Apr. 2015
Beantwortet: Image Analyst
am 29 Apr. 2015
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 Kommentare
Akzeptierte Antwort
Image Analyst
am 29 Apr. 2015
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 Kommentare
Weitere Antworten (1)
Joseph Cheng
am 29 Apr. 2015
Bearbeitet: Joseph Cheng
am 29 Apr. 2015
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 Kommentare
Siehe auch
Kategorien
Mehr zu Characters and Strings finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!