Chang
Chang

Reputation: 3

Dymola can't load MAT-file

I am trying to load a .mat file outputed by matlab but it can't show me the variables name. FIG1

I have check the preference related to the mat file in matlab for some times and I'm sure its meet the dymola's requirement. FIG2

I want to use a 2-D interpolation function in dymola. But my data is stored in matlab. I tried to import directly in this way but failed. first try

And then I tried another way to import. anotherway step 1 anotherway step 2 anotherway step 3

You can see that the variables are not displayed. but another mat-file created by dymola is completely normal.

I guess there may be a problem with my matlab, but I don’t know what to do

that's my mat file https://drive.google.com/file/d/1kX_cBIu6cwkG-gDD32WnJvs2Edxzg_j_/view?usp=sharing

Upvotes: 0

Views: 858

Answers (1)

Markus A.
Markus A.

Reputation: 7500

After looking at your .mat file, I have a couple of comments that could help:

  • Probably the most important comment is on the format that is used in the MSL's CombiTables: You need to store the axis within the 2D table. This is part of the model's documentation, which can be accessed e.g. by switching to Dymola's "Documentation" Ribbon with the respective CombiTable being active in the Package browser. The important part of the documentation regarding the format says: enter image description here

  • Regarding the import via the GUI, mind the paragraph from the Dymola Manual:

Data for the table can also be loaded using the Import… button. The data can be imported from external Matlab 4 (.mat files), Scientific Data Format (.sdf) or Comma separated values files. Comma separated values files can have extensions .csv or .txt. Files in .txt format can have tab, space, semicolon or comma as separators.

So you need save your file in v4 format for importing via the GUI.

  • As an alternative: You should have "SDF Editor" on your computer (in Dymola's bin64 folder in case it is not in the Start menu). This tool will be able to read the mat v7.3 file e.g. by dragging and dropping it into the UI, and you will be able to copy the highlighted data from there using CTRL+C and paste it in the Matrix Editor using the "Paste Matrix" button in the Matrix Editor as shown below.

Matrix Editor

  • You can use the .mat file directly in the MSL's CombiTables as well. This can be done by configuring the table like this:

CombiTable Read-From File Config Regarding using data directly from the file: It makes sense to read the documentation on how to create the file by clicking the "Info" button shown above. For Dymola I think it makes most sense to create a MATLAB v7 file for reading the table from a file, as using your v7.3 file will gives me an error.

Reading the data directly form the file gives the advantage, that changes to the .mat file will have direct effect on the simulation - no need to re-import.

Personally I would use the "read-from-file" variant, as it should be the least effort and overcomes the need to re-import data in case of changes.

Upvotes: 2

Related Questions