MATLAB Answers

0

Flatten Matrix in Row Major Order in Arbitrary Dimensions

Asked by Lucas-Raphael Müller on 12 Jun 2019
Latest activity Answered by David Goodmanson on 15 Jun 2019
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 Comments

Sign in to comment.

1 Answer

Answer by David Goodmanson on 15 Jun 2019

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 Comments

Sign in to comment.