I have a do-loop in which I use recursively a NMinimize process and gives a result of the form
in: Do[NMinimize[f[i,V0,rd,d,n],{V0,rd,d,n}], {i,1,3}]
out:{V0 -> 200.700, rd -> 7.68528, d -> 0.722816, n -> 1.0}
{V0 -> 202.828, rd -> 7.46368, d -> 0.255458, n -> 1.0}
{V0 -> 208.434, rd -> 7.46236, d -> 0.479465, n -> 1.0}
I want to store that same result in a .txt file for later use as replacement lists, say:
VELO[V0,rd,d,n]/.{V0 -> 200.700, rd -> 7.68528, d -> 0.722816, n -> 1.0};
VELO[V0,rd,d,n]/.{V0 -> 202.828, rd -> 7.46368, d -> 0.255458, n -> 1.0};
VELO[V0,rd,d,n]/.{V0 -> 208.434, rd -> 7.46236, d -> 0.479465, n -> 1.0};
where VELO[V0,rd,d,n]
is a function of the four parameters. I export the file as
Do[Write[bestfit, MINREDCHISQRAT[i][[2]]];
, {i, 1, 3}];
Close["bestfit.txt"]
]
When I attempt to do it, and later I import the .txt file
Import["C:\\Users\\psrot\\bestfit.txt", "Table"]
I get something like
{{{V0, ->, 200.7, rd, ->, 7.68528, d, ->,0.722816, n, ->, 1.0}},
{{V0, ->, 202.828, rd, ->, 7.46368, d, ->, 0.255458, n, ->, 1.0}}, {{V0, ->,
208.434, rd, ->, 7.46236, d, ->, 0.479465, n,
->, 1.0}}}
which I can't use as a replacement because of the COMMAS.
My question is: How can I save the replacement lists in such a way that when I import the .txt that contains them, I could use them to evaluate my function in a do-loop for each set of parameters?
PS: I put only 3 as the steps of the do-loop, in reality I have more than 1000 steps.
MINREDCHISQRAT[i][[2]]
for one of thei
s? $\endgroup$Import["C:\\Users\\psrot\\bestfit.txt", "Package"]
. $\endgroup$