MATLAB: How to communicate MATLAB with MUPAD

comunication matlab-mupad

Dear Collegues,
I am trying to use from MATLAB a program created in MUPAD. I've saved this program in one archive.mu and when I've tried to use from MATLAB by doing:
read(symengine,'MYPROGRAM.mu') eval(char(feval(symengine,'solvproblem',matrix,number)))
As you can see the input of my solvproblem is a matrix and a number, and I've already know that this problem works, because I run in MUPAD. My question is: How can be posible that with the same matrix and the same number solvproblem always works in MUPAD does not work when I call it in MATLAB?, because MATLAB told me:
MuPAD error: Error: Column index out of range. [(Dom::Matrix(Dom::ExpressionField()))::_index]
I hope you understand my problem, and thanks a lot for reading it¡
María.

Best Answer

Never eval() a symbolic expression. You can subs() the expression, and you can double() the result. eval() tries to use MATLAB syntax, but MuPAD syntax is not the same as MATLAB syntax.
I have never seen read() take a symengine argument, but it is possible I missed that. I would instead try
feval(symengine, 'read', 'MYPROGRAM.mu')