2
$\begingroup$

I'm trying to create an SIR model of disease. These are the starting parameters, and i'd lake to be able to manipulate b and k. Thanks!

system = {y'[t] == -b y[t] i[t], i'[t] == b y[t] i[t] - k i[t], 
i[0] == 1.27*10^-6, r'[t] == k i[t], r[0] == 0, y[0] == 1}
$\endgroup$
6
$\begingroup$
system = {
   y'[t] == -b y[t] i[t], i'[t] == b y[t] i[t] - k i[t], r'[t] == k i[t],
   i[0] == 1.27*10^-6, r[0] == 0, y[0] == 1
 };

parfun = ParametricNDSolveValue[system, {y, i, r}, {t, 0, 60}, {b, k}];

Manipulate[
 Plot[
   Evaluate@Through[parfun[b, k][t]], {t, 0, 60},
   PlotLegends -> {"y[t]", "i[t]", "r[t]"}
 ],
 {{b, 3}, 0, 10}, {{k, 2}, 0, 10}
]

Mathematica graphics

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.