Ask Your Question
0

How to output data to a file

asked 2013-01-11 11:52:02 +0100

gjm gravatar image

updated 2013-01-11 13:52:28 +0100

calc314 gravatar image

Here is my code that graphs a function:

z1=2*pi*650*10^6

p1=2*pi*1.95*10^9

p2=2*pi*5*10^9

adc=.667

deltaF=.1*10^9

N=(adc*p1*p2)/z1

M(freq)=(2*i*pi*freq+z1)/((2*i*pi*freq+p1)*(2*i*pi*freq+p2))

Z=abs(N*M(freq))

g(freq)=20*log(Z,10)

pts=[(freq,g(freq).n()) for freq in srange(10^8,10^11,deltaF)]

list_plot(pts, plotjoined=True, scale='semilogx', gridlines="minor", ymin=-25, ymax=5)

How do I output this data to a file so I can compare it to data generated by another piece of software?

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
1

answered 2013-01-11 13:06:06 +0100

achrzesz gravatar image

updated 2013-01-11 14:38:18 +0100

edit flag offensive delete link more
0

answered 2013-01-11 14:18:16 +0100

gjm gravatar image

I actually want to output just the x and y axis data. The provided link does not appear to provide me with this function.

edit flag offensive delete link more

Comments

1

The second link from the answer provides you with this function

achrzesz gravatar imageachrzesz ( 2013-01-12 04:08:01 +0100 )edit
0

answered 2013-01-15 06:13:10 +0100

twch gravatar image

If I understood you right you just want to plot the data contained in your list pts.

This can for example be done with the python csv module:

plotlist=[(1,2),(3,4),(6,10)]
import csv
csvfile = open('/path/to/file/plotlist.csv', 'wb')
csvwriter = csv.writer(csvfile, delimiter=';')
for xy in plotlist:
    csvwriter.writerow([xy[0],xy[1]])
csvfile.close()

You can then open the csv file for example with open office calc...

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-01-11 11:52:02 +0100

Seen: 3,266 times

Last updated: Jan 15 '13