Lukas Häfliger
Lukas Häfliger

Reputation: 526

Matlab error saving containers.Map()

I try to save a map as a *.mat file which is quite big. (somewhere around 4 or 5gigs. I cannot be sure because I could never save the file...)

the map is generated by:

[amap, ~] = load_audio(config);

and saved later on by

save('audioMap', 'amap');

Now the generated file is only 218 bytes but no errors occur. Trying to read the contents of the file with whos('-file', 'audioMap.mat') results in the following error:

Warning: Unable to read some of the variables due to unknown MAT-file error.

every record of the map is a cell with 6 values. Now querying the size of the map in the Matlab workspace results in the following output:

Name         Size            Bytes  Class             Attributes
amap      2279x1               112  containers.Map

Now clearly the size is not correct but I am able to iterate through the map and all data is present. When querying the size of a record it is approximately 2.5MB.

I also tried to save the variable from the workspace with right-click and save-as with the same result. Anyone got any ideas why Matlab is not able to properly save this map?

Upvotes: 1

Views: 579

Answers (1)

Daniel
Daniel

Reputation: 36710

You where attempting to write a MAT-File version 7.0 which has a maximum variable size of 2^31 bytes=2GB

When you attempt to write Variables larger than the limit, the expected behaviour would be to receive a warning when saving the variable.

Warning: Variable 'varname' cannot be saved to a MAT-file whose version is older than 7.3. To save this variable, use the -v7.3 switch. Skipping...

For some reason the warning was not raised, but beeing unable to write such large objects is the expected behaviour.

Upvotes: 1

Related Questions