Formatted Output (Exporting Data)
- To: mathgroup at smc.vnet.net
- Subject: [mg64415] Formatted Output (Exporting Data)
- From: "tlhiv" <thenders at gmail.com>
- Date: Thu, 16 Feb 2006 03:05:24 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
I'm trying to export the data obtained by evaluating a function at certain points. The method that I'm currently using is: f[x_]:=x^2 Export["foo.d",Table[{x, f[x]}, {x, -1, 1, 0.2}], "Table"] This generates a file "foo.d" that look like: -1 1 -0.8 0.6400000000000001 -0.6 0.36 -0.39999999999999997 0.15999999999999998 -0.19999999999999996 0.03999999999999998 5.551115123125783e-17 3.0814879110195774e-33 0.20000000000000007 0.04000000000000003 0.4000000000000001 0.16000000000000006 0.6000000000000001 0.3600000000000001 0.8 0.6400000000000001 1. 1. I would very much like to have "foo.d" look like: -1 1 -0.8 0.64 -0.6 0.36 -0.4 0.16 -0.2 0.04 0 0 0.2 0.04 0.4 0.16 0.6 0.36 0.8 0.64 1 1 and with the delimeter being a TAB instead of a SPACE. In particular, the precision used above is not so good. I would like everything rounded off to, say, 6 significant digits. An analogous C style output would be something like fprintf(fid,"%6f\t%6f\n,x,f) and is performed for each "element" of x. Can this be accomplished easily with Mathematica? Thanks, Troy Henderson Assistant Professor Department of Mathematical Sciences 252 Thayer Hall United States Military Academy West Point, NY 10996 (845) 938-5649 http://www.tlhiv.org
- Follow-Ups:
- Re: Formatted Output (Exporting Data)
- From: Pratik Desai <pdesai1@umbc.edu>
- Re: Formatted Output (Exporting Data)