How to solve an ODE system with time-dependent variables in MATLAB?

6 ビュー (過去 30 日間)
Mohammad Khojastehmehr
Mohammad Khojastehmehr 2020 年 5 月 28 日
回答済み: Steven Lord 2020 年 5 月 28 日
I'm trying to solve an ODE system with time-dependent variables in MATLAB.
function dPdt = ode_Core1(~,P,landa,P_L,P_R)
dPdt = zeros(5,1);
dPdt(1) = 4*lambda*(-3*P(1) + P(2) + 2*P_L)/3;
dPdt(2) = lambda*(P(1) - 2*P(2) + P(3));
dPdt(3) = lambda*(P(2) - 2*P(3) + P(4));
dPdt(4) = lambda*(P(3) - 2*P(4) + P(5));
dPdt(5) = 4*lambda*(P(4) - 3*P(5) + 2*P_R)/3;
Where "lambda" is a time-dependent variable and should be calculated having P values at previous times. I have worked with "ode45" but I'm not quite sure this case can be solved using ode45. Can anyone help me with this?
  2 件のコメント
madhan ravi
madhan ravi 2020 年 5 月 28 日
Could you post the equation?
Mohammad Khojastehmehr
Mohammad Khojastehmehr 2020 年 5 月 28 日
The general form is dP/dx=alpha*d2P/dx2
It is a diffusion problem. However, it is a little modified in my case. I was trying to apply the method of lines.

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

回答 (2 件)

Star Strider
Star Strider 2020 年 5 月 28 日
One method of doing that is in ODE with Time-Dependent Terms using linear interpolation. However to do that you would have to pass the time variable to ‘ode_Core1’. In the code you posted, you are not.
  3 件のコメント
Mohammad Khojastehmehr
Mohammad Khojastehmehr 2020 年 5 月 28 日
Sorry instead of lambda I said alpha.
Star Strider
Star Strider 2020 年 5 月 28 日
Does alpha or lambda or whatever have any sort of specific expression?
Is it a vector or a function?
What specifically do you want from it?

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


Steven Lord
Steven Lord 2020 年 5 月 28 日
From your description, it sounds like you don't have an ordinary differential equation (ODE) but you have a delay differential equation (DDE). Take a look at the dde23 function.

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by