title: Gauss-Newton Solver: Improper assignment with rectangular empty matrix
body: <p>I don't understand why I am getting this error message.  I have implemented a Gauss-Newton solver to solve a system of linear equations.</p>
  
  <p>It keeps saying improper assignment with rectangular empty matrix at the line <code>"for i=1:m"</code></p>
  
  <pre><code>function [x, l] = GS(A, b, x0, TOL)
  [m n] = size(A);
  l = 1;
  x = [0;0;0];
  while (true)
      for i=1:m
          sum1 = 0; sum2 = 0;
      for j=1:i-1
          sum1 = sum1 + A(i,j)*x(j);
          for j=i+1:n
              sum2 = sum2 + A(i,j)*x(j);
          end
      end 
      x(i) = (-sum1-sum2+b(i))./A(i,j);    
  end
  if abs(norm(x) - norm(x0)) &lt; TOL   
      break
  end
  x0 = x;
  l = l + 1;
  end
  </code></pre>