python中使用mat,在Python中使用loadmat加载.mat和.m文件

  • Post author:
  • Post category:python


I am currently taking a Neural Network course, and I am trying to load a .mat file from Python using scipy.io.loadmat(filename), but I keep getting the following error message:

ValueError: Unknown mat file type, version 101, 58

The same message occured when I tried loading a .m file, rather than .mat file, using scipy.io.loadmat().

I don’t know how to resolve this issue, so I would really appreciate if someone on here could help me out.

解决方案

(converting my comments into an answer)

A .m file is a matlab / octave script. You don’t “load” a script. Not even in matlab / octave. You can only run it, and this may or may not result in a particular workspace that you can then save into a .mat file.

There are “matlab interfaces” for python that you could use to run an .m file from within a python session, e.g. the official MATLAB