question about edit box's value

4 visualizaciones (últimos 30 días)
hwanjo kim
hwanjo kim el 13 de Oct. de 2016
Respondida: Walter Roberson el 13 de Oct. de 2016
I have a question during the study
first i made edit box on gui there are string ' Edit Text '
then i get string by a = get(h,'String')
And I could check my workspace 'a' have 1 x 1 cell array
but when i changed edit box string by property before run gui which i made
there are a 'char' data on my workspace
because of this I can write data on my table pannel
how can i change to cell type not a char type
please help me....

Respuestas (2)

KSSV
KSSV el 13 de Oct. de 2016
s = 'mytext' ;
class(s)
iwant = cellstr(s)
class(iwant)
doc cellstr

Walter Roberson
Walter Roberson el 13 de Oct. de 2016
When you set the String property of an edit box, you can either set it to a single string or to a cell array of strings. If the user does not edit the string, then the data type of the String property will be whatever you set. If the user then edits the string, then sometimes if you had the Max property of the edit box set to 2 or more then if the user adds more lines, you might get a cell array back even if you had set a single string -- though in my testing a moment ago in R2016b on OS-X, I got back a char array after editing if I had set a single string.
If you are not certain which datatype you are getting back, the easiest thing to do is apply cellstr() to the returned value. cellstr() will leave cell arrays of strings the same, and will convert a plain character row to a cell array of string, and will convert multiple rows of characters to a cell array of strings each of which has had its trailing blanks removed (actually it will do the trailing blank removal even for a single row.)

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by