Read .mat files in Python

后端 未结 8 1730
时光说笑
时光说笑 2020-11-22 09:23

Is it possible to read binary MATLAB .mat files in Python?

I\'ve seen that SciPy has alleged support for reading .mat files, but I\'m unsuccessful with it. I install

8条回答
  •  迷失自我
    2020-11-22 09:45

    from os.path import dirname, join as pjoin
    import scipy.io as sio
    data_dir = pjoin(dirname(sio.__file__), 'matlab', 'tests', 'data')
    mat_fname = pjoin(data_dir, 'testdouble_7.4_GLNX86.mat')
    mat_contents = sio.loadmat(mat_fname)
    

    You can use above code to read the default saved .mat file in Python.

提交回复
热议问题