0
votes

So, I'm solving some ODEs in MATLAB using ode45. Nothing particularly complicated about them or the code, but each ODE solution takes 20-30 minutes to obtain, and I need to get about 10. (It's a parameter sweep.)

While sitting and waiting for the solutions to arrive, I find myself wishing there was some way to watch the solutions be plotted out as the ODEs are solved, both to reassure myself that progress is being made and to be able to end the solver if something seems to be off about the solution.

Is there a way to return the current (incomplete) solution from ode45 and plot it in real time as it's being solved? I'm currently plotting the solutions as they arrive, but that still takes some time, and real time would be fantastic.

2
The correct answer is to use an OutputFcn – see the ballode example.horchler

2 Answers

-1
votes

If you were to plot it in real time, you'd have to edit the code of the solver itself. In doing so, I imagine it would cause the solver to slow to a crawl when you run it because it has to graphically plot what it's doing. Not much of an answer im afraid, but for some reason the site didnt let me post this as a comment...

-1
votes

This is what I did to ode45 to make it plot while running

%line 470

f(:,1) = f(:,7); % Already have f(tnew,ynew)

%make plot

plot(tout(1:nout),yout(:,1:nout))

drawnow

%end of addition

end

....