Quote:
Originally Posted by Rapha Hello CaptainBlack!
Thank you so much for your helpful comment!
I tried it but it still doesn't work. Code: function dx = ivp(t, x)
dx = \dot{x} * x;
clearly represented, I wrote  for
then:
[t, x] = ode45(@ivp, [0, 10], [??,??,??,??] )
where ![t \in [0, 10] t \in [0, 10]](http://www.mathhelpforum.com/math-help/latex2/img/1c75f0e0c25ae64c5fe7e65227bbcb32-1.gif) and ?? = [x_3(0); x_4(0);, ...(0); ...(0)]
this is stupid, but I don't know the initial values :-( |
Somewere in the staement of the problem there should be initial values.
But you can try any initial values to test the code [0;0;1;1] should do.
the following seems to work on FreeMat:
Code:
function dx=deriv(t,x)
d1=sqrt(((x(1)+0.1)^2+x(2)^2)^3);
d2=sqrt(((x(1)-0.9)^2+x(2)^2)^3);
dx=zeros(4,1);
dx(1)=x(3);
dx(2)=x(4);
dx(3)=x(1)-2*x(4)-0.9*(x(1)+0.1)/d1-0.1*(x(1)-0.9)/d2;
dx(4)=x(2)-2*x(3)-0.9*x(2)/d1-0.1*x(2)/d2;
with calling statement:
Code:
[t,x]=ode45(@deriv ,[0,10],[0;0;1;1]);
(note the absurdty that we have state and derivative as colum vectors, but the output is an array of row vectors, one for each time point, but it does not work if we have row vectors for the state and derivative!!)
CB