title: Matlab: How to conditionally select a subset of a matrix based on a row function?
body: <p>I have a vector like this, which represents horizontal/vertical dimensions on a board</p>
  
  <pre><code>Hor   Verti
   1    2
   2    3 
   4    1 
   2    3      
   2    2 
   1    4 
   ..... and many more
  </code></pre>
  
  <p>I also have an starting vector of (1, 1) . I want to sub-select all rows of this matrix where either horizontal == 1 and vertical is +-2 units away, or vertical == 1 and horizontal = +-2. </p>
  
  <p>Think of like a rook on a mini-4x4 chess board, that is constrained to moving 2 spaces at a time. I want to find all the valid spaces that it can move to out of a series of proposed spaces, it is ok that some of the proposals exists more than once, because they are proposed by different people. </p>
  
  <p>I want subset of proposals where </p>
  
  <blockquote>
  <pre><code>[ (Hori== sInitial(1) &amp;&amp; (Vert - sInitial(2) &lt;=2) )
   ||           (Vert == sInitial(2) &amp;&amp; (Hori - sInitial(1) &lt;=2) ) 
     ]
  </code></pre>
  </blockquote>
  
  <p>Is it possible to do this without a for-loop?</p>