title: Ignore NaN elements in a matrix - Matlab
body: <p>Hi I need to ignore <code>NaN</code> elements in my matrix, please see the code below:</p>
  
  <pre><code>Coord = [230 400; 270 420; 300 400;340 430;390 380; 230 300; 
           300 290;370 280;250 200;290 200 ;320 200 ;200 190 
           ;250 100 ;310 120; 410 110; 390 180;];
  
  P =  [1 6 7 3 2 1 NaN NaN;
        3 7 8 5 4 3 NaN NaN;
        6 9 10 7 6 NaN NaN NaN;
        7 10 11 8 7 NaN NaN NaN;
        6 12 13 14 10 9 6 NaN;
        8 11 10 14 15 16 8 NaN];
  </code></pre>
  
  <p>you can see that the total number of rows in <code>Coord</code> and the maximum value of the matrix <code>P</code> is equal to <code>16</code></p>
  
  <p>When i try to do this: <code>Coord(P(1,:),:)</code><br>
  what i expect to get:</p>
  
  <pre><code>230   400
  230   300
  300   290
  300   400
  270   420
  230   400
  </code></pre>
  
  <p>Instead i get following <strong>error</strong>:</p>
  
  <blockquote>
    <p>Subscript indices must either be real positive integers or logicals.</p>
  </blockquote>