title: How can I replace some column values depending on a condition?
body: <p>I have a matrix <code>A</code> such that</p>
  
  <pre><code>A=
       4.0000  120.0000   92.0000         0         0   37.6000    0.1910   30.0000
      10.0000  168.0000   74.0000         0         0   38.0000    0.5370   34.0000
      10.0000  139.0000   80.0000         0         0   27.1000    1.4410   57.0000
       1.0000  139.0000   60.0000   23.0000  846.0000   30.1000    0.3980   59.0000
       5.0000  136.0000   72.0000   19.0000  175.0000   25.8000    0.5870   51.0000
       7.0000  121.0000         0         0         0   30.0000    0.4840   32.0000
  </code></pre>
  
  <p>I want to do two things:</p>
  
  <ol>
  <li>Replace the values of the first column that are greater than 5 by 0.</li>
  <li>In the second column, if the values are within the range 121-130, replace them by 0. If they are within the range 131-140, replace by 1, 141-150 by 2, 151-160 by 3, etc.</li>
  </ol>
  
  <p>So the desired result matrix would be:</p>
  
  <pre><code>A=
      4.0000   0.0000   92.0000         0         0   37.6000    0.1910   30.0000
      0.0000   4.0000   74.0000         0         0   38.0000    0.5370   34.0000
      0.0000   1.0000   80.0000         0         0   27.1000    1.4410   57.0000
      1.0000   1.0000   60.0000   23.0000  846.0000   30.1000    0.3980   59.0000
      5.0000   1.0000   72.0000   19.0000  175.0000   25.8000    0.5870   51.0000
      0.0000   0.0000         0         0         0   30.0000    0.4840   32.0000
  </code></pre>
  
  <p>How can I accomplish this?</p>
  
  <p>I was trying something like this:</p>
  
  <pre><code>counter=1;
  for i = 1: rows
      if A(i,1) &gt; 5
          A(i ,1) = 0;
      end
      if A(i,2) &gt; 120 &amp;&amp;  A(i,2) &lt; 130
          A(i ,2) = 0;
      end
      counter = counter+1;
  end
  </code></pre>
  
  <p>Would using a case do the trick?</p>