Converting a cell array to a multidimensional array
조회 수: 11 (최근 30일)
이전 댓글 표시
I have a 1xK cell array of MxN doubles. I need to covert it to a multidimentional array of NxMxK doubles. I should be able to do this without a "for loop" using some combination of cellfun, reshape, and permute. For the life of me I can't figure it out. Note: I saw a very similar question here (how-to-convert-from-cell-array-to-multidimensional-array).
K = 6;
M = 1000;
N = 4;
A = repmat({rand(M,N)},1,K);
%B = ?
% size(B)
% ans =
% 4 1000 6
댓글 수: 0
채택된 답변
Voss
2021년 12월 20일
AA = cellfun(@(x)x.',A,'UniformOutput',false); % transpose each element of A
B = cat(3,AA{:}); % concatenate along the third dimension
댓글 수: 2
추가 답변 (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!