dvxdt=@(t,x,vx) GM*x./(x.^2+y.^2).^3;
that accepts vx as a parameter but does not use it.
It does not have any parameter named y but uses y. In that case, it is going to use the variable value that the variable y had at the time the anonymous function was created, which comes from
This is a vector, and even though it only contributes 0 at all components, it makes the result of dvxdt be a vector. That becomes a problem because it means that
k1vx = dvxdt(t(i) ,x(i) ,vx(i));
gives a vector result, so
vx(i+1)=vx(i)+h/6*(k1vx+2*k2vx+2*k3vx+k4vx);
has a vector on the right hand side, but designates a scalar output location.
Best Answer