How to convert cell (with 6x1 tables) into a multirow table?

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

采纳的回答

Stephen23
Stephen23 2023-6-11
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 个)

类别

Help CenterFile Exchange 中查找有关 Structures 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by