title: Matlab: How to solve the system of nonlinear equations with additional parameters?
body: <p>I would like to create a function that finds the parameters p and q of Bass diffusion model, given the data of two time periods.</p>
  
  <p>The model (equation) is the following:</p>
  
  <pre><code>n(T) = p*m + (q-p)*n(T-1) + q/m*n(T-1)^2
  </code></pre>
  
  <p>where</p>
  
  <pre><code>n(T) = number of addoptions occuring in period T
  n(T-1) = number of cumulative adoptions that occured before T
  p = coefficient of innovation
  q = coefficient of imitation
  m = number of eventual adopters
  </code></pre>
  
  <p>for example if m = 3.000.000
  and the data for the years below is the following:</p>
  
  <pre><code>2000: n(T) = 820, n(T-1) = 0
  2005: n(T) = 25000, n(T-1) = 18000
  </code></pre>
  
  <p>then the following equation system has to be solved (in order to determine the values of p and q):</p>
  
  <pre><code>p*m + (q-p)*0 + q/3.000.000 * 0^2 == 820
  p*m + (q-p)*18000 + q/3.000.000 * 18000^2 == 25000
  </code></pre>
  
  <p>By following <a href="http://www.mathworks.com/help/toolbox/optim/ug/fsolve.html" rel="nofollow">Matlab documentation</a> I tried to create a function Bass:</p>
  
  <pre><code>function F = Bass(m, p, q, cummulativeAdoptersBefore)
  
  F = [p*m + (q-p)*cummulativeAdoptersBefore(1) + q/m*cummulativeAdoptersBefore(1).^2;
      p*m + (q-p)*cummulativeAdoptersBefore(2) + q/m*cummulativeAdoptersBefore(2).^2];
  
  
  end
  </code></pre>
  
  <p>Which should be used in fsolve(@Bass,x0,options) but in this case m, p, q, cummulativeAdoptersBefore(1), and cummulativeAdoptersBefore(2) should be given in x0 and all variables would be considered as unknown instead of just the latter two.</p>
  
  <p>Does anyone know how to solve the system of equations such as above?</p>
  
  <p>Thank you!</p>