# Manipulate with DSolve

I have defined a set of differential equations stored in sol and I'd like to plot them while being able to change the parameters. I've tried it like so:

    Manipulate[
sol = DSolve[{Derivative[1][x][t] == -b x[t],
Derivative[1][p][t] == -(1 - r) p[t] + b x[t], x[0] == 100,
p[0] == 10}, {x[t], p[t]}, t],
Plot[Evaluate[p[t] /. sol[[1, 1]], {t, 0, 10}], {b, 0, 1}, {r, 0, 1}]
]


but I'm receiving the error message:

"Manipulate argument Plot[Evaluate[p[t]/. \ sol[[1,1]],{t,0,10}],{b,0,1},{r,0,1}] does not have the correct form \ for a variable specification."

Any idea how I can fix this? I'd be much appreciated.

You have a few syntax errors. See below for corrected code:

Manipulate[
sol = DSolve[
{Derivative[1][x][t] == -b x[t],
Derivative[1][p][t] == -(1 - r) p[t] + b x[t],
x[0] == 100, p[0] == 10},
{x[t], p[t]}, t
];
Plot[Evaluate[p[t] /. sol[[1, 1]]], {t, 0, 10}],
{b, 0, 1}, {r, 0, 1}
]


• Yeah, I couldn't because I didn't have enough "points". I have now so it's done :) Jul 7, 2016 at 14:57
• @phytab Thank you! Jul 7, 2016 at 20:12