Reading cell array strings into GUI edit text box
3 views (last 30 days)
Show older comments
Quite a simple question today:
I've got a fairly basic GUI with an edit text box. I've got one main block of code in my push button callback. The code produces a cell array of strings and using a loop at the end of the code I want to populate the edit text box with each row respectively of the cell.
So far I have this at the end of my push button callback (could be in completey wrong place)
for zz=1:length(matchescell)
message=matchescell{zz,1};
set(handles.edit10, 'String',message);
end
The only function this has at the moment is to remove the existence of the box on the GUI. I know I'm doing something fundamentally wrong here, there's not much info around looping cell array data into GUIs.
EDIT: I've worked out that the formatting in the strings (line breaks \n) are causing it to not work. I've split the lines up into different columns, so now I need to tell it to do something like this:
set(handles.edit10, 'String',matchescell{v,1} sprintf('\n') matchescell{v,2});
1 Comment
Geoff Hayes
on 11 Dec 2014
Stephen - try avoiding the loop altogether and just set the string with the cell array, ensuring that your edit text box has multiline enabled.
Accepted Answer
Geoff Hayes
on 12 Dec 2014
Stephen - a very simple example would be to set the edit10 text control to multiline and then try the following example in the button callback
msg = {'hello', 'goodbye', 'seeya', 'ciao'};
set(handles.edit10,'String',msg);
and all four strings will appear one after the other in the control.
More Answers (0)
See Also
Categories
Find more on Large Files and Big Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!