我正在使用 oct2py 用 python 运行 octave 函数。它正在工作,但是当我尝试将 2 矩阵相乘时出现错误。我能做些什么来解决这个问题?
这是一个示例 matlab 函数
%% MATLAB
function lol = jk2(arg1,arg2)
arg1 = arg1;
arg2 = arg2;
lol = arg1*arg2;
end
这是调用函数的代码
import oct2py
from oct2py import octave
a=3
b=4
octave.call("/MATLAB/jk2.m",a,b) # this call works
a=np.array([[1,2],[3,4]])
b=np.array([[5,6],[1,2]])
octave.call("/MATLAB/jk2.m",a,b) # this call report an errors
这是错误信息
>>> octave.call("/home/donbeo/Documents/MATLAB/jk2.m",a,b)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/oct2py-1.2.0-py2.7.egg/oct2py/session.py", line 210, in call
resp = self._eval(cmd, verbose=verbose)
File "/usr/local/lib/python2.7/dist-packages/oct2py-1.2.0-py2.7.egg/oct2py/session.py", line 350, in _eval
return self._session.evaluate(cmds, verbose, log, self.logger)
File "/usr/local/lib/python2.7/dist-packages/oct2py-1.2.0-py2.7.egg/oct2py/session.py", line 523, in evaluate
raise Oct2PyError(msg)
oct2py.utils.Oct2PyError: Oct2Py tried to run:
"""
[a__] = jk2(A__, B__)
"""
Octave returned:
binary operator '*' not implemented for 'int64 matrix' by 'int64 matrix' operations
>>>