0
$\begingroup$

I am trying to write a Piecewise function that includes the SawtoothWave function. Can someone indicate how to do this, or if it is possible within mathematica?

The piecewise code is here:

G = -1/50; (*G gradient*)
P = 6; (*pulse period in seconds*)

L = 3.08/2; (*pulse width in dimensionless units*)
tform = 1; (*time allowed for soliton to form independently,e.g.100*)

bell[s_, x_] := Exp[-(x/s)^2/2]

Astep[x_, t_] := -bell[1, x] bell[10, t - 10] + Piecewise[{{G SawtoothWave[{-1, 1}, x/L + t/P]}, t > tform}, 0]

Animate[Plot[Astep[x, t], {x, -10, 10}, PlotRange -> {{-10, 10}, {-0.05, 0.05}}], {t, 0, 50}, AnimationRunning -> False]

The error message I receive is as follows:

enter image description here

$\endgroup$
  • 3
    $\begingroup$ you should have Piecewise[{{G SawtoothWave[{-1, 1}, x/L + t/P], t > tform}}, 0] instead of Piecewise[{{G SawtoothWave[{-1, 1}, x/L + t/P]}, t > tform}, 0] (misplaced '}'). $\endgroup$ – kglr Jun 16 at 17:35
  • $\begingroup$ Thanks! That has solved it. $\endgroup$ – Brendan Darrer Jun 16 at 17:41

Your Answer

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

Browse other questions tagged or ask your own question.