如何从matlab调用python类的“ku call_uu9()”方法

2020-11-25 09:45:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我和这样一个班一起工作:

class Select(object):       
    def __init__(self, interface):
        ...

    def project(self, ID):
        ...

    def __call__(self, datatype_or_path):
        ...

当我试图从Matlab调用此方法(基本上是函子)时,如:

^{pr2}$

我得到以下错误:

Array formation and parentheses-style indexing with objects of class
'py.pyxnat.core.select.Select' is not allowed.  Use objects of class
'py.pyxnat.core.select.Select' only as scalars or use a cell array.

编辑:

select.('__call__')('blah')似乎也不起作用

2条回答
网友
1楼 ·

显然,您在代码中使用的Select类是py.pyxnat.core.select.Select,而不是您自己的Select类。检查您的导入(特别是在导入您自己的Select类的行之后检查“starimport”-from xxx import *。在

网友
2楼 ·

来自Matlab技术支持:

My name is sai and I am writing in reference to your Technical Support Case #01708094 regarding 'Calling python functors through matlab'.

I understand that you are experiencing issues while invoking a functor defined in python from MATLAB.

I see that you are using MATLAB R2014b. Please note that this is a known issue in MATLAB R2014b which has been fixed in MATLAB R2015a and there are no known work arounds for this issue in R2014b. If it is feasible, I would recommend to upgrade to MATLAB R2015a which will help you resolve this issue.

相关问题