So the objective here is to generate sequential data from a mathematical function - a sine wave is used in this post. Also, the goal is to use Python to do this. We are going to sample a sine wave at a pre-defined interval and dump it to a file for future use in other Python scripts.
Starting with the imports:
We will use these modules to get our work done.
Next, we set our range for the x-axis and define our functions.
This will generate two lists
y with our x-axis and y-axis data.
We'll now dump the y-axis data into our file for future use.
The above snippet writes the data of
y into a file named sinedata.md. Pickle is specific to Python and it can be used to load the data into another Python script later.
Next, we will visualize the data. Here is the code to do this:
I think the comments in the snippet do a good job at the explanation. The plot will look something like this: