Im trying to load a .mat file in python using:
Y = scipy.io.loadmat('XYZ.mat')
These are the keys of the dictionary created
dict_keys(['__header__', '__version__', '__globals__', 'X', 'Y'])
type(Y['X']) is
<class 'scipy.io.matlab.mio5_params.MatlabObject'>
Now, i want the contents of key X as a numpy array.
Y = np.array(Y['X'])
does not work. When i print Y, this is what i get:
array([[(array([[[........]]]), array([[ 5, 201, 61]], dtype=uint8))]],
dtype=[('data', 'O'), ('size', 'O')])
How do i access the elements of the array?
Y['X'][0]?numpystructured array is handled bysavemat/loadmat. At the MATLAB end it is imported asstruct. Inscipyis imported a structured array with object dtype fields.stackoverflow.com/questions/70963723/…