MatFileHandler icon indicating copy to clipboard operation
MatFileHandler copied to clipboard

Matlab 7.3 support

Open simmarn opened this issue 6 years ago • 4 comments

Hi!

MatFileHandler works brilliantly with Matlab 5.0 mat files. But I need support for reading Matlab 7.0. Is that in the pipe?

Right now I get when trying to read:

Unhandled Exception: System.NotSupportedException: Unknown element.
   at MatFileHandler.DataElementReader.Read(BinaryReader reader)
   at MatFileHandler.MatFileReader.Read(BinaryReader reader)
   at MatFileHandler.MatFileReader.Read()
   at MatReaderTest.Program.Main(String[] args) in C:\Users\Martin Olausson\source\repos\MatReader\MatReader\Program.cs:line 28

simmarn avatar Aug 30 '18 08:08 simmarn

Thanks for your feedback! I think Matlab 7.0 files are supported, as long as they only contain "ordinary" things like matrices, structure arrays, cell arrays, etc. However, reading Matlab "objects" (instances of user-defined Matlab classes) is not currently supported. The documentation for object storage seems scarce (I believe the official documentation is non-existent). Could you please share some file that you cannot import, and I'll take a closer look at it? This way we will be really sure what we're talking about.

mahalex avatar Aug 30 '18 14:08 mahalex

Certainly. Here you have the Matlab 7.0 file I can not open. I do not think it contains any "objects". https://simmarn.mydns.se/nextcloud/index.php/s/k3rA4Z4P4egiDqG

simmarn avatar Aug 30 '18 18:08 simmarn

It looks like this file is actually in Matlab 7.3 format. It was produced by libmatio rather than Matlab (and it incorrectly states that it's Matlab 7.0 in the comment). Supporting 7.3 format would mean dealing with the horrible HDF5 format. A year ago (when I last researched HDF5) it seemed close to impossible. To my knowledge, there are still no native C# libraries for accessing HDF5 data, so I would have to rely on external C libraries, which doesn't sound exciting to me. Maybe the situation has changed since then, so I'll try to look into it again. In any case, I don't think there is a quick fix for that, sorry!

mahalex avatar Sep 02 '18 09:09 mahalex

OK. Thanks for checking.

simmarn avatar Sep 02 '18 14:09 simmarn