Exporting a matrix in Mathematica in curly brackets format

593 Views Asked by At

I am trying to export a matrix in a file using Mathematica. I get the matrix and then use

Export["myfile.dat", MyMatrix, "???Format???"]

There are many formats. I want the one that prints the matrix in this way:

{{0,1,0,....},{0,0,1,...},...}

That is the classic Mathematica format....

How can I do this? Which one is the correct format?

2

There are 2 best solutions below

0
On

Export["file.txt",MyMatrix,"String"] works in Mathematica 6

0
On

In really you can do this just with Put:

a = Table[RandomInteger[], {10}, {10}];
a >> "C:\\test.txt"