How to combine cell arrays to form one nested cell array entry
조회 수: 4 (최근 30일)
이전 댓글 표시
Hello, I have a variable (X) that is a cell array (size 64X634). In the each location of cell array X, there is a nested 1x2 cell array.
How can I combinethe nested 1x2 cell arrays across the 634 columns in X such that the variable(X) is now the desired size of 64x1, where each row entry of the cell arrray X contains the new 634x2 nested cell array?
In other words, I want to combine each of the 1x2 cell arrays found in the columns of the original variable(X) so that each row of variable(X) only has one column (now a nested cell array with all the original 1x2 nested cell arrays). Thanks!
댓글 수: 0
채택된 답변
Voss
2024년 5월 21일
% 4x3 instead of 64x634, for demonstration
X = { ...
{1 2} {3 4} {5 6}; ...
{7 8} {9 10} {11 12}; ...
{13 14} {15 16} {17 18}; ...
{19 20} {21 22} {23 24}; ...
};
X
X{1,1},X{1,2},X{1,3}
N = size(X,1);
Y = cell(N,1);
for ii = 1:N
Y{ii} = vertcat(X{ii,:});
end
X = Y;
X
X{1}
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!