I am confused as to why the two functions below yield different results (as vs ss)? One function assigns the Piecewise function directly, while the other reads the same function from a list of lists. Why doesn't the second function repeat?
piecewiseLists =
{
{
Piecewise[{{signal, t < 2700.}, {0., 2700. <= t < 5400.}}]
},
{
Piecewise[{{signal, t < 15000.}, {0., 15000. <= t < 30000.}}]
}
};
signal = 1;
a[t_] := Piecewise[{{signal, t < 2700.}, {0., 2700. <= t < 5400.}}]
as[y_, repeat_] := a[Mod[y, repeat]];
Plot[as[t, 5400.], {t, 0, 36000.}]
s[t_] := piecewiseLists[[1, 1]]
ss[y_, repeat_] := s[Mod[y, repeat]];
Plot[ss[t, 5400.], {t, 0, 36000.}]
After implementing @Pirx's solution, I noticed that symbolic assignment of the piecewise function fails if placed within an actual function. My suspicion is that either there is something strange happening with the independent variable being hidden in the symbolic function. Or there is some other weird Context issues that at this point is beyond my understanding.
piecewiseLists = {{Piecewise[{{signal, t < 2700.}, {0.,
2700. <= t < 5400.}}]}, {Piecewise[{{signal, t < 15000.}, {0.,
15000. <= t < 30000.}}]}};
generatePeriodicity[piecewiseLists_] :=
Module[{s, ss},
s[t_] = piecewiseLists[[1, 1]];
ss[y_, repeat_] := s[Mod[y, repeat]];
Plot[ss[t, 5400.], {t, 0, 36000.}]];
generatePeriodicity[piecewiseLists]