title: Indexing must appear last in an index expression
body: <p>I have a vector <code>CD1</code> (120-by-1) and I separate <code>CD1</code> into 6 parts. For example, the first part is extracted from row 1 to row 20 in <code>CD1</code>, and second part is extracted from row 21 to row 40 in CD1, etc. For each part, I need to compute the means of the absolute values of <a href="https://stackoverflow.com/questions/13022814/finding-means-of-the-absolute-values-of-second-differences-between-elements">second differences of the data</a>.</p>
  
  <pre><code>for PartNo = 1:6   
  
      % extract data                
      Y(PartNo) = CD1(1 + 20*(PartNo-1):20*(PartNo),:); 
  
      % find the second difference  
      Z(PartNo) = Y(PartNo)(3:end) - Y(PartNo)(1:end-2);  
  
      % mean of absolute value
      MEAN_ABS_2ND_DIFF_RESULT(PartNo) = mean(abs(Z));    
  
  end
  </code></pre>
  
  <p>However, the commands above produce the error: </p>
  
  <pre><code>()-indexing must appear last in an index expression for Line:2
  </code></pre>
  
  <p>Any ideas to change the code to have it do what I want?</p>