title: MATLAB: How do I check if any element in my matrix is nan and do something if that is the case
body: <p>I know I can use <code>isnan</code> to check for individual elements, such as</p>
  
  <pre><code>for i=1:m
      for j=1:n
          if isnan(A(i,j))
              do something
          end
      end
  end
  </code></pre>
  
  <p>However, instead what I want to do is</p>
  
  <pre><code> if any(isnan(A))
        do something
   end
  </code></pre>
  
  <p>When I tried to do this, it doesn't go into the argument because it is considered false. If I just type <code>any(isnan(A))</code>, I just get <code>1 0 1</code>.
  So how do I do this?</p>