I am doing a simulation on a matrix (suppose a 5x5 matrix). One of the elements of this matrix is known (the back square in below; this location will not be always in center) and I want to start from that location and spirally visit the other elements (I have shown the orders in number). How I can define this order in a large matrix (e.g. 1000x1000)? Because I cannot do it manually and I am looking for a more heuristic way. I am doing a simulation on a matrix (suppose a