【发布时间】:2019-08-12 14:58:23
【问题描述】:
我正在制作一个调用 matlab 函数的软件,我想在 python 中使用 matlab.engine 将 dict 作为参数传递给 matlab 函数。
像这样:
def Parametrize(confFile):
""" Return
Argument:
confFile -- str() Configuration File path
Function that call MatLab function passing handles structure/dict as
argument. The return value of MatLab function called Parametrize(handles)
is the modified handles structure.
"""
print("ouai")
test = dict()
keys = range(4)
values = ["Hi", "I", "am", "John"]
for i in keys:
test[str(i)] = values[i]
eng = matlab.engine.start_matlab()
eng.addpath(vssFolderPath)
res = eng.Transit(test)
print(type(res))
print(res)
matlab 函数非常基本,我正在测试如何将数据从 Python 传递到 Matlab:
function a = Transit(test)
field = 'Value1';
value = {'TEST'};
disp(test)
a = struct(field,value);
我总是有这个错误:
ValueError: invalid field for MATLAB struct
但我读到了这个document,它解释了如何将数据从 python 传递到 matlab,但我不知道为什么它对我不起作用。
【问题讨论】:
标签: python matlab matlab-engine