Flatten Matrix in Row Major Order in Arbitrary Dimensions

조회 수: 58 (최근 30일)
Lucas-Raphael Müller
Lucas-Raphael Müller 2019년 6월 12일
답변: David Goodmanson 2019년 6월 15일
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,

답변 (1개)

David Goodmanson
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.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by