MATLAB: 2nd order nonlinear differential equations as “State Space Representation” for ode45()

differential equationsMATLABnumerical integrationode15iode45state space representationSymbolic Math Toolbox

Hi Community,
in recent days I read a lot about solving differential equations with the numerical solver ode45(..). But after all it is not clear to me how to handle the following problem, which is only schematically described, due to too high complexity of the actual problem (stated below).
Consider a system of two nonlinear differential equations with two unknowns to be solved for. The first one is of second order in both unknowns and the second equation is of first order in both unknows. The unknowns are y1 & y2 .
Eq1:
f(y1(t)'', y2(t)'', y1(t)', y2(t)', y1(t), y2(t))
e.g. a*y1(t)'' + b*y2(t)'' + c*y2(t)' + d*y1(t) = e*y1(t)'
Eq2:
f(y1(t)', y2(t)', y1(t), y2(t)) e.g.: g*y1(t)' - h*y2(t)' - k*y2(t) = 0
To solve these equations with ode45(…) it is necessary to write them as first order diff. eqns ( State Space Model ). Therefore the equations should be solved for y1(t)'' & y2(t)'', but I don't know how to do this WITHOUT differentiating the second equation and solving the system with backsubstitution. I want to avoid this because it makes things way more complicated due to all the nonlinearities.
Anyone an idea?
For those who are interested: This is my electrical circuit I want to solve for xk, xs & xv. Where
vk = xk', vs = xs' & vv = xv'.
Moreover the electro-mechanical transform has a nonlinearity of the form:
Bl(xk) = bl0 + bl1*xk + bl2*xk^2
The resistances Rs & Rv look like:
Rs = rs0 + rs1 * vs + rs2 * vs^2
Rv = rv0 + rv1 * vv + rv2 * vv^2
and the capacitances Cs & Cv:
Cs = cs0 + cs1 * xs + cs2 * xs^2
Cv = cv0 + cv1 * xv + rv2 * xv^2
and the generator Ug(t) is of the form:
Ug(t) = U*cos(2*pi*f*t)

Best Answer

Use ODE15I instead of ODE45.
Best wishes
Torsten.