Access .mat file containing matlab classes in python

依然范特西╮ 提交于 2019-11-27 15:31:54

Unfortunately, SciPy does not support mat files that contain new-style class objects (those defined with classdef), nor does any third-party mat-file reader as far as I'm aware. That __function_workspace__ element in the returned mat dictionary contains the information you're after in some undocumented and as-yet-not-reverse-engineered way.

The easiest solution is to convert your custom classes into basic struct objects within Matlab before saving them to disk. This can be achieved (albeit with a warning) by simply calling struct(futureDS). It exposes all public and private properties as plain fields, which can be read by any third-party reader worth its salt.

(More technically, Matlab saves these objects with the Matlab Array type id of 17; the official documentation (PDF) only enumerates types up through 15).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!