title: ODE solver of a system with adaptive law
body: <p>I have an unknown non-linear system and I want to model it using another system with some adaptable parameters (for instance, a neural network). So, I want to fix an online learning structure of the unknown system without knowing its dynamics, I can only interact with it through inputs-outputs. My problem is that I can not make it work in MATLAB using ode solvers. Lets say that we have this real system (my actual system is more complicated, but I will give a simple example in order to be understood):</p>
  
  <pre><code>function dx = realsystem(t, x)
  u = 2;
  dx = -3*x+6*u;
  end
  </code></pre>
  
  <p>and we solve the equations like this:</p>
  
  <pre><code>[t,x_real] = ode15s(@(t,x)realsystem(t,x), [0 1], 0)
  </code></pre>
  
  <p>We suppose that is an unknown system and we do not know the coefficients 3 and 6 so we take an adaptive system with the 2 adaptive laws:</p>
  
  <p>dx(t) = -p1(t)*x(t) + p2(t)*u(t)</p>
  
  <p>dp1(t) = -e(t)*x(t)</p>
  
  <p>dp2(t) = e(t)*u(t)</p>
  
  <p>with e(t) the error e(t) = x(t) - x_real(t).</p>
  
  <p>The thing is that I cannot find a way to feed the real values for each t to the ode solver in order to have online learning.</p>
  
  <p>I tried with something like this but it didn't work:</p>
  
  <pre><code>function dx = adaptivesystem(t, x, x_real)
  dx = zeros(3,1);
  e = x_real - x;
  u = 2;
  dx(1) = -x(2)*x(1)+x(3)*u;
  dx(2) = -e*x(1); %dx(2) = dp1(t)
  dx(3) = e*u; %dx(3) = dp2(t)
  end
  </code></pre>