[SciPy-dev] Patch for writing Matlab structs with long field names

Matthew Brett matthew.brett at gmail.com
Sat Dec 6 13:05:31 EST 2008


Hi,

> The actual behaviour of the current version of Matlab is to both read
> and write fieldnames of up to 64 characters (63 characters + NUL).  We
> discovered this because we encountered some .mat files in the wild that
> broke our scipy scripts.

I assume that scipy can read these, but not write them - is that correct?

> It is possible that some previous Matlab version can only handle 32
> characters.  Even with the patch, this should not cause problems as long
> as the actual fieldnames your write are no longer than 32 characters.

Yes, but I don't know what the effect will be of writing out 63
character names for versions of matlab that don't accept this.  It may
just generate an invalid .mat file, and that will seem to people like
a bug in scipy - which it would be.

We could try passing the maximum number of characters as an option
somehow, or we can encode this variable with the matlab file format -
now just '4' or '5', but in due course maybe '6', '7.0', '7.1', and so
on.

Best,

Matthew



More information about the SciPy-Dev mailing list