Closed kupiqu closed 5 years ago
the message from matlab is quite weird, I guess something is not parsed properly:
sending msg:
{"identifier":"MATLAB:m_invalid_lhs_of_assignment","message":"Error: Incorrect use of '=' operator. To assign a value to a variable, use '='. To compare values for equality, use '=='.","stack":{"file":"\/home\/miniconda\/envs\/cenv1\/lib\/python3.7\/site-packages\/transplant\/transplant_remote.m","name":"transplant_remote","line":129},"type":"error"}
msg sent.
eval
in Matlab has strange semantics, in that it errors if you try to assign its result. What you are seeing is the same thing you would see if you typed y = eval("x = 1:100")
in Matlab. A more correct approach would use matlab.eval("x=1:100", nargout=0)
, but this fails as well, because this eval
tries to assign a variable inside Transplant, which it is not allowed to.
In general, if you want to eval some code, use evalin("base", "...")
instead, which works, and does what you want to do.
Also, is there any other way (than with eval) to pass a vector such as
1:100
to matlab in matlab notation?
In general, I would advise you to read the documentation of Transplant. It says right there that you need to use Numpy in Python to create the equivalent of Matlab double arrays. So, use the appropriate Numpy function, i.e. numpy.arange(1, 101)
.
I knew about that (numpy.arange), I was asking about matlab notation specifically. Thanks for the info about evalin...
Somehow I thought that matlab.
instructions were parsed directly to be interpreted only in Matlab, which would be powerful, but it doesn't seem to be the case, perhaps because it's not easy to "hide" those from the python interpreter.
Thanks.
matlab.eval("x=1:100")
fails:Also, is there any other way (than with eval) to pass a vector such as
1:100
to matlab in matlab notation?