9

I have some data generated in MATLAB that I want to process using Perl. I saved the data from MATLAB in a .mat file. Is there any way to read it in Perl?

Amro
  • 121,265
  • 25
  • 232
  • 431
Nathan Fellman
  • 108,984
  • 95
  • 246
  • 308

2 Answers2

7

One option would be to save the binary MAT file as ASCII from inside MATLAB using something like:

load('test_data.mat');
save('test_data.asc', 'var1', 'var2', '-ascii');

Then you would have ASCII data to process in Perl.

If you need a solution completely written in Perl, then you should be able to automate the process using the Math::MATLAB package on CPAN.

NOTE: If Python is an option, you could use the loadmat function in the SciPy Python library.

Community
  • 1
  • 1
Tim Henigan
  • 55,120
  • 11
  • 81
  • 76
1

The Java library JMatIO has worked well for me. Maybe you can try using inline Java.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
weiyin
  • 6,429
  • 4
  • 43
  • 55