Reading cell array strings into GUI edit text box

3 ビュー (過去 30 日間)
Stephen
Stephen 2014 年 12 月 11 日
コメント済み: Stephen 2014 年 12 月 12 日
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 件のコメント
Geoff Hayes
Geoff Hayes 2014 年 12 月 11 日
Stephen - try avoiding the loop altogether and just set the string with the cell array, ensuring that your edit text box has multiline enabled.

サインインしてコメントする。

採用された回答

Geoff Hayes
Geoff Hayes 2014 年 12 月 12 日
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.
  1 件のコメント
Stephen
Stephen 2014 年 12 月 12 日
Modified this method to suit my problem, thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLarge Files and Big Data についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by