title: matlab column and row element summation using a for loop
body: <p>I need to wire an algorithm for class without using any Matlab functions and using for and while loops, that gives me two new vectors one with the sum of elements of each column, and another with the sum of elements in each row and compares them.</p>
  
  <p>I got this far based on a similar code I wrote in python:</p>
  
  <pre><code>A = input('Matrix Input: '); 
  [m, n] = size(A);
  
  for i = 1:m;
      sumRow = zeros(1,m);
      for j = 1:n;
          sumRow = sumRow + A(i,j);
      end;
  end;
  for i = 1:n;
      sumCol = zeros(1,n);
      for j = 1:m;
          sumCol = sumCol + A(j,i);
      end;
  end;
  A %#ok&lt;NOPTS&gt;
  sumRow %#ok&lt;NOPTS&gt;
  sumCol %#ok&lt;NOPTS&gt;
  </code></pre>
  
  <p>but in Matlab I can only get to to store in the new vectors the sum of the elements in the last row and last column, while in python I get vectors with one element for each row or column.</p>
  
  <p>I'd appreciate any help.</p>