title: matlab percentage change between cells
body: <p>I'm a newbie to Matlab and just stumped how to do a simple task that can be easily performed in excel. I'm simply trying to get the percent change between cells in a matrix. I would like to create a for loop for this task. The data is setup in the following format:</p>
  
  <pre><code>                DAY1 DAY2 DAY3...DAY 100
  </code></pre>
  
  <p>SUBJECT              RESULTS</p>
  
  <p>I could only perform getting the percent change between two data points. How would I conduct it if across multiple days and multiple subjects? And please provide explanation</p>
  
  <p>Thanks a bunch</p>
  
  <p>FOR EXAMPLE, FOR DAY 1 SUBJECT1(RESULT=1), SUBJECT2(RESULT=4), SUBJECT3(RESULT=5), DAY 2 SUBJECT1(RESULT=2), SUBJECT2(RESULT=8), SUBJECT3(RESULT=10), DAY 3 SUBJECT1(RESULT=1), SUBJECT2(RESULT=4), SUBJECT3(RESULT=5). 
  I WANT THE PERCENT CHANGE SO OUTPUT WILL BE DAY 2 SUBJECT1(RESULT=100%), SUBJECT2(RESULT=100%), SUBJECT3(RESULT=100%). DAY3 SUBJECT1(RESULT=50%), SUBJECT2(RESULT=50%), SUBJECT3(RESULT=50%)</p>
  
  <p>updated:</p>
  
  <h2>Hi thanks for responding guys. sorry for the confusion. zebediah49 is pretty close to what I'm looking for. My data is for example a 10 x 10 double. I merely wanted to get the percentage change from column to column. For example, if I want the percentage change from rows 1 through 10 on all columns (from columns 2:10). I would like the code to function for any matrix dimension (e.g., 1000 x 1000 double) zebediah49 could you explain the code you posted? thanks</h2>
  
  <p>updated2:
  zebediah49,</p>
  
  <p>(data(1:end,100)- data(1:end,99))./data(1:end,99)</p>
  
  <p>output=[data(:,2:end)-data(:,1:end-1)]./data(:,1:end-1)*100;</p>
  
  <p>Observing the code above, How would I go about modifying it so that column 100 is used as the index against all of the other columns(1-99)? If I change the code to the following:</p>
  
  <p>(data(1:end,100)- data(1:end,:))./data(1:end,:)</p>
  
  <p>matlab is unable because of exceeding matrix dimensions. How would I go about implementing that?</p>
  
  <p>UPDATE 3</p>
  
  <p>zebediah49,</p>
  
  <p>Worked perfectly!!! Originally I created a new variable for the index and repmat the index to match the matrices which was not a good idea. It took forever to replicate when dealing with large numbers.
  Thanks for you contribution once again.</p>
  
  <p>Thanks Chris for your contribution too!!! I was looking more on how to address and manipulate arrays within a matrix.</p>