You can use the functions Simplify`PWToUnitStep
and Simplify`SimplifyUnitStep
to convert a Piecewise
function to one using UnitStep
:
s[t_] := Piecewise[{{1, t < 300.}, {0, 300. <= t < 1500.}, {1, t <= 3600}}];
s2[t_] := Simplify`SimplifyUnitStep[Simplify`PWToUnitStep[s@t]];
s2[t]
1 - UnitStep[-300. + t] + UnitStep[3600 - t, -1500. + t]
To use HeavisideTheta
instead of UnitStep
:
s2[t] /. UnitStep -> HeavisideTheta
1 - HeavisideTheta[-300. + t] + HeavisideTheta[3600 - t, -1500. + t]
Row[Plot[#, {t, 0., 4000.}, PlotStyle -> Thick, ImageSize -> 300] & /@ {s[t], s2[t]}]

Piecewise
causesNDSolve
to succeed in my experience. $\endgroup$ – Michael E2 Apr 23 '16 at 19:33x^0.5
is very different fromx^(1/2)
, and so on. When someone here posts a problem withNDSolve[sys,...]
and it seems related to this issue, I usually try it withNDSolve[Rationalize[sys, 0],...]
, if nothing else seems more likely. $\endgroup$ – Michael E2 Apr 24 '16 at 20:34