从Oct2Py返回类对象

问题描述

我正在尝试运行定义一个类的基本MATLAB脚本,并将该类对象返回给python。我不太了解MATLAB,并且对Oct2Py还是很陌生,所以我可能完全误解了如何执行此操作。任何帮助将不胜感激。

这是Matlab文件(取自here

classdef Basicclass
   properties
      Value {mustBeNumeric}
   end
   methods
      function r = roundOff(obj)
         r = round([obj.Value],2);
      end
      function r = multiplyBy(obj,n)
         r = [obj.Value] * n;
      end
   end
end

然后我在python脚本中用以下代码调用

from oct2py import octave
octave.addpath(r'C:\Users\i13500020\.spyder-py3\IST')
oclass = octave.class_example(nout=1)

运行此命令时,我会得到警告,打印四次,然后显示错误消息

第一:

warning: struct: converting a classdef object into a struct overrides the access restrictions defined for properties. All properties are returned,including private and protected ones.

然后:

TypeError: 'nonetype' object is not iterable

从Oct2Py页面运行roundtrip example没有任何麻烦,所以我知道我的安装很好

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)