title: MATLAB moving a point in the XY plane
body: <p>In MATLAB, I have an XY plane that is represented by finite number of points. The possible values of x are stored in a vector X and the possible values of y are stored in another vector Y. I have a point, say A, such that A(1) belongs to X is the x-coordinate and A(2) belongs to Y is the y-coordinate.</p>
  
  <p>This point A can move in one of 8 ways if it is in the middle:</p>
  
  <pre><code>          .   .   .                      .   A                .    .
  
            .   A   .        OR            .   .       OR       .    A
  
            .   .   .                                           .     .
  </code></pre>
  
  <p>Of course, the set of these points changes if the point A is on the edge (sometimes only 5, sometimes only 3 if it is a corner). How can I find the set of these "1-hop" neighboring points? What about the set of "k-hop" neighboring points? By set I mean two vectors one for x-coordinates and another for y-coordinates. Thanks!</p>