首页 > 解决方案 > 将数组值从 Python 传递到 Matlab

问题描述

所以我想用python调用一个matlab函数。python代码如下:

import matlab.engine
eng = matlab.engine.start_matlab()
gt_data=[(22.304667, 114.180459, 13, 0, 0, 0)]
eng.GNSS_RUMS_main_ver1_SUMO(gt_data)

python脚本已启动,但有时我收到以下错误:

Error using GNSS_RUMS_main_ver1_SUMO (line 79)
An UndefinedFunction error was thrown on the workers for 'times'.  This might be because the file containing 'times' is not accessible on the workers. Use addAttachedFiles(pool, files) to specify the required files to be attached.  For more information, see the documentation for 'parallel.Pool/addAttachedFiles'.

Caused by:
    Undefined function 'times' for input arguments of type 'cell'.

请注意:matlab中gt_data的结构如下:

gt_data{1}= [22.304667 114.180459 13 0 0 0];

从 matlab 运行时,脚本运行良好。

标签: pythonmatlab

解决方案


推荐阅读