DifferentialEquations & Plots -- transforming solutions before plot

I have computed sol from DifferentialEquations, and need to transform selected values before plotting them. Specifically, I want to convert values from fraction to percentage (f2p).

Suppose I want transform a single variable, say variable nr. 2. I can do that by:

f2p = (t,x) -> (t,100x)

Next, suppose I want to plot variable nr. 1, 2, and 4:



  • Is there a way to use the same mapping to percentage on variables 1, 2, 4 in a single plot command?

The following does not work:

plot(sol, vars=(f2p,0,[1,2,4]))

Is there a way to do this without doing it the “hard” way:

plot(sol, vars=(f2p,0,1))
plot!(sol, vars=(f2p,0,2))
plot!(sol, vars=(f2p,0,3))


1 Like