I'm currently calculating a periodic square wave current function to feed into a particle accelerator. It's a square wave that ramps up to a certain frequency and then drops back to the base frequency and starts all over.
Between Mathematica and an iterative python script, I managed to get a list of 308 times (between t=0 and t=8.4*10^-6) when the voltage needs to flip from high to low, or the reverse.
Basically, I have a giant CSV from the python script that I have read into Mathematica as a list of values. At t=0, the voltage will be at 5000, and it should flip between 5000 and 0 at each time value in the list.
Is there a better way than using Python to construct a mile-long function using Piecewise that lists all the intervals where it should be on high voltage? Is there a way to make it periodic, so that repeats on modulo (2*Last[b] - Part[b,-2])?
Finally, is there a way to have Mathematica try to calculate the Fourier transform of this ugly piecewise function so that I can more easily port it into MATLAB for use with the function generator?
Somewhat terrible drawing of this graph (black is my values, red line is where it should become periodic):
How I'm importing:
b = Import["C:\\Users\\user\\Desktop\\calculations\\swaptimes.txt", "List"]