I am importing a matlab file using scipy.io, and trying to find its dimensions. It seems, even though the file is getting loaded into python, it's not able to give the dimensions. Why is that? And how to fix this?
>>> import scipy.io
>>> pref_mat = scipy.io.loadmat('pref_mat_loc.mat')
>>> R=pref_mat
>>> import numpy
>>> R=numpy.array(R)
>>> len(R)
0
>>> R # We see that the first line of the file is getting printed, means the file has been loaded.
array({'pref_mat': array([[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
...,
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0]], dtype=uint16), '__header__': b'MATLAB 5.0 MAT-file, Platform: PCWIN64, Created on: Mon May 08 23:42:05 2017', '__version__': '1.0', '__globals__': []}, dtype=object)
>>> len(R.shape) # But it appears here as though R is empty
0
>>> R.shape # As does here
()
len(R.shape)is the same asR.ndimfor future reference.R=pref_mat? Why not justR = scipy.io.loadmat(...)?R=numpy.array(R)? Do you understand whatloadmatreturns?loadmatloads the matlab file; I don't know what it returns though. Is it a dictionary?