How to convert cell (with 6x1 tables) into a multirow table?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Tomaszzz
le 11 Juin 2023
Réponse apportée : Stephen23
le 11 Juin 2023
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 commentaires
Réponse acceptée
Stephen23
le 11 Juin 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Structures dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!