title: Replacing elements with a random number in matlab
body: <p>I have three variables that I have made and i want to change the value of some of the elements.  If the participant answered correct (1 in the third column) then i want to change their reaction time to be a random number with a mean and standard deviation of 1, squared with .3 added to it. </p>
  
  <pre><code>stimnum = randi([1 3], [1 100]);
  rt = ((1 + 1.*randn(1, 100)).^2) + .1; 
  correct = rand(1,100)&gt;0.2; 
  m = [stimnum; rt; correct ]';
  </code></pre>
  
  <p>I have written code that does this basically, but every time it replaces an element it puts in the same exact random number, i want matlab to pull up a new random number each time it replaces the rt element. </p>
  
  <pre><code>m(m(:,3)&gt;.5, 2) = ((1 + 1.*randn).^2) + .3;
  </code></pre>