MATLAB: Negative numbers on table

cell2table

Hi there,
I have a cell with different types, for example cellN = {43.1; -29; 'xyz'}. Want to have a table with RowNames and VariableNames, and to do that, use cell2table.
When I do cell2table(cellN) I get the following 'Warning: Out of range or non-integer values truncated during conversion to character.'
After some search, I realised that is due to the negative number -29.
How to overcome this??
Thanks Rui

Best Answer

Rui - I suspect that the problem is more likely due to the fact that you have included a string, 'xyz', in with your numbers. In fact, if I remove the string from your cellN example and run the code
cell2table(cellN)
there is no error (like you, I observe the same warning when I leave the string in).
I think that the idea with the table is that all columns will be of a like data type, and you are mixing numbers with strings and so that can lead to unexpected behaviour (or warnings). If you wish to create a table from a cell array, then ensure that all elements in each column of the cell are of the same data type.