You want to say that you need each data point in its own row?
48.9013471471 48.6057858287 48.1145061659 47.4294863684
If so, then you might like to try something like this:
for i in drange2(0, 2*math.pi + 0.0634665182543392 , 0.0634665182543392): for x in range(1,N+1): yEst = yEst + a * cos(x* i) f.write( str(yEst) + "\n" ) f.close()
First, to write each data point in a row, it must be "inside" the loop - so I added extra space to the row before I f.write .
The second thing I added is + "\n" - this will add a new line character to the end of the line. You can change it to whatever you want! A few examples:
f.write( str(yEst) + " " ) will add one place after each data point:
48.9013471471 48.6057858287 48.1145061659 47.4294863684
f.write( str(yEst) + "|" ) will add one channel character after each data point:
48.9013471471|48.6057858287|48.1145061659|47.4294863684|
If, on the other hand, you prefer to just save the data as an array, try the following:
yEst = 0 # or some initial value yEstArray = [] for i in drange2(0, 2*math.pi + 0.0634665182543392 , 0.0634665182543392): for x in range(1,N+1): yEst = yEst + a * cos(x* i) yEstArray.append(yEst)
Then you can iterate over the array this way:
for yEst in yEstArray: do something with yEst
or
for yEst, index in enumerate(yEstArray): do something with yEst and its index