[?] Get a part of the matrix?

I’m trying to extract a 5x5 part of a 1200x1500 matrix around the max of the matrix.
To find the max i use:

Max[DivdLight[[1]]]

and to find the corresponding row and column i use:

 Position[DivdLight[[1]],Max[DivdLight[[1]]]

Now to get out a 5x5 about the max point i use:
DivdLight[1][[tx - 5 ;; tx + 5, ty - 5 ;; ty + 5]]
and i get the following error:

But if i put in the number, without call from the list like:

DivdLight[[1]][[481- 5 ;; 481 + 5, 835 - 5 ;; 835 + 5]]

then the code works as intended

do you guys have any idea why that’s the case? And if so help please

Pruthvi,

Your tx is a list, not a number:

In[1]:= array = RandomReal[{-10,10},{500,600}];
In[2]:= pos = Position[array,Max[array]][[1]]
Out[2]= {112,479}
In[3]:= abs = array[[pos[[1]]-5;;pos[[1]]+5,pos[[2]]-5;;pos[[2]]+5]];
In[4]:= abs//Dimensions
Out[4]= {11,11}

Regards,

Neil