Solving System of two second order ODE's
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Amos
le 9 Jan 2015
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 commentaires
Amos
le 11 Jan 2015
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.
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!