MATLAB: Rearranging Array Rows into Multiple Blocks while Maintaining the Old Order

array rearrangementpermuterearrangereshapereshaping arrays

How can I rearrange an array from alternating rows to multiple blocks, maintaining the order of the rows?

Best Answer

You should learn about indexing, one of the most essential aspects of Matlab:
M = randi(4,10,5) ; M(:,1) = 1:size(M,1) % example data
M2 = M([1:2:end 2:2:end], :) % re-ordering the rows