Message Boards Message Boards


How can I manipulate variables in an NDSolve differential equation?

Posted 10 years ago
2 Replies
2 Total Likes
ecosh =
NDSolve[{ex'[t] == r - (a*h*ex[t] ep[t]),
    ep'[t] == (f*a*ex[t]*ep[t])/(1 + a*h*ex[t]) - q*ep[t],
    ex[0] == 300, ep[0] == 100} /. {a -> 0.1, h -> 0.1, q -> 0.115,
    f -> 0.15, r -> 0}, {ex, ep}, {t, 0, 50}]
Plot[Evaluate[{ex[t], ep[t]} /. ecosh], {t, 0, 10}]

That's my code and there's the plot it yields. I'm tweaking a model and I want to be able to adjust all the parameters (i.e. a, h, q, f, r) as well as the starting conditions (ex[0] and ep[0]) quickly. However I haven't found a way that's compatible with using NDSolve. Any ideas?
POSTED BY: Jamby Humbert
2 Replies
Posted 10 years ago
I do these types of things all of the time. I typically take the Manipulate approach. In this approach, wrap the NDSolve function in a Manipulate, and give each parameter a range of values. Just think of this as using Table to specify lists for each of the parameters, then you could iteratively search through the list or specify different values.
ParametricNDSolve gives you an NDSolve setup than contains parameters.
POSTED BY: Frank Kampas
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract