令x1 = x, x2 = x', x3=y, x4=y'
得
x1' = x2;
x2' = -x2*sqrt(x2^2+x4^2);
x3' = x4;
x4' = -x4*sqrt(x2^2+x4^2) - 9.8;
程序为
f = @(t, x)[x(2);
-x(2)*sqrt(x(2).^2+x(4).^2);
x(4);
-x(4)*sqrt(x(2).^2+x(4).^2)-9.8];
[t, y ]= ode45(f, [0,5], [0;35.355;0;35.355]);
plot(t,y)
legend('x1', 'x2', 'x3', 'x4')