How to convert cell (with 6x1 tables) into a multirow table?
3 views (last 30 days)
Show older comments
Hi all,
I have a 16x1 cell with 6x1 tables. I want to covert it into a table using a for loop. Can you help please?
for k = 1:numel(my_cell)
variable1 = my_cell{k}.bf_nw;
variable2 = my_cell{k}.bf_dtw;
variable3 = my_cell{k}.cv_nw;
variable4 = my_cell{k}.cv_dtw;
variable5 = my_cell{k}.ml_nw;
variable6 = my_cell{k}.ml_dtw;
myarray{k} =[(variable1), (variable2), (variable3), (variable4), (variable5), (variable6)];
mytable{k} = array2table(myarray,'VariableNames',{'variable1', etc}),
end
Unable to perform assignment because brace indexing is not supported for variables of this type.
Alternatively I was trying to do the same using writematrix, which seems to do the job for one variable. Cant figure out the way to write all variables in seperate columns though (for example var1 in column A, var2 in column B etc.
Can you suggest a most optimal methods to do this please?
writematrix(variable1, 'mytable.csv','WriteMode','Append');
0 Comments
Accepted Answer
Stephen23
on 11 Jun 2023
If all of the tables in the cell array have compatible sizes and column/variable names, then all you need is:
T = vertcat(my_cell{:})
0 Comments
More Answers (0)
See Also
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!