NOTE: See update at end of question
I have a function smoothstep
(based on the derivative of a smoothstep function) that gives a single impulse as follows:
smoothstep = Piecewise[{{0, x <= -1},
{(1/32)*(35 - 105*x^2 + 105*x^4 - 35*x^6), -1 < x < 1},
{1, x >= 1}}]
Plot[{smoothstep}, {x, -1, 1}, GridLines -> Automatic,
PlotLegends -> "Expressions"]
**Piecewise[{{0, x <= -1},
{(1/32)*(35 - 105*x^2 + 105*x^4 - 35*x^6), -1 < x < 1},
{1, x >= 1}}, 0]**
I want to use this as the basis for a train of impulses, where single impulses like the one above appear at all instances of x+n a
where n
is the set of integers and a
is a chosen positive integer. For example, for a=4
, the function would return impulses in each of the ranges {...-9<=x<=-7,-5<=x<=-3,,-1<=x<=1,3<=x<=5,7<=x<=9...}
, and return 0
in the ranges {...-7<x<-5,-3<x<-1,1<x<3,5<x<7...}
.
I can't figure out the syntax to deliver this as a new piecewise function. How do I define n
and a
? Presumably it involves slots or double-slots...?
(I tried the following with no success:)
smoothstepimpulsetrain = Piecewise[
{{(1/32)*(35 - 105*(x - n*a)^2 + 105*(x - n*a)^4 -
35*(x - n*a)^6), Element[n, Integers]},
{0, NotElement[n, Integers]}}]
Plot[{smoothstepimpulsetrain /. a -> 4}, {x, 15, 15},
GridLines -> Automatic, PlotLegends -> "Expressions"]
UPDATE
@Michael E2 and @MikeY made the following suggestion, but it doesn't quite work, as you can see from the plot for a=1
:
smoothstep[x_] := Piecewise[{{0, x <= -1},
{(1/32)*(35 - 105*x^2 + 105*x^4 - 35*x^6), -1 < x < 1},
{0, x >= 1}}];
train[x_, a_] := smoothstep[Mod[x, a, -1]];
Plot[{train[x, 1], train[x, 3], train[x, 5], train[x, 7]},
{x, 0, 10}]
Also note that summing these trains produces an incorrect plot - note the feeble little bump at x=5
, and the anomalous behaviour in the range x=6->8
:
Plot[{train[x, a] /. a -> 3 + train[x, a] /.
a -> 5 + train[x, a] /. a -> 7}, {x, 0, 10}]
Further suggestions?
f[Mod[x, 4, -1]]
? $\endgroup$ – Michael E2 Dec 19 '18 at 17:03f
here is supposed to be your piecewise function. So plugMod[..]
forx
. Or write an functionf[x_] := Piecewsie[..]
. $\endgroup$ – Michael E2 Dec 19 '18 at 17:36