MATLAB: How to solve a systems of ODE and Algebraic Equations

MATLABodeode45

I have a system of 3 nonlinear ODE and 2 nonlinear algebraic equations.
Please how can I solve these systems of equation.
ODE 45 can easily solve the ODE part. However, I don't know how to combine the solution from ODE45 and the algebraic equations.
Thank you.

Best Answer

looks like you've got a non-autonomous DAE.
with u=x(4) and y = x(5), you'd have:
dx(1) = -wh.*x(1) + wh.* x(5)
dx(2) = -wl.*x(2) + A.*sin(w.*t).* wl.*(x(5) - x(1))
dx(3) = K.*x(2)
0 = x(3) + A.* sin(w.*t) - x(4)
0 = 25 - (5 - x(4) ).^2 - x(5) % = 25 - (25 -10*x4 + x4^2) -x5 = x4*(10 -x4)-x5
and check this old post:
https://www.mathworks.com/matlabcentral/answers/360710-how-to-solve-a-set-of-odes-and-a-nonlinear-equation