# ParametricNDSolveValue with coupled DEs and manipulation

How do I separate the solutions to these coupled DEs in the plot?

I want to plot the solutions to these equations at time t=7 as a function of parameter a while manipulating parameter b.

Code:

Manipulate[
sol = ParametricNDSolveValue[
{s'[t] == -a*b*d[t], d'[t] == +b*s[t], s == 100, d == 0},
{s, d},
{t, 0, 20},
{a}
];

Show[{
Plot[sol[a], {a, 0.1, 10}, ImageSize -> 400,
PlotStyle -> {Black, Blue}, PlotLabel -> populations]
}],

Text["Test-----"],
{{b, 1, "b"}, 0.1, 10, Appearance -> "Open"}
]


I tried

Plot[Evaluate@Table[(s[t],d[t])/.sol[a]],{a,0.1,10}]


and

Plot[Evaluate@Table[(s[a][t],d[a][t])/.sol],{a,0.1,10}]


and various other lines but Mathematica is giving me errors like "is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing"

Two changes in your code: (1) made sol a two-parameter function and evaluate it outside Manipulate, (2) used {sol[a,b][],sol[a,b][]} as the first argument in Plot:

sol = ParametricNDSolveValue[{s'[t] == -a*c*d[t], d'[t] == c*s[t],
s == 100, d == 0}, {s, d}, {t, 0, 20}, {a, c}];

Manipulate[Plot[{sol[a, b][], sol[a, b][]}, {a, 1/10, 10},
PerformanceGoal -> "Speed", ImageSize -> 400,
PlotStyle -> {Black, Blue}],
{{b, 1, "b"}, .1, 10, Appearance -> "Open"}] Note: If we use sol[a,b] or Evaluate@sol[a,b] instead of {sol[a, b][], sol[a, b][]} we get two curves with the same color.

• Thanks so much! I have a lot to learn. PerformanceGoal is a nice touch. – Takeitfromme Aug 30 '18 at 8:11
• @Takeitfromme, my pleasure. Welcome to mma.se. – kglr Aug 30 '18 at 19:20