title: How do I set all nonzero values in my matrix to 1 in MATLAB?
body: <p>I have a <code>matrix A</code>, the size of which is <code>40*20*20 double</code>. The minimum value of <code>matrix A</code> is <code>0</code>. The maximum value of <code>matrix A</code> is <code>126</code>. I want to set all nonzero values in <code>matrix A</code> to be <code>"1"</code>.I use this following command, but it does not work.</p>
  
  <pre><code>find(A(:,:,:)~= 0) = 1; 
  </code></pre>
  
  <p>Can anyone tell me why?</p>