in reply to Re^3: Write Matlab binary MAT-files from Perl (binmode)
in thread Write Matlab binary MAT-files from Perl
Thanks tye!
I saw the link, and tried to read it.
I admit it was quite intimidating at first, but actually quite simple!
Thank you very much!
The script works now!
You've helped me a lot!
For others who might find this thread and need this MAT saving routine from Perl,
below you can see the modified function.
Works perfectly now (with binmode activated)!
Thanks,
Koby
sub mat4_write { # Variable name. my $name = shift; # Number of rows. my $m = shift; # Number of columns. my $n = shift; # Matrix elements in column major layout, this is the native # Matlab storage layout for matrices. my @a = splice (@_, 0, $m * $n); # File handle. my $h = shift; # use binnary-mode: binmode($h); # Type flag. my $type = $mat4_type; # No imaginary part. my $imag = 0; # Length of variable name including terminating null character. my $len = length ($name) + 1; # Encode and print matrix. print ($h pack ('l5Z*d*', $type, $m, $n, $imag, $len, $name, @a)); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Write Matlab binary MAT-files from Perl (binmode)
by Anonymous Monk on Jul 25, 2014 at 22:37 UTC | |
by tye (Sage) on Jul 25, 2014 at 22:59 UTC | |
by Anonymous Monk on Jul 25, 2014 at 23:41 UTC | |
by Anonymous Monk on Jul 26, 2014 at 00:36 UTC | |
by BrowserUk (Patriarch) on Jul 26, 2014 at 01:07 UTC | |
| |
by Anonymous Monk on Jul 25, 2014 at 23:44 UTC | |
by Anonymous Monk on Jul 25, 2014 at 23:54 UTC |