This function parses a Modelica result file (*.mat) into a tree structue so that all variables can be accessed the same way as in Modelica.
The path to the result file has to be provided. The user can also pass a regular expression to the function to limit the return variables.
The output is a nested structure where all variables can be accessed via dot-notation. Arrays of objects in Modelica are parsed into arrays in Matlab.
res = modelicaImport(path, regex);
This function is pretty much a byproduct of a simulation project I did for university - I hope that is is useful. I have used this function with OpenModelica 1.9.1+dev (r22052) and Dymola 2015.
Many thanks for this - it worked great in translating old Modelica data I had into a sensible format when I no longer had dymload.m available.
It worked like a charm. The resulting structure is the same you may find in your Modelica IDE.
Thanks a lot, this solved the problem! I have found another small bug when reading out the combiTable1D data from OpenModelica. Your code only reads out the y-values of the table data twice, but not the input data. I have checked the raw data from OpenModelica and the values are there in data_1. Can you please fix this? Best regards, Markus
there was a problem, when modelica left out some fields in object arrays. I uploaded an updated version, that can handle this.
I hope, this solves your problem.
Hello, i use this function to import some data from openmodelica to matlab, unfortunately it sometimes crashes and generates no output at all, depending on the input file and regex parameters. I am not really familiar with matlab so i cannot fix the problem on my own. Can someone please help me to fix the problems? Following two errors it can generate:
* Subscripted assignment between dissimilar structures.
* Error using cellfun
Non-scalar in Uniform output, at index 1, output 1.
Set 'UniformOutput' to false.
Many thanks in advance!
I never needed this myself, but I remember that there was another package here on the file exchange that provides this functionality.
You can find it here: https://de.mathworks.com/matlabcentral/fileexchange/20120-openmodelica-matlab-interface
hi, do you know some way how i can run Modelica from matlab?
Resolved a bug with array parsing.