1
$\begingroup$

The following code described an input to the system only during t less than minInfusionTime after time zero. Any way to give this same input every x time (e.g. every week) after time of zero, to an ODE system A[t]? In another word, the system receive an input every week, with an input rate of (mgDose/minInfusionTime)

mgDose = 50;
minInfusionTime = 15;
inputSignal = 
  Function[t, 
   Piecewise[{{mgDose/minInfusionTime, t < minInfusionTime}}, 0]];



$\endgroup$
  • $\begingroup$ Welcome to Mathematica.SE, Math Entry! I suggest the following: 1) Take the tour and check the faqs. 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. $\endgroup$ – Chris K May 10 at 14:16
0
$\begingroup$

You can use If and Mod inside NDSolve to achieve this. Here I assume time is measured in hours and there are first-order decay kinetics.

mgDose = 50;
minInfusionTime = 15;
τ = 7*24; (* period *)
tmax = 5 τ;
l = 0.001;

sol = NDSolve[{a'[t] ==
  If[0 < Mod[t, τ] < minInfusionTime, mgDose/minInfusionTime, 0] - l a[t],
  a[0] == 0}, a, {t, 0, tmax}][[1]];

Plot[a[t] /. sol, {t, 0, tmax}, PlotRange -> All]

Mathematica graphics

$\endgroup$
  • $\begingroup$ Thank you! Besides Mod, any other approaches? $\endgroup$ – Math Entry May 10 at 15:26
  • $\begingroup$ If you are OK with an impulsive input instead of one distributed over the finite time minInfusionTime, you could use WhenEvent inside the NDSolve. $\endgroup$ – Chris K May 10 at 15:37

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.