[SciPy-user] Matlab IO -- can others with matlab test this bug?

Jonathan Hunt jjh@42quarks....
Mon Jul 28 22:43:41 CDT 2008

Which version of SciPy are you using? I have 0.6.0 and MATLAB (R2008a).

>> import scipy.io
>> scipy.io.savemat('works.mat', {'abcde':1}) # My version of SciPy doesn't support a format argument
>> scipy.io.savemat('fails.mat', {'abcd':1})

works fine.

Hope this helps.

On Tue, Jul 29, 2008 at 1:04 PM, Zachary Pincus <zachary.pincus@yale.edu> wrote:
> Hi,
> I have found that scipy's .mat-file IO creates version-5 files that
> cannot be read by the version of matlab I have access to, if a
> variable with less than five letters in the name is saved to that file.
> The version of matlab I have is (R13). Here's an example
> to show the issue:
> python:
>  >>> import scipy.io
>  >>> scipy.io.savemat('works.mat', {'abcde':1}, format='5')
>  >>> scipy.io.savemat('fails.mat', {'abcd':1}, format='5')
> matlab:
>  >> load works
>  >> load fails
> ??? Error using ==> load
> Can't read file.
> Could others please test this code out with the version(s) of Matlab
> that they have access to?
> The issue is that it appears that (at least my version of) matlab
> assumes that for variables with <= 4-byte names, the "compressed data
> element" format will be used in the file. Scipy.io.savemat does not do
> this... However, the mat-file specification clearly states that this
> format is *optional*, and so the scipy routines are technically
> correct -- this is a matlab bug.
> If this bug with matlab's file IO is widespread, I will make a patch
> for scipy so that short elements are written in the compressed format;
> otherwise I'll just work around the issue by ensuring that I never use
> any short names.
> I would be very grateful if others would test this.
> Zach
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user

Jonathan J Hunt <jjh@42quarks.com>
Homepage: http://www.42quarks.net.nz/wiki/JJH
(Further contact details there)
"Physics isn't the most important thing. Love is." Richard Feynman

More information about the SciPy-user mailing list