Hi,
I am trying to re-arrange a square matrix of any order to the format given below.
I tried to work on a looping method, considering the the matrix index j as starting from 2 and ending at the maximum number of rows (or columns) in the original matrix, while the the index i would always start at 1 and increase till the value of j. Also, within a single loop, the index j would decrease from the initial value to 1. The code I tried is below,
for j=2:6; xq=x(1:j,j:-1:1);end
While I expected the indices i and j to change simultaneously, I understood that this behaves like a nested for loop. Do we have some method to increment and decrement the indices simultaneously? Else, is there any other elegant way of approaching this problem? I appreciate your help.
Thanks in advance.
Best Answer