[SciPy-user] loadmat behaviour

Carlos Medrano ctmedra at unizar.es
Wed Oct 18 01:37:09 CDT 2006


Matthew Brett <matthew.brett <at> gmail.com> writes:

> 
> 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
> 

Hi

If I try your code I get the following error:
>>> import scipy.io as sio 
>>> MR = sio.MatFile5Reader(open('datafile_v7.mat'), matlab_compatible=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: 'module' object has no attribute 'MatFile5Reader'

Anyway, you give me a valuable information. If this is caused by the way matlab 
saves the data, this means I was not doing anything wrong. So perhaps the best 
way to solve this kind of problems is to use some other way of saving data in 
matlab (fprintf and friends).

Thank you 

Carlos Medrano





More information about the SciPy-user mailing list