Let's say I have a function W[x_]; and would like to export the data for xrange -100 to 100

I have tried this

Result=W[#] & /@Range[-100,100];
Export = ["result,txt",Result,"List"]

Eg: The output I get:


But I would like to save the x_ values as the first column and w[x_] as the second column

 x_      w[x_]
 -100      -1.0
 -99       -1.5
 -98       -2.0
 ...        ....
 100       5.0

How does one print x_ values too ?


1 Answer 1


Using your code in Export data from NIntegrate and Piecewise this is how to do it

 data = {#, W[#]} & /@ Range[-2, 2]

Mathematica graphics

Now save it using the same commands in the above answer

Export["result.txt", data, "List"]

Change the Range command above to whatever you want.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.