the code is like
nwwa = List["#w#"]; nkka = List["#ks#"];For[j = -4, j <= 4, j++,w = 16*(0.5 + 0.1*j);nwwa = Append[nwwa, w];//calculate ksnkka = Append[nkka, ks];]Export["mathematica1.dat",Transpose[{OutputForm[NumberForm[nwwa, {3, 1}]],OutputForm[NumberForm[nkka, 6]]}], "Table"];
But I got the error:
"The first two levels of {{"#w#", 1.6, 3.2, 4.8, 6.4, 8., 9.6, 11.2, 12.8, 14.4}, {"#ks#", 0.28995, 0.1955, 0.14515, 0.1159, 0.09655, 0.0828, 0.07255, 0.0646, 0.05815}}cannot be transposed".
the numbers are the values of nwwa and nkka.
If I just use
Export["mathematica1.dat",Transpose[{nwwa,nkka}], "Table"];
it works. but in the output file the values are like
3.200000000000003 0.19549999999999998
not what I want
3.2 0.1955
any tips?
Best Answer
The output formatting needs to be mapped over the results.
Export["mathematica1.dat",Transpose[{Map[OutputForm[NumberForm[#, {3, 1}]] &, nwwa],Map[OutputForm[NumberForm[#, 6]] &, nkka]}], "Table"];