MATLAB: Splitting matrix to different row

splitting matrix to different row

I have the following matrix and I want to split it.
A=[0 2 4 ,5 0 4]
it should be like this:
[0 2]
[2 4]
[4 2]
[5 0]
[0 4]
[4 5]
Please write me, If you have answer. Thanks

Best Answer

Trying to piece together all the guesses that these kind volunteers have made in trying to help you. Does this do what you want?
A = [0 2 4; 5 0 4];
At = A';
chunkSize = size(A,2);
shiftedIndex = bsxfun(@plus,mod(1:chunkSize,chunkSize)',[0:chunkSize:numel(At(:))-chunkSize]) + 1;
B = [At(:) At(shiftedIndex(:))]
[ EDIT: I changed this code to correspond to what I wrote in my comment below. Given the new information you provided, I think this is correct.]
Related Question