I have two coupled first order non-linear ODEs, which have coefficients that depend on the functions and their first derivatives. I tried a few conditionals such as If and Piecewise, but NDSolve claims that: "NDSolve::ndnum: Encountered non-numerical value for a derivative at t == 0.`. >>".
This must come up all the time in control systems--do I need to use that formalism (I only have version 8 home edition), or can I get "under the hood" of NDSolve to do this? It works if A is defined without conditions, but I need to find the best A (according to different utility functions) subject to certain constraints.
A[i_, h_] := Piecewise[{{1 - i*0.1, h >= 0.0}, {0, h < 0}}]
sol[i_] :=
NDSolve[{n'[t] ==
kg + n[t] (A[i, hc - hi[y[t], y'[t]]] (qc - qi[hi[y[t], y'[t]]]) +
qi[hi[y[t], y'[t]]] - 1),
y'[t] == (p[i, y[t], y'[t]] - A[i, hc - hi[y[t], y'[t]]]) b,
n[0] == ninit, y[0] == 1}, {n[t], y[t], n'[t], y'[t]}, {t, 0, 100}]