[SciPy-user] loadmat behaviour

Matthew Brett matthew.brett at gmail.com
Tue Oct 17 12:10:47 CDT 2006


Hi,

> When I try to use io.loadmat it reads numbers as unsigned integers
>
> >>> ret=io.loadmat('datafile.mat')
> >>> ret['L1']
> array([        10, 4294966944,      97346], dtype=uint32)
>
>
> How can I do to read the original data type?

This is because matlab saves the data in that format.  You could try
this hardly documented feature:

import scipy.io as sio
MR = sio.MatFile5Reader(open('datafile.mat'), matlab_compatible=True)
ret = MR.get_variables()

Best,

Matthew


More information about the SciPy-user mailing list