Filter löschen
Filter löschen

Converting between cell & matrix

1 Ansicht (letzte 30 Tage)
Jared
Jared am 19 Okt. 2011
I am trying to display a data table with uitable. I am using sprintf to control the data precision/format before I store the values in an 11 x n cell named tbl.
I try to generate the table with the following code:
f=figure('Position', [25 400 550 220],'NumberTitle','off','Name','Summary');
colnames={...};
rownames={...};
uitable(f, 'Data', tbl, 'ColumnName', colnames, 'RowName',rownames,'Position', [0 0 550 220]);
I get this error: ??? Error using ==> uitable Cell array of strings may only contain string and numeric matrices
I think it's because I am trying to put a cell instead of matrix into the uitable function. Tried using cell2mat thinking this might solve the problem, but get another error: ??? Error using ==> cat CAT arguments dimensions are not consistent.
I tried googling these answers but didn't find anything to lead me in the right direction.

Akzeptierte Antwort

Fangjun Jiang
Fangjun Jiang am 19 Okt. 2011
Check the contents of your variable tbl. It shouldn't be any problem if none of its cell contains matrix or cells.
use celldisp(tbl) to show the contents. The following example works.
tbl={'a','b',1;2,3,'abc'};
uitable('Data',tbl);

Weitere Antworten (0)

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by