I want to create a non-periodic square wave with values of 1 and -1(not necessarily alternating).
For e.g. I want to convert an arbitrary array like {1,-1,-1,1,-1,1,-1} into a function.
I tried using Piecewise but I don't know how to do this without typing a huge number of conditions.
I also want to add the length of each stack(i.e. the duration for which it is in 1 or -1) e.g. two inputs value={1,-1,-1,1,-1,1,-1} and duration={5,6,1,2,3,8,2}
Please Help
P.S: The version I am using is 8.0.4.0





