Flatten Matrix in Row Major Order in Arbitrary Dimensions
58 次查看(过去 30 天)
显示 更早的评论
Hey there,
is there a canonical way on how to flatten a arbitrarily high dimensional matrix in C order (i.e. row major, or last index first)? All I can find is for 2D which is comparably easy.
Cheers,
0 个评论
回答(1 个)
David Goodmanson
2019-6-15
Hello Lucas-Raphael,
I'm not sure this is what you are looking for, but
B = permute(A,[6 5 4 3 2 1]); % (however many dimensions there are)
B = B(:);
has a lot of the right properties.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!