MATLAB cannot load MAT file created by Dymola

My problem is to open some MAT files generated by Dymola. Several times for small models, MATLAB opens the created MAT file without any problems. Then I can see the structure in the workspace. But I also have a huge simulation model with 31.536.000 data points. For this model, MATLAB cannot open it. I always get a 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 the 64-bit version of R2014a, and my Dymola version is the 64-bit version of 2014 FD001. I also tried to fix the problem using the tool provided on the MathWorks homepage to resolve damaged variable names ( loadfixnames / savebadnames ). But this is not entirely correct, because this tool cannot restore the data_2 matrix. Can anyone give me some advice to solve this problem?

+6
source share
3 answers

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

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

If Dymola is able to output fewer variables, the file may work fine in Matlab. You can also try the alist program that comes with Dymola to output select variables in a mat file in csv format (if alist can handle large files).

+3
source

Using the so-called choice of variables in your model, you can reduce your file of simulation results to a more manageable size. Supported in later versions of Dymola.

0
source

In our experience, when opening Dymola crashes in Matlab, Octave can do it very well. Therefore, if you don't like the whole workflow in Octave, you can simply use it to read and convert the data to a more regular mat file, and then open it in Matlab.

0
source

Source: https://habr.com/ru/post/970145/


All Articles