Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question
    
With version 9 it works correctly. I cannot test with version 7. –  Szabolcs Apr 8 '13 at 18:33
    
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. –  Szabolcs Apr 8 '13 at 18:36
    
Thank you, I'll try to install M9. –  nail Apr 8 '13 at 18:51
add comment

1 Answer

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.

share|improve this answer
    
Are you a MATLAB user too? –  Szabolcs Apr 8 '13 at 18:52
    
Matlab is my native tongue... –  bill s Apr 8 '13 at 19:02
    
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... –  bill s Apr 8 '13 at 19:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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