Solving Coupled ODE's by ode45
古いコメントを表示
I have several ODE's with initial condition. I've given them as example.
dx/dt = dy/dt + r,
r = a*x+b (a,b are parameters)
dy/dt = z for 1st 30 minutes (z = e*f)
after 30 minutes
dy/dt = z - k*f (k,f are parameters)
How can I solve this?
4 件のコメント
James Tursa
2020 年 5 月 18 日
What have you done so far? What specific problems are you having with your code? Typically you would call ode45( ) with a time span of 30 minutes, then take that result as the initial conditions for the next time span and call ode45( ) again with the different derivative function.
Swachwa Dey
2020 年 5 月 18 日
James Tursa
2020 年 5 月 18 日
Have you looked at the ode45( ) doc? There are examples there for solving systems of equations:
Basically you make a vector (in your case a two element vector since you have two variables x and y) and then write your equations based on this vector.
Swachwa Dey
2020 年 5 月 19 日
回答 (1 件)
James Tursa
2020 年 5 月 19 日
Start with your example (assuming that dx/dy was supposed to be dx/dt as you had originally):
dx/dt = 3*(dy/dt) + 4*x, dy/dt = dz/dt + 4*x and dz/dt = 4*x?
Then make these state vector definitions, using Y as the state vector for all the variables:
Y(1) = x
Y(2) = y
Y(3) = z
The derivative function would look something like this
function dYdt = myderiv(t,Y)
x = Y(1);
y = Y(2);
z = Y(3);
dzdt = 4*x; % do this one first, doesn't depend on the others
dydt = dzdt + 4*x; % then this one next since we now have dzdt
dxdt = 3*dydt + 4*x; % then do this one last since we now have dydt
dYdt = [dxdt;dydt;dzdt];
end
1 件のコメント
Swachwa Dey
2020 年 5 月 21 日
編集済み: Swachwa Dey
2020 年 5 月 22 日
カテゴリ
ヘルプ センター および File Exchange で Ordinary Differential Equations についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
