1
$\begingroup$

This question already has an answer here:

I have just completed setup of MATLink for Windows to use with Mathematica 11.1 Student Edition with MATLAB R2017b (not student edition). I have confirmed both are 64 bit mode. I have followed the linking procedures and the troubleshooting procedures. I have registered MATLAB as a COM server.

In Mathematica I run:

Needs["MATLink`"]
OpenMATLAB[]

and get no errors, hangs or anything else concerning.

Afterward, I have a process "mengine.exe" running according to Task Manager.

Despite this, creating a test variable in MATLAB:

x = 1.0;

And attempting to retrieve its value in Mathematica as such:

MGet["x"]

returns

$Failed

and nothing else. I have checked and double checked my path variable, restarted each program several times etc, but to no avail. Looking for any help or anyone with similar experience that can help resolve this.

Interestingly, when I try another test in Mathematica:

MEvaluate["mat = magic(4)"]

Mathematica returns:

mat =

16     2     3    13
 5    11    10     8
 9     7     6    12
 4    14    15     1

And I do not have any new variables in my MATLAB workspace.

$\endgroup$

marked as duplicate by Szabolcs, Henrik Schumacher, Coolwater, Sektor, Community Jan 14 '18 at 15:16

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ What exactly do you mean by "creating a test variable in MATLAB"? If you type that into a separate MATLAB window that you started manually, that is an entirely isolated session that is not connected to Mathematica. MATLink starts up its own private copy of MATLAB. Use MEvaluate["x=1.0"], then MGet["x"]. $\endgroup$ – Szabolcs Jan 14 '18 at 9:12
  • $\begingroup$ @Szabolcs I knew you would be able to provide a more competent answer =o) $\endgroup$ – Henrik Schumacher Jan 14 '18 at 9:59
  • $\begingroup$ I'll mark the possible duplicate as the answer. I misunderstood the core functionality of MATLink - that unless you set it up as an automation server on windows you cannot actually share the workspace of an existing MATLAB session. Thanks everyone. I did not find that question when searching to solve my problem initially. $\endgroup$ – Tyler Morrison Jan 14 '18 at 15:16

Browse other questions tagged or ask your own question.