MATLAB Exporting Multiple Variables from Mathematica to MATLAB - Quick and Easy Guide

  • Thread starter Thread starter member 428835
  • Start date Start date
  • Tags Tags
    Mathematica Matlab
AI Thread Summary
To export two matrices, A and B, from Mathematica to MATLAB, the user initially succeeded with exporting one matrix using the command Export["data.mat", {A}]. The discussion highlights the need for exporting multiple variables simultaneously and directly into MATLAB's workspace without manual file uploads. Users suggested checking resources from MathWorks and provided a link to a relevant MathWorks page. The original poster later found a solution in Mathematica's documentation regarding the MAT format. Additional references were shared, including RosettaCode.org for comparing Mathematica and MATLAB solutions, and a conversion tool for code snippets. However, caution was advised as not all solutions are optimal or reliable, particularly for complex code.
member 428835
Hi PF!

I'm trying to export two matrices ##A## and ##B## from Mathematica into MATLAB. I can export one just fine; so far what I write is

Code:
SetDirectory[NotebookDirectory[]]
Export["data.mat", {A}]

Do you know how I can export two variables at a time and then how I can export directly into MATLAB's workspace rather than have to click on the .mat file and upload manually? I have a mac if that's relevant.

Thanks!
 
Physics news on Phys.org
I didn't find any reference to Mathematica at CodeProZone and the Matlab link had nothing posted either so its a no go.

RosettaCode.org is a better reference

https://rosettacode.org/wiki/Category:Mathematica

https://rosettacode.org/wiki/Category:MATLAB

Pick a solved task and then use the links to compare how it was solved using the selected language. From there you can piece together how to do your conversion.

NOTE: not all solutions are optimal or guaranteed to work.

I also found a conversion tool for snippets:

https://library.wolfram.com/infocenter/MathSource/577/

and here's some commentary on using the ToMatlab() tool:

https://comp.soft-sys.matlab.narkive.com/5KrdC51S/mathematica-to-matlab-file-conversion

which doesn't look promising for more complex code.
 

Similar threads

Replies
7
Views
8K
Replies
1
Views
3K
Replies
2
Views
2K
Replies
2
Views
4K
Replies
4
Views
11K
Back
Top