I want some variables to appear in the (edit text box) in the gui along with some string info.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Ahmed Alnahdi
am 28 Apr. 2015
Bearbeitet: Stephen23
am 4 Mai 2015
Hi, I'm trying to add some text that contains codes within it and I want all of it to appear in the (edit box) in the gui what function should I use for example
the winning number is (x) and the price is (y)...... where is x and y are the variables
0 Kommentare
Akzeptierte Antwort
Stephen23
am 30 Apr. 2015
Bearbeitet: Stephen23
am 4 Mai 2015
It is much neater and faster to use sprintf, rather than num2str and concatenating strings together:
>> x = 1;
>> y = 2;
>> sprintf('The winning number is %d and the price is %d', x, y)
ans =
The winning number is 1 and the price is 2
Note that there are many options for converting numeric values (precision,, leading and trailing zeros, etc), so please read the sprintf documentation carefully and pick the format that suits your application best!
0 Kommentare
Weitere Antworten (1)
Joseph Cheng
am 28 Apr. 2015
you can use the function num2str() to convert the double to a string.
x = 1
y = 2
outputstring = ['the winning number is ' num2str(x) ' and the price is ' num2str(y)]
0 Kommentare
Siehe auch
Kategorien
Mehr zu Startup and Shutdown 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!