How do you set up an ode solver with a more than one function in the ode?
2 次查看(过去 30 天)
显示 更早的评论
For example, if you have an ode such as a*df(t)/dt + b*dg(t)/dt + f(t) + g(t) + c = 0 that you'd like to solve and if you want to set one of the derivatives to be zero, how do you do that?
(By "ode solver" in the title I mean solve numerically.)
4 个评论
回答(2 个)
Walter Roberson
2023-10-8
syms f(t) g(t) a b c
df = diff(f);
dg = diff(g);
eqn = a*df + b*dg + f(t) + g(t) + c == 0
sol = dsolve(eqn, g)
eqn2 = subs(diff(sol.f), t, 0) == 0
constant_of_integration = setdiff( symvar(eqn2), [a b c])
solution_for_constant = solve(eqn2, constant_of_integration)
subs(subs(eqn, sol), constant_of_integration, solution_for_constant)
subs(sol, constant_of_integration, solution_for_constant)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!