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

Zachary Pincus zachary.pincus@yale....
Mon Jul 28 22:04:24 CDT 2008


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:

 >>> import scipy.io
 >>> scipy.io.savemat('works.mat', {'abcde':1}, format='5')
 >>> scipy.io.savemat('fails.mat', {'abcd':1}, format='5')

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


More information about the SciPy-user mailing list