# How do you set up an ode solver with a more than one function in the ode?

조회 수: 2 (최근 30일)
L'O.G. 2023년 10월 7일
댓글: Sam Chak 2023년 10월 9일
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개 표시이전 댓글 2개 숨기기
Walter Roberson 2023년 10월 8일
Use ode15i
Sam Chak 2023년 10월 9일
I would like to suggest providing a specific example of this generic "Exact differential equation" form:
This would allow us to test which ODE solver might be suitable for solving it.

댓글을 달려면 로그인하십시오.

### 답변 (2개)

Torsten 2023년 10월 7일
이동: Torsten 2023년 10월 7일
If you have two unknown functions (f and g), you need two equations.
##### 댓글 수: 0이전 댓글 -2개 표시이전 댓글 -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
eqn(t) =
sol = dsolve(eqn, g)
sol = struct with fields:
g: 0 f: exp(-t/a)*(C1 - c*exp(t/a))
eqn2 = subs(diff(sol.f), t, 0) == 0
eqn2 =
constant_of_integration = setdiff( symvar(eqn2), [a b c])
constant_of_integration =
solution_for_constant = solve(eqn2, constant_of_integration)
solution_for_constant =
0
subs(subs(eqn, sol), constant_of_integration, solution_for_constant)
ans(t) =
subs(sol, constant_of_integration, solution_for_constant)
ans = struct with fields:
g: 0 f: -c

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

R2021b

### Community Treasure Hunt

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

Start Hunting!

Translated by