January 10th, 2013, 03:17 AM

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
January 10th, 2013, 05:47 AM

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
January 16th, 2013, 04:37 AM

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
January 16th, 2013, 09:59 AM

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
[code]
Code tags[/code] are essential for python code and Makefiles!
January 29th, 2013, 10:50 PM

Is there a relationship between x in sine(x) and time?
Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25