new lines from an edit text component
Mostra commenti meno recenti
Hi,
I am building a small gui using GUIDE and have a multiline edit text box. I would like to consider each line seperately. Is it possible to obtain the string in the edit box as a cell array with an element for each line?
3 Commenti
Fangjun Jiang
il 14 Nov 2011
What do you mean? If you run Str=get(hObject,'String'), it's already a cell array of strings.
Daniel Shub
il 14 Nov 2011
In r2011a I get an nxm character array.
Fangjun Jiang
il 14 Nov 2011
Then would cellstr(get(hObject,'String')) be enough?
Risposta accettata
Più risposte (1)
Walter Roberson
il 14 Nov 2011
0 voti
One only gets back a character array from a uicontrol if one initialized to a character array or character vector and does not change it afterwards.
There are an exceptions to this:
- if one created a popup or listbox from a character vector that has embedded '|' characters, then each '|' marks the end of a string, and the character vector with '|' will be converted to a cell array.
edit boxes do not break lines at '|' characters.
My recollection is that if a user edits a multi-line edit box then they will get a cell array back even if the original was a character array or character vector.
I do not recall at the moment what happens for a single-line edit box that is initialized to a character vector and then edited by the user.
Categorie
Scopri di più su Cell Arrays in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!