title: Solving a linear system of equations in Scilab
body: <p>I want to solve the following system <code>Ax=b</code> where the dimensions of <code>A</code> are <code>m</code>,<code>n</code> <code>(m&gt;n)</code>, <code>b</code> <code>m</code>,<code>1</code> and <code>x</code> <code>n</code>,<code>1</code>. After the solution under Scilab, I found that some components of my vector x are complex, I find that strange because I was told that the vector <code>x</code> must be real. How can you explain that?</p>
  
  <p>Here is my code :</p>
  
  <pre><code>function [x] = sys_()
      [fid1,err1] = mopen("D:\Documents\sys_surdet\Donnees_test_A.txt","r");
      [fid2,err2] = mopen("D:\Documents\sys_surdet\Donnees_test_B.txt","r");
      A = mfscanf(-1,fid1,'%f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f');
      b = mfscanf(-1,fid2,'%f');
      A=10^(-A/10);
      b=10^(b/10);
      col = size(A);
      j = zeros(col(1,1),1);
      x = zeros(col(1,2),1);
      if rank(A)==col(1,2) then
          x=(A'*A)\(A'*b);
      else
          x=-1;
      end
      mclose(fid1);
      mclose(fid2);
  endfunction
  </code></pre>