0
$\begingroup$

I'm running a code over different parameter values in mathematica using do loop. I want to open separate files for each parameter within the code itself using loop and write output corresponding to each parameter value into separate files. How can I do this?

$\endgroup$
5
  • $\begingroup$ Hi, welcome to Mathematica.SE. Where are you stuck? Notice that nothing even indicates that it is about Wolfram Mathematica. Please read asking guidelines $\endgroup$
    – Kuba
    Nov 28, 2018 at 9:07
  • $\begingroup$ When I use do loop for OpenWrite command as Do[OpenWrite["m.dat"]; Close[m], {m, 1, 2}]; It is giving error as 1 is not string $\endgroup$
    – HMB
    Nov 28, 2018 at 9:11
  • $\begingroup$ What is this code supposed to do? What do you mean by Close[1]? Please edit the question with the code. $\endgroup$
    – Kuba
    Nov 28, 2018 at 9:14
  • $\begingroup$ I want to do something like this Do[pth = OpenWrite["file_i.dat"]; Do [Write[pth, n^2], {n, {4, 5}}]; Close[pth], {i, 1, 2}] I want output corresponding to n=4 to be written in file named file_1.dat and output corresponding to n=2 in file_2.dat $\endgroup$
    – HMB
    Nov 28, 2018 at 9:23
  • 1
    $\begingroup$ StringJoin + ToString presented in linked topics is the way to go for you. Let me know if you disagree. $\endgroup$
    – Kuba
    Nov 28, 2018 at 9:33

0

Browse other questions tagged or ask your own question.