As in the subject, ie. how to load given *.mat
file and convert it to numpy array? Say, I've got a matlab matrix:
X =
8 1 6
3 5 7
4 9 2
I saved it as data.mat
, and now I want to load it in my python script, where next I want to convert it to numpy array, so it will become:
np.array([[8, 1, 6], [3, 5, 7], [4, 9, 2]])
I know already, that I can use the scipy.io.loadmat()
function, but when I try to call it just like that:
mat = scipy.io.loadmat('data')
...I'm getting an error:
Traceback (most recent call last):
File "C:/Users/jsmith/PycharmProjects/MagicScript.py", line 4, in <module>
mat = si.loadmat('data')
File "C:\Users\jsmith\Anaconda3\lib\site-packages\scipy\io\matlab\mio.py", line 131, in loadmat
MR = mat_reader_factory(file_name, appendmat, **kwargs)
File "C:\Users\jsmith\Anaconda3\lib\site-packages\scipy\io\matlab\mio.py", line 55, in mat_reader_factory
mjv, mnv = get_matfile_version(byte_stream)
File "C:\Users\jsmith\Anaconda3\lib\site-packages\scipy\io\matlab\miobase.py", line 237, in get_matfile_version
% ret)
ValueError: Unknown mat file type, version 46, 51
Thank you in advance.