Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
Tomaszzz
Tomaszzz el 11 de Jun. de 2023
Respondida: Stephen23 el 11 de Jun. de 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');

Respuesta aceptada

Stephen23
Stephen23 el 11 de Jun. de 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{:})

Más respuestas (0)

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by