Reading cell array strings into GUI edit text box

3 visualizaciones (últimos 30 días)
Stephen
Stephen el 11 de Dic. de 2014
Comentada: Stephen el 12 de Dic. de 2014
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 comentario
Geoff Hayes
Geoff Hayes el 11 de Dic. de 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.

Iniciar sesión para comentar.

Respuesta aceptada

Geoff Hayes
Geoff Hayes el 12 de Dic. de 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.

Más respuestas (0)

Categorías

Más información sobre Large Files and Big Data 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