Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MATLAB is unable to load MAT-file created by Dymola

My problem is to open some MAT-files generated by Dymola. Some times for small models MATLAB has no problem to open the created MAT-file. Then I can see the structure in the workspace. But I have also a huge simulation model with 31.536.000 data points. For this model MATLAB is not able to open it. I always get the hint

Error using load
Unable to read MAT-file C:\Users\Patrick\Desktop\DymolaWork\GridHH_SLP.mat

File may be corrupt.

My MATLAB version is R2014a 64bit and my Dymola version is 2014 FD001 64bit. I also tried to fix the problem with a tool provided on the MathWorks homepage to solve corrupted variable names (loadfixnames/savebadnames). But that does not work quite right because this tool cannot restore the matrix data_2. Can anybody give me an advise to solve this problem?

like image 255
Patrick Avatar asked Jun 01 '14 10:06

Patrick


1 Answers

It should not be a problem with the Matlab4 format. The number of rows and columns of a matrix are stored as 2 32-bit unsigned integers, which should make a double matrix of size 8*(2^32-1) *(2^32-1) possible. It is just an implementation issue for reading the format.

Given the number of data points, if the model has more than roughly 136 variables, the total size of the data_2 matrix is greater than 4GB (you can probably tell from the file size of GridHH_SLP.mat if this is true). If this is the case, maybe Matlab was not programmed to handle matrices of this size. I tried a 39GB data_2 matrix in Octave and it just says: error: out of memory or dimension too large for Octave's index type. I could open the same file in OpenModelica (but it is inefficient for plotting such large files because they are not saved in transposed format by default).

If Dymola is capable of outputting a fewer number of variables, the file could work fine in Matlab. You could also try the program alist that comes with Dymola to output select variables in a mat-file into csv format (if alist can handle large files).

like image 173
sjoelund.se Avatar answered Oct 03 '22 10:10

sjoelund.se