title: Solving systems of non-linear equations with two unknown coefficients a and b (scalars or vectors solutions ?)
body: <p>I have systems of non-linear equations and I am looking for getting the two unknown &quot;<code>a</code>&quot; and &quot;<code>b</code>&quot; of the problem ( for the moment, I don't know if &quot;<code>a</code>&quot; and &quot;<code>b</code>&quot; could be only vectors or matrix solutions or maybe only scalars).</p>
  <p><strong>The difficulty is that my equation is under matrix form (I mean that I have simply in theory only scalars &quot;<code>a</code>&quot; and &quot;<code>b</code>&quot; that multiplies matrices).</strong></p>
  <p>I would like to use Matlab to solve this system of two non-linear equations (<code>a</code> and <code>b</code> are the unknown).</p>
  <p>Here is the two independent equations : caution ! : &quot;<code>FISH_sp</code>&quot;, &quot;<code>FISH_xc</code>&quot;, &quot;<code>eigenv_sp</code>&quot; and &quot;<code>eigenv_xc</code>&quot; are known matrices.</p>
  <p><code>eigen_sp</code>, <code>eigen_xc</code> and <code>FISH_eigen_sum</code> are also scalar knonw.</p>
  <p>I have coded the following system of 2 non-linear equations implemented in the following function (with <code>a</code> and <code>b</code> to find) :</p>
  <pre><code>myfun=@(a,b) [
  % First equation
  a^2*eye(7) + a*b*FISH_sp*FISH_xc'+a*b*FISH_xc*FISH_sp'+b^2*eye(7);
  % Second equation
  a*FISH_sp*eigenv_sp + b*FISH_eigen_sp*eigenv_xc + a*FISH_xc*eigenv_sp +...
  b*FISH_xc*eigenv_xc - (eigenv_sp + eigenv_xc)*FISH_eigenv_sum];
  
  % Solution of system of non linear equations
  a0 = 0.5;
  b0 = 0.5;
  x0 = [ a0 b0 ];
  y = fsolve(@(x)myfun(x(1),x(2)), x0)
  </code></pre>
  <p>But this gives me the following error :</p>
  <pre><code>Error using vertcat
  Dimensions of matrices being concatenated are not consistent.
  
  Error in
  compute_solving_Matricial_Equations&gt;@(a,b)[a^2*eye(7)+a*b*FISH_sp*FISH_xc'+a*b*FISH_xc*FISH_sp'+b^2*eye(7);a*FISH_sp*eigenv_sp+b*FISH_eigen_sp*eigenv_xc+a*FISH_xc*eigenv_sp,+b*FISH_xc*eigenv_xc-(eigenv_sp+eigenv_xc)*FISH_eigenv_sum]
  
  Error in compute_solving_Matricial_Equations&gt;@(x)myfun(x(1),x(2))
  
  Error in fsolve (line 230)
              fuser = feval(funfcn{3},x,varargin{:});
  
  Error in compute_solving_Matricial_Equations (line 55)
  y = fsolve(@(x)myfun(x(1),x(2)), x0)
  
  Caused by:
      Failure in initial objective function evaluation. FSOLVE cannot continue.
  </code></pre>
  <p>Anyone could see what's wrong to solve this system of 2 non linear functions described in the function <code>myfun</code> ?</p>