x at location (1,3) is 3, not 7. x(3,1) is the one which is 7.
Array indexing is row first and then column. Arrays are stored internally in memory by going down columns. The internal order of the array you show would be 1, 4, 7, 2, 5, 8, 3, 6, 9.
Anyhow, I cannot see any way that the positions you list could be considered "adjacent" unless you are wrapping around in both the horizontal and vertical directions.
If you want horizontal and vertical wrapping, then:
Let R be the number of rows and C be the number of columns. Let x be the row number and y the column number for the position to work relative to. Then the positions you want are:
X = 1+mod([x;x-1;x+1;x;x]-1,R);
Y = 1+mod([y,y,y,y-1,y+1]-1,C);