title: Changing values in one MatLab matrix based on ranges stored in a second matrix
body: <p>Elements of a column matrix of non-sequential numbers (<code>sourceData</code>) should have their values incremented if their index positions lie between certain values as defined in a second column matrix (<code>triggerIndices</code>) which lists the indices sequentially. </p>
  
  <p>This can be easily done with a <code>for</code>-loop but can it be done in a vectorized way?</p>
  
  <pre><code>%// Generation of example data follows
  sourceData = randi(1e3,100,1);
  
  %// sourceData = 1:1:1000; %// Would show more clearly what is happening
  triggerIndices = randperm(length(sourceData),15);
  triggerIndices = sort(triggerIndices);
  
  %// End of example data generation
  
  %// Code to be vectorized follows
  
  increment = 75;
  addOn = 100;
  for index = 1:1:length(triggerIndices)-1
      sourceData(triggerIndices(index):1:triggerIndices(index+1)-1) = ...
          sourceData(triggerIndices(index):1:triggerIndices(index+1)-1) + addOn;
      addOn = addOn + increment;
  end
  
  sourceData(triggerIndices(end):1:end) = ....
      sourceData(triggerIndices(end):1:end) + addOn;
  %// End of code to be vectorized
  </code></pre>