Import symbolic variables from Matlab with MATLink

I'm trying to manipulate with Mathematica symbolic expression created in Matlab. I'm using the MATLink package, and I've succedeed in importing numerical variables, but not symbolic ones :

MEvaluate["syms g real"]
MEvaluate["syms l real"]
MEvaluate["u = g + l"]
MGet["u"]


will output :

u =
g + l % Matlab correctly defines the variable
{}    % Mathematica doesn t succeed in getting the variable


Anyone with experience in dealing with this ?

-
MATLAB/Mupad's symbolic variables are not supported in MATLink. If you want to use symbolic variables, then why not do it in Mathematica itself? It's much more powerful... –  The Toad Oct 24 '13 at 16:12
As rm said, symbolic variables are not supported in MATLink. But MGet["u"] should return \$Failed here and not {}. What operating system are you using? –  Szabolcs Oct 24 '13 at 19:27
I'm using Windows 7. Is there another package that could do the trick, or is doing all the work with Mathematica the only way ? Thanks a lot for your help ! –  user10179 Oct 24 '13 at 21:24
I am not aware of any package that can do this. –  Szabolcs Oct 25 '13 at 2:50
@user10179 Matlab is just the wrong tool for symbolic stuff (I am very tempted to widely generalize here), so the sooner you realize that the more productive you will be. –  Leonid Shifrin Oct 25 '13 at 11:33

MATLink does not support transferring symbolic variables. If you need to do symbolic calculations I would recommend using Mathematica for them. Is there a symbolic computation you cannot easily do in Mathematica that you can do with MATLAB?

If you still want to transfer symbolic expressions between the systems, you can convert them to a string, then try to parse the string in Mathematica. This will require some additional effort except in the simplest of cases when the syntaxes between the two systems are close enough.

In[1]:= << MATLink

In[2]:= OpenMATLAB[]

In[3]:= MEvaluate["
syms g l real
u=g+l"]

Out[3]= ">>
u =

g + l

"

In[4]:= MEvaluate["char(u)"]

Out[4]= ">>
ans =

g + l

"

In[5]:= MGet["ans"]

Out[5]= "g + l"

In[6]:= ToExpression[%]

Out[6]= g + l
`
-