solving odes (resiscted 3 body problem)

ive been trying to solve these equations -
d2x dt2 = 2 dy dt + x− M(x + E) r3 E − E(x−M) r3 M
d2y dt2 = −2 dx dt + y− My r3 E − Ey r3 M
z1 = x, z2 = dx dt , z3 = y, and z4 = dy dt
but keep getting this error
Error using vertcat Dimensions of matrices being concatenated are not consistent.
Error in secodef (line 10) zprime = [z(2);2*z(4)+z(1)-((M*(z(1)+E))/Re^3)-((E*(z(1)+M))/Rm^3);z(4);-2*z(2)+z(3) -(M*z(3))/Re^3 -(E*z(3))/Rm^3];
Error in odearguments (line 90) f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115) odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in solode (line 5) [t,z] = ode45(@secodef,xspan,z0);
what do?

 채택된 답변

James Tursa
James Tursa 2017년 11월 28일
편집: James Tursa 2017년 11월 28일

0 개 추천

Building matrices with [ ] can be picky when it comes to spaces. E.g.,
>> [1;5-3;4]
ans =
1
2
4
>> [1;5 -3;4]
??? Error using ==> vertcat
CAT arguments dimensions are not consistent.
>> [1;(5 -3);4]
ans =
1
2
4
In the second case above, because of that extra space the parser interpreted the "5 -3" as a 1x2 vector and not as a single scalar. To fix this, either get rid of all of your spaces, or use parentheses as shown.
Side Note: Your line 10 seems to be missing some E's and M's when compared to your posted equations. You might check that.

추가 답변 (0개)

카테고리

질문:

del
2017년 11월 28일

댓글:

del
2017년 11월 28일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by