A = [1 2 3 4 5; 6 7 8 9 10; 11 12 13 14 15; 16 17 18 19 20]; mover = 2;
A_out = zeros(size(A)); outerIndices = [A(1,:), A(2:end-1,end).', A(end,end:-1:1),A(end-1:-1:2,1).']; A_out_2 = circshift(outerIndices,mover,2) A_inner = [A(2,2:end-1), A(end-1, 2:end-1)]; ctr = 0; for ii = A(1, :) A_out(ii) = A_out_2(1,1:5); end A_out
I have now found all the numbers on the outer ring and the numbers in the inner ring. Can I use a loop to put these numbers in a place? or can I use the zeros function to make two arrays and add them together. I do not know where to go from here.