【发布时间】:2017-01-16 00:51:38
【问题描述】:
我有一个.mat 文件,我使用scipy 加载:
from oct2py import octave
import scipy.io as spio
matPath = "path/to/file.mat"
matFile = spio.loadmat(matPath)
我得到一个 numpy 数组,我想使用 oct2py 将其传递给 octave 函数,如下所示:
aMatStruct = matFile["aMatStruct"]
result = octave.aMatFunction(aMatStruct)
但我收到以下错误:
oct2py.utils.Oct2PyError: Datatype not supported
似乎是由于数组dtype,看起来像:[('x', 'O'), ('y', 'O'), ('z', 'O')]
所以我考虑将其更改为 'S'、'U' 或受支持的内容。
- 怎么做?
- 我在otc2py documentation 中找不到受支持的数据类型。有什么帮助吗?
- 有没有办法用另一个(支持的)dtype 加载
.mat文件?我查看了here,但找不到任何有用的东西。
请注意,在 aMatFunction 内部,它使用 aMatStruct 就像这样:x = aMatStruct.x。
【问题讨论】:
-
你能上传一份你的matfile的副本并指定失败的确切八度函数吗?
-
“O”表示“对象”。该数组有 3 个字段。 matlab 源代码、单元格、结构上的 srray 是什么样的? oct 函数期望什么?
标签: python numpy scipy octave oct2py