title: finding neighborhood in a specific location
body: <p>I have a 2D matrix and I want to find the neighborhood of (i,j) in this matrix with M and N sizes in x and y directions, respectively. I know that it is easy to do, but my problem is that when (i,j) is close to corners and M and N are large! In this case I do not want to exceed the matrix. Is there any function or simple solution for this problem in MATLAB?</p>