question about edit box's value

1 回表示 (過去 30 日間)
hwanjo kim
hwanjo kim 2016 年 10 月 13 日
回答済み: Walter Roberson 2016 年 10 月 13 日
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....

回答 (2 件)

KSSV
KSSV 2016 年 10 月 13 日
s = 'mytext' ;
class(s)
iwant = cellstr(s)
class(iwant)
doc cellstr

Walter Roberson
Walter Roberson 2016 年 10 月 13 日
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.)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by