See here:
https://community.wolfram.com/groups/-/m/t/440741
Edit:
I have a solution of myself:
Sum[UnitBox[k (x - T j)], {j, -10, 10}]
UnitBox gives a top hat centered at 0, width 1. The k
makes it with a shorter width. The T
is the periodicity.
When k=1/T, you get a straight line.
And when k<1/T you get a different thing than the one you asked for.
But if k>1/T, you get this pulse train.
You can also add a phase, to make the function start where you want:
Sum[UnitBox[k (x - T j+phi)], {j, -10, 10}]
With a phi
that runs from 0 to T.
Change the values for j
to get the number of pulses. Number of pulses=2j+1.
I hope it helps!