ode45 MATLAB ODE solver
Afficher commentaires plus anciens
Hello I am using the MATLAB ODE solver ode45. But, the integration was not completed, and I still want to continue. So, How can I force the ode45 solver to continue???
3 commentaires
madhan ravi
le 15 Août 2018
Upload the code so that it could be debugged.
Ahmad Alalyani
le 16 Août 2018
Modifié(e) : Walter Roberson
le 16 Août 2018
Walter Roberson
le 16 Août 2018
Why are you continuing on from half way through the timespan it integrated over? Why not from the last time it integrated for?
Why are you passing in r and also declaring r to be global? MATLAB releases are changing with regards to what will happen for that situation. In some releases, the result would be to replace the passed in parameter 'r' with the current value of the global variable, which would probably be [] .
Réponses (1)
Walter Roberson
le 15 Août 2018
maxtries = 500;
first_time = 0; %or as appropriate
end_time = 10; %or as appropriate
tspan = [first_time, end_time];
y0 = [-1 3]; %set as appropriate
for counter = 1 : maxtries
[this_t, this_y] = ode45(fun, tspan, y0);
if counter == 1
t{counter} = this_t; y{counter} = this_y;
else
t{counter} = this_t(2:end); y{counter} = this_y(2:end,:);
end
ended_at = this_t(end);
if ended_at >= tspan(end)
break; %got to end of time span we wanted
end
tspan = [ended_at, end_time];
x0 = this_y(end,:);
end
overall_t = cell2mat(t);
overall_y = cell2mat(y);
2 commentaires
madhan ravi
le 16 Août 2018
Your brilliance is extraordinary Sir Walter I admire your work.
Ahmad Alalyani
le 16 Août 2018
Catégories
En savoir plus sur Ordinary Differential Equations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!