Solving System of two second order ODE's
2 ビュー (過去 30 日間)
古いコメントを表示
Hi , I have tried solving the following system of ODE's (eq1 attached) using Matlab. first i reduced it into a system of four 1st order ODE's (eq2 attached). thani tried to solve it using ode45() in the following manner:
function xprime = Mirage(t,x);
k=2;
xprime=[x(1); k*(1-x(1).^2)./(1+k*x(2)); x(3) ; -(k*x(1)*x(3))./(1+k*x(2))];
end
x0=[1 1 1 1];
tspan=[0,20];
[t,x]=ode45(@Mirage,tspan,x0)
did i set the vector x well in the function? where did i wrong? i will appreciate your help.
0 件のコメント
回答 (1 件)
Amos
2015 年 1 月 9 日
In order to get a system of first order equations, you substitute y' by t and z' by s, right? So your independent functions are then y,t,z,s. These should be ordered in a vector, e.g. x=[y,t,z,s]. The function xprime obviously returns the derivative of the four entries of x. But then x(1)' should be set to x(2), as you have y'=t and not y'=y. The same holds for x(3)' which should not be set to x(3) but rather to x(4).
2 件のコメント
Amos
2015 年 1 月 11 日
So what is actually your question?
When I run the code, I get a four column matrix for x, as you expected. It is true that t=x(2) is stationary, but this is just a consequence of t' being proportional to 1-t. So, if you start with t=1, t' is zero and therefore t doesn't change.
By the way, I think in your corrected version Mirage(t,x), there is a minus sign missing in the last entry of xprime.
参考
カテゴリ
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!