Can ode45 solve a ODE with space dependent parameters?

Hello,
I read ode45() can solve functions with time dependent parameters like this below by interpolating f and g during each time step.
y'(t)+f(t)y(t)=g(t)
However, can ode45 (or other solver) solve a system of odes like this below in which [A], [B] and [C] are matrices with some terms dependent of y and y=y(t)?
{dy/dt} = [A]{y^4}+[B]{y}+{C}
Ai=Ai(y)
Bi=Bi(y)
Ci=Ci(y)
Well, since this equation appears in a problem I solve using Simscape (Backward Euler method as default), I suppose I could find a solver to solve it inside Matlab codes without using Simscape.

2 件のコメント

Jan
Jan 2019 年 1 月 29 日
The notation is not clear to me: "{dy/dt} = [A]{y^4}+[B]{y}+{C}"
Marlon Saveri Silva
Marlon Saveri Silva 2019 年 1 月 29 日
編集済み: Marlon Saveri Silva 2019 年 1 月 29 日
Actually this is not a MATLAB command line notation, I tried this "mathematical notation" to emphasize y, dy/dt and C are vectors whereas A and B are matrices.
{y} = {y1, y2, y3, ... , yn}
{C} = {c1, c2, c3, ... , cn}
{dy/dt} = {y1', y2', y3', ... , yn'}
Moreover, by {y^4} I tried to indicate the vector is {y1^4, y2^4, y3^4, ... yn^4}.

サインインしてコメントする。

 採用された回答

James Tursa
James Tursa 2019 年 1 月 29 日

2 投票

Yes. In general, if the derivative is a function of current state and time (even if there are vectors or matrices involved), then you can use ode45 to get a numerical solution. The caveat is that the function needs to be "nice" enough for ode45 to handle. Otherwise you may need stiff solvers, etc.

5 件のコメント

Marlon Saveri Silva
Marlon Saveri Silva 2019 年 1 月 29 日
Hm... And what about nonlinear terms? Should the expression be linearized before apply ode45? Terms like y1^4 - y2^4 are easily linearized by the rule of subtration of powers; however when something like y2'= y1*y2^2 appears in the equations I don't know if we can linearize it. The only thing I can think in this case is considering it like y2'=f(y1)*y2 and calculate f(y1,y2) in each time step as we do in the solution you have just presented.
James Tursa
James Tursa 2019 年 1 月 29 日
Derivative can have nonlinear terms. As long as you can write it in the form dydt = f(t,y) then you can code it up and feed it to ode45. f does not have to be linear in y or t.
Marlon Saveri Silva
Marlon Saveri Silva 2019 年 1 月 29 日
Hm, pretty nice. I'll try to code it tomorrow. Thanks.
Ying Wu
Ying Wu 2021 年 8 月 5 日
Hi Silva, I have met the same problem, my ODE has parameter A which is the piecewise function of the first directive y'(t). Have you succeed in solving this problem?
James Tursa
James Tursa 2021 年 8 月 5 日
@Ying Wu It would be best if you posted a new Question with the details of your particular problem & derivative functions.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by