Hi guys,
I'm trying to write matlab binary MAT files from Perl.
Does anyone have a working routine/function that does that already?
I guess I'm not the first one trying to do this... but couldn't find a solution on this website or other pages.
I've been trying to follow this thread:
http://mathforum.org/kb/message.jspa?messageID=7738560
which basically works, but only for arrays that are shorter than 9 elements...
Arrays longer than that (in most cases) cannot be loaded correctly into matlab and produce the following error message:
> ??? Error using ==> load
> Unable to read MAT-file C:\tools\mat4.mat
>
> File may be corrupt.
For example:
This works fine:
> mat4_write('foo', 1, 9, (1,2,3,4,5,6,7,8,9), *MAT);
And this does not (generates the error message above when trying to load the file into matlab):
> mat4_write('foo', 1, 10, (1,2,3,4,5,6,7,8,9,10), *MAT);
I saw the mat4_write routine (from the link above) uses the 'pack' function in this way:
print ($h pack ('l5Z*d*', $type, $m, $n, $imag, $len, $name, @a));
I also noticed that the mat file created is very close to the needed format, but not identical...
And by comparing the created file to a similar file created from matlab (with same data, for a reference) I saw they differ in 1 additional byte...
I have never used the 'pack' function, and the help from the link below is hard to follow:
http://perldoc.perl.org/functions/pack.html
I couldn't find a match there for the 'l5Z*d*' format the routine above uses...
Can someone please help me with that...?
Does anyone have a working conversion function?
Please help!
Thanks,
Koby