I use this command from the Mathematica documentation center

Export["1.mat", {"t" -> {{1,2,3}},"u" -> {{4,5,6}}}, "LabeledData"]

to save data as mat file with two variables t and u, and it does not work. The file is empty! The command Export["1.mat",{{1,2,3}}] works fine. How to solve this problem? I'd like to save in single file plenty variables. I am using Mathematica 7.

  • $\begingroup$ With version 9 it works correctly. I cannot test with version 7. $\endgroup$
    – Szabolcs
    Commented Apr 8, 2013 at 18:33
  • $\begingroup$ If you don't have access to any more recent versions of Mathematica, and v7 won't export correctly, you can try using some Mathematica-MATLAB interface (e.g. here) to transfer the data. $\endgroup$
    – Szabolcs
    Commented Apr 8, 2013 at 18:36
  • $\begingroup$ Thank you, I'll try to install M9. $\endgroup$
    – nail
    Commented Apr 8, 2013 at 18:51

1 Answer 1


I think you can only export data in the form of matrices in version 7. If you want to store multiple pieces of data x and y, you can do something like this:

x = {1, 2, 3};
y = {4, 5, 6, 7, 8};
z = PadRight[{x, y}];
Export["testz.mat", z]

In Matlab, you will have one thing, called "Expression1" that consists of the matrix z. You will have to unpack it yourself over in Matlab to use x and y separately again.

  • $\begingroup$ Are you a MATLAB user too? $\endgroup$
    – Szabolcs
    Commented Apr 8, 2013 at 18:52
  • $\begingroup$ Matlab is my native tongue... $\endgroup$
    – bill s
    Commented Apr 8, 2013 at 19:02
  • $\begingroup$ Szabolcs -- I just saw your post about mEngine mathematica.stackexchange.com/questions/10231/… -- I had no idea that such a thing existed. It sounds like a great resource... $\endgroup$
    – bill s
    Commented Apr 8, 2013 at 19:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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