Converting between cell & matrix

1 次查看(过去 30 天)
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.

采纳的回答

Fangjun Jiang
Fangjun Jiang 2011-10-19
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);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by