title: How to replace values in a specific column of a matrix within a defined index range in MATLAB?
body: <p>I have the following matrix in MATLAB where the first column contains just ones:
  <img src="https://i.stack.imgur.com/j91D1.png" alt="Original Matrix"> </p>
  
  <p>How can I replace the values in column 1 (regardless of what the original value is) with a new value (e.g. 99) within a specific index range (e.g. just for rows 9 to 12) to obtain this:</p>
  
  <p><img src="https://i.stack.imgur.com/c6SNk.png" alt="desired result"></p>
  
  <p>If I use the following command I can replace all the 1 in the first column with 99:</p>
  
  <pre><code>finalMatrix(finalMatrix(:,1) == 1,1) = 99;
  </code></pre>
  
  <p>To replace just the values in column 1 from index 9 to 12 I tried this</p>
  
  <pre><code>finalMatrix(finalMatrix(9:12,1) == 1,1) = 99;
  </code></pre>
  
  <p>but it doesn't work.</p>
  
  <p>Any suggestion?</p>