2

I am solving a system of ODEs with DSolve, which returns the results as interpolating functions. The solver always stops after some finite time because of resolution issues, so the domain of the outputted interpolating function is limited.

Hence, if I then plot those functions with a Plot command, I have to specify the range {t,0,tmax}. However tmax would change a bit everytime I run the DSolve command, and it is a pain to always change tmax manually.

Is there a way to address the domain of such a function directly?

Britzel
  • 663
  • 3
  • 10

1 Answers1

3

You can get the domain of an interpolation-object quite simple.

For example the simulation timerange of

sol = NDSolveValue[{x'[t] == -x[t], x[0] == 1, WhenEvent[x[t] < .5, "StopIntegration"]}, x, {t, 0, 1}]

is

sol["Domain"][[1]]
(*{0., 0.693147}*)
Ulrich Neumann
  • 53,729
  • 2
  • 23
  • 55