Numerical solution to an ODE as input to solve another ODE?

I have the following ordinary differential equation (ODE):
where, y is given by the solution to
(f and g denote functions)
If the second ODE has an analytic solution, solving the first ODE numerically, for example using ODE45, is straight forward as can be substituted.
However, if an analytic solution for y is not available, how can I use the numerical solution to the second ODE as input to the first ODE? Or is there any other way to solve the problem?

 采纳的回答

Solve
dy/dt (= dy/dx * dx/dt) = g(y,x)*f(y,x)
dx/dt = f(y,x)
together using ODE45.

2 个评论

Thanks Torsten. That works perfectly.
I have a related question: is there a way to impose constraints on the variables ? For example .
No, the functions f and g and the initial conditions for x and y uniquely determine the solution. Thus the solution is already fixed in advance - no chance to impose constraints.
If the solution for x exceeds the bounds you listed for x because of numerical errors, you might try to strengthen the tolerances of the solver.
Best wishes
Torsten.

请先登录,再进行评论。

更多回答(0 个)

类别

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by