[Date Index]
[Thread Index]
[Author Index]
Re: Saving file problem
*To*: mathgroup at smc.vnet.net
*Subject*: [mg54579] Re: Saving file problem
*From*: Bill Rowe <readnewsciv at earthlink.net>
*Date*: Wed, 23 Feb 2005 03:11:59 -0500 (EST)
*Sender*: owner-wri-mathgroup at wolfram.com
On 2/22/05 at 4:23 AM, nilaakash at gmail.com (nilaakash) wrote:
>Here I want to save my file in the following way
>\!\(For[i = 1, i ≤ 5, t = Table[{i, x, Sin[
> x\^i]}, {x, \(-2\) π,
> 2 π}]; \[IndentingNewLine]Export["\<tmp.txt\>",
> t, "\<Table\>"]; \(i++\)]\)
>But it prints only the last value of i.
Right. Export over writes any existing file. So, by including the Export inside the For loop, the only value that can appear in the output file is with the last value of i since all previous output will have been over written.
>Please could you tell me how to save all the i values.
Create the complete table then write it to a file.
The code you posted is nearly incomprehensible. So, I cannot determine exactly what you are attempting to do. But I doubt you need a For loop. For example,
Export["tmp.txt",
Table[{n, x, Sin[x^n]}, {n,5},{x, -2 Pi, 2 Pi, Pi/4}]//N,
"Table"]
will output all of the values.
If you need separate files, you could do something like
For[n = 1, n < 6,
Export["tmp"<>ToString@n<>".txt",
Table[{n, x, Sin[x^n]},{x, -2 Pi, 2 Pi, Pi/4}]//N,
"Table"];
n++]
--
To reply via email subtract one hundred and four
Prev by Date:
**Re: pattern matching all list elements but last**
Next by Date:
**Re: pattern matching all list elements but last**
Previous by thread:
**Saving file problem**
Next by thread:
**Saving file problem**
| |