I have a python code within which I want to manipulate a list using a Matlab function and return it as a new list to python.
To test matlab.engine
, I've tried the following:
import matlab.engine
eng = matlab.engine.start_matlab()
eng.cd('~/Documents/someDirWithMatlabFunctions/')
a = testFnc(2)
where testFnc.m
looks like
function [list2] = testFnc(list)
for i = 1:numel(list)
list(i) = 3*list(i)
end
list2 = list;
end
When I run the python code, I get the following output:
>>> a = eng.testFnc(4)
>>> a
12L
>>> print a
12
My first question is what is 12L
? Furthermore, when I try to pass a list as an argument:
>>> a = eng.testFnc([1,2,3])
Undefined function 'mtimes' for input arguments of type 'cell'.
It then references the line of the Matlab function in which the multiplication takes place, as where the error occurs. I had anticipated that this might be a problem, as lists and matrices are different things. How can I properly pass variables to and from Matlab?