Converting a cell array to a multidimensional array
12 次查看(过去 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!