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
Click For Summary

Discussion Overview

The discussion revolves around the process of exporting multiple variables from Mathematica to MATLAB, specifically focusing on exporting two matrices simultaneously and directly into MATLAB's workspace. The context includes practical application and user experiences with the export process.

Discussion Character

  • Exploratory, Technical explanation, Homework-related

Main Points Raised

  • One participant shares their method for exporting a single matrix from Mathematica and seeks advice on exporting two matrices at once.
  • Another participant suggests checking official resources from MATLAB and Mathematica for guidance.
  • A different participant mentions they found a solution through Mathematica's documentation, indicating they were able to resolve their issue.
  • One participant expresses difficulty finding relevant references and recommends RosettaCode.org for comparing solutions between Mathematica and MATLAB.
  • Additional resources are shared, including a conversion tool and commentary on the limitations of the ToMatlab() tool for complex code.

Areas of Agreement / Disagreement

Participants do not appear to reach a consensus on the best method for exporting variables, with some suggesting different resources and approaches. The discussion remains unresolved regarding the optimal solution for the export process.

Contextual Notes

Limitations include potential gaps in the resources referenced, the effectiveness of the suggested tools, and the varying complexity of code that may affect the export process.

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
3
Views
3K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 7 ·
Replies
7
Views
8K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 4 ·
Replies
4
Views
12K