Running a matlab function with python
13 views (last 30 days)
Dear all, I am executing a Matlab function that I have created from python by means of the Matlab engine, however I get the following error:Integers can only be raised to positive integral powers. Running the function from Matlab does not give any problem, therefore I do not understand what is wrong when I do it from python. Do you have any idea of the cause of this problem? Thanks.
Bo Li on 25 Apr 2016
Not sure what exact MATLAB function you are calling from Python, but it looks like that you are passing a Python integer to MATLAB while the MATLAB function expects a non-integer as input.
For example, following function call in Python gives you error "Undefined function 'sqrt' for input arguments of type 'int64'.":
The reason is that Python integer is converted into MATLAB int64, but "sqrt" does not work with int64. However, "sqrt(4)" works in MATLAB because by default the type of a number is double in MATLAB. You could see the same error if you run "sqrt(int64(4))" in MATLAB.
More related info: