Error in ode45
Mostrar comentarios más antiguos
I added to a code another planet and when i added the Mercury planet on ode45 i got an error that is:
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in SimpleGravity (line 39)
[attime,finalposition]=ode45(@Propagator,[0:stepsize:finaltime],[EarthInitial]);
%% Inputs
stepsize=1; %step size in days, should not exceed 1
finaltime=10; %days from t0
%% System Conditions
global sunm G
sunm=1.9891e30; %kg
G=1.4879*10^(-34); %AU^3/(kg*Day^2)
%% Earth Initial Conditions
x=-7.829690890802676E-01; %AU
y=6.009223815219861E-01; %AU
z=-1.377986550047871E-05; %AU
Vx=-1.075646922487205E-02;%AU/day
Vy=-1.370584048238274E-02;%AU/day
Vz=3.974096024543801E-08; %AU/day
EarthInitial=[x,y,z,Vx,Vy,Vz]; %summary of initial conditions of the earth
%% New planet
Mx=-2.829690890802676E-01; %AU
My=8.009223815219861E-01; %AU
Mz=-4.377986550047871E-05; %AU
MVx=-0.075646922487205E-02;%AU/day
MVy=-2.370584048238274E-02;%AU/day
MVz=5.974096024543801E-08; %AU/day
MercuryInitial=[Mx,My,Mz,MVx,MVy,MVz];
%% Call the Function
%outpu=call the function, time to run, initial conditions
[attime,finalposition]=ode45(@Propagator,[0:stepsize:finaltime],[EarthInitial,MercuryInitial]); %% this is where the problem is when I added Mercuryinitial
%% Plot the Result
hold ON
plot3(finalposition(:,4),finalposition(:,5),finalposition(:,6),'g'); %plot of position of earth in green
plot3(finalposition(:,10),finalposition(:,11),finalposition(:,12),'g');
xlabel('Distance (AU)');ylabel('Distance (AU)');zlabel('Distance (AU)'); %label the axis
legend('Earth'); %tell me what the green line is
axis equal %fix the axis so it has the same scale in x, y and z
%note: sun is at 0,0,0
2 comentarios
Steven Lord
el 18 de Mayo de 2020
That doesn't look like the whole error message. Please show us all the text displayed in red and/or orange when you try to run your code.
christian fares
el 18 de Mayo de 2020
Editada: christian fares
el 18 de Mayo de 2020
Respuesta aceptada
Más respuestas (1)
Meysam Mahooti
el 28 de Jul. de 2021
Editada: Walter Roberson
el 29 de Jul. de 2021
0 votos
Categorías
Más información sobre Numerical Integration and Differential Equations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!