0
$\begingroup$

I want to export the following matrix,

MatrixForm[Flatten /@Table[{f[a, b, c], a, b, c}, {a, 0, 2}, {b, 0, 2}, {c, 0, 2}]]

is there any way to export the first four columns and the next four columns below to the first exported columns?

So the one exported file (.dat or .txt) contains only 4 columns with many rows.

something like,

f[0,0,0] 0 0 0
f[1,0,0] 1 0 0
f[2,0,0] 2 0 0
f[0,0,1] 0 0 1
f[1,0,0] 1 0 1
f[2,0,1] 2 0 1
.
.
.
.
.
.
$\endgroup$
3
  • $\begingroup$ Use Transpose and remove MatrixForm. $\endgroup$ – Henrik Schumacher Jul 23 '20 at 10:21
  • $\begingroup$ Then Export["file.txt", matrix, "List"] should do the trick. $\endgroup$ – Henrik Schumacher Jul 23 '20 at 10:23
  • $\begingroup$ @HenrikSchumacher no, it didn't work. $\endgroup$ – Muhammad Ali Jul 23 '20 at 11:11
2
$\begingroup$
Export[
 "file.txt",
 Flatten[Transpose[
   Table[{f[a, b, c], a, b, c}, {a, 0, 2}, {b, 0, 2}, {c, 0, 2}], {3, 
    1, 2}], 2],
 "Table"
 ]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.