필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
Tomaszzz
Tomaszzz 2023년 6월 11일
답변: Stephen23 2023년 6월 11일
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에서 Multidimensional Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by