6
votes

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?

3
Would it be helpful if you use .SDF file instead of .mat file? Have you ever tried it?Jack

3 Answers

3
votes

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).

0
votes

By using so called variable selections in your model, you can reduce your simulation result file to a more manageable size. Supported in more tecent versions of Dymola.

0
votes

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