从python将枚举数据传递给MATLAB

时间:2020-04-17 20:09:14

标签: python matlab

我试图从我的python脚本调用MATLAB函数,并且其中一个matlab脚本采用enum参数。

++++++++ MATLAB端++++++++++++++

枚举定义

classdef eCharCents
    enumeration
        vQs1,vQv1,vQs2,vQv2     
    end 
end

这就是我运行MATLAB函数的方式

testFunction(eCharCents.vQv2)

++++++++等效于Python ++++++++++++++

这就是我

import matlab.engine as MAT_ENG
from enum import Enum

class eCharCents(Enum):
     vQs1,vQv1,vQs2,vQv2 = range(0,4)  # I had to add range here as python needs data and value

print(eCharCents.vQs1)    # this outputs eCharCents.vQs1 

eng = MAT_ENG.start_matlab()
eng.testFunction(eCharCents.vQv2)   #  throws an error saying unsupported Data type

请告诉我是否有任何解决方法/评论/建议

MATLAB文档未指定有关ENUM的任何内容

https://www.mathworks.com/help/matlab/matlab_external/pass-data-to-matlab-from-python.html#bui0jkn

0 个答案:

没有答案