tags:

views:

88

answers:

1

It seems I can only load everything as uint8 type, just with the following two lines,

import scipy.io X1=scipy.io.loadmat('one.mat')

all double precision numbers get transformed. I believe the creators of scipy are aware of the fact that floating-point numbers are much more common...

So, what should I do? Thank you!

A: 

What level matfile are you trying to read? According to the docs,

v4 (Level 1.0), v6 and v7 to 7.2 matfiles are supported.

You will need an HDF5 python library to read matlab 7.3 format mat files. Because scipy does not supply one, we do not implement the HDF5 / 7.3 interface here.

For the supported levels, variables should be reloaded with the dtype with which they were saved; if you'd rather load them as matlab would, add mat_dtype=True at the end of the parameters with which you call loadmat.

Alex Martelli
Thanks! I saved data with the command: "save -v4 data" and now it works. I still wish you can implement the interface so scipy will become more powerful and convenient.
mayasky
If by "the interface" you mean HDF5, you can get one e.g from http://h5py.alfven.org/ -- as for why it's not seamlessly integrated in scipy yet, well, since scipy (like most open source) is all done by volunteers, what's missing is just somebody that cares enough about it to be willing to work to make it happen!-)
Alex Martelli