Unable to read mat file created with MATLAB 2020b #18

Closed
opened 2021-05-27 07:53:24 +00:00 by EtHRoVel · 1 comment
EtHRoVel commented 2021-05-27 07:53:24 +00:00 (Migrated from github.com)

While reading of this simple mat file matlab.zip I get an IndexOutOfRangeException at MatFileReader.Read().
Stack trace is:

   at MatFileHandler.SubsystemDataReader.GatherClassAndObjectInformation(Dictionary`2 classIdToName, String[] fieldNames, Dictionary`2 objectClasses, Dictionary`2 objectPositionsToValues, Dictionary`2 embeddedObjectPositionsToValues)
   at MatFileHandler.SubsystemDataReader.Read(Byte[] bytes, SubsystemData subsystemData)
   at MatFileHandler.MatFileReader.ReadRawVariables(BinaryReader reader, Int64 subsystemDataOffset, SubsystemData subsystemData)
   at MatFileHandler.MatFileReader.Read(BinaryReader reader)
   at MatFileHandler.MatFileReader.Read()
   at MatFileNugetTest.Program.Main(String[] args)

I have used the latest MatFileHandler Nuget package ver. 1.3.0.

Any idea why this happens?

While reading of this simple mat file [matlab.zip](https://github.com/mahalex/MatFileHandler/files/6552061/matlab.zip) I get an IndexOutOfRangeException at MatFileReader.Read(). Stack trace is: ``` at MatFileHandler.SubsystemDataReader.GatherClassAndObjectInformation(Dictionary`2 classIdToName, String[] fieldNames, Dictionary`2 objectClasses, Dictionary`2 objectPositionsToValues, Dictionary`2 embeddedObjectPositionsToValues) at MatFileHandler.SubsystemDataReader.Read(Byte[] bytes, SubsystemData subsystemData) at MatFileHandler.MatFileReader.ReadRawVariables(BinaryReader reader, Int64 subsystemDataOffset, SubsystemData subsystemData) at MatFileHandler.MatFileReader.Read(BinaryReader reader) at MatFileHandler.MatFileReader.Read() at MatFileNugetTest.Program.Main(String[] args) ``` I have used the latest MatFileHandler Nuget package ver. 1.3.0. Any idea why this happens?
mahalex commented 2021-05-27 17:04:53 +00:00 (Migrated from github.com)

Thank you for the report!
Looks like this file contains variables of some Simulink-specific types. MATLAB R2020b (without Simulink) actually refuses to read it. To be precise, it reads it, but spits a handful of warnings like "Warning: Variable 'BOOLEAN8' originally saved as a Simulink.AliasType cannot be instantiated as an object and will be read in as a uint32.", and the result is a variable BOOLEAN8 that is a 6x1 uint32 array with values [3707764736; 2; 1; 1; 1; 1]. I happen to have an idea what 3707764736 means, but I doubt that's what you would like to see. So I wouldn't call it a "MATLAB" .mat file, I would call it "Simulink" .mat file.
That said, the exception that you get is probably not a proper way of reporting error (and it's not very informative). So I'll think about how to improve handling of types that are not built-in MATLAB types, but I don't think we are going to have support for Simulink types in the near future.

Thank you for the report! Looks like this file contains variables of some Simulink-specific types. MATLAB R2020b (without Simulink) actually refuses to read it. To be precise, it reads it, but spits a handful of warnings like "Warning: Variable 'BOOLEAN8' originally saved as a Simulink.AliasType cannot be instantiated as an object and will be read in as a uint32.", and the result is a variable BOOLEAN8 that is a 6x1 uint32 array with values [3707764736; 2; 1; 1; 1; 1]. I happen to have an idea what 3707764736 means, but I doubt that's what you would like to see. So I wouldn't call it a "MATLAB" .mat file, I would call it "Simulink" .mat file. That said, the exception that you get is probably not a proper way of reporting error (and it's not very informative). So I'll think about how to improve handling of types that are not built-in MATLAB types, but I don't think we are going to have support for Simulink types in the near future.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mahalex/MatFileHandler#18
No description provided.