title: MATLAB Matrix Sum using Nested For
body: <p>I am trying to find the sum of the following matrix in matlab [1 1 1 1; 1 2 1 2; 4 5 3 2; 1 3 2 4; 10 11 1 1; 90 9 2 1]</p>
  
  <p>I am trying to do so using a nested for statement yet i keep getting errors. please help</p>
  
  <p>Must use nested for</p>
  
  <p>My code:</p>
  
  <pre><code>A = [1 1 1 1; 1 2 1 2; 4 5 3 2; 1 3 2 4; 10 11 1 1; 90 9 2 1];
  for j=1:4,
    for i=1:6,
      sum = A(j,:)+A(j+1,:)+A(j+2,:)
    end
  end
  </code></pre>