MATLAB: Cell Array to table

cellMATLABtable

I have a cell array that contains elements of different sizes:
Values =
1×8 cell array
{[1]} {[0.35]} {1×3 double} {[0]} {1×2 double} {[0]} {1×2 double} {[1]}
I want to save Values, into an existing table. The table has VariableTypes set to cell.
obj.Table{i}(indx,:) = Values
Conversion to cell from double is not possible.
Table should look something like this:
Capture.PNG

Best Answer

Alberto, you are mixing metaphors.
You have a cell array containing values you want to put in a table, and (apparently) a table that is preallocated with cell variables. It looks like what you want is a table that has double variables, some with one column, some with more than one. I'm guessing, though you haven't really given any context, that you will have many of those cell arrays, and you want to assign them one at a time into each row of the table.
You have obj.Table{i}. Again, I can only guess that obj.Table is a cell array, and obj.Table{i} is a table that's been preallocated. It would help if you would either remove the parts of your code that are irrelevant to your question, or explain the code sufficiently.
In any case: Let's say t = obj.Table{i}. t is a table, and t(indx,:) is one row of that table. To assign to that one row, you need to have a table on the right-hand side. You have a cell array. So in that sense, madhan's suggestion is correct. But table actually gives you a short-cut: you can assign a one-row cell array to a row of a table, and the table on the LHS behaves "as if" you had already called cell2table. It's a convenience to save you some typing, and some execution time.
But the target has to be variables that are the right types. You say, "variable types set to cell", and there's your problem. You are, as the error msg says, trying to assign double values into cell arrays. Preallocate with double (and the right number of columns for each).
Related Question