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

  • Context: MATLAB 
  • Thread starter Thread starter member 428835
  • Start date Start date
  • Tags Tags
    Mathematica Matlab
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 4K views
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.