Displaying 2D cell arrays in GUIDE Edit Text box

3 ビュー (過去 30 日間)
Jurgens Wolfaardt
Jurgens Wolfaardt 2017 年 10 月 1 日
コメント済み: Jurgens Wolfaardt 2017 年 10 月 1 日
Hi All
Have been browsing and I don't see an answer - should be a simple (I think)
I want to display my 2D cell array in my GUI Edit Text box in a similar way it would appear when you display it on the command line i.e. disp({1 2 3;'a' 'b' 'c';6 7 9}).
My multiline Edit Text box works fine for a numeric array, by using
set(handles.texteditbox,'String',num2str([1 2 3;4 5 6;6 7 9])). The shape of the array is preserved in the Text Edit box.
However, if I use a cell array by doing:
set(handles.texteditbox,'String',{1 2 3;'a' 'b' 'c';6 7 9}))
Then the array is displayed in one long column vector, column by column from the original array.
How do I preserve the shape of the cell array in the Edit Text Box?
Thanks!

採用された回答

Image Analyst
Image Analyst 2017 年 10 月 1 日
Why not use a uitable, then display it?
ca = {1 2 3;'a' 'b' 'c';6 7 9}; % Create cell array
handles.uitable1.Data = ca;
  1 件のコメント
Jurgens Wolfaardt
Jurgens Wolfaardt 2017 年 10 月 1 日
Haven't tried that (actually have never used tables before...). Looks like a good idea!

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 10 月 1 日
You can evalc() the disp, capture the result, cellstr() it, and set that as your String property on your multiline uicontrol style text (or style edit)
  1 件のコメント
Jurgens Wolfaardt
Jurgens Wolfaardt 2017 年 10 月 1 日
Thanks Walter - I learned a lot from your reply. I just like the look/control of the table!

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

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by