### Thread: Sine wave plotted in file

1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Nov 2012
Posts
6
Rep Power
0

#### Sine wave plotted in file

represent a sine
wave with a period of 20ms.

this has to be representet in numbers, plottet into a file, and it has to be in a function sine(), but most of all i need help how to generate the numbers for the sine signal? :P
2. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Nov 2012
Posts
6
Rep Power
0
very simplistically:

Code:
```#vary parameters to get the amplitude/wavelength you want.
import math
plotend=2*math.pi
l=[]
x=0
while x<plotend:
l.append(math.sin(x))
x+=0.01
#print l to file```
3. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Nov 2012
Posts
6
Rep Power
0
Originally Posted by verstapp
very simplistically:

Code:
```#vary parameters to get the amplitude/wavelength you want.
import math
plotend=2*math.pi
l=[]
x=0
while x<plotend:
l.append(math.sin(x))
x+=0.01
#print l to file```
it somewhat helps, but i cant really figure out how to implement it, i want to be able to yield one number at the time and plot it into a file, where every line in the file is a ms in time
4. You could replace
l.append(math.sin(x))
with
print(math.sin(x))
or even
print('%g %g'%(x,math.sin(x)))

then run python on the command line redirect stdout to a file. Yes, it ought to work in DOS.

shell_prompt> python my_program.py > sinusoid.dat
5. Is there a relationship between x in sine(x) and time?